//Shopping cart scripts
var iMultipleBlinds = 0;
function CalcPrice(checkJS){
	var frmEle = eval("document.shopcart");
	var Price = 0;var OptionsPrice = 0;var TaxPrice = 0;var TapePrice = 0;
	if(frmEle.TapePrice){TapePrice = eval(frmEle.TapePrice.value);}
	var blindWidth = frmEle.WidthInches.value + frmEle.Width8ths.value;
	var blindHeight = frmEle.HeightInches.value + frmEle.Height8ths.value;
	//round sizes to next highest values
	
	//set check that enabled
	if(checkJS != 1){frmEle.jsBrowserCheck.value = "1";}
	
	blindWidth = RoundUp(blindWidth);
	blindWidth = getPriceBreak(blindWidth,aWidths);
	blindHeight = RoundUp(blindHeight);
	blindHeight = getPriceBreak(blindHeight,aHeights);
	
	//Display Oversize fee
	if((eval(frmEle.WidthInches.value) + eval(frmEle.Width8ths.value)) >= eval(document.shopcart.OverSizeWidth.value)){
		document.getElementById("ShippingFee").innerHTML = "See shopping cart";
	}
	else{
		document.getElementById("ShippingFee").innerHTML = "FREE";
	}
	
	//calc base price
	Price = getBasePrice(blindWidth,blindHeight);
	//setup option availability prior to setting option pricing
	SetOptionStatus();
	//calc option price
	OptionsPrice = getOptionPrices(Price);
	
	//check for tape option
	if(frmEle.TapeColorID){
		if(frmEle.TapeColorID.value != 0){//Tapes and Edge Banding and Trims
			if(frmEle.pid.value == 19){//EdgeBanding
				OptionsPrice += 35;
			}
			else if(frmEle.pid.value == 83 || frmEle.pid.value == 84){//EdgeBanding Woodlands
				//Get price based on shade width.
				if(blindWidth < 24){
					OptionsPrice += 50;
				}
				else if(blindWidth < 30){
					OptionsPrice += 55;
				}
				else if(blindWidth < 32){
					OptionsPrice += 55;
				}
				else if(blindWidth < 36){
					OptionsPrice += 55;
				}
				else if(blindWidth < 42){
					OptionsPrice += 60;
				}
				else if(blindWidth < 48){
					OptionsPrice += 65;
				}
				else if(blindWidth < 60){
					OptionsPrice += 65;
				}
				else if(blindWidth < 72){
					OptionsPrice += 75;
				}
				else if(blindWidth < 84){
					OptionsPrice += 80;
				}
				else{
					OptionsPrice += 90;
				}
			}
			else if(frmEle.pid.value == 9 || frmEle.pid.value == 31 || frmEle.pid.value == 54 || frmEle.pid.value == 55 || frmEle.pid.value == 56 || frmEle.pid.value == 57 || frmEle.pid.value == 58){//Rollers
				//no price for hems
			}
			else{//Cloth Tapes 20%
				//OptionsPrice += (Price * (20/100));
				OptionsPrice += TapePrice;
				if(document.shopcart.Option6){//2 in 1
					if(document.shopcart.Option6.checked){//Add for second blind tape
						OptionsPrice += TapePrice;
					}
				}
				if(document.shopcart.Option8){//3 in 1
					if(document.shopcart.Option8.checked){//Add for third blind tape
						OptionsPrice += (TapePrice * 2);
					}
				}
			}
		}
	}
	Price += OptionsPrice + TaxPrice;
	var SalePercentage = eval(frmEle.SalePercentage.value);
	var MSRPPrice = 1.3 * (Price/frmEle.mul.value);
	if(document.shopcart.pid.value == 32 || document.shopcart.pid.value == 33 || document.shopcart.pid.value == 83 || document.shopcart.pid.value == 84 || document.shopcart.pid.value == 87){
		MSRPPrice = 10 * (Price/frmEle.mul.value);
	}
	if(document.shopcart.pid.value == 101 || document.shopcart.pid.value == 102 || document.shopcart.pid.value == 103 || document.shopcart.pid.value == 104 || document.shopcart.pid.value == 110 || document.shopcart.pid.value == 100){
		MSRPPrice = 3 * (Price/frmEle.mul.value);
	}
	var Savings = ((MSRPPrice - Price) / MSRPPrice) * 100;
	Savings = ToDollarsAndCents(Savings);	
	MSRPPrice = ToDollarsAndCents(MSRPPrice) + " (You save " + Math.round(Savings) + "%)";
	Price = ToDollarsAndCents(Price);
	SalePrice = ((Price - (OptionsPrice + TaxPrice)) * SalePercentage) + (OptionsPrice + TaxPrice);//give discount on base price only
	SalePrice = ToDollarsAndCents(SalePrice);
	frmEle.Price.value = SalePrice;
	frmEle.DisplayPrice.value = Price;
	//frmEle.DisplayPrice2.value = Price;
	document.getElementById("DisplayPriceDiv").innerHTML = "$" + Price;
	document.getElementById("DisplayPriceDivSale").innerHTML = "$" + SalePrice;
	frmEle.DisplayMSRPPrice.value = MSRPPrice;
}

