  var http = false;
  //var http = null;

  if(navigator.appName == "Microsoft Internet Explorer") {
    http = new ActiveXObject("Microsoft.XMLHTTP");
    //alert("a");
  } else {
    //alert("b");
    http = new XMLHttpRequest();
  }



function saveCurrency(sId){
  sUrl = "http://www.paygol.com/js/ajax.php?mode=saveCurrency&currencyCode="+sId;

  http.open("GET", sUrl, true);

  http.onreadystatechange=function() {
  	if(http.readyState == 4) {
  	 //alert("ok");
  	 document.getElementById("divProfileCurrency").innerHTML = http.responseText;
 		}
	}
	http.send(null);
}

function changePass(){
  currentPass = document.getElementById("current_pass").value;
  newPass = document.getElementById("new_pass").value;
  repeatNewPass = document.getElementById("repeat_new_pass").value;
  
  sUrl = "http://www.paygol.com/js/ajax.php?mode=changePass&currentPass="+currentPass+"&newPass="+newPass+"&repeatNewPass="+repeatNewPass;

  http.open("GET", sUrl, true);

  http.onreadystatechange=function() {
  	if(http.readyState == 4) {
  	 document.getElementById("divPass").style.display = 'block';
  	 document.getElementById("divPass").innerHTML = http.responseText;
 		}
	}
	http.send(null);
}

function alertDeclined(sId){
  sUrl = "http://www.paygol.com/js/ajax.php?mode=alertDeclined&alertid="+sId;

  http.open("GET", sUrl, true);

  http.onreadystatechange=function() {
  	if(http.readyState == 4) {
  	 //alert("ok");
 		}
	}
	http.send(null);
}

function calculateAffiliate(){
  sUrl = "http://www.paygol.com/js/ajax.php?mode=calculateAffiliate";
  
  http.open("GET", sUrl, true);

  http.onreadystatechange=function() {
	}
	http.send(null);
}

function calculatePayout(){
  sPrice = document.getElementById("mp_price").value;
  sOrderby = document.getElementById("txtOrderby").value;
  sCurrency = document.getElementById("mp_currency").value;

  sUrl = "http://www.paygol.com/js/ajax.php?mode=calculatedPayout&price="+sPrice+"&orderby="+sOrderby+"&currency="+sCurrency;
  
  http.open("GET", sUrl, true);

  http.onreadystatechange=function() {
  	if(http.readyState == 4) {
 			document.getElementById("divCoverage").innerHTML = http.responseText;   			
 		}
	}
	http.send(null);
}

function calculatePayoutCoverage(){
  sPrice = document.getElementById("mp_price").value;
  sOrderby = document.getElementById("txtOrderby").value;
  sCurrency = document.getElementById("mp_currency").value;

  sUrl = "http://www.paygol.com/js/ajax.php?mode=calculatePayoutCoverage&price="+sPrice+"&orderby="+sOrderby+"&currency="+sCurrency;
  
  http.open("GET", sUrl, true);

  http.onreadystatechange=function() {
  	if(http.readyState == 4) {
 			document.getElementById("divCoverage").innerHTML = http.responseText;   			
 		}
	}
	http.send(null);
}

function calculate(){
  sPrice = document.getElementById("txtPrice").value;
  sOrderby = document.getElementById("txtOrderby").value;
  sCurrency = document.getElementById("cbxCurrency").value;
  
  sUrl = "js/ajax.php?mode=calculated&price="+sPrice+"&orderby="+sOrderby+"&currency="+sCurrency;
  
  http.open("GET", sUrl, true);

  http.onreadystatechange=function() {
  	if(http.readyState == 4) {
  		//alert(http.responseText);
 			document.getElementById("divCoverage").innerHTML = http.responseText;   			
 		}
	}
	http.send(null);
}

//Send phone and message
function sendMessage() {
  sShortcode  = document.frmEmulator.txtPhoneNumber.value;
  sMessage    = document.frmEmulator.txtMessage.value;

  sUrl = "http://www.paygol.com/ws/mp/emulator/paygol_micropayment.php";
  
  sData = "shortcode="+sShortcode+"&message="+sMessage; 
  
  //alert(sData);

  var xmlHttpReq = false;
  var self = this;
  // Mozilla/Safari
  if (window.XMLHttpRequest) {
      self.xmlHttpReq = new XMLHttpRequest();
  }
  // IE
  else if (window.ActiveXObject) {
      self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
  }
  self.xmlHttpReq.open('POST', sUrl, true);
  self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  self.xmlHttpReq.onreadystatechange = function() {
      if (self.xmlHttpReq.readyState == 4) {
   			document.getElementById("loader").style.display = "none";   			
   			document.getElementById("result").innerHTML = self.xmlHttpReq.responseText;   			
      	document.getElementById("divNew").style.display = "block";   			
      }
  }
  self.xmlHttpReq.send(sData);

}



//Send phone and message
function updateStatus(sServiceId, sObj, show, sLoader, sChangerEnabled, sChangerTesting, sStatus){
  //alert(sServiceId);
  //alert(sStatus);
  //alert(sChanger);
  
  sUrl = "http://www.paygol.com/update_status.php?serviceid="+sServiceId+"&status="+sStatus; 

  http.open("GET", sUrl, true);

  http.onreadystatechange=function() {
  	if(http.readyState == 4) {
  		//alert(http.responseText);
 			document.getElementById(sLoader).style.display = "none";
      if (sStatus=='Enabled'){ 
        document.getElementById(sChangerEnabled).style.display = "block";
        document.getElementById(sChangerTesting).style.display = "none";
		  }else{
        document.getElementById(sChangerEnabled).style.display = "none";
        document.getElementById(sChangerTesting).style.display = "block";
      }
 			//document.getElementById(sChanger).innerHTML = "<a href='javascript:changeStatus(\"sServiceId\", \"sObj\", true, \"sLoader\", \"sChanger\", \"sStatus\")' class='txt_small'><img src='http://www.paygol.com/images/icons/16x16/".$sStatusImage.".png' align='absmiddle' border='0'></a>&nbsp;<span class='txt_small'>"+sStatus+"</span>";   			
 			//document.getElementById(sChanger).innerHTML = "<a href='javascript:changeStatus("+sServiceId+", \"+sObj+\", true, sLoader, sChanger, sStatus);' class='txt_small'><span class='txt_small'><img src='http://www.paygol.com/images/icons/16x16/"+sStatus+".png' align='absmiddle' border='0'></a>&nbsp;"+sStatus+"</span>";   			
 			//document.getElementById("result").innerHTML = http.responseText;   			
    	//document.getElementById("divNew").style.display = "block";   			
 		}
	}
	http.send(null);
}

