var CART_ONLOAD = "document.forms['add_to_cart'].elements['requestedQuantity'].focus();";

	function add_to_cart(itemGroupOid, baseItemOid, numberSku){
	        
		var cart_box=new dynRegion('/ajaxView', 'cart-box');

		show_cart_box();
		cart_box.onloadevent = CART_ONLOAD;
		cart_box.update('view=productCart&itemGroupOID=' + itemGroupOid + '&baseItemOID=' + baseItemOid + '&numberSKU=' + numberSku);
	}
	
	function add_to_cart_form(itemGroupOid, baseItemOid, numberSku, attributeHash){
	        
		var cart_box=new dynRegion('/ajaxView', 'cart-box');

		show_cart_box();
		cart_box.onloadevent = CART_ONLOAD;
		cart_box.update('view=productCart&itemGroupOID=' + itemGroupOid + '&baseItemOID=' + baseItemOid + '&numberSKU=' + numberSku + '&attrib=' + attributeHash);
	}
	
	function add_to_cart_with_attrib(itemGroupOid, baseItemOid, numberSku, attributeHash, pickListSelectedValue){
	        
		var cart_box=new dynRegion('/ajaxView', 'cart-box');

		show_cart_box();
		cart_box.onloadevent = CART_ONLOAD;
		cart_box.update('view=productCart&itemGroupOID=' + itemGroupOid + '&baseItemOID=' + baseItemOid + '&numberSKU=' + numberSku + '&attrib=' + attributeHash  + '&pickListSelectedValue=' + pickListSelectedValue);
	}
	
	function displayPhoneOnly(){	        
		var cart_box=new dynRegion('/ajaxView', 'cart-box');

		show_cart_box();
		cart_box.update('view=productPhoneOnly');
	}
	
	function show_cart_box(){
		var pop_box=document.getElementById('cart-box-wrapper');
		var screen_mask=document.getElementById('screen-mask');
		if(document.body && document.body.scrollTop)
			scrollTop = document.body.scrollTop;  
		else if(document.documentElement && document.documentElement.scrollTop)
			scrollTop = document.documentElement.scrollTop; 
		else if(window.pageYOffset)
			scrollTop = window.pageYOffset;  
		else
			scrollTop =0;

		screen_mask.style.height=Math.max(document.body.scrollHeight,document.body.offsetHeight)+"px";
		set_opacity(screen_mask,50);
		screen_mask.style.visibility='visible';
		screen_mask.style.display='block';
		pop_box.style.top=(80+scrollTop)+"px";
		pop_box.style.visibility='visible';
	}

	function hide_cart_box(){
		var pop_box=document.getElementById('cart-box-wrapper');
		var screen_mask=document.getElementById('screen-mask');
		screen_mask.style.visibility='hidden';
		pop_box.style.visibility='hidden';
		screen_mask.style.display = "none";
	}

	
	
	function displayProductInfo()
	{
    	if (document.getElementById("attrRadio") != null) 
    	{
    		if (document.getElementById("attrRadio").checked==true)
    		{
				displayChart();    			
    		}
    		else
    		{
    			displaySkus();
    		}    	
    	}
 		if (document.getElementById("tab-accessories-active") != null)
		{
			document.getElementById("tab-accessories-active").style.display="none";
		}
		if (document.getElementById("tab-productInfo-active") != null)
		{
			document.getElementById("tab-productInfo-active").style.display="block";
		}
	}
	function displaySkus()
	{
    	if (document.getElementById("chartSection") != null) 
    	{
    		document.getElementById("chartSection").style.display="none";
    	}
    	if (document.getElementById("skuViewSection") != null) 
    	{
    		document.getElementById("skuViewSection").style.display="block";
    	}
    	if (document.getElementById("accessoriesSection") != null) 
    	{
    		document.getElementById("accessoriesSection").style.display="none";
    	}
    	if (document.getElementById("infoViewMethod") != null) 
    	{
    		document.getElementById("infoViewMethod").style.display="block";
    	}
	}
	
    function displayChart() 
    {
    	if (document.getElementById("chartSection") != null) 
    	{
    		document.getElementById("chartSection").style.display="block";
    	}
    	if (document.getElementById("skuViewSection") != null) 
    	{
    		document.getElementById("skuViewSection").style.display="none";
    	}
    	if (document.getElementById("accessoriesSection") != null) 
    	{
    		document.getElementById("accessoriesSection").style.display="none";
    	}
    	if (document.getElementById("infoViewMethod") != null) 
    	{
    		document.getElementById("infoViewMethod").style.display="block";
    	}
    }

    function displayAccessories() 
    {
    	if (document.getElementById("chartSection") != null) 
    	{
	    	document.getElementById("chartSection").style.display="none";
    	}
    	if (document.getElementById("skuViewSection") != null) 
    	{
    		document.getElementById("skuViewSection").style.display="none";
    	}
    	if (document.getElementById("accessoriesSection") != null) 
    	{
    		document.getElementById("accessoriesSection").style.display="block";
    	}
    	if (document.getElementById("infoViewMethod") != null) 
    	{
    		document.getElementById("infoViewMethod").style.display="none";
    	}
		if (document.getElementById("tab-accessories-active") != null)
		{
			document.getElementById("tab-accessories-active").style.display="block";
		}
		if (document.getElementById("tab-productInfo-active") != null)
		{
			document.getElementById("tab-productInfo-active").style.display="none";
		}
    }
    
    
    
    /*
     * New javascript functions for Ecommerce 3.0
     * 
     * The three displayPhoneOnly methods are just to cover the three ways that the 
     * buttons are built. It's easier to include the three javascript
     * functions than to change the processing involved in building them. In 
     * essence, for these three, it does not matter what params come in.
     */
	
	function displayPhoneOnlySingle(sku){ 
		displayPhoneOnly();
	}
	
	function displayPhoneOnlyPicklist(form, label){ 
		displayPhoneOnly();
	}
	
	function displayPhoneOnlyMultibuttonPicklist(form, list, label){ 
		displayPhoneOnly();
	}

    function addToCart(sku){
        var productGroupId = document.getElementById("productGroupId").value;
        add_to_cart(productGroupId, productGroupId, sku);
    }

    function addToCartMultibuttonPicklist(form, list, pickListLabel) {
    	var stylePick = form.elements["pickListSelectedValue"].value;
    	var productGroupId = document.getElementById("productGroupId").value;
    	if (stylePick == "Select") {
    		displayErrorMessages(PRD_DTL_SEL_PICKLIST + pickListLabel + "<br>");
    		return;
    	} else {
    		hideErrorMessages();
    	}
        var listArray = list.split("||");
        var skuList = new Array(listArray.length);
        var skuAttr = '';
        for (var i = 0; i < listArray.length; i++) {
        	skuAttr = listArray[i].split("|");
        	if (stylePick == skuAttr[0]) {
        		var sku = skuAttr[1];
        		add_to_cart(productGroupId, productGroupId, sku);
        	}
        }
        
    }
    
    function addToCartPicklist(form, pickListLabel) {
    	var sku = form.elements["pickListSelectedValue"].value;
    	var productGroupId = document.getElementById("productGroupId").value;
    	if (sku == "Select") {
    		displayErrorMessages(PRD_DTL_SEL_PICKLIST + pickListLabel + "<br>");
    		return;
    	} else {
    		hideErrorMessages();
    	}
		add_to_cart(productGroupId, productGroupId, sku);
    }
	