function getOptionPrices(BasePrice){
	var frmEle = eval("document.shopcart");
	var frmEleOption; var frmOptionUnit; var frmOptionPrice;
	var i = 0;
	var Price = 0;
	if(frmEle.Options){
		if(frmEle.Options.length){
			for(i=0;i<frmEle.Options.length;i++){
				//check each option if checked
				frmEleOption = eval("document.shopcart.Option" + frmEle.Options[i].value);
				frmOptionPrice = eval("document.shopcart.OptionPrice" + frmEle.Options[i].value);
				frmOptionUnit = eval("document.shopcart.PriceType" + frmEle.Options[i].value);
				if(frmEleOption.checked == true){
					if(frmOptionUnit.value == 1){//Dollars
						Price += eval(frmOptionPrice.value);
					}
					else{//Percentage
						Price += BasePrice * (eval(frmOptionPrice.value)/100);
					}
//					alert(Price);
				}
			}
		}
		else{//Single option
			frmEleOption = eval("document.shopcart.Option" + frmEle.Options.value);
			frmOptionPrice = eval("document.shopcart.OptionPrice" + frmEle.Options.value);
			frmOptionUnit = eval("document.shopcart.PriceType" + frmEle.Options.value);
			if(frmEleOption.checked == true){
				if(frmOptionUnit.value == 1){//Dollars
					Price += eval(frmOptionPrice.value);
				}
				else{//Percentage
					Price += BasePrice * (eval(frmOptionPrice.value)/100);
				}
			}
		}
	}
	if(frmEle.FeatureOption5){//Fold Type Option(Bamboo)
		if(frmEle.FeatureOption5.value == 17){//DuoFold
			Price += 100;
		}
		if(frmEle.FeatureOption5.value == 21){//RollEase
			Price += 35;
		}
	}
	if(frmEle.FeatureOption10){//Hem Style Option(Roller)
		if(frmEle.FeatureOption10.value == 24){//Plain
			//do not change price
			//MM_showHideLayers('Tapes','','hide');
		}
		else {//Fancy Hem
			var rollerWidth = frmEle.WidthInches.value + frmEle.Width8ths.value;
			var HemPrice = rollerWidth/1.5;
			Price += HemPrice;
			//MM_showHideLayers('Tapes','','show');
		}
	}
	if(frmEle.FeatureOption11){//Roller Type Option(Roller)
		if(frmEle.FeatureOption4){//Lift Option
			if(frmEle.FeatureOption11.value == 30){//Spring
				frmEle.FeatureOption4.disabled = true;
			}
			else{//Chain
				frmEle.FeatureOption4.disabled = false;
			}
		}
	}
	if(frmEle.FeatureOption7){//Draw Type(vertical)
		if(frmEle.FeatureOption7.value != 13){//not standard
			Price += 20;
		}
	}
	if(frmEle.Option22){//Motorization
		if(frmEle.Option22.checked){//Motor selected
			if(document.shopcart.Option6){//2 in 1
				if(document.shopcart.Option6.checked){//Add for second blind motor
					Price += (frmEle.OptionPrice22.value * 1);
					
				}
			}
			if(document.shopcart.Option8){//3 in 1
				if(document.shopcart.Option8.checked){//Add for second and third blind motor
					Price += (frmEle.OptionPrice22.value * 2);
				}
			}
		}
	}
	if(frmEle.Option9){//Motorization
		if(frmEle.Option9.checked){//Motor selected
			if(document.shopcart.Option6){//2 in 1
				if(document.shopcart.Option6.checked){//Add for second blind motor
					Price += (frmEle.OptionPrice9.value * 1);
					
				}
			}
			if(document.shopcart.Option8){//3 in 1
				if(document.shopcart.Option8.checked){//Add for second and third blind motor
					Price += (frmEle.OptionPrice9.value * 2);
				}
			}
		}
	}
	return Price
}

