
var xmlreqs = new Array();
var theDiv = '';
//var ajaxPath = "http://192.168.1.2/holland/_ajax/";
var ajaxPath = "_ajax/";
var ajaxWorkingImage = "<img src='"+ajaxPath+"_img/loading-anim.gif' class='ajaxLoader' />";
function addLoadEvent(func){
var oldonload=window.onload;
if(typeof window.onload!='function'){
window.onload=func;
}else{
window.onload=function(){
oldonload();func();}}}

function CXMLReq(type,xmlhttp,theDiv){
this.type = type;
this.xmlhttp = xmlhttp;
this.theDiv = theDiv;
}

function xmlreqGET(url,theDiv){
var xmlhttp=false;
var theDiv=theDiv;
if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange = xmlhttpChange;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
} else if (window.ActiveXObject) {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
if(xmlhttp){xmlhttp.onreadystatechange=xmlhttpChange;
xmlhttp.open("GET",url,true);
xmlhttp.send();
}}
var xmlreq=new CXMLReq('',xmlhttp,theDiv);
xmlreqs.push(xmlreq);
}

function xmlhttpChange(){
if (typeof(window['xmlreqs']) == "undefined") return;
for (var i=0; i < xmlreqs.length; i++) {
if (xmlreqs[i].xmlhttp.readyState == 4) {
if (xmlreqs[i].xmlhttp.status==200||xmlreqs[i].xmlhttp.status==304) {
handle_response(xmlreqs[i].theDiv,xmlreqs[i].xmlhttp);xmlreqs.splice(i,1);i--;
}else{
xmlreqs.splice(i,1);i--;
}}}}
function handle_response(theDiv,xmlhttp){
var thisResponse=xmlhttp.responseText;
if(theDiv!=''){document.getElementById(theDiv).innerHTML=thisResponse;
}}

function createRequestObject(){
var ro;
var browser=navigator.appName;
if(browser=="Microsoft Internet Explorer"){
ro=new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro=new XMLHttpRequest();
}
return ro;
}

function searchChange(s,c,i,l) {
 if (s == '' && c == '' && i == '') {
  var s_id = document.getElementById('searchSector').value;
  var c_id = document.getElementById('searchCategory').value;
  var i_id = document.getElementById('searchIndustry').value;  
  var l_id = document.getElementById('searchLocation').value;
 } else {
  var s_id = s;
  var c_id = c;
  var i_id = i;
  var l_id = l;
 }
 if (s_id != '') {
  xmlreqGET(ajaxPath+'genlist.cats.php?sector_id='+s_id+'&cat_id='+c_id+'&industry_id='+i_id,'search2');
  xmlreqGET(ajaxPath+'genlist.industries.php?sector_id='+s_id+'&cat_id='+c_id+'&industry_id='+i_id,'search3');
  xmlreqGET(ajaxPath+'genlist.locations.php?sector_id='+s_id+'&cat_id='+c_id+'&industry_id='+i_id+'&location_id='+l_id,'search4');
 }
}

function searchGo() {
 var s_id = document.getElementById('searchSector').value;
 var c_id = document.getElementById('searchCategory').value;
 var i_id = document.getElementById('searchIndustry').value;
 var l_id = document.getElementById('searchLocation').value;
 if (s_id != '') {
  var url = 'search-results.php?sector_id='+s_id+'&cat_id='+c_id+'&industry_id='+i_id+'&location_id='+l_id;
  window.open(url,'_self');
 } else {
  alert('Please choose a sector');
 }
}

function findUs() {
 window.open("find-us.php","findus","width=600,height=400");
}

function jobMarker(point,number) {
 var marker = new GMarker(point);
 GEvent.addListener(marker, "click", function() {
 marker.openInfoWindowHtml("<b>Job title</b><br>Reference: blah<br>Salary: blah");
 });
 return marker;
}