// JavaScript Document var xmlHttp; var xmlHttpn; var xmlHttpc; var total=0; function getresult(pid,pqnt,post,coun,subtot,k){ xmlHttpn=GetXmlHttpObject(); if (xmlHttpn==null) { alert ("Your browser does not support AJAX!"); return; } var url="gettotalcost.php"; url=url+"?pid="+pid+"&pqnt="+pqnt+"&post="+post+"&coun="+coun+"&sub="+subtot+"&key="+k; url=url+"&sid="+Math.random(); xmlHttpn.onreadystatechange=gettotalPostage; xmlHttpn.open("GET",url,true); xmlHttpn.send(null); } function gettotalPostage(){ if (xmlHttpn.readyState==4) { var res=xmlHttpn.responseText; var nresult=res.split('||'); if(nresult[1]!='exit'){ document.getElementById("status").innerHTML=""; //document.getElementById("postdiv").innerHTML=""; //document.getElementById("postalcharge").style.display="block"; //document.getElementById("postalcharge").value=nresult[1]; var tprice=(parseFloat(nresult[1])+parseFloat(document.getElementById("subprice").value)).toFixed(2); if(parseFloat(document.getElementById("discount").value)>parseFloat(tprice)){ document.getElementById("status2").innerHTML=""; //document.getElementById("totprice").value=(parseFloat(document.getElementById("postalcharge").value)+parseFloat(document.getElementById("subprice").value)).toFixed(2); document.getElementById("totprice").value=parseFloat(document.getElementById("subprice").value).toFixed(2); alert("Full discount or More than that is not allowed."); document.getElementById("discount").value="0.00"; document.getElementById("couponcode").value=""; return; }else{ if(document.getElementById("discount").value!=""){ var dprice=document.getElementById("discount").value; }else{ dprice=0; } } document.getElementById("totprice").value=tprice-dprice; document.getElementById("status").innerHTML=""; }else{ document.getElementById("status").innerHTML=""; //document.getElementById("postalcharge").style.display="none"; //document.getElementById("postdiv").innerHTML="Call For Quote."; document.getElementById("totprice").value=(parseFloat(document.getElementById("subprice").value)).toFixed(2); } }else{ document.getElementById("status").innerHTML=""; } } function applycoupon(){ xmlHttpc=GetXmlHttpObject(); if (xmlHttpc==null) { alert ("Your browser does not support AJAX!"); return; } if(document.getElementById("couponcode").value==""){ alert("Please enter valid Coupon Code."); document.getElementById("couponcode").focus(); return; }else{ ccode=document.getElementById("couponcode").value; //total=(parseFloat(document.getElementById("subprice").value)+parseFloat(document.getElementById("postalcharge").value)).toFixed(2); total=(parseFloat(document.getElementById("subprice").value)).toFixed(2); var url="getfinalcost.php"; url=url+"?ccode="+ccode+"&tot="+total; url=url+"&sid="+Math.random(); xmlHttpc.onreadystatechange=getDiscount; xmlHttpc.open("GET",url,true); xmlHttpc.send(null); } } function getDiscount(){ if (xmlHttpc.readyState==4) { var disc=(xmlHttpc.responseText).split("||"); if(disc[1]=="no"){ document.getElementById("status2").innerHTML=""; //document.getElementById("totprice").value=(parseFloat(document.getElementById("postalcharge").value)+parseFloat(document.getElementById("subprice").value)).toFixed(2); document.getElementById("totprice").value=parseFloat(document.getElementById("subprice").value).toFixed(2); alert("The coupon code you are trying is invalid or may be expired."); document.getElementById("discount").value="0.00"; document.getElementById("couponcode").value=""; return; }else if(disc[1]=="exit"){ document.getElementById("status2").innerHTML=""; //document.getElementById("totprice").value=(parseFloat(document.getElementById("postalcharge").value)+parseFloat(document.getElementById("subprice").value)).toFixed(2); document.getElementById("totprice").value=parseFloat(document.getElementById("subprice").value).toFixed(2); alert("Full discount or More than that is not allowed."); document.getElementById("discount").value="0.00"; document.getElementById("couponcode").value=""; return; }else{ document.getElementById("discount").value=parseFloat(disc[1]).toFixed(2); document.getElementById("totprice").value= (total-parseFloat(disc[1])).toFixed(2); document.getElementById("status2").innerHTML=""; } }else{ document.getElementById("status2").innerHTML=""; } } function showrangedet(subt,pstid){ xmlHttpn=GetXmlHttpObject(); if (xmlHttpn==null) { alert ("Your browser does not support AJAX!"); return; } var url="getdelcost.php"; url=url+"?sub="+subt+"&stid="+pstid; url=url+"&sid="+Math.random(); xmlHttpn.onreadystatechange=getPostage; xmlHttpn.open("GET",url,true); xmlHttpn.send(null); } function getPostage(){ if (xmlHttpn.readyState==4) { var npost=xmlHttpn.responseText; //document.getElementById("postdiv").innerHTML=""; //document.getElementById("postalcharge").style.display="block"; //document.getElementById("postalcharge").value=npost; var tprice=(parseFloat(npost)+parseFloat(document.getElementById("subprice").value)).toFixed(2); if(document.getElementById("discount").value!=""){ var dprice=document.getElementById("discount").value; }else{ dprice=0; } document.getElementById("totprice").value=tprice-dprice; document.getElementById("status").innerHTML=""; }else{ document.getElementById("status").innerHTML=""; } } function showdet(pid,pqnt,stid,coun) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="getcost.php"; url=url+"?pid="+pid+"&pqnt="+pqnt+"&stid="+stid+"&coun="+coun; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState==4) { var post=xmlHttp.responseText; //document.getElementById("postdiv").innerHTML=""; //document.getElementById("postalcharge").style.display="block"; //document.getElementById("postalcharge").value=post; tnprice=(parseFloat(post)+parseFloat(document.getElementById("subprice").value)); if(document.getElementById("discount").value!=""){ var dnprice=document.getElementById("discount").value; }else{ dnprice=0; } document.getElementById("totprice").value=tnprice-dnprice; document.getElementById("status").innerHTML=""; }else{ document.getElementById("status").innerHTML=""; } } 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; }