// JavaScript Document
var xmlHttp;

function SearchProjects(country, application, product) {
  xmlHttp = GetXmlHttpObject();

  // No browser support
  if(xmlHttp == null) {
    alert("Your browser does not support AJAX!");
    return;
  }
  
  // Pass variables in the url string
  url = "search.php";
  url += "?country="     + country;
  url += "&application=" + application;
  url += "&product="     + product;

  xmlHttp.onreadystatechange = ResultsChanged;
  xmlHttp.open("GET", url, true);
  xmlHttp.send(null);
}

function ResultsChanged() {
  // Hide primary feature
  var Node = document.getElementById("primary_feature");
  Node.style.display = "none";
  // Display search animation
  document.getElementById("results").innerHTML = '<img src="http://www.lighting.philips.com/europe/image_region/projects/searching.gif" />';
  // On script process complete display the results
  if(xmlHttp.readyState == 4) {
    document.getElementById("results").innerHTML = xmlHttp.responseText;
  }
}

function GetXmlHttpObject() {
  var xmlHttp = null;
  try {
    // Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch(e) {
    // Internet Explorer
    try {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e) {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlHttp;
}
