// JavaScript Document

function goCart()
{var x = window.document.frm;
	//window.alert("hello");
	//x.action = x.action + '#top';
	var i;
	var sts;
	var total;
	var subtotal;
	var temp;
	var chkTotal;
	
	total    = 0;
	chkTotal = parseInt(x.ncolor.value);
	subtotal = x.ptSize.value;
	//alert("subtotal " + subtotal);
	sts = 0;
	
	for(i=1;i<=chkTotal;i++)
	{
		
		  if (eval("x.chkcolor"+i+".checked")== true) 
		  {
			  sts = sts + 1;
		  }
	}
	
	if (sts==0)
	{
		window.alert("You missed product color");
			
		return(false);
	}
	if (sts > 1)
	{
		window.alert("Please select only one color");
		
		return(false);
	}
	sts = 0;
	
	for(i=0;i<x.workType.length;i++)
	{
		if(x.workType[i].checked == true) 
		{
			sts = 1;
		}
	}
	if (sts==0)
	{
		window.alert("You missed printing type");
	    return(false);
	}
	
//		var chkColorFlag=0;
//	for(i=0;i< document.frm.chkcolor.length;i++)
//	{
//	    if(document.frm.chkcolor[i].checked==true)
//	    {
//	        chkColorFlag =parseInt(chkColorFlag) + 1;
//	        
//	        document.frm.hidNoOfColors.value=chkColorFlag;
//	        
//	    }
//	}

//	if (chkColorFlag <=0 )
//	{
//		window.alert("Please select an ink color");
//	    return(false);
//	}

	for (i=1;i<=subtotal;i++)
	{
	    //alert(i);
		temp = eval("window.document.frm.txt"+i).value;
		//alert(parseInt(eval("window.document.frm.txt"+i).value));
		//total = total + parseInt(eval("window.document.frm.txt"+temp).value);
		//alert("total " + i + total)
		total = total + parseInt(eval("window.document.frm.txt"+i).value);
		
		
	}
	
	x.quantity.value   = total
	x.txtquantity.value= total
//    	alert(document.getElementById("hidTotal"));
//    x.quantity.value =document.getElementById("hidTotal").value;
//	x.txtquantity.value=document.hidTotal.value;

	if (total < parseInt(x.pMinQuantitylevel.value))
	{
		window.alert("Minimum " + x.pMinQuantitylevel.value + " quantity required");
		return(false);
	}
	
	x.action ="instant-addto-cart.asp"
	window.document.frm.submit();
	 
}
function checkQuoteForProduct()
{
    var x = window.document.frm;
	var i;
	var sts;
	var total;
	var subtotal;
	var temp;
	var chkTotal;
	
	total    = 0;

	chkTotal = parseInt(x.ncolor.value);

	subtotal = x.ptSize.value;
	//alert("subtotal " + subtotal);
	sts = 0;
	
	var selectedColor = document.getElementById("hidSelectedColor")
	if (selectedColor == "")
	{
		window.alert("You missed product color");
		
		return(false);
	}
	sts = 0;
	
	for(i=0;i<x.workType.length;i++)
	{
		if(x.workType[i].checked == true) 
		{
			sts = 1;
		}
	}
	if (sts==0)
	{
		window.alert("You missed printing type");
	    return(false);
	}

	
//	for (i=1;i<=subtotal;i++)
//	{
//        var productSize = document.getElementById("txtproductsize_" + i);
//		temp =parseInt(eval(productSize).value,10);

//		total = total + parseInt(eval(productSize).value,10);
//		window.document.getElementById("sizeprice"+i).value=temp;
//		
//		        
//	}
    if(subtotal > 1)
    {
        var txtproductSize;
        for (i = 0; i < subtotal; i++)
        {
            
            txtproductSize = document.getElementsByName("txtproductsize");
            if(txtproductSize[i].value != '')
                total = total + parseInt(txtproductSize[i].value);
        }
    }
    else
    {
        if(x.txtproductsize.value != '')
            total = parseInt(x.txtproductsize.value);
    }
	x.quantity.value   = total
	x.txtquantity.value= total
	
	if (total < parseInt(x.pMinQuantitylevel.value))
	{
		window.alert("Minimum " + x.pMinQuantitylevel.value + " quantity required");
		return(false);
	}
	
    if(x.screenPrint.checked)
	{
	    if (x.scrFrontColor.value==0 && x.scrBackColor.value ==0 && x.scrRightColor.value ==0 && x.scrLSleevColor.value ==0 )
	    {
	    window.alert("Please select a Screenprint Location");
	    return (false);
	    }
    }
    if (x.embroidery.checked)
    {
        if (x.embFrontColor.checked==false && x.embBackColor.checked ==false && x.embHatColor.checked ==false )
	    {
	    window.alert("Please select an Embroidery Location");
	    return (false);
	    }   
    }   
	
	return true;
}
function check()
{
	var x = window.document.frm;
	//window.alert("hello");
	//x.action = x.action + '#top';
	var i;
	var sts;
	var total;
	var subtotal;
	var temp;
	var chkTotal;
	
	total    = 0;
	chkTotal = parseInt(x.ncolor.value);
	subtotal = x.ptSize.value;
	//alert("subtotal " + subtotal);
	sts = 0;
	
	for(i=1;i<=chkTotal;i++)
	{
		
		  if (eval("x.chkcolor"+i+".checked")== true) 
		  {
			  sts = sts + 1;
		  }
	}
	
	if (sts==0)
	{
		window.alert("You missed product color");
		
		return(false);
	}
	if (sts > 1)
	{
		window.alert("Please select only one color");
		
		return(false);
	}
	sts = 0;
	
	for(i=0;i<x.workType.length;i++)
	{
		if(x.workType[i].checked == true) 
		{
			sts = 1;
		}
	}
	if (sts==0)
	{
		window.alert("You missed printing type");
	    return(false);
	}
//	var chkColorFlag=0;
//	for(i=0;i< document.frm.chkcolor.length;i++)
//	{
//	    if(document.frm.chkcolor[i].checked==true)
//	    {
//	        chkColorFlag =parseInt(chkColorFlag) + 1;
//	        document.frm.hidNoOfColors.value=chkColorFlag;
//	     
//	    }
//	}

//	if (chkColorFlag <=0 )
//	{
//		window.alert("Please select an ink color");
//	    return(false);
//	}
	
	for (i=1;i<=subtotal;i++)
	{
		//alert(eval("window.document.frm.txt"+i).value);
		temp =parseInt(eval("window.document.frm.txt"+i).value,10);
		//alert(parseInt(eval("window.document.frm.txt"+i).value));
		//total = total + parseInt(eval("window.document.frm.txt"+temp).value);
		//alert("total " + i + total)
		//alert(temp);
		//alert(parseInt(temp,10));
		total = total + parseInt(eval("window.document.frm.txt"+i).value,10);
		window.document.getElementById("sizeprice"+i).value=temp;
		//if (window.document.getElementById("sizeprice"+i).value)
		//{
		    //alert('test ' + window.document.getElementById("sizeprice"+i).value + 'temp ' + temp )
		    //window.document.getElementById("sizeprice"+i).value=temp;
		//}
		//if (x.eval("window.document.frm.sizeprice"+i).value != "0")
		    //x.eval("window.document.frm.sizeprice"+i).value=temp;
		// else
		        //x.eval("window.document.frm.sizeprice"+i).value=0;
		        
	}
	
	x.quantity.value   = total
	x.txtquantity.value= total

        //x.quantity.value =document.getElementById("hidTotal").value;
	    //x.txtquantity.value=document.hidTotal.value;
	
	if (total < parseInt(x.pMinQuantitylevel.value))
	{
		window.alert("Minimum " + x.pMinQuantitylevel.value + " quantity required");
		return(false);
	}
	
    if(x.screenPrint.checked)
	{
	    if (x.scrFrontColor.value==0 && x.scrBackColor.value ==0 && x.scrRightColor.value ==0 && x.scrLSleevColor.value ==0 )
	    {
	    window.alert("Please select a Screenprint Location");
	    return (false);
	//window.alert(x.scrFront.value);
	    }
    }
    if (x.embroidery.checked)
    {
        if (x.embFrontColor.checked==false && x.embBackColor.checked ==false && x.embHatColor.checked ==false )
	    {
	    window.alert("Please select an Embroidery Location");
	    return (false);
	//window.alert(x.scrFront.value);
	    }   
    }   
	//window.location.href = x.action
	
	return true;
}
