if(GBrowserIsCompatible()){
	var map;
	// main map call 
	function init_map(json,default_latitude,default_longitude,default_zoom){
		map = new GMap2(document.getElementById("map"));
		bounds = new GLatLngBounds();
		map.setCenter(new GLatLng(default_latitude,default_longitude), default_zoom);
		mapui=map.getDefaultUI();
		mapui.controls.maptypecontrol=false;
		mapui.controls.menumaptypecontrol=true;
		mapui.controls.scalecontrol=true;
		mapui.controls.smallzoomcontrol3d=false;
		mapui.controls.largemapcontrol3d =true;
		map.setUI(mapui);
		// initial load of map
		//addMarkers(json,true);
	}
	
	// create the marker and add it to the map
	function createMarker(latitude,longitude,id) {
		var point=new GLatLng(latitude,longitude);
		var marker=new GMarker(point);
		GEvent.addListener(marker,"click",function(){
			$("#map-accordion").accordion("activate",$("#store-accord-"+id))
		});
		map.addOverlay(marker);
		bounds.extend(point);
	}
	
	// take the json of results and put the markers on the map 
	function addMarkers(json,clear_map,site){
		// clear the map if requested
		if(clear_map){map.clearOverlays()};
		
		// loop the json and place markers based on the json
		for(x in json){
			var store=json[x];
			createMarker(store.latitude,store.longitude,store.id);
		}
		
		
		// now we have set all our markers, set the zoom and centre of the map
		map.setZoom(map.getBoundsZoomLevel(bounds));
		map.setCenter(bounds.getCenter());
	}
	
	/*
	function addHouse(house_json){
		var x,i,markers=[];
		var mc_styles=[{url:"/img/gmap/cluster1.png",width:24,height:23,opt_textColor:"#ffffff"},{url:"/img/gmap/cluster2.png",width:34,height:33,opt_textColor:"#ffffff"},{url:"/img/gmap/cluster3.png",width:69,height:69,opt_textColor:"#ffffff"}];
		map.clearOverlays();
		if(mc != null){mc.clearMarkers()}
		if(house_json.results.HOUSES.length){
			for (x in house_json.results.HOUSES){
				var house=house_json.results.HOUSES[x];
				var point = new GLatLng(house.latitude,house.longitude);
				var images=house_json.results.IMAGES[house.id];
				// set the images up ready for insertion into the html 
				if(images.length){
					// we got images, setup the main image first
					var imagepri='';
					if(!isNaN(house.message_id) && house.message_id != 0){imagepri='<div class="relative"><div class="contacted-overlay-thumb contacted-overlay-thumb-gmap"><a href="/my-messages/read/'+house.message_id+'/" title="You have contacted this member Click to view message">You have contacted this member Click to view message</a></div></div>'};
					imagepri=imagepri+'<a href="'+house.LINK+'" class="img"><img src="/assets/image/house/'+images[0].house_uuid+'/large_fixed/'+images[0].filename+'" id="gmap-lead-'+house.id+'" width="241" height="159" alt="'+house.name+'" title="'+house.name+'" /></a>';
					var imagesec='<ul>';
					for (i in images){
						if(house.video_thumb.length && i==2){
							imagesec=imagesec+'<li style="padding-right:0"><div class="relative"><div class="video-overlay-thumb"><a href="javascript:;" onclick="gmapVideo('+house.id+')"></a></div></div><a href="javascript:;" onclick="gmapVideo('+house.id+')"><img src="'+house.video_thumb+'" width="75" height="50" alt="'+house.name+'" title="'+house.name+'" /></a></li>';
						}else{
							var image=images[i];
							var style="";
							if(i==2){style="padding-right:0"}
							// onclick cos IE won't read the event, ergh!
							imagesec=imagesec+'<li style="'+style+'"><a href="#" onclick="gmapThumb(this)" data-house_uuid="'+image.house_uuid+'" data-image="'+image.filename+'" data-target_id="gmap-lead-'+house.id+'" data-house_id="'+house.id+'"><img src="/assets/image/house/'+image.house_uuid+'/thumb/'+image.filename+'" width="75" height="50" alt="'+house.name+'" title="'+house.name+'" /></a></li>';
						}
					}
					imagesec=imagesec+'</ul>';
				}else{
					// no images
					var imagepri='<a href="'+house.LINK+'" class="img"><img src="/img/placeholders/large_fixed.gif" width="241" height="159" alt="'+house.name+'" title="'+house.name+'" /></a>';
					var imagesec='';
				}
				// build the entire html template
				var html='<div class="house-gmap-overlay"><h1 class="alt-font"><a href="'+house.LINK+'" class="dgrey">'+house.name+'</a></h1><h2 class="alt-font">'+house.name_town+', '+house.name_country+'</h2><div style="width:243px;height:161px;float:left"><div id="gmap-main-video-'+house.id+'" style="display:none"></div><div id="gmap-main-image-'+house.id+'">'+imagepri+'</div></div>'+imagesec+'</div>';
				markers.push(createMarker(point,html));
				bounds.extend(point);
			}
			mc=new MarkerClusterer(map, markers,{maxZoom:6,gridSize:60,styles:mc_styles});
			map.setZoom(map.getBoundsZoomLevel(bounds));
			map.setCenter(bounds.getCenter());
			$("#search-withoutresults").hide();
			$("#search-withresults").show();
		}else{
			$("#search-withresults").hide();
			$("#search-withoutresults").show();
		}
	}*/
	
}



