function setQty(state)
{
		document.getElementById("totPrices").style.display="none";	
		document.getElementById("AddToCart").disabled=true;
	if(state=="0")
	{
		document.getElementById("pquantity").disabled=true;
		document.getElementById("AddToCart").disabled=true;
	}
	else
	{
		document.getElementById("AddToCart").disabled=false;
		document.getElementById("pquantity").disabled=false;
	}
}
function displayRows(name, type)
{
	var form = document.Form;
	state = form.state_code.options[form.state_code.selectedIndex].value;
	if (state==0)
	{
		mess = "<font color='#5C5CF4' size='1'>Complete form to view delivered price.</font>"
	}
	else
	{
		mess = "<font color='#5C5CF4' size='1'>Please enter the quantity to view delivered price.</font>";
	}
	document.getElementById('totPrices').innerHTML=mess;

	if(name=="pshape_row")
	{
		var oObj = document.all(name);
		var oObj1 = document.all('pcolor1');
		var oObj2 = document.all('pcolor2');
		var oObj3 = document.all('pcolor3');
		var oObj4 = document.all('pcolor4');
		var oObj5 = document.all('pshapeRow1');
		var oObj6 = document.all('pshapeRow2');
		var oObj7 = document.all('RoundSafetyPadPrice');

		if(type=="1")
		{
//			oObj.style.display='none';

			oObj1.style.display='none';
			oObj2.style.display='';
			oObj3.style.display='';
			oObj4.style.display='';
			oObj5.disabled=true;
			oObj6.disabled=true;
			oObj7.innerHTML="<P class=small><font color='#5C5CF4' size='2'>&nbsp;&nbsp;Not compatible with enclosure.</font>";
		}
		else
		{
			oObj.style.display='';
			oObj5.disabled=false;
			oObj6.disabled=false;
			oObj7.innerHTML="";
		}
	}
	else if(name=="pshape")
	{
		var oObj1 = document.all('pcolor1');
		var oObj2 = document.all('pcolor2');
		var oObj3 = document.all('pcolor3');
		var oObj4 = document.all('pcolor4');
//		var oObj5 = document.all('pcolor5');
		if(type=="pcolor1")
		{
			oObj1.style.display='';
			oObj2.style.display='none';
			oObj3.style.display='none';
			oObj4.style.display='none';
//			oObj5.style.display='none';
		}
		else if(type=="pcolor2")
		{
			oObj1.style.display='none';
			oObj2.style.display='';
			oObj3.style.display='';
			oObj4.style.display='';
//			oObj5.style.display='';
		}
	}

	//qObj5 = form.all("pquantity");
//	qObj5 = document.all("state_code");
//	qObj5.value = '0';		
	qObj5 = document.all("pquantity");
	qObj5.value = '';		

	document.getElementById("AddToCart").disabled=true;
	//document.getElementById("totPrices").style.display="none";

}
function validate(form)
{

	var form = document.Form;
	//obj = form.all('psize');
	obj = form.psize;
	psize = obj.value;
	if(psize==0)
	{
		alert("Please select the frame size.");
		obj.focus();
		return false;
	}
	
	//obj = form.all('enclosure');
	obj = form.enclosure;
	if(!obj[0].checked && !obj[1].checked)
	{
		alert("Please select the enclosure unit type.");
		obj[0].focus();
		return false;
	}
	
	//obj = form.all('pshape');
	obj = form.pshape;
	if(obj[0].checked)
	{
		var totColor = 0;
		//colObj1 = form.all("color_qty1");
		colObj1 = form.color_qty1;
		//colObj2 = form.all("color_qty2");
		colObj2 = form.color_qty2;
		//colObj3 = form.all("color_qty3");
		colObj3 = form.color_qty3;

		if(colObj1.value!='' && !isNaN(colObj1.value) && colObj1.value!=0)
		{
			totColor += Math.round(colObj1.value);
		}
		if(colObj2.value!='' && !isNaN(colObj2.value) && colObj2.value!=0)
		{
			totColor += Math.round(colObj2.value);
		}
		if(colObj3.value!='' && !isNaN(colObj3.value) && colObj3.value!=0)
		{
			totColor += Math.round(colObj3.value);
		}
		if(totColor!=8)
		{
			alert("Please enter 8 color for sections.");
			colObj1.focus();
			return false;
		}
	}
	var pstate = document.Form.state_code.options[document.Form.state_code.selectedIndex].value;
	if(pstate==0)
	{
		alert("Please select state.");
		return false;
	}

	//qObj = form.all("pquantity");
	qObj = form.pquantity;
	var pqty = qObj.value;
	if (pqty == "")
	{
		alert("Please enter the quantity.");
		qObj.focus();
		return false;
	}
	if (!(pqty <= 99999 && pqty  > 0))
	{
		alert("Please enter a numeric value for quantity");
		qObj.focus();
		return false;
	}

	//obj = form.all('zipcode');if(obj=="")	{alert("Please enter valid code.");	obj.focus();	return false;}

	document.Form.submit();
    return true;
}


function e( name )
{
	//return document.all[name];
}