function getBasePrice(theWidth,theHeight){
	var i = 0;
	var Price = 0;
	var testWidth = document.shopcart.WidthInches.value + document.shopcart.Width8ths.value;
	var testHeight = document.shopcart.HeightInches.value + document.shopcart.Height8ths.value;
	for(i=0;i<aPricing.length;i++){
		if(theWidth==aPricing[i].width && theHeight==aPricing[i].height) {
			//Find matching price
			Price = aPricing[i].price;
			if(Price == 0){
				alert("Due to wieght Constraints, the size you have selected is not available!");
				//document.shopcart.submit.style.display = 'none';
				document.all.submit.style.display = 'none';
			}
			else{
				//document.shopcart.submit.style.display = 'block';
				document.all.submit.style.display = 'block';
			}
			if(aPricing[i].dualBlinds == 1){
				iMultipleBlinds = 1;
				if(document.shopcart.Option6 && document.shopcart.Option8){//Both 2 in 1 and 3 in 1
					document.shopcart.Option6.disabled = false;
					document.shopcart.Option8.disabled = false;
					if(document.shopcart.Option6.checked == false && document.shopcart.Option8.checked == false){
						alert("Due to the weight of blinds the size you have selected we recommend separating them into 2 sections on one headrail.");
					}
				}
				else if(document.shopcart.Option8){//3 in 1
					document.shopcart.Option8.disabled = false;
					if(document.shopcart.Option8.checked == false){
						alert("Due to the weight of blinds the size you have selected we recommend separating them into 2 sections on one headrail.");
					}
				}
				else if(document.shopcart.Option6){//2 in 1
					document.shopcart.Option6.disabled = false;
					if(document.shopcart.Option6.checked == false){
						if (document.shopcart.pid.value >= 64 && document.shopcart.pid.value <= 69){
							if(document.shopcart.Option11){
								if(document.shopcart.Option11.checked == false){
									alert("Due to the weight of blinds the size you have selected we recommend separating them into 2 sections on one headrail or using a Continuous Loop Lift Cord.");
								}
							}
						}
						else{
							alert("Due to the weight of blinds the size you have selected we recommend separating them into 2 sections on one headrail.");
						}
					}
				}
				else{//No multiple blinds on one headrail option
					//alert("Due to the weight of blinds the size you have selected two separate blinds are recommended.");
				}
			}
			else{
				iMultipleBlinds = 0;
			}
			if (document.shopcart.pid.value == 87){//Designer Faux
				if((((testWidth * testHeight) / 144) > 30) && (document.shopcart.FeatureOption3.value == 7)){//if wand and over 30 sq. ft
					alert("We cannot make blinds with a Wand Tilter over 30 sqaure feet!");
					document.shopcart.FeatureOption3.value = 6;
				}
			}
			if (document.shopcart.pid.value >= 83 && document.shopcart.pid.value <= 84){//Bamboo Shades
				if (document.shopcart.Option19){//Top Down Bottom Up
					if (document.shopcart.Option19.checked && testWidth > 72){
						alert("We cannot make any shades 'Top Down-Bottom Up' over 72 inches wide!")
						document.shopcart.Option19.checked = false;
					}
					if (document.shopcart.Option19.checked && testWidth < 24){
						alert("We cannot make any shades 'Top Down-Bottom Up' under 24 inches wide!")
						document.shopcart.Option19.checked = false;
					}
				}
				if (document.shopcart.Option21){//Rollease
					if (document.shopcart.Option21.checked && testWidth < 24){
						alert("We cannot make any shades with the 'Rollease' option under 24 inches wide!")
						document.shopcart.Option21.checked = false;
					}
				}
			}
			if (document.shopcart.pid.value >= 64 && document.shopcart.pid.value <= 69){//Cell Shades
				if (document.shopcart.Option18){//Top Down Bottom Up
					if (document.shopcart.pid.value == 68){//Room Darkening
						if (document.shopcart.Option18.checked && (testWidth > 60 || testHeight > 60)){
							alert("We cannot make any shades 'Top Down-Bottom Up' over 60 inches wide or 60 inches high.")
							document.shopcart.Option18.checked = false;
						}
					}
					else if (document.shopcart.pid.value == 67){//3/4" Blackout
						if (document.shopcart.Option18.checked && (testWidth > 72 || testHeight > 80)){
							alert("We cannot make any shades 'Top Down-Bottom Up' over 72 inches wide or 80 inches high.")
							document.shopcart.Option18.checked = false;
						}
					}
					else{
						if (document.shopcart.Option18.checked && (testWidth > 72 || testHeight > 96)){
							alert("We cannot make any shades 'Top Down-Bottom Up' over 72 inches wide or 96 inches high.")
							document.shopcart.Option18.checked = false;
						}
					}
				}
				if (document.shopcart.Option16){//Cordless
					if (document.shopcart.Option16.checked && (testWidth < 18 || testHeight < 8)){//Min Width
						alert("We cannot make any shades 'Cordless' under 18 inches wide or 8 inches high.")
						document.shopcart.Option16.checked = false;
					}
					if (document.shopcart.pid.value == 68){//Room Darkening
						if (document.shopcart.Option16.checked && (testWidth > 66 || testHeight > 84)){
							alert("We cannot make any shades 'Cordless' over 66 inches wide or 84 inches high.")
							document.shopcart.Option16.checked = false;
						}
					}
					else if (document.shopcart.pid.value == 69){//double cell trans.
						if (document.shopcart.Option16.checked && (testWidth > 96 || testHeight > 84)){
							alert("We cannot make any shades 'Cordless' over 96 inches wide or 84 inches high.")
							document.shopcart.Option16.checked = false;
						}
					}
					else{
						if (document.shopcart.Option16.checked && (testWidth > 120 || testHeight > 84)){
							alert("We cannot make any shades 'Cordless' over 120 inches wide or 84 inches high.")
							document.shopcart.Option16.checked = false;
						}
					}
				}
			}
			if(document.shopcart.FeatureOption7){//Draw Type(vertical)
				if(document.shopcart.FeatureOption18){//Wand-Chain Cord
					if(document.shopcart.FeatureOption7.value == 14 && document.shopcart.FeatureOption18.value == 45){
						alert('We cannot make vertical blinds with a "Split Draw" and "Wand Tilter!" Tilter will change to "Cord and Chain"');
						document.shopcart.FeatureOption18.value = 44;
					}
				}
			}
			i = aPricing.length;
		}
	}
	return Price;
}

