// JavaScript Document
var xmlhttp;

function getxmlhttpobject()
{
var xmlhttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlhttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlhttp;
}

function fine_size(val){
	var url="ajax1.php?prod_id="+val;
		//alert(url);
		xmlHttp=getxmlhttpobject();
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{	
				document.getElementById("size_disp").innerHTML=xmlHttp.responseText;
			}else{	
				document.getElementById("size_disp").innerHTML='<img src="images/loading.gif" width="32" height="32" />';
			}		
		}
		xmlHttp.open("POST",url,true);
		xmlHttp.send(null);	
}

function find_stock(prod,size){
	var url="ajax1.php?prod_id1="+prod+"&size_id="+size;
		//alert(url);
		xmlHttp=getxmlhttpobject();
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{	
				document.getElementById("stock_disp").innerHTML=xmlHttp.responseText;
			}else{	
				document.getElementById("stock_disp").innerHTML='<img src="images/loading.gif" width="32" height="32" />';
			}		
		}
		xmlHttp.open("POST",url,true);
		xmlHttp.send(null);	
}

function find_finishes(prod,size,stock){
	var url="ajax1.php?prod_id2="+prod+"&size_id1="+size+"&stock_id="+stock;
		//alert(url);
		xmlHttp=getxmlhttpobject();
		xmlHttp.onreadystatechange=function()
		{
			
			if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{	
				//alert(xmlHttp.responseText);
				document.getElementById("finishes_disp").innerHTML=xmlHttp.responseText;
			}else{	
				document.getElementById("finishes_disp").innerHTML='<img src="images/loading.gif" width="32" height="32" />';
			}		
		}
		xmlHttp.open("POST",url,true);
		xmlHttp.send(null);	
}

function find_color(prod,size,stock,finishes){
	var url="ajax1.php?prod_id3="+prod+"&size_id2="+size+"&stock_id1="+stock+"&finishes="+finishes;
		//alert(url);
		xmlHttp=getxmlhttpobject();
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{	
				//alert(xmlHttp.responseText);
				document.getElementById("color_disp").innerHTML=xmlHttp.responseText;
			}else{	
				document.getElementById("color_disp").innerHTML='<img src="images/loading.gif" width="32" height="32" />';
			}		
		}
		xmlHttp.open("POST",url,true);
		xmlHttp.send(null);	
}

function find_folding(prod,size,stock,finishes,color){
	var url="ajax1.php?prod_id4="+prod+"&size_id3="+size+"&stock_id2="+stock+"&finishes1="+finishes+"&color="+color;
		//alert(url);
		xmlHttp=getxmlhttpobject();
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{	
				//alert(xmlHttp.responseText);
				document.getElementById("folding_disp").innerHTML=xmlHttp.responseText;
			}else{	
				document.getElementById("folding_disp").innerHTML='<img src="images/loading.gif" width="32" height="32" />';
			}		
		}
		xmlHttp.open("POST",url,true);
		xmlHttp.send(null);	
}

function find_service(prod,size,stock,finishes,color,folding){
	var url="ajax1.php?prod_id5="+prod+"&size_id4="+size+"&stock_id3="+stock+"&finishes2="+finishes+"&color1="+color+"&folding="+folding;
		//alert(url);
		xmlHttp=getxmlhttpobject();
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{	
				//alert(xmlHttp.responseText);
				document.getElementById("service_disp").innerHTML=xmlHttp.responseText;
			}else{	
				document.getElementById("service_disp").innerHTML='<img src="images/loading.gif" width="32" height="32" />';
			}		
		}
		xmlHttp.open("POST",url,true);
		xmlHttp.send(null);	
}

function find_quantity(prod,size,stock,finishes,color,folding,services){
	var url="ajax1.php?prod_id6="+prod+"&size_id5="+size+"&stock_id4="+stock+"&finishes3="+finishes+"&color2="+color+"&folding1="+folding+"&services="+services;
		//alert(url);
		xmlHttp=getxmlhttpobject();
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{	
				document.getElementById("quantity_disp").innerHTML=xmlHttp.responseText;
			}else{	
				document.getElementById("quantity_disp").innerHTML='<img src="images/loading.gif" width="32" height="32" />';
			}		
		}
		xmlHttp.open("POST",url,true);
		xmlHttp.send(null);	
}



function find_price(prod,size,stock,finishes,color,folding,services,quantity){
	var url="ajax1.php?prod_id7="+prod+"&size_id6="+size+"&stock_id5="+stock+"&finishes4="+finishes+"&color3="+color+"&folding2="+folding+"&services1="+services+"&quantity="+quantity;
		//alert(url);
		xmlHttp=getxmlhttpobject();
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{	
				document.getElementById("price_disp").innerHTML=xmlHttp.responseText;
			}else{	
				document.getElementById("price_disp").innerHTML='<img src="images/loading.gif" width="32" height="32" />';
			}		
		}
		xmlHttp.open("POST",url,true);
		xmlHttp.send(null);	
}

function cal_ups(val){
	var zip = document.getElementById("zip").value;
	var wgt = document.getElementById("weight").value;
	var url="displayRate.php?zip="+zip+"&wgt="+wgt+"&ser="+val;
		//alert(url);
		xmlHttp=getxmlhttpobject();
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{	
				document.getElementById("ship_rate").innerHTML=xmlHttp.responseText;
				disp_total();
			}else{	
				document.getElementById("ship_rate").innerHTML='<img src="images/loading.gif" width="32" height="32" />';
			}		
		}
		xmlHttp.open("POST",url,true);
		xmlHttp.send(null);	
}

function disp_total(){
	var price = document.getElementById("price_temp").value;
	var shipping = document.getElementById("shiping_temp").value;
	document.getElementById("ups").value=document.getElementById("shiping_temp").value;
	var total = parseFloat(price)+parseFloat(shipping);
	total = formatNumber(total,2);
	document.getElementById("total_amt").innerHTML="$"+total;
}