/*
function displayMessage(form,type)
{
	var form = document.Form;
//	obj = form.all('shippingPrice');
//	obj.innerHTML="Please wait .. while we calculate shipping price.";
	//obj = form.all('totPrices');
	obj = form.totPrices;
	if(type=='1')
	{
		//form.zipcode.value="";
		obj.innerHTML="Please input all the required parameters";
	}
	else
	{
		obj.innerHTML="Please wait .. while we calculate total price.";
	}
}	
*/
function callShipment()
{	
	var form = document.Form;
	var enclosure = "";
	var psize = "";
	var padshape = "";
	
	//obj = form.all('psize');
	obj = form.psize;
	psize = obj.value;

// enclousre

	obj = form.enclosure;
	if(obj[0].checked || obj[1].checked)
	{
		if(obj[0].checked)
		{
			enclosure = obj[0].value;
		}
		if(obj[1].checked)
		{
			enclosure = obj[1].value;
		}
	}
	else if(!obj[0].checked && !obj[1].checked)
	{
		alert('Please select the Enclosure Unit');
		obj[0].focus();
		return false;
	}

// pad

	obj = form.pshape;
	if(obj[0].checked || obj[1].checked)
	{
		if(obj[0].checked)
		{
			padshape = obj[0].value;
		}
		if(obj[1].checked)
		{
			padshape = obj[1].value;
		}
	}
	else if(!obj[0].checked && !obj[1].checked)
	{
		alert('Please select the Safety Pad');
		obj[0].focus();
		return false;
	}


	obj = form.state_code;
	state_code = obj.value;
	//obj = form.all('pquantity');
	obj = form.pquantity;
	qty = obj.value;
	if(qty=="")
		obj.value=1;
	qty = obj.value;


	var strVariables = 'action=totPrice&shape=octagonal&psize=' + psize+"&qty="+qty+"&enclosure="+enclosure+"&padshape="+padshape+"&state_code="+state_code;
	
	
	if(qty =="0" || qty == "" || isNaN(qty))
	{		
		document.getElementById("totPrices").style.display="none";	
		document.getElementById("AddToCart").disabled=true;
	}

	if(psize!="0" && qty!="" && !isNaN(qty) && qty!="0" && state_code!='0')
	{
		//displayMessage("Form","0");
		document.getElementById("AddToCart").disabled=false;
		document.getElementById("totPrices").style.display="";
		makeRequest('ajax_function.php?'+strVariables, "totPrices");
	}
	
}

function padColor()
{
	var form = document.Form;
	var totColor = 0;
	//colObj1 = form.all("color_qty1");
	colObj1 = form.color_qty1;
	//colObj2 = form.all("color_qty2");
	colObj2 = form.color_qty2;
	//colObj3 = form.all("color_qty3");
	colObj3 = form.color_qty3;

	if(colObj1.value!='' && !isNaN(colObj1.value) && colObj1.value!=0)
	{
		totColor += Math.round(colObj1.value);
	}
	if(colObj2.value!='' && !isNaN(colObj2.value) && colObj2.value!=0)
	{
		totColor += Math.round(colObj2.value);
	}
	if(colObj3.value!='' && !isNaN(colObj3.value) && colObj3.value!=0)
	{
		totColor += Math.round(colObj3.value);
	}
	var strVariables = 'action=countPadColorOcta&totColor=' + totColor;
	//alert(totColor)
	if(totColor > 0 || totColor =='')
	{
		makeRequest('ajax_function.php?'+strVariables, "colorCount");
	}
}
function countPadColor()
{
	var form = document.Form;
	var totColor = 0;
	//colObj1 = form.all("color_qty1");
	colObj1 = form.color_qty1;
	//colObj2 = form.all("color_qty2");
	colObj2 = form.color_qty2;
	//colObj3 = form.all("color_qty3");
	colObj3 = form.color_qty3;

	if(colObj1.value!='' && !isNaN(colObj1.value) && colObj1.value!=0)
	{
		totColor += Math.round(colObj1.value);
	}
	if(colObj2.value!='' && !isNaN(colObj2.value) && colObj2.value!=0)
	{
		totColor += Math.round(colObj2.value);
	}
	if(colObj3.value!='' && !isNaN(colObj3.value) && colObj3.value!=0)
	{
		totColor += Math.round(colObj3.value);
	}
	if(totColor > 8)
	{
		alert("Please designate color for only 8 safety pad sections.");
//		colObj1.focus();
		return false;
	}
}
/*
function setRoundEnclosurePrice()
{
	var form = document.Form;
	var psize = "";
	//obj = form.all('psize');
	obj = form.psize;
	psize = obj.options[obj.selectedIndex].value;
	if(psize != "")
	{
		var strVariables = 'action=EnclosurePrice&shape=round&psize=' + psize;
		makeRequest('ajax_function.php?'+strVariables, "RoundEnclosurePrice");
		setTimeout("setRoundSafetyPadPrice("+psize+");", 100);
	}
}
function setRoundSafetyPadPrice(psize)
{
	var strVariables = 'action=SafetyPadPrice&shape=round&psize=' + psize;
	makeRequest('ajax_function.php?'+strVariables, "RoundSafetyPadPrice");
}
*/