function getPriceBreak(theSize,theType){
	var i = 0;
	var PriceBreak = 0;
	for(i=0;i<theType.length;i++){
		if(theSize <= theType[i] || i==(theType.length-1)) {
			//Find price break for selected size selected
			PriceBreak = theType[i];
			i = theType.length;
		}
	}
	return PriceBreak;
}
function checkit(name)
{//Check to ensure they want to delete
	if (! confirm ('Do you want to delete: ' + name + '?'))
	{
		return false	
	}
}
function RoundUp(valueToRound){
	var Value = "";
	s = new String(valueToRound);
    decimalPos = s.indexOf(".");
    if (decimalPos == -1) {
      // whole number, do nothing
      Value = valueToRound;
	}
	else{
	  Value = eval(valueToRound.substring( 0, decimalPos ));
	  theLength = valueToRound.length - decimalPos
	  if(eval(valueToRound.substr(decimalPos,theLength)) != 0){
		Value = Value + 1;
	  }
	}
	return Value;
}

function validateShopCart(frmEle){
	
	if(frmEle.FeatureOption1){
		if(frmEle.FeatureOption1.value == '0'){
		//No mount type selected
			alert("You must select a mount type!");
			frmEle.FeatureOption1.focus();
			return false;
		}
	}
	if(frmEle.FeatureOption8){
		if(frmEle.FeatureOption8.value == '0'){
		//No mount type selected
			alert("You must select a mount type!");
			frmEle.FeatureOption8.focus();
			return false;
		}
	}
	if(frmEle.ColorID.value == "0"){//No color selected
		alert("You must select a color!");
		frmEle.ColorID.focus();
		return false;
	}
	if(frmEle.TapeColorID){//check for Colors that edge binding is not available
		if((frmEle.ColorID.value >= 622 && frmEle.ColorID.value <= 625) && frmEle.TapeColorID.value != 0){
			alert("Edge Binding is not available with this color bamboo shade!");
			frmEle.TapeColorID.value=0;
			frmEle.ColorID.focus;
			return false;
		}
	}
	if(frmEle.TapeColorID && (frmEle.pid.value == "9" || frmEle.pid.value == "31" || frmEle.pid.value == "54" || frmEle.pid.value == "55" || frmEle.pid.value == "56" || frmEle.pid.value == "57" || frmEle.pid.value == "58"))
	{//Roller, require trim color
		//if(frmEle.TapeColorID.value == "0"){
		//	alert("You must select a trim color!");
		//	frmEle.TapeColorID.focus();
		//	return false;
		//}
	}
	//Rollers
	if(frmEle.FeatureOption10){//Hem Style Option(Roller)
		if(frmEle.FeatureOption10.value != 24){//NOT Plain
			if(frmEle.FeatureOption10){//Hem Style Option(Roller)
				if(frmEle.TapeColorID){//Are trim colors there?
					if(frmEle.TapeColorID.value == 0){//Trim color must be chosen
						alert("You must select a Trim Color when using a Decorative Hem!");
						frmEle.TapeColorID.focus();
						return false;
					}
				}
			}
		}
	}
	if(frmEle.FeatureOption13){//Hem Style
		if(frmEle.FeatureOption13.value == 34){//Plain Hem
			if(frmEle.TapeColorID){//Are trim colors there?
				if(frmEle.TapeColorID.value == 0){//Trim color must be chosen
					alert("You must select a Trim Color when using a Plain Hem!");
					frmEle.TapeColorID.focus();
					return false;
				}
			}
		}
	}
	//Small size
	if(frmEle.WidthInches.value < 13.5 && frmEle.pid.value == 100){//1" designer basswood
		alert('NOTICE: Blinds under 13.5" come standard with tilter in the center and no lift cord.')
	}
	else if(frmEle.WidthInches.value < 12){
		categoryID = 0
		if(frmEle.cid){
			categoryID = frmEle.cid.value;
		}
		if(categoryID == 4 || categoryID == 7 || categoryID == 8){
			//If horizontal blind
			alert('NOTICE: Blinds under 12" come standard with tilter in the center and no lift cord.')
		}
	}
	
}

function DisableRoutless(theVal){
	if(document.shopcart.Option2){
		if(theVal == 0){
			if(document.shopcart.Option2){//Disable Routless
				document.shopcart.Option2.disabled = false;
			}
			if(document.shopcart.Option9){//Disable Remote
				document.shopcart.Option9.disabled = false;
			}
		}
		else{
			if(document.shopcart.Option2){//Routless
				document.shopcart.Option2.disabled = true;
				if(document.shopcart.Option2.checked == true){
					alert("You may not choose tapes on routless blinds! The routless option has been removed.");
					document.shopcart.Option2.checked = false;
				}
			}
			if(document.shopcart.Option9){//Remote
				document.shopcart.Option9.disabled = true;
				if(document.shopcart.Option9.checked == true){
					alert("You may not choose tapes on remote control blinds! The remote control option has been removed.");
					document.shopcart.Option9.checked = false;
				}
			}
		}
	}
}

