function getXMLObject()  //XML OBJECT
{
   var xmlHttp = false;
   try {
     xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")  // For Old Microsoft Browsers
   }
   catch (e) {
     try {
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")  // For Microsoft IE 6.0+
     }
     catch (e2) {
       xmlHttp = false   // No Browser accepts the XMLHTTP Object then false
     }
   }
   if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
     xmlHttp = new XMLHttpRequest();        //For Mozilla, Opera Browsers
   }
   return xmlHttp;  // Mandatory Statement returning the ajax object created
}
 
var xmlhttp = new getXMLObject();	//xmlhttp holds the ajax object
 
function getSelect(formValue) {
	
  var getdate = new Date();  //Used to prevent caching during ajax call
  if(xmlhttp) 
		{ 
	    xmlhttp.open("POST","php/timezone_update.php",true); //calling testing.php using POST method
	    xmlhttp.onreadystatechange  = handleServerResponse;
	    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	    
	    index = formValue.selectedIndex;
	    selectValue = formValue[index].value;
	    
	    variable = 	"timezone=" + selectValue + "/";
	    xmlhttp.send(variable); //Posting variables to PHP File
  	}
}
 
function handleServerResponse() {
   if (xmlhttp.readyState == 4) {
     if(xmlhttp.status == 200) {
       document.getElementById("cityDropdown").innerHTML=xmlhttp.responseText; //Update the HTML Form element 
       document.getElementById("showTime").innerHTML="";
       document.getElementsByName('company').item(0).timezoneSet.value = 'no';
     }
		else if (request.status == 404) {
    	alert ("Requested URL is not found.");
    } 
		else if (request.status == 403) {
    	alert("Access denied.");
    }
		else {
      alert("Error during AJAX call. Status is " + request.status);
    }
  }
}

var timeDisplay = new getXMLObject();	//xmlhttp holds the ajax object

function showLocalTime(dropdownValue) {
	
  var getdate = new Date();  //Used to prevent caching during ajax call
  if(timeDisplay) 
		{ 
	    timeDisplay.open("POST","php/timedisplay_update.php",true); //calling testing.php using POST method
	    timeDisplay.onreadystatechange  = handleResponse;
	    timeDisplay.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

	    index = dropdownValue.selectedIndex;
	    selectValue = dropdownValue[index].value;
	    
	    variable = 	"tzone_city=" + selectValue;
	    timeDisplay.send(variable); //Posting variables to PHP File
  	}
}
 
function handleResponse() {
   if (timeDisplay.readyState == 4) {
     if(timeDisplay.status == 200) {
       document.getElementById("showTime").innerHTML=timeDisplay.responseText; //Update the HTML Form element
			 if ( timeDisplay.responseText == "No time available")
	       document.getElementsByName('company').item(0).timezoneSet.value = 'no';
			else	  
  	     document.getElementsByName('company').item(0).timezoneSet.value = 'yes';
     }
     else {
        alert("Error during AJAX call. Please try again");
     }
   }
}
		