// this script is used on yahoo store pages at bigeasystore.com

function changedate() {

	var months=new Array(13);
	months[1]="Jan";
	months[2]="Feb";
	months[3]="Mar";
	months[4]="Apr";
	months[5]="May";
	months[6]="Jun";
	months[7]="Jul";
	months[8]="Aug";
	months[9]="Sep";
	months[10]="Oct";
	months[11]="Nov";
	months[12]="Dec";
	
	var now=new Date();
	var month=months[now.getMonth() + 1];
	var day=now.getDate();
	var year=now.getYear();
	if (year < 2000) year = year + 1900; // y2k fix
	
	defaultday = day + 1; // set default day
	
	day = day + ""; // convert to string
	defaultday = defaultday + ""; // convert to string
	
	if (day.length == 1)
		day = "0" + day; // add a leading 0
	if (defaultday.length == 1)
		defaultday = "0" + defaultday; // add a leading 0
	
	var defaultdate = month + " " + defaultday + ", " + year; // make default selected date
	
	var f = window.document.yourform; // id of form
	var max = f.Date.options.length; // # of dates in dropdown

	defaultdatecompare = new Date(getDateFromFormat(defaultdate,"MMM dd, yyyy")); // make defaultdate a comparable date

	var disabledcount = 0;
	
	for (i = 0; i < max; i++) {

		j = i - disabledcount; // use variable 'j' to reflect changes to shape of options array

		rowdate = new Date(getDateFromFormat(f.Date.options[j].text,"MMM dd, yyyy")); // make the current row a comparable date

		if (rowdate < defaultdatecompare) {
			f.Date.options[j] = null;
			disabledcount = disabledcount + 1; // indicate a change to the shape of the options array
		}
		
		if (f.Date.options[j].text == defaultdate) {
			f.Date.selectedIndex = j; // change selected option to defaultdate
			break;
		}
	}
	
}


function changeage() {

	var f = window.document.yourform; // id of form
	var max = f.Age.options.length; // # of ages in dropdown

	var pricediv = "yahooprice";
	if (document.all) {
		var origprice = parseFloat(document.all[pricediv].innerHTML);
	} else if (document.getElementById) {
		var origprice = parseFloat(document.getElementById(pricediv).innerHTML);
	}
	
	
	for (i = 0; i < max; i++) {
		t = f.Age.options[i].text;
		offset = 0;
		pricechange = 0;

		if (t.indexOf("$") != -1) offset++;
		
		plusplace = (t.indexOf("(+"));
		minusplace = (t.indexOf("(-"));
		
		if (plusplace != -1) {
			sign = "+";
			offset = offset + plusplace + 2;
			pricechange = t.substring(offset, t.length-1);
		} else if (minusplace != -1) {
			sign = "-";
			offset = offset + minusplace + 2;
			pricechange = t.substring(offset, t.length-1) * (-1);
		}
		newprice = origprice + parseFloat(pricechange); // calculate full price of this option
		
		newprice = newprice + "" ; // convert to a string
		if (newprice.indexOf(".") == -1) newprice = newprice + ".00"; // add trailing zeros if there is no decimal
		newprice = " ($" + newprice + ")"; // add dollar sign and parentheses

		if (plusplace != -1) {
			newtext = t.substring(0,plusplace) + newprice;
		} else if (minusplace != -1) {
			newtext = t.substring(0,minusplace) + newprice;
		} else {
			newtext = t + newprice;
		}
		
		f.Age.options[i].text = newtext;
	}

}


function inityahooform() {
	changedate();
	changeage();
}


onload = function() { inityahooform () };
