// JavaScript Document

var skuData = new Array();

function sizeSelected()
{
	var lSkuId;
	
	// lSkuId=lstProdSize.options[lstProdSize.options.selectedIndex].value;
	lSkuId = window.document.getElementById("lstProdSize").options[window.document.getElementById("lstProdSize").options.selectedIndex].value;

	var oItemPrice = window.document.getElementById("txtItemPrice");
	oItemPrice.value = skuData[lSkuId][2];
	
	oAddToCartBtn = window.document.getElementById("btnAddToCart");
	oProdQtyTxt = window.document.getElementById("txtProdQty");

	if(skuData[lSkuId][4]!="1")
	{
		oProdQtyTxt.value = 0;
		oProdQtyTxt.style.display="none";
		oAddToCartBtn.src = "images/common/shared/outofstock.jpg";
	}
	else
	{
		oProdQtyTxt.value = "";
		oProdQtyTxt.style.display = "block";
		oAddToCartBtn.src = "images/common/shared/addbag.jpg";
	}
}

function addToCart()
{
 var lLstSize = window.document.getElementById("lstProdSize");
 var lItemId = lLstSize.options[lLstSize.options.selectedIndex].value;
 
	
     if (skuData[lItemId][4]!="1")
     {
         alert("This item is not in stock.");
         return false;
     }
	
	lItemQty = window.document.getElementById("txtProdQty").value;
	lItemQty = parseInt(lItemQty);
	lItemQty = (isNaN(lItemQty)?0:lItemQty);

	if(lItemQty <= 0)
	{
		alert("Please enter a quantity.");
		return false;
	}        
	
	
	if(lItemQty > 4)
	{
		alert("We're sorry, orders are limited to no more that 4 units of any item.");
		return false;
	}
	
	//var oFrmUserItem = window.document.getElementsByName("frmUserItem");
	//oUserSku = oFrmUserItem[0].getElementById("sku");
	oUserSku = window.document.getElementById("sku");
	oUserSku.value = lItemId+"|"+lItemQty; 
	
	window.document.frmUserItem.action="https://shop.chanel.com/Cart.aspx";
	
	window.document.frmUserItem.submit();
}


function prePopulateSKU(pSKU) {
    lList = document.getElementById("lstProdSize");
    sLen = lList.length;
    for (var i = 0; i < sLen; i++) {
        if(lList[i].value == pSKU) {
            lList[i].selected = "selected";
        }
    }
}
skuData["106522"] = new Array("089100043162", "", "$46.00", "", "1");
sizeSelected("106522")
