function getSubLocations(location_id,sublocation_id){ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	var url=HTTP_BASE+"locations/get_sublocations/"+location_id+'/'+sublocation_id;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

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;
}

function stateChanged() { 
	if (xmlHttp.readyState==4){ 
		document.getElementById("sublocation").innerHTML=xmlHttp.responseText;
	}
}


function AJAXInteraction(url, divid, callback) {

    var req = ajax_init();
	var divid = (divid == null) ? "" : divid;
	var callback = (callback == null) ? "" : callback;
    req.onreadystatechange = processRequest;
       
	//alert(url); document.write(url); return false;	  
	  
    function ajax_init() {
      if (window.XMLHttpRequest) {
        http_request =  new XMLHttpRequest();
      } else if (window.ActiveXObject) {        
	   try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
				http_request = false;
			}
         }
      }      
	  if (!http_request) {
         alert('Cannot create ajax instance. Please enable javascript for this site to function properly.');
         return false;
      }
	  return http_request;
    }
    
    function processRequest () {
      if (req.readyState == 4) {
        if (req.status == 200) {//alert(divid);alert(req.responseText);alert(callback);
          if (callback) 
		  	callback(req.responseText , divid);
		  else
		  	if(document.getElementById(divid))
				document.getElementById(divid).innerHTML=req.responseText;		  
          //if (callback) callback(req.responseXML);
        }
      }
    }

    this.doGet = function() {
      req.open("GET", url, true);
      req.send(null);
    }
    
    this.doPost = function(vals) {
      req.open("POST", url, true);
      req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      req.setRequestHeader("Content-length", vals.length);
	  req.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	  req.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	  req.setRequestHeader("Pragma", "no-cache");
      req.setRequestHeader("Connection", "close");
      req.send(vals);
    }
}