function SetOptionStatus(){	
	//Not allow multiple headrail if too small
	if(iMultipleBlinds == 1){
		if(document.shopcart.Option8){
			document.shopcart.Option8.disabled = false;//3 in 1
		}
		if(document.shopcart.Option6){
			document.shopcart.Option6.disabled = false;//2 in 1 headrail
		}
	}
	else{//Dont allow if blind too small
		if(document.shopcart.Option6){//Both 2 in 1
			document.shopcart.Option6.checked = false;
			document.shopcart.Option6.disabled = true;//2 in 1 headrail
		}
		if(document.shopcart.Option8){//Both 8 in 1
			document.shopcart.Option8.checked = false;
			document.shopcart.Option8.disabled = true;//3 in 1 headrail
		}
	}
	
	// not allow 2 in 1 and 3 in 1 headrail
	if(document.shopcart.Option8 && document.shopcart.Option6){
		if(document.shopcart.Option8.checked == true){//3 in 1 headrail
			document.shopcart.Option6.disabled = true;//2 in 1 headrail
		}
		else if(document.shopcart.Option6.checked == true){//2 in 1 headrail
			document.shopcart.Option8.disabled = true;//3 in 1 headrail
		}
		else{//enable both
			if(iMultipleBlinds == 1){
				document.shopcart.Option8.disabled = false;//3 in 1
				document.shopcart.Option6.disabled = false;//2 in 1 headrail
			}
		}
	}
	//Bamboo shades top-up bottom down, 2 in one headrail and contiuous cord
	if(document.shopcart.Option19 && document.shopcart.Option21 && document.shopcart.Option6 && document.shopcart.Option8){
		if(document.shopcart.Option21.checked == true){//cont. cord checked
			document.shopcart.Option19.disabled = true;//Top-up Bottom Down
			document.shopcart.Option6.disabled = true;//2 in 1 headrail
			document.shopcart.Option8.disabled = true;//3 in 1 headrail
		}
		else if(document.shopcart.Option19.checked == true){//Top-up Bottom Down
			document.shopcart.Option21.disabled = true;//cont. cord checked
			document.shopcart.Option6.disabled = true;//2 in 1 headrail
			document.shopcart.Option8.disabled = true;//3 in 1 headrail
		}
		else if(document.shopcart.Option6.checked == true){//2 in 1 headrail
			document.shopcart.Option21.disabled = true;//cont. cord checked
			document.shopcart.Option19.disabled = true;//Top-up Bottom Down
			document.shopcart.Option8.disabled = true;//3 in 1 headrail
		}
		else if(document.shopcart.Option8.checked == true){//3 in 1 headrail
			document.shopcart.Option21.disabled = true;//cont. cord checked
			document.shopcart.Option19.disabled = true;//Top-up Bottom Down
			document.shopcart.Option6.disabled = true;//2 in 1 headrail
		}
		else{//enable all
			document.shopcart.Option21.disabled = false;//cont. cord checked
			document.shopcart.Option19.disabled = false;//Top-up Bottom Down
			if(iMultipleBlinds != 1){
				document.shopcart.Option6.disabled = true;//2 in 1 headrail
				document.shopcart.Option8.disabled = true;//3 in 1 headrail
			}
		}
	}
	
	//Cell shades top-up bottom down, 2 in one headrail and contiuous cord
	if(document.shopcart.Option18 && document.shopcart.Option11 && document.shopcart.Option6 && document.shopcart.Option16){
		if(document.shopcart.Option11.checked == true){//top-up if cont. checked
			document.shopcart.Option18.disabled = true;//Top-up Bottom Down
			document.shopcart.Option6.disabled = true;//2 in 1 headrail
			document.shopcart.Option16.disabled = true;//Cordless
		}
		else if(document.shopcart.Option18.checked == true){//Top-up Bottom Down
			document.shopcart.Option11.disabled = true;//top-up if cont. checked
			document.shopcart.Option6.disabled = true;//2 in 1 headrail
			document.shopcart.Option16.disabled = true;//Cordless
		}
		else if(document.shopcart.Option6.checked == true){//2 in 1 headrail
			document.shopcart.Option11.disabled = true;//top-up if cont. checked
			document.shopcart.Option18.disabled = true;//Top-up Bottom Down
			document.shopcart.Option16.disabled = true;//Cordless
		}
		else if(document.shopcart.Option16.checked == true){//Cordless
			document.shopcart.Option11.disabled = true;//top-up if cont. checked
			document.shopcart.Option18.disabled = true;//Top-up Bottom Down
			document.shopcart.Option6.disabled = true;//2 in 1 headrail
		}
		else{//enable all
			document.shopcart.Option11.disabled = false;//top-up if cont. checked
			document.shopcart.Option18.disabled = false;//Top-up Bottom Down
			if(iMultipleBlinds != 1){
				document.shopcart.Option6.disabled = true;//2 in 1 headrail
			}
			document.shopcart.Option16.disabled = false;//Cordless
		}
	}
	else if(document.shopcart.Option18 && document.shopcart.Option11 && document.shopcart.Option6){
		if(document.shopcart.Option11.checked == true){//top-up if cont. checked
			document.shopcart.Option18.disabled = true;//Top-up Bottom Down
			document.shopcart.Option6.disabled = true;//2 in 1 headrail
		}
		else if(document.shopcart.Option18.checked == true){//Top-up Bottom Down
			document.shopcart.Option11.disabled = true;//top-up if cont. checked
			document.shopcart.Option6.disabled = true;//2 in 1 headrail
		}
		else if(document.shopcart.Option6.checked == true){//2 in 1 headrail
			document.shopcart.Option11.disabled = true;//top-up if cont. checked
			document.shopcart.Option18.disabled = true;//Top-up Bottom Down
		}
		else{//enable all
			document.shopcart.Option11.disabled = false;//top-up if cont. checked
			document.shopcart.Option18.disabled = false;//Top-up Bottom Down
			//document.shopcart.Option6.disabled = false;//2 in 1 headrail
			if(iMultipleBlinds != 1){
				document.shopcart.Option6.disabled = true;//2 in 1 headrail
			}
		}
	}
	else if(document.shopcart.Option18 && document.shopcart.Option11){
		if(document.shopcart.Option11.checked == true){//top-up if cont. checked
			document.shopcart.Option18.disabled = true;//Top-up Bottom Down
		}
		else if(document.shopcart.Option18.checked == true){//Top-up Bottom Down
			document.shopcart.Option11.disabled = true;//top-up if cont. checked
		}
		else{//enable both
			document.shopcart.Option11.disabled = false;//top-up if cont. checked
			document.shopcart.Option18.disabled = false;//Top-up Bottom Down
		}
	}
	else if(document.shopcart.Option18 && document.shopcart.Option6){
		if(document.shopcart.Option18.checked == true){//Top-up Bottom Down
			document.shopcart.Option6.disabled = true;//2 in 1 headrail
		}
		else if(document.shopcart.Option6.checked == true){//2 in 1 headrail
			document.shopcart.Option18.disabled = true;//Top-up Bottom Down
		}
		else{//enable both
			document.shopcart.Option18.disabled = false;//Top-up Bottom Down
			//document.shopcart.Option6.disabled = false;//2 in 1 headrail
			if(iMultipleBlinds != 1){
				document.shopcart.Option6.disabled = true;//2 in 1 headrail
			}
		}
	}
	
	
	// not allow routless and remote control
	if(document.shopcart.Option2 && document.shopcart.Option9){
		if(document.shopcart.Option9.checked == true){//routeless
			document.shopcart.Option2.disabled = true;//remote
		}
		else if(document.shopcart.Option2.checked == true){//remote
			document.shopcart.Option9.disabled = true;//routeless
		}
		else{//enable both
			document.shopcart.Option2.disabled = false;//routeless
			document.shopcart.Option9.disabled = false;//remote
		}
	}
	if(document.shopcart.FeatureOption18 && document.shopcart.FeatureOption7){//Vertical blinds. opposite stack with wand
		if(document.shopcart.FeatureOption18.value == 45 && document.shopcart.FeatureOption7.value == 16){
			alert("The wand option is not available on opposite stack blinds! Tilter control will be set to chain and cord.");
			document.shopcart.FeatureOption18.value = 44;
		}
	}
	if(document.shopcart.FeatureOption13 && document.shopcart.TapeColorID){//Roller - Decoractive Trim and Deco Bar
		if(document.shopcart.FeatureOption13.value == 35 && document.shopcart.TapeColorID.value != 0){
			alert("Decorative trims are not available with the deco bar hem style! Bottom hem style will be set to plain hem.");
			document.shopcart.FeatureOption13.value = 34;
		}
	}	
}

