var xmlHttp

function GetXmlHttpObject(){ 
	var objXMLHttp=null
	if (window.XMLHttpRequest){
		objXMLHttp=new XMLHttpRequest()
	} else if (window.ActiveXObject){
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}

//============== Home Page ================

function Get_Models(category_id,pos_id,product_line_id) { 
     //alert("***");
	 
		  document.frm_search.Set_Count.value=pos_id
		  document.frm_search.Sel_Cat_Id.value=category_id
		  
		  id = 'Display_Moels' + pos_id;
		  document.getElementById(id).innerHTML="<font color='#FFA303'>&nbsp;Loading ...</font>";		

//pluspath="http://server/ldd/images/plus_sign_new.gif";
//minuspath="http://server/ldd/images/minus_sign_new.gif";

pluspath="http://www.lddlight.com/images/plus_sign_new.gif";
minuspath="http://www.lddlight.com/images/minus_sign_new.gif";

if(eval("document.pimg"+pos_id+".src")==pluspath){

eval("document.pimg"+pos_id+".src='images/minus_sign_new.gif'");

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url="Get_Models.php"
	url=url+"?category_id="+category_id+"&product_line_id="+product_line_id+"&pos_id="+pos_id
	url=url+"&ram_id="+Math.random()	
	xmlHttp.onreadystatechange=Get_Models_Change
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} else {
	Set_Null(pos_id)
}
	
} // function close

function Get_Models_Change(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		
		var Total_Count=document.frm_search.Total_Count.value
			for(var i=0; i<Total_Count; i++) {
				id = 'Display_Moels' + i;				
				document.getElementById(id).innerHTML=""
				eval("document.pimg"+i+".src='images/plus_sign_new.gif'");
			}

		var pos_id=document.frm_search.Set_Count.value
		id = 'Display_Moels' + pos_id;
		document.getElementById(id).innerHTML=xmlHttp.responseText	
		eval("document.pimg"+pos_id+".src='images/minus_sign_new.gif'");
		
		var Sel_Cat_Id=document.frm_search.Sel_Cat_Id.value
		Get_All_Models(Sel_Cat_Id,pos_id)
	} 
}

//============== Home Page ================

function Get_All_Models(category_id,pos_id) { 

document.getElementById("Display_Moel_Detail").innerHTML="<font color='#FFA303'>&nbsp;Loading ...</font>";		
var product_line_id

product_line_id=document.frm_search.Sel_product_line_id.value

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url="Get_All_Models.php"
	url=url+"?category_id="+category_id
	url=url+"&pos_id="+pos_id
	url=url+"&product_line_id="+product_line_id
	url=url+"&ram_id="+Math.random()	
	xmlHttp.onreadystatechange=Get_All_Models_Change
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} // function close

function Get_All_Models_Change(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 		
		document.getElementById("Display_Moel_Detail").innerHTML=xmlHttp.responseText		
	} 
}

//============================================
function Set_Null(pos_id){
		  eval("document.pimg"+pos_id+".src='images/plus_sign_new.gif'");		
		  id = 'Display_Moels' + pos_id;
		  document.getElementById(id).innerHTML="";		
}

//============== Home Page ================

function Get_Model_Detail(category_id,model_id) { 

  document.getElementById("Display_Moel_Detail").innerHTML="<font color='#FFA303'>&nbsp;Loading ...</font>";		

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url="Get_model_detail.php"
	url=url+"?category_id="+category_id
	url=url+"&model_id="+model_id
	url=url+"&ram_id="+Math.random()	
	xmlHttp.onreadystatechange=Get_Model_Detail_Change
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
} // function close

function Get_Model_Detail_Change(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("Display_Moel_Detail").innerHTML=xmlHttp.responseText		
	} 
}

//============== Home Page ================

function Get_Parts(category_id,model_id) { 

  document.getElementById("Display_Moel_Detail").innerHTML="<font color='#FFA303'>&nbsp;Loading ...</font>";		

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url="Get_Parts.php"
	url=url+"?category_id="+category_id
	url=url+"&model_id="+model_id
	url=url+"&ram_id="+Math.random()	
	xmlHttp.onreadystatechange=Get_Parts_Change
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
} // function close

function Get_Parts_Change(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("Display_Moel_Detail").innerHTML=xmlHttp.responseText		
	} 
}

//==================================================================

//============== Home Page ================

function Get_Gublinks(pos_id) { 

document.frmsearch.Set_Count.value=pos_id
 id = 'Display_Subliks_' + pos_id;
 document.getElementById(id).innerHTML="<font color='#FFA303'>&nbsp;Loading ...</font>";		

//pluspath="http://server/ldd/images/plus_sign_new.gif";
//minuspath="http://server/ldd/images/minus_sign_new.gif";

pluspath="http://www.lddlight.com/images/plus_sign_new.gif";
minuspath="http://www.lddlight.com/images/minus_sign_new.gif";


if(eval("document.pimg"+pos_id+".src")==pluspath){

eval("document.pimg"+pos_id+".src='images/minus_sign_new.gif'");

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url="Get_Gublinks.php"
	url=url+"?id="+pos_id
	url=url+"&ram_id="+Math.random()	
	//alert(url);
	xmlHttp.onreadystatechange=Get_Gublinks_Change
	xmlHttp.open("GET",url,true)
	
	xmlHttp.send(null)
} else {
	Set_Null_1(pos_id)
}
	
} // function close

//============================================
function Set_Null_1(pos_id){
		  eval("document.pimg"+pos_id+".src='images/plus_sign_new.gif'");		
		  id = 'Display_Subliks_' + pos_id;
		  //alert(id);
		  document.getElementById(id).innerHTML="";		
}




