// JavaScript Document

function getOptions() {
	//window.alert("getOptions() called");
	var str = "";
	
	var obj = document.getElementsByTagName("select").item(0);
	
	if ( obj != null ) {
	
		var fontTags = document.getElementsByTagName("font");
		var basePrice = "";
		for ( var i = 0; i < fontTags.length; i++ ) {
			if ( fontTags.item(i).className == "pricecolor colors_productprice" ) {
				basePrice = fontTags.item(i).innerHTML.substr(1);
				break;
			}
		}
		
		str+="base is " + basePrice + ":\n";
		//window.alert(str);
		
		for ( var x = 1; x < obj.options.length; x++ ) {
			var option = obj.options[x].text;
			var newText = "";
			var start = option.indexOf("$")+1;
			var end = option.indexOf("]");
			var endSize = option.indexOf("[")-1;
			
			var addPrice = option.substring(start, end);
			
			var size = option.substring(0,endSize);
			
			var newPrice = (parseFloat(basePrice) + parseFloat(addPrice)).toFixed(2);
			
			if ( addPrice ==  '' ) { // if there's not an addPrice in option
				newText = option + " ($" + basePrice.rtrim() + ")";
			} else { 
				
				newText = size + " ($" + newPrice + ")";
			}
			//write the new text
			obj.options[x].text = newText;	
			str += newText + "\n";
		}
		//window.alert(str);
	
	}
	
}

//getOptions();

function checkPage(strcheck) { // check to see if this string exists in the URL to verify what page it is
	var url = location.href;
	if ( url.indexOf(strcheck)>=0) {
		return true;
	} else {
		
		return false;
	}
}


if ( checkPage("product-p") || checkPage("ProductCode")) {
//window.alert(document.forms.length);
getOptions();

}