// JavaScript Document
var centerLatitude = 53.351298 ;
var centerLongitude = -2.885815  ;
var startZoom = 8;
var map;

 


function init() 
{

	if (GBrowserIsCompatible())
	{
		
		
		 
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		
		map.removeMapType(G_HYBRID_MAP);
		
        var mapControl = new GMapTypeControl();
        map.addControl(mapControl);
		
		map.clearOverlays();

										
		var theSW = new GLatLng(minX, minY);
		var theNE = new GLatLng(maxX, maxY);																								
		
		var gLatLngBound 	= new GLatLngBounds();//theSW, theNE); 								
		gLatLngBound.extend(theSW); 	
		gLatLngBound.extend(theNE); 	
		
		var centerPoint 	= new GLatLng();
		centerPoint 	= gLatLngBound.getCenter();	




		var newZoom = map.getBoundsZoomLevel(gLatLngBound); 
		
		map.setCenter(centerPoint,newZoom);	
		
		
		
	
		var i=0;
		for(id in markers) 
		{
			
			
										
			if(i==0)
			{
				var infoTabs = [
								new GInfoWindowTab("Tab 1", "You are here<br>This is default user location")
								];
				addMarker(markers[id].latitude , markers[id].longitude, infoTabs);
			}
		    else
			{

				var infoTabs = [
								new GInfoWindowTab("Property", markers[id].description+"<br>"+markers[id].image),
								new GInfoWindowTab("Let By", markers[id].owner)
								];
				addMarker(markers[id].latitude , markers[id].longitude, infoTabs);
			}
			
			i++;
			
		}	
		
	}
	
	
}


function addMarker(latitude , longitude, infoTabs)
{
	var marker = new GMarker(new GLatLng(latitude, longitude));
	GEvent.addListener(marker, 'click',
	function() {
	
				marker.openInfoWindowTabsHtml(infoTabs,{
				selectedTab:0,
				maxWidth:300
				});
	}
	);
	map.addOverlay(marker);
}

function pointout(index)
{

	var point = new GPoint(markers[index].longitude,markers[index].latitude);	
	var marker = new GMarker(point);

	map.addOverlay(marker);
	var infoTabs = [
						new GInfoWindowTab("Property", markers[index].description+"<br>"+markers[index].image),
						new GInfoWindowTab("Let By", markers[index].owner)
				   ];
	
	marker.openInfoWindowTabsHtml(infoTabs,{
				selectedTab:0,
				maxWidth:300
				});
	
		GEvent.addListener(marker,'click',function() {
		marker.openInfoWindowTabsHtml(infoTabs);
		});
}






function change_me(catId,mode){

	
	$.getJSON('ajaxget/rental_items.php?cat_id=' + catId+'&mode='+mode,
		function(responseData){		
		eval( responseData.theScript );
		document.getElementById('body_container').innerHTML = responseData.theContent;
	  });
}