function SetPreviewColor(ID,ColorType){
	var eleTapeColorImage = document.getElementById("TapeColor");
	var eleColorImage = document.getElementById("BlindColor");
	var eleColorImage3 = document.getElementById("BlindColor3");
	var ColorID = document.shopcart.ColorID.value;
	var TapeColorID = 0;
	if(document.shopcart.TapeColorID){
		TapeColorID = document.shopcart.TapeColorID.value;
	}
	
	if(ColorID == 0){//No color selected, Set all color to nothing
		//Set blind sections to empty
		eleColorImage.src = "images/spacer.gif";
		if(eleColorImage3){	eleColorImage3.src = "images/spacer.gif";}
		
		//Set tape color
		if(eleTapeColorImage){
			if(TapeColorID == 0){//No tape selected
				eleTapeColorImage.src = "images/spacer.gif";
			}
			else{//Show tape color
				eleTapeColorImage.src = "images/tapes/tape_" + TapeColorID + ".jpg";
			}
		}
	}
	else{//Color Selected
		//Set color on blind sections
		eleColorImage.src = "images/blinds/blindcolor_" + ColorID + ".jpg";
		//if(eleColorImage3){eleColorImage3.src = "images/blinds/blindcolor_" + ColorID + "_3.jpg";}
		if(eleColorImage3){eleColorImage3.src = "images/blinds/blindcolor_" + ColorID + ".jpg";}
		if(eleTapeColorImage){
			if(TapeColorID == 0){//No tape selected
				if(eleColorImage3){
					//eleTapeColorImage.src = "images/blinds/blindcolor_" + ColorID + "_2.jpg";
					eleTapeColorImage.src = "images/blinds/blindcolor_" + ColorID + ".jpg";
				}
				else{//old products
					eleTapeColorImage.src = "images/spacer.gif";
				}
			}
			else{//Set to tape color
				eleTapeColorImage.src = "images/tapes/tape_" + TapeColorID + ".jpg";
			}
		}
	}
}

function validatePayment(frmEle){

	if(frmEle.measure_disclaimer.checked == false){
		alert("You must read the Measuring Instructions and Color Disclaimer and agree to the terms!");
		frmEle.measure_disclaimer.focus();
		return false;
	}
	//if(frmEle.color_disclaimer.checked == false){
	//	alert("You must read the color disclaimer agree to the terms! If you are worried about the color we suggest that you order a sample from our sample page.");
	//	frmEle.color_disclaimer.focus();
	//	return false;
	//}
	if(frmEle.Check  && frmEle.Call){
		if(frmEle.Check.checked == true || frmEle.Call.checked == true){//Check/moneyorder
			//alert("moneyorder");
			//return true;
		}
		else{//Credit
			if(frmEle.PaymentID.value == "0"){
				alert("You must select a payment type.");
				frmEle.PaymentID.focus();
				return false;
			}
			if(frmEle.CardNumber.value == ""){
				alert("You must enter a credit card number.");
				frmEle.CardNumber.focus();
				return false;
			}
			if(frmEle.Name.value == ""){
				alert("You must enter the name on the credit card.");
				frmEle.Name.focus();
				return false;
			}
			if(frmEle.Zip.value == ""){
				alert("You must enter your zip code.");
				frmEle.Zip.focus();
				return false;
			}		
		}
	}
	MM_showHideLayers('PaymentDiv','','show');
}

