var time_variable;
 
function getXMLObject()  //XML OBJECT
{
   var xmlHttp = false;
   try {
     xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")  // per vecchi browser
   }
   catch (e) {
     try {
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")  //  Microsoft IE 6.0+
     }
     catch (e2) {
       xmlHttp = false   // No Browser accepts the XMLHTTP Object then false  serve un browsere più recente..
     }
   }
   if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
     xmlHttp = new XMLHttpRequest();        //For Mozilla, Opera Browsers
   }
   return xmlHttp;  // Mandatory Statement returning the ajax object created
}
 
var xmlhttpgpl = new getXMLObject();	//xmlhttp holds the ajax object
var xmlhttpgpl2 = new getXMLObject();	//xmlhttp holds the ajax object
// modello cerchi altro
function PreventivoGpl() {
var getdate = new Date();  //evito il precaching dei dati
var PresaCarica= document.getElementById("PresaCarica").value;
var MarcaVettura = document.getElementById("MarcaVettura").value;
var ModelloVettura = document.getElementById("ModelloVettura").value;
var Cw = document.getElementById("Cw").value;
var Cod_B2C = document.getElementById("Cod_B2C").value;
var turbo = document.getElementById("turbo").value;
var ContributoRegionale= document.getElementById("ContributoRegionale").value;
var Cilindri= document.getElementById("Cilindri").value;
var PresaCarica= document.getElementById("PresaCarica").value;
var TipoSerbatoio=document.getElementById("TipoSerbatoio").value;

if(xmlhttpgpl) {
    xmlhttpgpl.open("POST","gpl/risultatoprev.php",true); //calling testing.php using POST method
    xmlhttpgpl.onreadystatechange  = handleServerResponsegpl;
    xmlhttpgpl.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttpgpl.send("PresaCarica="+ PresaCarica+"&MarcaVettura="+ MarcaVettura+"&ModelloVettura="+ ModelloVettura+"&ContributoRegionale="+ ContributoRegionale+"&Cilindri="+ Cilindri+"&Cw="+ Cw+"&turbo="+ turbo+"&TipoSerbatoio="+ TipoSerbatoio+"&Cod_B2C="+ Cod_B2C); //Posting txtname to PHP File
  }
}
 
function handleServerResponsegpl() {
   if (xmlhttpgpl.readyState == 4) {
     if(xmlhttpgpl.status == 200) {
	    
	       
     document.getElementById("risultatigpl").innerHTML=xmlhttpgpl.responseText; //Update the HTML Form element 
	 
     }
     else {
        alert("Errore chiamata pagina dati, riprovare fra pochi secondi");
     }
   }else{
 
    document.getElementById("risultatigpl").innerHTML = '<p><div align="center"><img src="images/loader.gif"></div>'; //fino a che è 4 mostro loading

} 
}
//calcolo risparmio

function calcolarisparmio() {
var getdate = new Date();  //evito il precaching dei dati
var consumo= document.getElementById("consumo").value;
var distanza = document.getElementById("distanza").value;

if(xmlhttpgpl2) {
    xmlhttpgpl2.open("POST","gpl/calc_risparmio.php",true); //calling testing.php using POST method
    xmlhttpgpl2.onreadystatechange  = handleServerResponsegpl2;
    xmlhttpgpl2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttpgpl2.send("consumo="+ consumo+"&distanza="+ distanza); //Posting txtname to PHP File
  }
}
 
function handleServerResponsegpl2() {
   if (xmlhttpgpl2.readyState == 4) {
     if(xmlhttpgpl2.status == 200) {
	    
	       
     document.getElementById("risparmio").innerHTML=xmlhttpgpl2.responseText; //Update the HTML Form element 
	 
     }
     else {
        alert("Errore chiamata pagina dati, riprovare fra pochi secondi");
     }
   }else{
 
    document.getElementById("risparmio").innerHTML = '<p><div align="center"><img src="images/loader.gif"></div>'; //fino a che è 4 mostro loading

} 
}





