if (GBrowserIsCompatible()) {
	// updated 29-07-07
	var geocoder = null;
	geocoder = new GClientGeocoder();
	
	var map = new GMap2(document.getElementById("map"));
	
	//myCluster.fitMapMaxZoom=12;
	
	//var adsManager = new GAdsManager(map, 'ca-pub-9691276420944465', {channel:"9862592347",maxAdsOnMap:6});
	var publisher_id = "pub-9691276420944465";
	var adPos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(3, 40));
	adsManagerOptions = {
		maxAdsOnMap : 2,
		style: 'adunit',
		channel: '9862592347',
		position: adPos
	};
	adsManager = new GAdsManager(map, publisher_id, adsManagerOptions);
	adsManager.enable();
	
	var html = "<span id='hideMapAd' title='Hide Map Advertisement'>Hide Map Ad</span>";
	jQuery("#displayprice").prepend(html);

	jQuery("#hideMapAd").click(function(){
		adsManager.disable();
		jQuery("#hideMapAd").fadeOut();
	});
	jQuery("#hideMapAd").hover(function () { jQuery(this).css({'cursor' : 'pointer'}); });
	jQuery("#hideMapAd").css({'padding-right':'15px','color':'#0000cc','text-decoration':'underline'});


	/* *********************************************** */
	var houseMarker;
    var myPano;   
    var panoClient;
	var panoerrors = "";
	var pano_map_width = document.getElementById('main').offsetWidth+"px";

	//panoClient = new GStreetviewClient();   
	//myPano = new GStreetviewPanorama(document.getElementById("pano"));
	//myPano.hide();
	/* *********************************************** */


	map.addControl(new GSmallZoomControl3D());
	map.addControl(new GMapTypeControl());
	map.addMapType(G_PHYSICAL_MAP);

	try{
		if(mlongitude != "") {
			map.setCenter(new GLatLng(parseFloat(mlatitude), parseFloat(mlongitude)), 15);
		}else{
			map.setCenter(new GLatLng(-27.916766641249062, 134.033203125), 4);
		}
	}catch(e){
		map.setCenter(new GLatLng(-27.916766641249062, 134.033203125), 4);
	}

	// arrays to hold copies of the markers and html used by the sidebar
	// because the function closure trick doesnt work there
	var suburb_bar_html = "";
	var state_bar_html = "";
	
	var gmarkers = [];
	var htmls = [];
	var suburbs = [];
	var postcodes = [];
	var suburb_markers = [];
	var imarkercounter = 0;
	
	var search_suburb = "";
	var search_postcode = "";
			
	var vic = 'n';
	var act = 'n';
	var nsw = 'n';
	var qld = 'n';
	var nt = 'n';
	var wa = 'n';
	var sa = 'n';
	var tas = 'n';



	function initialize_pano(marker) {
		document.getElementById('pano').style.display = "";
		document.getElementById('pano').style.width = pano_map_width;
		document.getElementById('pano').style.height = "250px";
		
		panoClient = new GStreetviewClient();      
		
		// street icon
		var baseIcon = new GIcon();
		baseIcon.iconSize=new GSize(32,32);
		baseIcon.shadowSize=new GSize(56,32);
		baseIcon.iconAnchor=new GPoint(16,16);
		baseIcon.infoWindowAnchor=new GPoint(16,0);
		var the_view = new GIcon(baseIcon, "http://maps.google.com/mapfiles/kml/pal3/icon52.png", null, null);
		var point = new GLatLng(marker.getLatLng().lat(),  marker.getLatLng().lng());
		houseMarker = new GMarker(point,{icon:the_view, draggable: true, title:"Street View", bouncy:false, zIndexProcess:zback});
		map.addOverlay(houseMarker); 
		GEvent.addListener(houseMarker, "dragend", function() {
			map.closeInfoWindow();
			panoClient.getNearestPanorama(houseMarker.getLatLng(), showPanoData);
		});
		
		myPano = new GStreetviewPanorama(document.getElementById("pano"));
		panoClient.getNearestPanorama(houseMarker.getLatLng(), showPanoData);
		
		GEvent.addListener(myPano, "initialized", handleInitialized); 
		
		houseMarker.setLatLng(new GLatLng(marker.getLatLng().lat(), marker.getLatLng().lng()))
		panoClient.getNearestPanorama(houseMarker.getLatLng(), showPanoData);
	}

	function zback(marker,b) {
		return -999;
	}


	function handleInitialized(location) {
		houseMarker.setLatLng(new GLatLng(location.latlng.lat(), location.latlng.lng()))
		return;	
	}

	// A function to create the marker and set up the event window
	function createMarker(point,name,html,bar,suburb,postcode) {
		var marker = new GMarker(point, {title:suburb, draggable:true, bouncy:false} );
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(html);
			//var xml_stats_url = '/stats_xml.php?suburb=' + suburb + '&postcode=' + postcode;
			get_xml_stats(suburb, postcode);
			get_xml_pop_street(suburb, postcode);
		
		});

		// save the info we need to use later for the sidebar
		gmarkers[imarkercounter] = marker;
		htmls[imarkercounter] = html;
		suburbs[imarkercounter] = suburb;
		postcodes[imarkercounter] = postcode;
		
		
		// add a line to the sidebar html
		if(imarkercounter != 0 && imarkercounter != 8){
			if(bar == 'state' && state_bar_html != ""){
				state_bar_html += ', '
			}else if(bar == 'suburb' && suburb_bar_html.length > 98){
				suburb_bar_html += ', '
			}
		}
		if(bar == 'state'){
			state_bar_html += '<a href="javascript:myclick(' + imarkercounter + ')">' + name + '</a>';
		}else if(bar == 'suburb'){
			suburb_bar_html += '<a href="javascript:myclick(' + imarkercounter + ')">' + name + '</a>';
		}
		
		imarkercounter++;

		return marker;
	}


	// This function picks up the click and opens the corresponding info window
	function myclick(i) {
		
		gmarkers[i].openInfoWindowHtml(htmls[i]);

		var xml_url = "";
		if(i <= 7){
			add_aust();
		}
   

		if(i == 0){
			get_xml_data('/xml/sa.xml', 'suburb');
			map.setCenter(new GLatLng(-34.415973384481866, 137.63671875), 6);
		}else if (i == 1){
			get_xml_data('/xml/qld.xml', 'suburb');
			map.setCenter(new GLatLng(-25.34402602913433, 149.326171875), 6);
		}else if (i == 2){
			get_xml_data('/xml/act.xml', 'suburb');
			map.setCenter(new GLatLng(-35.47856499535729, 148.77685546875), 6);
		}else if (i == 3){
			get_xml_data('/xml/nt.xml', 'suburb');
			map.setCenter(new GLatLng(-15.855673509998681, 133.35205078125), 6);
		}else if (i == 4){
			get_xml_data('/xml/tas.xml', 'suburb');
			map.setCenter(new GLatLng(-42.04929263868684, 146.4697265625), 6);
		}else if (i == 5){
			get_xml_data('/xml/vic.xml', 'suburb');
			map.setCenter(new GLatLng(-36.96744946416932, 144.84375), 6);
		}else if (i == 6){
			get_xml_data('/xml/wa.xml', 'suburb');
			map.setCenter(new GLatLng(-31.69078180613681, 119.794921875), 6);
		}else if (i == 7){
			get_xml_data('/xml/nsw.xml', 'suburb');
			map.setCenter(new GLatLng(-33.43144133557529, 149.501953125), 6);
		}else{
			//xml_stats_url = '/stats_xml.php?suburb=' + suburbs[i] + '&postcode=' + postcodes[i];
			get_xml_stats(suburbs[i], postcodes[i]);
			get_xml_pop_street(suburbs[i], postcodes[i]);
		}
		
	}

	function myclick_center(i) {
		
		var xml_url = "";
		if(i <= 7){
			add_aust();
		}
		
		if(i == 0){
			get_xml_data('/xml/sa.xml', 'suburb');
			map.setCenter(new GLatLng(-34.415973384481866, 137.63671875), 6);
		}else if (i == 1){
			get_xml_data('/xml/qld.xml', 'suburb');
			map.setCenter(new GLatLng(-25.34402602913433, 149.326171875), 6);
		}else if (i == 2){
			get_xml_data('/xml/act.xml', 'suburb');
			map.setCenter(new GLatLng(-35.47856499535729, 148.77685546875), 6);
		}else if (i == 3){
			get_xml_data('/xml/nt.xml', 'suburb');
			map.setCenter(new GLatLng(-15.855673509998681, 133.35205078125), 6);
		}else if (i == 4){
			get_xml_data('/xml/tas.xml', 'suburb');
			map.setCenter(new GLatLng(-42.04929263868684, 146.4697265625), 6);
		}else if (i == 5){
			get_xml_data('/xml/vic.xml', 'suburb');
			map.setCenter(new GLatLng(-36.96744946416932, 144.84375), 6);
		}else if (i == 6){
			get_xml_data('/xml/wa.xml', 'suburb');
			map.setCenter(new GLatLng(-31.69078180613681, 119.794921875), 6);
		}else if (i == 7){
			get_xml_data('/xml/nsw.xml', 'suburb');
			map.setCenter(new GLatLng(-33.43144133557529, 149.501953125), 6);
		}else{
			xml_url = '/gmap_xml.php?suburb=' + suburbs[i] + '&postcode=' + postcodes[i];
			search_suburb = suburbs[i];
			search_postcode = postcodes[i];
			//document.getElementById("bar").innerHTML = xml_url;
			document.getElementById("suburb_bar").innerHTML = "<img src='/images/loader_blue.gif' alt='Loading Data' /> Loading : ";
			document.getElementById("stats_bar").innerHTML = "Searching : " + search_suburb;
			add_aust();
			get_xml_data(xml_url, 'suburb');
			get_xml_stats(search_suburb, search_postcode);
			get_xml_pop_street(search_suburb, search_postcode);
		}
	}


	function add_aust(){
		// reset values
		map.clearOverlays();
		if((typeof myPano) != 'undefined'){
			map.addOverlay(houseMarker);
		}
//myPano = "";

		document.getElementById("suburb_bar").innerHTML = "";
		suburb_bar_html = "<a href='javascript:view_surrounding_suburbs()' title='Click to re-center Surrounding Suburbs'><span style='color: #666666; font-family: arial;  font-weight:bold;'>Surrounding Suburbs</span></a> : ";
		document.getElementById("state_bar").innerHTML = "";
		state_bar_html = "";
		
		imarkercounter = 0;
		gmarkers = [];
		htmls = [];
		suburbs = [];
		postcodes = []; 
		
		
		// load values
		var bar = 'state';

		var point = new GLatLng("-34.9285600","138.6006700");
		var suburb = "Adelaide";
		var postcode = "5000";
		var html = suburb + ' ' + postcode + "<br/><a href='javascript:myclick(0);'>View State</a>";
		var marker = createMarker(point,suburb,html,bar,suburb,postcode);
		map.addOverlay(marker);
		
		var point = new GLatLng("-27.4725800","153.0265200");
		var suburb = "Brisbane";
		var postcode = "4000";
		var html = suburb + ' ' + postcode + "<br/><a href='javascript:myclick(1);'>View State</a>";
		var marker = createMarker(point,suburb,html,bar,suburb,postcode);
		map.addOverlay(marker);
		
		var point = new GLatLng("-35.3009400","149.1230000");
		var suburb = "Canberra";
		var postcode = "2600";
		var html = suburb + ' ' + postcode + "<br/><a href='javascript:myclick(2);'>View State</a>";
		var marker = createMarker(point,suburb,html,bar,suburb,postcode);
		map.addOverlay(marker);
			
		var point = new GLatLng("-12.4606800","130.8427900");
		var suburb = "Darwin";
		var postcode = "800";
		var html = suburb + ' ' + postcode + "<br/><a href='javascript:myclick(3);'>View State</a>";
		var marker = createMarker(point,suburb,html,bar,suburb,postcode);
		map.addOverlay(marker);
			
		var point = new GLatLng("-42.8837000","147.3256800");
		var suburb = "Hobart";
		var postcode = "7000";
		var html = suburb + ' ' + postcode + "<br/><a href='javascript:myclick(4);'>View State</a>";
		var marker = createMarker(point,suburb,html,bar,suburb,postcode);
		map.addOverlay(marker);           
		
		var point = new GLatLng("-37.8176400","144.9465400");
		var suburb = "Melbourne";
		var postcode = "3000";
		var html = suburb + ' ' + postcode + "<br/><a href='javascript:myclick(5);'>View State</a>";
		var marker = createMarker(point,suburb,html,bar,suburb,postcode);
		map.addOverlay(marker);
			
		var point = new GLatLng("-31.9532700","115.8581200");
		var suburb = "Perth";
		var postcode = "6000";
		var html = suburb + ' ' + postcode + "<br/><a href='javascript:myclick(6);'>View State</a>";
		var marker = createMarker(point,suburb,html,bar,suburb,postcode);
		map.addOverlay(marker);
		
		var point = new GLatLng("-33.8668500","151.2042500");
		var suburb = "Sydney";
		var postcode = "2000";
		var html = suburb + ' ' + postcode + "<br/><a href='javascript:myclick(7);'>View State</a>";
		var marker = createMarker(point,suburb,html,bar,suburb,postcode);
		map.addOverlay(marker);

		document.getElementById("state_bar").innerHTML = state_bar_html;
	}

	function get_xml_data(xml_location,bar){
		document.getElementById("suburb_bar").innerHTML = "<img src='/images/loader_blue.gif' alt='Loading Data' /> Loading : ";
		// reset markers array
		suburb_markers = [];

		if(bar == 'state'){
			document.getElementById("state_bar").innerHTML = "<img src='/images/loader_blue.gif' alt='Loading Data' /> Loading ...";
		}else if (bar == 'suburb'){
			document.getElementById("suburb_bar").innerHTML = "<img src='/images/loader_blue.gif' alt='Loading Data' /> Loading ...";
		}
		if(xml_location == ""){
			var search_suburb = document.display_options.suburbname.value;
			var search_postcode = document.display_options.suburbpostcode.value;
			xml_location = '/gmap_xml.php?suburb=' + search_suburb + '&postcode=' + search_postcode;
		}
		var request = GXmlHttp.create();
		request.open('GET', xml_location, true);
		request.onreadystatechange = function() {
			if (request.readyState == 4) {
				var xmlDoc = request.responseXML;
				// obtain the array of markers and loop through it
				var markers = xmlDoc.documentElement.getElementsByTagName("marker");
				
				var center_map = "";
				var center_lat = "";
				var center_long = "";
				var lat = "";
				var lng = "";
				for (var im = 0; im < markers.length; im++) {
					// obtain the attribues of each marker
					lat = parseFloat(markers[im].getAttribute("lat"));
					lng = parseFloat(markers[im].getAttribute("lng"));
					var point = new GLatLng(lat,lng);
					//var html = markers[i].getAttribute("html");
					//var label = markers[i].getAttribute("label");
					var suburb = markers[im].getAttribute("suburb");
					var postcode = markers[im].getAttribute("postcode");
					var click_id = im + 8; // 8 is the num of states
					var dispsub = new ELabel(new GLatLng(lat, lng), '<div style="background-color:#ffffff;border:1px solid black; font-family: arial, helvetica; font-size:10px; width:75px;">'+ suburb + '<\/div>', null, new GSize(6,-30), 75);
					map.addOverlay(dispsub);	
					var html = suburb + ' ' + postcode + '<br/>' + '<a href=\'javascript:myclick_center(' + click_id + ')\'>View Surrounding Suburbs</a>';
					// get the map center
					center_map = markers[im].getAttribute("center");
					if(center_map == "true"){
						center_lat = lat;
						center_long = lng;
					}
					
					// create the marker
					suburb_markers[im] = createMarker(point,suburb,html,bar,suburb,postcode);
					map.addOverlay(suburb_markers[im]);
					
				}
				// center the map
				if(center_lat != "" && center_long != ""){
					map.setCenter(new GLatLng(center_lat, center_long));      
				}else{
					map.setCenter(new GLatLng(lat, lng));   
				}

				// put the assembled sidebar_html contents into the sidebar div
				if(bar == 'state'){
					document.getElementById("state_bar").innerHTML = state_bar_html;
				}else if (bar == 'suburb'){
					suburb_bar_html +=  "<h2 style='color: #666666; text-align: center;'><img src='/images/tip.gif' alt='Helpfull Tip' />Click on Suburb to search</h2>";

					document.getElementById("suburb_bar").innerHTML = suburb_bar_html;
				}
			}
		}
		request.send(null);
	}
	
	
	function get_xml_stats(suburb, postcode){
		document.display_options.suburbname.value = suburb;
		document.gearth.suburb.value = suburb;
		document.gearthrent.suburb.value = suburb;
		
		document.display_options.suburbpostcode.value = postcode;
		document.gearth.postcode.value = postcode;
		document.gearthrent.postcode.value = postcode;
		var xml_stats_url = '/total_stats_xml.php?suburb=' + suburb + '&postcode=' + postcode;
		
		//document.getElementById("stats_bar").innerHTML = "Loading : " + suburb;
		var stats_array = new Array();
		var request = GXmlHttp.create();
		request.open('GET', xml_stats_url, true);
		request.onreadystatechange = function() {
			if (request.readyState == 4) {
				var xmlDoc = request.responseXML;
				// obtain the array of markers and loop through it
				var stats = xmlDoc.documentElement.getElementsByTagName("stat");

				var stats_bar_html = "";
				var rent = "";
				var buy = "";
				var display_rent = "";
				var display_buy = "";
				
				if(stats.length > 0){
					//stats_bar_html = "<div id='stats_info' style='background-image: url(/images/found.gif); background-repeat: no-repeat; background-position: top center; '>";
					stats_bar_html = "<div id='stats_info'>";
					//stats_bar_html += "<h2 style='color:#009;'>Property Results</h2>";
					
					//stats_bar_html += '<h3>' + suburb + '</h3>';
					stats_bar_html += "<table class='search_results'>\n";
					stats_bar_html += "	<tr class='search_title'>\n";
					stats_bar_html += "		<td>" + suburb + "</td>\n";
					if(stats[0].getAttribute("buy") > ""){
						stats_bar_html += "		<td>Buy</td>\n";
					}else{
						stats_bar_html += "		<td></td>\n";
					}
					if(stats[0].getAttribute("rent") > ""){
						stats_bar_html += "		<td>Rent</td>\n";
					}else{
						stats_bar_html += "		<td></td>\n";
					}
					stats_bar_html += "	</tr>\n";
					for (var i = 0; i < stats.length; i++) {
						// obtain the attribues of each marker
						var site = stats[i].getAttribute("site");
						
						buy = stats[i].getAttribute("buy");
						
						rent = stats[i].getAttribute("rent");
						//var total = parseFloat(stats[i].getAttribute("total"));
						var last_update = stats[i].getAttribute("last_update");

						if(site == "all"){
							//stats_bar_html += 'Total :' + total;
							stats_bar_html += "	<tr>\n";
							stats_bar_html += "		<td class='found_total'>TOTAL</td>\n";
							if(buy != ""){
								stats_bar_html += "			<td class='found_total'>" + buy + "</td>\n";
								display_buy = "y";
							}else{
								stats_bar_html += "			<td></td>\n";
							}
							if(rent != ""){
								stats_bar_html += "			<td class='found_total'>" + rent + "</td>\n";
								display_rent = "y";
							}else{
								stats_bar_html += "			<td></td>\n";
							}
							stats_bar_html += "	</tr>\n";
						}else if (site == "summary"){
							//stats_bar_html += '<br/>Last Update : ' + last_update;
							stats_bar_html += "	<tr>\n";
							stats_bar_html += "		<td colspan='3' class='last_updated'>Last Updated :" + last_update +"</td>\n";
							stats_bar_html += "	</tr>\n";

						}else{
							//stats_bar_html += '<br/>' + site + ' (' + total + ')';
							stats_bar_html += "		<tr class='site_results'>\n";
							stats_bar_html += "			<td>" + site + "</td>\n";
							if(buy != ""){
								stats_bar_html += "			<td>" + buy + "</td>\n";
							}else{
								stats_bar_html += "			<td></td>\n";
							}
							if(rent != ""){
								stats_bar_html += "			<td>" + rent + "</td>\n";
							}else{
								stats_bar_html += "			<td></td>\n";
							}
							stats_bar_html += "		</tr>\n";
						}
					}
					stats_bar_html += "</table>\n";
					document.getElementById("stats_info").innerHTML = stats_bar_html;
					stats_bar_html = "";
					var gearth_url_buy = '/gearth/google_earth.php?suburb=' + suburb + '&postcode=' + postcode;
					var gearth_url_rent = '/gearth/google_earth_rent.php?suburb=' + suburb + '&postcode=' + postcode;
					
					var gmap_url = 'http://www.suburbview.com/gearth/google_map.php?suburb=' + suburb + '&postcode=' + postcode;
					
					stats_bar_html +=  "<div style='width:350px;'id='detailscontainer'>\n";
					stats_bar_html +=  "<div style='float:left; height:500px; width:19px;' id='showhide'><a href=\"javascript:showhide_propdetails('hide')\" title='Hide Property Details'><img src='/images/hide.gif' alt='Hide Property Listings' /></a></div>";
					stats_bar_html +=  "<div style='float:left; height:500px; width:330px; overflow:auto;' id='prop_details'>";
					stats_bar_html += "<img src='/images/loader_blue.gif' alt='Loading Data' /> Loading... ";
					stats_bar_html +=  "</div>";
					stats_bar_html +=  "</div>";

					stats_bar_html +=   "<div style='width:220px; float:left;' id='optionscontainer'>\n";
					stats_bar_html +=      "<div style='float:left; height:500px; width:19px;' id='showhideoptions'><a href=\"javascript:showhide_propoptions('hide')\" title='Hide Property Options'><img src='/images/hide.gif' alt='Hide Property Listings' /></a></div>\n";
					stats_bar_html +=      "<div style='float:left; height:500px; width:200px; overflow:auto;' id='prop_options_details'>";


					stats_bar_html += 	"<div id='map_summary' style='width:200px;'>\n";

					stats_bar_html += "<img src='/images/loader_blue.gif' alt='Loading Data' /> Loading... ";

					stats_bar_html +=  "<div id='show_options'>\n";
					stats_bar_html +=  "</div>\n";
					stats_bar_html += 	"</div>\n";
					stats_bar_html +=  "</div>";
					stats_bar_html +=  "</div>";
					stats_bar_html += "</div>";

					document.getElementById("gearthbuylink").innerHTML ="<a href='" + gearth_url_buy + "' rel='nofollow' title='Click to view in Google Earth (Default Settings)'><img src='/images/bar_icon_link.gif'></a>";
					document.getElementById("gearthrentlink").innerHTML ="<a href='" + gearth_url_rent + "' rel='nofollow' title='Click to view in Google Earth (Default Settings)'><img src='/images/bar_icon_link.gif'></a>";
					
				}else{
					stats_bar_html =  no_results(suburb);
					document.getElementById("map_summary").innerHTML = stats_bar_html;
				}
				// turned this off 24/07/07
				//				document.getElementById("stats_bar").innerHTML = stats_bar_html;
				var ajax_loading = "<img src='/images/loader_blue.gif' alt='Loading Data' /> Loading... ";
				document.getElementById("prop_details").innerHTML = ajax_loading;
				document.getElementById("map_summary").innerHTML = ajax_loading;


				//display the show options
				load_property_map(suburb ,postcode, display_type);

				//hide_options(); // comes from the Options JS
			}else{
				document.getElementById("prop_details").innerHTML = "";
				document.getElementById("map_summary").innerHTML = "";
			}
		}
		request.send(null);
	}

	function display_suburb_markers(){
		for (var i = 0; i < suburb_markers.length; i++) {
			map.addOverlay(suburb_markers[i]);
		}
	}

	function set_zoom(iz){
		if(iz == "+"){
			iz = map.getZoom() + 1;
			if(iz > 17){
				iz = 17;
			}
		}else if(iz == "-"){
			iz = map.getZoom() - 1;
			if(i < 1){
				iz = 1;
			}
		}
		map.setZoom(iz);
	}
	

	GEvent.addListener(map, "moveend", function() {
		//var center = map.getCenter();
		//document.getElementById("message").innerHTML = center.toString();
		var found_zoom_level = map.getZoom();

		document.getElementById("zoom_country").innerHTML = "<a href='javascript:set_zoom(4);' style='border: 1px solid #5D7DBA; background-color: #243E6C; color:#FFFFFF; font-weight:bold'>Country</a>";
		document.getElementById("zoom_state").innerHTML = "<a href='javascript:set_zoom(6);' style='border: 1px solid #5D7DBA; background-color: #243E6C; color:#FFFFFF; font-weight:bold'>State</a>";
		document.getElementById("zoom_suburb").innerHTML = "<a href='javascript:set_zoom(13);' style='border: 1px solid #5D7DBA; background-color: #243E6C; color:#FFFFFF; font-weight:bold'>Suburb</a>";
		document.getElementById("zoom_street").innerHTML = "<a href='javascript:set_zoom(15);' style='border: 1px solid #5D7DBA; background-color: #243E6C; color:#FFFFFF; font-weight:bold'>Street</a>";
		
		if(found_zoom_level < 5){
			document.getElementById("zoom_country").innerHTML = "<b>Country</b>";
		}else if(found_zoom_level >= 5 && found_zoom_level < 7){
			document.getElementById("zoom_state").innerHTML = "<b>State</b>";
		}else if(found_zoom_level >= 7 && found_zoom_level < 14){
			document.getElementById("zoom_suburb").innerHTML = "<b>Suburb</b>";
		}else if(found_zoom_level >= 14){
			document.getElementById("zoom_street").innerHTML = "<b>Street</b>";
		}
	});

	// used to display an address marker
	function showAddress(search_address, search_suburb, search_state) {
		if (geocoder && search_suburb != 'Suburb') {
			if (search_address == "Street Address"){
				search_address = "";
			}
		
			var address = search_address + "," + search_suburb + ", " + search_state +",Australia";
			var display_address = search_address + "<br/>\n <a href='http://www.suburbview.com/index.php?suburb="+ search_suburb + "&state="+search_state+"'>" + search_suburb + "</a>";
			geocoder.getLatLng(
				address,
				function(point) {
						if (!point) {
						alert(address + " not found");
					} else {
						var current_zoom =  map.getZoom();
						var display_zoom = current_zoom;
						if (current_zoom < 13){
							display_zoom = 15;
						}
						map.setCenter(point, display_zoom);
						var search_marker = new GMarker(point, {draggable: true});
						map.addOverlay(search_marker);
						GEvent.addListener(search_marker, "click", function() {
							search_marker.openInfoWindowHtml(display_address);
						});
						search_marker.openInfoWindowHtml(display_address);
						show_street(search_marker);
					}
				}	
				);
		}else{
			alert('Enter Address, and Suburb to Display Address');
		}
	}
	
	function view_surrounding_suburbs(){
		add_aust();
		get_xml_data("","suburb");
	}
	
	function no_results(the_suburb){
		var stats_bar_html = ""
		//stats_bar_html +=  "<div  id='stats_info' style='background-image: url(/images/not_found.gif); background-repeat: no-repeat; background-position: top center; '>";
		stats_bar_html +=  "<h2 style='color:#009;'>Search Results</h2>\n";
		stats_bar_html +=  "No results found for <strong>" + the_suburb + "</strong>.\n";
		stats_bar_html +=  "<br/><br/><br/><br/><br/><br/><img src='/images/tip.gif' alt='Helpfull Tip' />Search results are usually updated every 24hrs. Try again tomorrow.";
		stats_bar_html +=  "<br/><br/><br/><br/><br/><br/><br/>\n";
		//stats_bar_html +=  "</div>";
		
		if(display_type == "share"){
			no_share_data(the_suburb);
		}
		
		return stats_bar_html;
	}


	function createMapLoader (){
		MapLoaderStatus = function() {};
		MapLoaderStatus.prototype = new GControl();
		MapLoaderStatus.prototype.initialize = function(map) {
			var container = document.createElement("div");
			var mapStatusDiv = document.createElement("div");
			mapStatusDiv.id = "map_status";
			this.setButtonStyle_(mapStatusDiv);
			container.appendChild(mapStatusDiv);
			map.getContainer().appendChild(container);
			return container;
		}

		MapLoaderStatus.prototype.getDefaultPosition = function() {
			return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(70, 0));
		}

		MapLoaderStatus.prototype.setButtonStyle_ = function(button) {
			button.style.color = "#0000cc";
			button.style.backgroundColor = "white";
			button.style.border = "1px solid black";
			button.style.padding = "2px";
			button.style.marginBottom = "3px";
			button.style.textAlign = "center";
			button.style.width = "230px";
		}
	}

	function createMapNoAddress (){
		MapNoAddressStatus = function() {};
		MapNoAddressStatus.prototype = new GControl();
		MapNoAddressStatus.prototype.initialize = function(map) {
			var container = document.createElement("div");
			var mapStatusDiv = document.createElement("div");
			mapStatusDiv.id = "map_no_address";
			this.setButtonStyle_(mapStatusDiv);
			container.appendChild(mapStatusDiv);
			map.getContainer().appendChild(container);
			return container;
		}

		MapNoAddressStatus.prototype.getDefaultPosition = function() {
			var top = parseInt(($('#map').height() * 0.7) / 2);
			return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(70, top));
		}

		MapNoAddressStatus.prototype.setButtonStyle_ = function(button) {
			button.style.color = "#0000cc";
			button.style.backgroundColor = "white";
			button.style.border = "1px solid black";
			button.style.padding = "2px";
			button.style.marginBottom = "3px";
			button.style.textAlign = "center";
			button.style.width = parseInt(($('#map').width() - 70 )* 0.8) + "px";
			button.style.height = ($('#map').height() * 0.3) + "px";
			
		}
	}
	
	function no_share_data(suburb){
		var html = "";
		var code = getShareCode(suburb);
		html = "<div class='mapdata'>";
		html += "<img src='/images/easyroommate_large.png' />";
		html += "<br/>For people having a room to rent: <a href='http://au.easyroommate.com/default.aspx?"+code+"at=H&ac=suburbview&lc=1' target='_blank' onclick='banner_link(this)'>Click Here</a>";
		html += "<br/>For people looking for a room: <a href='http://au.easyroommate.com/default.aspx?"+code+"at=L&ac=suburbview&lc=1' target='_blank' onclick='banner_link(this)'>Click Here</a>";
		html += "<br/><br/>";
		html += "<div style='text-align:right'><small>[<a href='#' onclick='hide_share_banner();return false;'>Hide</a>]</small></div>";
		html += "</div>";
		$('#map_no_address').html(html);
		$('#map_no_address').show();
	}

	function getShareCode(suburb){
		//http://au.easyroommate.com/default.aspx?mc=sydn&at=L&ac=suburbview&lc=1
		//http://au.easyroommate.com/default.aspx?mc=pert&at=L&ac=suburbview&lc=1
		var code = "mc=";
		var getData = function(suburb,state){
			jQuery.ajax({
				url			: "/json/share_code.php?suburb="+suburb+"&state="+state, 
				dataType	: "json",
				async		: false,
				success		: function(data){
					code += data.code;
				}
			});
		};
		getData(suburb,jQuery('[name=suburbstate]').val());
		return code+"&";
	}
	function banner_link(value){
		var url = "/ad/"+value.href;
		urchinTracker(url);
	}
	
	function hide_share_banner(){
		$('#map_no_address').fadeOut();
		return false;
	}
	
	var tempMapLoader = new createMapLoader();
	var NoAddress = new createMapNoAddress();
	map.addControl(new MapLoaderStatus());
	map.addControl(new MapNoAddressStatus());
	
	$('#map_status').html("<img src='/images/loader_blue.gif' alt='Loading Data' /> Loading Real Estate");
	$('#map_no_address').html("");
	$('#map_no_address').hide();
}