function validatePaymentMethod(){
	frmEle = document.shopcart;
	if((frmEle.Check.checked == true || frmEle.Call.checked == true) && (frmEle.PaymentID.value != "0")){
		//var b = confirm("You have selected multiple Payment Methods!\n\n1-Click OK to pay with credit card\n2-Click CANCEL to remove your credit card information and use an alternate payment method.");
		//if(b){//Remove alternative payment methods
		//if(myConfirm("You have selected multiple Payment Methods!\n\nPlease choose an option.","Credit Card","Alternative Method")){
		myConfirm("You have selected multiple Payment Methods!\n\nPlease choose an option.","Credit Card","Alternative Method",function(answer) { if(answer?"Credit Card":"Alternative Method" == "Credit Card"){setPayment(1);}else{setPayment(2);} })

	}
	if(frmEle.Check.checked == true && frmEle.Call.checked == true){
		myConfirm("You have selected multiple Payment Methods!","Cashiers Check/Money Order","Have USABlinds.com Call for Credit Card",function(answer) { if(answer?"Have USABlinds.com Call for Credit Card":"Cashiers Check/Money Order" == "Have USABlinds.com Call for Credit Card"){setPayment(3);}else{setPayment(4);} })
	}
}
function setPayment(theType){
	if(theType == 1){//Remove alternative payment methods
		frmEle.Check.checked = false;
		frmEle.Call.checked = false;
	}
	else if(theType == 2){//Pay with alternative method
		frmEle.PaymentID.value = 0;
		frmEle.CardNumber.value = "";
	}
	else if(theType == 3){//Call for credit card selected
		frmEle.Call.checked = false;
	}
	else if(theType == 4){//Money Order selected
		frmEle.Check.checked = false;
	}
}
var answerFunction;
function myConfirm(text,button1,button2,answerFunc) {
	var box = document.getElementById("confirmBox");
	box.getElementsByTagName("p")[0].firstChild.nodeValue = text;
	var button = box.getElementsByTagName("input");
	button[0].value=button1;
	button[1].value=button2;
	answerFunction = answerFunc;
	box.style.visibility="visible";
}
function answer(response) {
	document.getElementById("confirmBox").style.visibility="hidden";
	answerFunction(response);
}

//Sample Scripts
function validateSamples(frmEle,useDhtml){
	var count = 0;var BambooCount = 0;
	var sSelSamples = "";var SampleValue = "";
	var ItemID = 0;
	
	for(x=frmEle.Sample.length-1;x>=0;x--){
		if(frmEle.Sample[x].checked){
			//Update Number of selected samples
			count++
			ItemID = frmEle.Sample[x].value;
			if(useDhtml == 1){//Setup inner html for list of selected samples
				sSelSamples += eval("document.samplesForm.scn" + ItemID + ".value") + "<br>"
			}
			var aItemID = ItemID.split("_");
			//alert(aItemID[1]);
			if (aItemID.length > 0){
				if (aItemID[1] == "60" || aItemID[1] == "62" || aItemID[1] == "83" || aItemID[1] == "84"){
					BambooCount++
					//alert(BambooCount);
				}
			}
		}
	}
	if(count == 0){
		alert("You must select at least one Sample!");
		//Hide Sample list
		if(useDhtml == 1){//document.all.SelectedSamples.style.display="none";
			MM_showHideLayers('SelectedSamples','','hide');
		}
		return false;
	}
	if(count > 20){
		alert("We thank you for your interest in our blinds, but we limit our samples to 20 per customer. Please remove one sample and then click the Enter Shipping button to complete your transaction.");
		return false;
	}
	if(BambooCount > 4){
		alert("We thank you for your interest in our blinds, but we limit our BAMBOO samples to 4 per customer. Please remove one sample and then click the Enter Shipping button to complete your transaction.");
		return false;
	}
	if(count > 0 && useDhtml == 1){//Show seleccted sample list
		var sHeader = "<table width='195' cellpadding='2' cellspacing='0' class='FullBox'><tr><td><font class='PageHeader'><nobr><h2>Selected Samples</h2></font></nobr>";
		var sFooter = "</td></tr></table>";
		document.getElementById("SelectedSamples").innerHTML = sHeader + sSelSamples + sFooter;
		//document.all.SelectedSamples.innerHTML = 
		document.all.SelectedSamples.style.display="block";
		MM_showHideLayers('SelectedSamples','','show');
		MM_showHideLayers('upArrow','','show');
		MM_showHideLayers('downArrow','','hide');
	}
}

