const SERVER_URL = "root/fk_smooz_corporate/classes/timeZone.php";
 
//Start phpRequest Object
function phpRequest() {
  //Set some default variables
  this.parms = new Array();
  this.parmsIndex = 0;
 
  //Set the server url
  this.server = SERVER_URL;
 
  //Add two methods
  this.execute = phpRequestExecute;
  this.add = phpRequestAdd;
}
 
function phpRequestAdd(name,value) {
  //Add a new pair object to the params
  this.parms[this.parmsIndex] = new Pair(name,value);
  this.parmsIndex++;
}
 
function phpRequestExecute(server1) {
  //Set the server to a local variable
  if ((server1 != "") || (server1 != 'undefined')) {
  	var targetURL = server1;
  } else {
  	var targetURL = this.server;
  }

  //Try to create our XMLHttpRequest Object
  try {
    var httpRequest = new XMLHttpRequest();
  }catch (e){
    alert('Error creating the connection!');
    return;
  }
  
  //Make the connection and send our data
  try {
    var txt = "?1";
    for(var i in this.parms) {
      txt = txt+'&'+this.parms[i].name+'='+this.parms[i].value;
    }
    //Two options here, only uncomment one of these
    //GET REQUEST
    httpRequest.open("GET", targetURL+txt, false, null, null);  
 
    //POST REQUEST EXAMPLE
    /*
    httpRequest.open("POST", targetURL+txt, false, null, null);  
    httpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    */
    httpRequest.send('');
  }catch (e){
    alert('An error has occured calling the external site: '+e);
    return false;
  } 
 
  //Make sure we received a valid response
  switch(httpRequest.readyState) {
    case 1,2,3:
      alert('Bad Ready State: '+httpRequest.status);
      return false;
    break;
    case 4:
      if(httpRequest.status !=200) {
        alert('The server respond with a bad status code: '+httpRequest.status);
        return false;
      } else {
        var response = httpRequest.responseText;
      }
    break;
  }
  
  return response;
}
 
//Utility Pair class
function Pair(name,value) {
  this.name = name;
  this.value = value;
}