// XMLHttpRequest function to initiate request object
function AJAX() {
  var o = false;
  /*@cc_on @*/
  /*@if (@_jscript_version >= 5)
    try {
    o = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try {
    o = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
    o = false;
    }
    }
    @end @*/
  if (!o && typeof XMLHttpRequest!='undefined') {
    o = new XMLHttpRequest();
  }
    
  return o;
}

function updateById( httpObject, id ) {
  if( httpObject.readyState == 4 ){ //Finished loading the response
    /* We have got the response from the server-side script,
       let's see just what it was. using the responseText property of 
       the XMLHttpRequest object. */
    var response = httpObject.responseText;
    /* And now we want to change the product_categories <div> content.
       we do this using an ability to get/change the content of a page element 
       that we can find: innerHTML. */
    document.getElementById( id ).innerHTML = response;
    //alert ( response );
  }
}


var http  = AJAX(); 
var http2 = AJAX();

function selectCountryLetter( id ) {
  if ( !id || id == '' ) return;
  http.open( 'get', ROOT_PATH + '/ajax/get_country_list.phtml?id=' + id );
  http.onreadystatechange = updateCountryList;
  http.send(null);
}

function updateCountryList() {
  updateById( http, 'cpd' );
}

function selectCountry( id ) {
  if ( !id || id == '' ) return;
  http.open( 'get', ROOT_PATH + '/ajax/get_country_data.phtml?id=' + id );
  http.onreadystatechange = updateCountryData;
  http.send(null);

  http2.open( 'get', ROOT_PATH + '/ajax/get_country_continent.phtml?id=' + id );
  http2.onreadystatechange = updateCountryContinent;
  http2.send(null);
}

function updateCountryData() {
  updateById( http, 'cs' );
}

function updateCountryContinent() {
  updateById( http2, 'cc' );
}

function selectEmployee( id ) {
  if ( !id || id == '' ) return;
  http.open( 'get', ROOT_PATH + '/ajax/get_employee_bio.phtml?id=' + id );
  http.onreadystatechange = updateEmployeeData;
  http.send(null);
}

function updateEmployeeData() {
  updateById( http, 'bio' );
}