function validateSampleUser(frmEle){
	if(frmEle.FirstName.value == ""){
		alert("You must enter your Firstname!");
		frmEle.FirstName.focus();
		return false;
	}
	if(frmEle.LastName.value == ""){
		alert("You must enter your Lastname!");
		frmEle.LastName.focus();
		return false;
	}
	if(frmEle.Address.value == ""){
		alert("You must enter a Address!");
		frmEle.Address.focus();
		return false;
	}
	if(frmEle.Email){
		if(frmEle.Email.value == ""){
			alert("You must enter a Email!");
			frmEle.Email.focus();
			return false;
		}
		var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
		var check=/@[\w\-]+\./;
		var checkend=/\.[a-zA-Z]{2,4}$/;
		
		emailad = frmEle.Email.value;
		
		if(((emailad.search(exclude) != -1)||(emailad.search(check))
		== -1)||(emailad.search(checkend) == -1)){
	  		alert("Incorrect email address!  Please ammend.");
			frmEle.Email.focus();
			return false;
		}
	 }
	if(frmEle.City.value == ""){
		alert("You must enter a City!");
		frmEle.City.focus();
		return false;
	}
	if(frmEle.State.value == "" || frmEle.State.value == "0"){
		alert("You must enter a State!");
		frmEle.State.focus();
		return false;
	}
	if(frmEle.Zip.value == ""){
		alert("You must enter a Zip!");
		frmEle.Zip.focus();
		return false;
	}
	if(frmEle.Shipping.value != "0"){
		if(frmEle.Phone.value == ""){
			alert("You must enter a Phone!");
			frmEle.Phone.focus();
			return false;
		}
	}
}

function validateSamplePayment(frmEle){
		if(frmEle.PaymentID.value == "0"){
			alert("You must select a payment type.");
			frmEle.PaymentID.focus();
			return false;
		}
		if(frmEle.CardNumber.value == ""){
			alert("You must enter a credit card number.");
			frmEle.CardNumber.focus();
			return false;
		}
		if(frmEle.BillName.value == ""){
			alert("You must enter the name on the credit card.");
			frmEle.BillName.focus();
			return false;
		}
		if(frmEle.BillZip.value == ""){
			alert("You must enter your zip code.");
			frmEle.BillZip.focus();
			return false;
		}
}

//User scripts
function validateUser(frmEle){
	if(frmEle.FirstName.value == ""){
		alert("You must enter a Firstname!");
		frmEle.FirstName.focus();
		return false;
	}
	if(frmEle.LastName.value == ""){
		alert("You must enter a Lastname!");
		frmEle.LastName.focus();
		return false;
	}
	if(frmEle.Address.value == ""){
		alert("You must enter a Address!");
		frmEle.Address.focus();
		return false;
	}
	if(frmEle.Email){
		if(frmEle.Email.value == ""){
			alert("You must enter a Email!");
			frmEle.Email.focus();
			return false;
		}
		var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
		var check=/@[\w\-]+\./;
		var checkend=/\.[a-zA-Z]{2,4}$/;
		
		emailad = frmEle.Email.value;
		
		if(((emailad.search(exclude) != -1)||(emailad.search(check))
		== -1)||(emailad.search(checkend) == -1)){
	  		alert("Incorrect email address!  Please ammend.");
			frmEle.Email.focus();
			return false;
		}
	 }
	if(frmEle.City.value == ""){
		alert("You must enter a City!");
		frmEle.City.focus();
		return false;
	}
	if(frmEle.State.value == "" || frmEle.State.value == "0"){
		alert("You must enter a State!");
		frmEle.State.focus();
		return false;
	}
	if(frmEle.Zip.value == ""){
		alert("You must enter a Zip!");
		frmEle.Zip.focus();
		return false;
	}
	if(frmEle.Phone.value == ""){
		alert("You must enter a Phone Number!");
		frmEle.Phone.focus();
		return false;
	}
	if(frmEle.Password){
		if(frmEle.Password.value == ""){
			alert("You must enter a Password!");
			frmEle.Password.focus();
			return false;
		}
		if(frmEle.Password.value != frmEle.Password2.value){
			alert("Passwords do not match!");
			frmEle.Password.focus();
			return false;
		}
	}
}

//Gift Card Scripts
function validateGiftCardPayment(frmEle){
		if(frmEle.Amount.value == "0"){
			alert("You must select a Gift Certificate type.");
			frmEle.Amount.focus();
			return false;
		}
		if(frmEle.PaymentID.value == "0"){
			alert("You must select a payment type.");
			frmEle.PaymentID.focus();
			return false;
		}
		if(frmEle.CardNumber.value == ""){
			alert("You must enter a credit card number.");
			frmEle.CardNumber.focus();
			return false;
		}
		if(frmEle.BillName.value == ""){
			alert("You must enter the name on the credit card.");
			frmEle.BillName.focus();
			return false;
		}
		if(frmEle.BillZip.value == ""){
			alert("You must enter your zip code.");
			frmEle.BillZip.focus();
			return false;
		}
		if(frmEle.Email.value == ""){
			alert("You must enter your Email.");
			frmEle.Email.focus();
			return false;
		}
}

//Generic Scripts
function ToDollarsAndCents(n) 
{ 
   var s = "" + Math.round(n * 100) / 100 
   var i = s.indexOf('.') 
   if (i < 0) return s + ".00" 
   var t = s.substring(0, i + 1) + s.substring(i + 1, i + 3) 
   if (i + 2 == s.length) t += "0" 
   return t 
}