// JavaScript Document

//<![CDATA[

		var map = null;
    var geocoder = null;

    function load() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
				// 
				map.addControl(new GLargeMapControl());
				map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(-33.745, 150.69603), 14);
        geocoder = new GClientGeocoder();

		if(document.getElementById("searchBus").value != ""){
			ajaxFunction();
			document.getElementById('mapQuickSearchResults').style.visibility='visible';
			//document.getElementById("mapSearch").submit();
		}else {
		if(document.getElementById("searchLoc").value != ""){
			showAddress(document.getElementById("searchLoc").value,document.getElementById("searchLoc").value,'','')
			}
		}
      }
	  else{
		  alert("Browser is not compatible for Google Maps!")
	  }
    }

    function showAddress(town,address,bname,image,w,h,id) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
				if(town != ""){
				showAddress('',town,bname,image,w,h,id)
				}else{
				  alert(address + " not found");
				}
            } else {
              map.setCenter(point, 15);
              var marker = new GMarker(point);
              map.addOverlay(marker);
			  if(town != ""){
				  if(image != ""){
					  marker.openInfoWindowHtml("<div style='text-align:center;'><a href='../directory_details.asp?ID="+id+"'><img src='../"+image+"' border='0' width='"+w+"' height='"+h+"' /><br><b>"+bname+"</b></a><br>" + address +"</div>");
				  }else{
					  marker.openInfoWindowHtml("<div style='text-align:center;'><b><a href='../directory_details.asp?ID="+id+"'>"+bname+"</a></b><br>" + address +"</div>");
				  }
			  }else{
				  if(image != ""){
					  marker.openInfoWindowHtml("<div style='text-align:center;'><a href='../directory_details.asp?ID="+id+"'><img src='../"+image+"' border='0' width='"+w+"' height='"+h+"' /><br><b>"+bname+"</b></a><br>Address unavailable - " + address +"</div>");
				  }else{
					  marker.openInfoWindowHtml("<div style='text-align:center;'><b><a href='../directory_details.asp?ID="+id+"'>"+bname+"</a></b><br>Address unavailable - " + address +"</div>");
				  }
				  }
            }
          }
        );
      }
    }
		
		//]]>

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function closeSearchWindow() {
	document.getElementById('mapQuickSearchResults').style.visibility='hidden'
}

function ajaxFunction()
  {  var xmlHttp;
  try
    {    // Firefox, Opera 8.0+, Safari    
	xmlHttp=new XMLHttpRequest();
	}
  catch (e)
    {    // Internet Explorer    
	try
      {      
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	  }
		catch (e)
		  {      
		  try
			{        
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 
			}
		  catch (e)
			{        
			alert("Your browser does not support AJAX!");
			return false;
			}
		}
	}
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("searchresults").innerHTML=xmlHttp.responseText;
        }
      }
   	xmlHttp.open("GET","area_maps_google_searchresults.asp?name="+document.getElementById("searchBus").value+"",true);
    xmlHttp.send(null);
	}
		
