/**
 * @xmlHttp used to detect the browser and fix required images
 *
 */
var xmlHttp

/**
 * @GetXmlHttpObject used to detect the browser and set
 * 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;
}

/**
 * @showCustomer used to detect the browser and fix required images
 * Function to be called from the main pages.
 * showCustomer(this.options[this.selectedIndex].value);
 * price.options[price.selectedIndex].value + ' ' + this.options[this.selectedIndex].value
 *
 */
function showCustomer(str1, str2, str3, str4, str5){
  // Set xmlHttp object for browser
  xmlHttp=GetXmlHttpObject();
  // Condition for browser
  if (xmlHttp==null){
    alert ("Your browser does not support AJAX!");
    return;
  }
  // Vairable setup for php or asp
  var url="ptariff.php";
  url=url+"?q1="+str1+"&q2="+str2+"&q3="+str3+"&q4="+str4+"&q5="+str5;
  // Must be used , dont change
  url=url+"&sid="+Math.random();

  // Call output function
  xmlHttp.onreadystatechange=stateChanged;
  // Execute GET method
  xmlHttp.open("GET",url,true);
  // Send Get or post method
  xmlHttp.send(null);
}

/**
 * @stateChanged
 * Handle the process output
 */
function stateChanged(){
  if (xmlHttp.readyState==4){
    //Following line is used to get query result output
    document.getElementById("min").innerHTML=xmlHttp.responseText;
    // This is the rate
    //xmlHttp.responseText = xmlHttp.responseText
    //document.getElementById("min").innerHTML="OK";
  }
}




/**
 * @stateChanged
 * Handle the process output
 */
function showE1(str1,str2){
//Totalminute/str2 = at a time calls
//1440 * E1 * channel
    var ab1;
    var ab2;
    ab1 = (1440*str1)*30;
    ab2 = ab1/str2;

    document.getElementById("r1").innerHTML="Result:";
    document.getElementById("r2").innerHTML=str1*2 + " In/out";
    document.getElementById("r3").innerHTML=ab1 + " Minutes/per day";
    document.getElementById("r4").innerHTML=ab2 + " calls/per day";
}
