var itemIndex = 0;
var handed = 1;

function selectDoor(index, hand) {
	itemIndex = index;
	handed = hand;

	/*for (x = 0; x < document.frmDoor.quantitySelect.length; x++) {
		document.frmDoor.quantitySelect[x].value = "0";
	}*/

	//document.frmDoor.quantitySelect[index].value = "1";
}


function ShoppingCart()
   {

	document.frmDoor.referrer.value=document.referrer; 
	document.frmDoor.action.value='NewSessionCart'; 

	document.frmDoor.submit(); 
   }


function addToCart() {
	var productFound = false;
	for (x = 0; x < document.frmDoor.product.length; x++) {
		if (document.frmDoor.product[x].checked) {
			productFound = true;
		}
	}
	
	if (!productFound) {
		alert("Please select a product to add to your cart.");
		return false;
	}

	if (handed == 1) {
		if (document.frmDoor.hand[0].checked == false && document.frmDoor.hand[1].checked == false) {
			alert("Please select what side the hinges should be on.");
			document.frmDoor.hand[0].focus();
			return false;
		}
		else {
			if (document.frmDoor.hand[0].checked) {
				document.frmDoor.handing.value = 'RightHand';
			}
			else {
				document.frmDoor.handing.value = 'LeftHand';
			}
		}
	}
	else {
		document.frmDoor.handing.value = 'Double';
	}
	
/*
	for (x = 0; x < document.frmDoor.color.length; x++) {
		if (document.frmDoor.color[x].checked) {
			document.frmDoor.doorcolor.value = document.frmDoor.color[x].value; 
		}
	}
*/

	var qty = 1;
	//document.frmDoor.quantitySelect[itemIndex].value;
	
	/*if (isNaN(qty)) {
		alert("Please enter a valid quantity.");
		document.frmDoor.quantitySelect[itemIndex].focus();
		return false;
	}
	
	if (qty < 1) {
		alert("Please enter at least 1 for the quantity.");
		document.frmDoor.quantitySelect[itemIndex].focus();
		return false;
	}*/
	
	document.frmDoor.quantity.value = qty;
	document.frmDoor.itemnumber.value = document.frmDoor.product[itemIndex].value;
	
	//alert (document.frmDoor.quantity.value + " " + document.frmDoor.itemnumber.value + " " + document.frmDoor.handing.value);
	
	document.frmDoor.submit();
}
