var url_base =  "http://www.guidancemedia.com/";
if (window.XMLHttpRequest) {liveSearchReq = new XMLHttpRequest();}

function ImageOn(imageId) 
{
  var ImageName, ImageRef, ImageClick;
  ImageName = imageId;
  ImageRef = imageId + "On";
  changeImage('usa', ImageRef);

}

function ImageOff(imageId) {
  var ImageName, ImageRef;
  ImageName = imageId;
  ImageRef = imageId + "Off";		
  changeImage('usa', ImageRef);
}


	

function changeImage(imageId, imageName) {	
  document.images[imageId].src = eval(imageName +  ".src");
}

function load_store_details(shopid) 
{
  document.getElementById("location").innerHTML='<img src="images/ajax-loader.gif" alt="loading"/>';
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
    {
      alert ("Browser does not support HTTP Request");
      return;
    }
  var url = url_base + "ajax_store_details.php";	
  url = url + "?shop_id="+shopid;
  xmlHttp.onreadystatechange=received_store_details ;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);  		
}

function received_store_details () 
{
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 
      document.getElementById("location").innerHTML=xmlHttp.responseText ;
    } 
}


// load_store_list and received_store_list update the store list with actual store names and addresses.
function load_store_list (type, country, location, division) 
{
  document.getElementById("location").innerHTML='<img src="images/ajax-loader.gif" alt="loading"/><br/>  <br/>  <br/>  <br/>  <br/>';
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
    {
      alert ("Browser does not support HTTP Request");
      return;
    }
  //  Sample URL :: http://www.guidancemedia.com/store_details_ajax.php?country=United%20Kingdom&location=Europe
  var url = url_base + "ajax_store_list.php";
  if (type == 'town') {
    url = url + "?country=" + country + "&location=" + location + "&town=" + division;
  } 
  if (type == 'state') {
    url = url + "?country=" + country + "&location=" + location + "&state=" + division;
  } 
  if (type == 'all') {
    url = url + "?country=" + country + "&location=" + location ;
  }
  xmlHttp.onreadystatechange=received_store_list ;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);  
}

function received_store_list()
{ 
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 
      document.getElementById("store_list").innerHTML=xmlHttp.responseText ;
      document.getElementById("location").innerHTML="  <br/>  <br/>  <br/>  <br/>  <br/>  <br/>";
      /*       document.getElementById("bmark").style.display="inline"; */
    } 
}



// load_country_details and received_toplevel_store_locations update the shop list table (the "storetable" div). 
function load_country_details (location, country) 
{
  document.getElementById("location").innerHTML='<img src="images/ajax-loader.gif" alt="loading"/><br/>  <br/>  <br/>  <br/>  <br/>';
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
    {
      alert ("Browser does not support HTTP Request");
      return;
    }
  //  Sample URL :: http://www.guidancemedia.com/store_details_ajax.php?country=United%20Kingdom&location=Europe
  var url = url_base + "ajax_store_groups.php?country=" + country + "&location=" + location;
  xmlHttp.onreadystatechange=received_toplevel_store_locations ;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);  
}

function received_toplevel_store_locations()
{ 
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 
      document.getElementById("store_list").innerHTML=xmlHttp.responseText ;
      document.getElementById("location").innerHTML="  <br/>  <br/>  <br/>  <br/>  <br/>  <br/>";
      /*       document.getElementById("bmark").style.display="inline"; */
    } 
}



// load_locations and received_country_list update the list of areas (the "store_list" div).
function load_locations (location) 
{
  document.getElementById("location").innerHTML='<img src="images/ajax-loader.gif" alt="loading"/><br/> <br/>  <br/>  <br/>  <br/>  <br/>';
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
    {
      alert ("Browser does not support HTTP Request");
      return;
    }
  var url = url_base + "ajax_country_list.php?location=" + location;
  xmlHttp.onreadystatechange=received_country_list ;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);  
}

function received_country_list() 
{ 
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 
      document.getElementById("store_list").innerHTML=xmlHttp.responseText ;
      document.getElementById("location").innerHTML="  <br/>  <br/>  <br/>  <br/>  <br/>  <br/>";
      /*       document.getElementById("bmark").style.display="inline"; */
    } 
} 


function GetXmlHttpObject()
{ 
  var objXMLHttp=null;
  if (window.XMLHttpRequest)
    {
      objXMLHttp=new XMLHttpRequest();
    }
  else if (window.ActiveXObject)
    {
      objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  return objXMLHttp;
} 


if (document.images) {

  usaOn = new Image();
  usaOn.src = "splash/international_usa.gif";

  usaOff = new Image();
  usaOff.src = "splash/international_map.gif";

  canadaOn = new Image();
  canadaOn.src = "splash/international_canada.gif";

  africaOn = new Image();
  africaOn.src = "splash/international_africa.gif";

  australiaOn = new Image();
  australiaOn.src = "splash/international_australia.gif";

  chinaOn = new Image();
  chinaOn.src = "splash/international_china.gif";

  eurorussiaOn = new Image();
  eurorussiaOn.src = "splash/international_eurorussia.gif";

  indiajapanOn = new Image();
  indiajapanOn.src = "splash/international_indiajapan.gif";

  mexicoOn = new Image();
  mexicoOn.src = "splash/international_mexico.gif";

  mideastOn = new Image();
  mideastOn.src = "splash/international_mideast.gif";

  southamericaOn = new Image();
  southamericaOn.src = "splash/international_southamerica.gif";

}
