
var http = getXMLHTTPRequest();

function getXMLHTTPRequest() {
  try {
    req = new XMLHttpRequest();
  } catch(err1) {
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (err2) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (err3) {
        alert("Your browser does not support AJAX!");
        req = false;
      }
    }
  }
  return req;
}

function getCountryInfo() {
    if ( document.Countries.CountryList.selectedIndex > 0 ) {

        var country = document.Countries.CountryList.options[document.Countries.CountryList.selectedIndex].value  ;
//        var product = document.Countries.ProductList.options[document.Countries.ProductList.selectedIndex].value  ;

        var myurl = '/distributors/distributors.cgi?Action=CountryDetails&Name='+country ;
        myRand = parseInt(Math.random()*999999999999999);

        var modurl = myurl+"&r="+myRand;
        // alert ( modurl ) ;
        //        document.getElementById('ajaxFeedback').innerHTML = modurl ;
        http.open("POST", modurl, true);
        http.onreadystatechange = useHttpResponse;
        http.send(null);
    }
}

function getInternationalInfo() {
        var product = document.Countries.ProductList.options[document.Countries.ProductList.selectedIndex].value  ;

        var myurl = '/distributors/distributors.cgi?Action=InternationalUsers&Product='+product;
        myRand = parseInt(Math.random()*999999999999999);

        var modurl = myurl+"&r="+myRand;
        // alert ( modurl ) ;
        //        document.getElementById('ajaxFeedback').innerHTML = modurl ;
        http.open("POST", modurl, true);
        http.onreadystatechange = useHttpResponse;
        http.send(null);
}

function useHttpResponse() {
  if (http.readyState == 4) {
    if(http.status == 200) {
      if ( http.responseText == null ) {
        document.getElementById('cgiFeedback').innerHTML = 'server error'
      } else {
        document.getElementById('cgiFeedback').innerHTML = http.responseText ;
      }
    }
  } else {
     document.getElementById('cgiFeedback').innerHTML = '<img src="/images/wait20trans.gif">';
  }
}