function Get_Gublinks_Change(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		
			document.getElementById(id).innerHTML=xmlHttp.responseText
			for(var i=0; i<3; i++) {
				id = 'Display_Subliks_' + i;				
				//document.getElementById(id).innerHTML=""
				//eval("document.pimg"+i+".src='images/plus_sign_new.gif'");
			}
			
		var pos_id=document.frmsearch.Set_Count.value
		id = 'Display_Subliks_' + pos_id;
		
		
		document.getElementById(id).innerHTML=xmlHttp.responseText	
			
	} 
}

//============== Home Page ================

function Get_Models_1(category_id,pos_id,product_line_id) { 
     //alert("***");
	 
		  document.frm_search.Set_Count.value=pos_id
		  document.frm_search.Sel_Cat_Id.value=category_id
		  
		  id = 'Display_Moels' + pos_id;
		  document.getElementById(id).innerHTML="<font color='#FFA303'>&nbsp;Loading ...</font>";		

//pluspath="http://server/ldd/images/plus_sign_new.gif";
//minuspath="http://server/ldd/images/minus_sign_new.gif";

pluspath="http://www.lddlight.com/images/plus_sign_new.gif";
minuspath="http://www.lddlight.com/images/minus_sign_new.gif";



if(eval("document.pimg"+pos_id+".src")==pluspath){

eval("document.pimg"+pos_id+".src='images/minus_sign_new.gif'");

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url="Get_Models.php"
	url=url+"?category_id="+category_id+"&product_line_id="+product_line_id+"&pos_id="+pos_id
	url=url+"&ram_id="+Math.random()	
	xmlHttp.onreadystatechange=Get_Models_1_Change
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} else {
	Set_Null(pos_id)
}
	
} // function close

function Get_Models_1_Change(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		
		var Total_Count=document.frm_search.Total_Count.value
			for(var i=0; i<Total_Count; i++) {
				id = 'Display_Moels' + i;				
				document.getElementById(id).innerHTML=""
				eval("document.pimg"+i+".src='images/plus_sign_new.gif'");
			}

		var pos_id=document.frm_search.Set_Count.value
		id = 'Display_Moels' + pos_id;
		document.getElementById(id).innerHTML=xmlHttp.responseText	
		eval("document.pimg"+pos_id+".src='images/minus_sign_new.gif'");
	} 
}

//============== Home Page ================


//============== Home Page ================

function Get_Add_Part(prt_id,prodtype,pos_id) { 
var qty,prodtype,mode

document.frmcart.SEL_POS_ID.value=pos_id

if (prodtype=="part"){
	qty=document.frmcart.quantity.value
} else {
	qty=eval("document.frmaccess.quantity"+prt_id+".value");
}
//alert(qty)
if(qty<=0 || isNaN(qty))
{
	alert("Please enter valid quantity");
	return false;
	
}

mode="add";
  
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url="Get_Add_Part.php"
	url=url+"?qty="+qty+"&prt_id="+prt_id+"&prodtype="+prodtype+"&mode="+mode
	url=url+"&ram_id="+Math.random()	
	xmlHttp.onreadystatechange=Get_Add_Part_Change
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} // function close

function Get_Add_Part_Change(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
	var id, pos_id
	pos_id=document.frmcart.SEL_POS_ID.value
	id = 'Show_Cart_Message_' + pos_id;
	document.getElementById(id).innerHTML=xmlHttp.responseText		
	//document.getElementById("Show_Cart_Message").innerHTML=xmlHttp.responseText			
	Get_Cart_Total()
	} 
}

//============== Home Page ================

//============== Home Page ================

function Get_Add_Part_1(prt_id,prodtype,pos_id) { 
var qty,prodtype,mode

//alert(prodtype)

document.frmaccess.SEL_POS_ID.value=pos_id
qty=document.frmaccess.quantity.value
//alert(qty)

if(qty<=0 || isNaN(qty))
{
	alert("Please enter valid quantity");
	return false;
	
}


mode="add";
  
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url="Get_Add_Part.php"
	url=url+"?qty="+qty+"&prt_id="+prt_id+"&prodtype="+prodtype+"&mode="+mode
	//alert(url)
	url=url+"&ram_id="+Math.random()	
	xmlHttp.onreadystatechange=Get_Add_Part_1_Change
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} // function close

function Get_Add_Part_1_Change(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
	document.getElementById("Show_Cart_Message").innerHTML=xmlHttp.responseText		
	//document.getElementById("Show_Cart_Message").innerHTML=xmlHttp.responseText			
	Get_Cart_Total()
	} 
}

//============== Home Page ================

function Get_Cart_Total() { 

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url="Get_Cart_Total.php?"
	url=url+"ram_id="+Math.random()	
	xmlHttp.onreadystatechange=Get_Cart_Total_Change
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} // function close

function Get_Cart_Total_Change(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 		
		document.getElementById("Show_Total").innerHTML=xmlHttp.responseText	
	} 
}

function Get_shipping(total_weight) { 

   xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	} 
	
  shipstate=trim(document.getElementById("sstate").value);
  szip=trim(document.getElementById("szip").value);
  
  
  for (var i=0; i<document.frmmember.servicetype.length; i++)
   {
   if (document.frmmember.servicetype[i].checked)
      {
      servicetype = document.frmmember.servicetype[i].value;
      }
   }
 

	var url="Get_shipping.php?total_weight="+total_weight+"&service="+servicetype+"&dest_zip="+szip+"&sstate="+shipstate
	url=url+"&ram_id="+Math.random()	
	//alert(url);
	
	xmlHttp.onreadystatechange=Get_shipping_Change
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} // function close

function Get_shipping_Change(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 		
		document.getElementById("Show_shipping").innerHTML=xmlHttp.responseText	
	} 
}


