/**************************************************************************/
// BEGIN map functionality

	function map_refresh(e){
		//map.LatLongToPixel(new VELatLong(latitude, longitude), zoomLevel, alert(map.));
		pixel = new VEPixel(0,0);
		corner = map.PixelToLatLong(pixel);
		
		pixel2 = new VEPixel(400,350);
		corner2 = map.PixelToLatLong(pixel2);
		
		center = map.GetCenter();
		zoom = map.GetZoomLevel();
//alert(corner);
		//alert('/content/properties/ajax/map_refresh.php?tl='+corner.Latitude+'&bl='+corner2.Latitude+'&ll='+corner.Longitude+'&rl='+corner2.Longitude);
		//top_lat = corner[0];
		//bottom_lat = corner[1];
		//alert("---"+corner[0]+"---");
		//left_lon = ;
		//right_lon = ;
		alert(corner.Longitude);
		//$("#new_pins").load('/content/properties/ajax/map_refresh.php',{tl:corner.Latitude,bl:corner2.Latitude,ll:corner.Longitude,rl:corner2.Longitude });	
		$("#new_pins").load('/content/properties/ajax/map_refresh.php');	
		
	}
	/* bing map */
	function GetMap(clat,clon,zoomLevel){
		map = new VEMap('myMap');
		map.SetDashboardSize(VEDashboardSize.Normal);
		map.LoadMap(new VELatLong(clat,clon));
		map.SetZoomLevel(zoomLevel);
		map.ShowDashboard();
		map.AttachEvent("onmouseup", map_refresh);
	}     
	function AddPushpin(p){
		var shape = new VEShape(VEShapeType.Pushpin, new VELatLong(p['lat'],p['lon']));
		shape.SetCustomIcon(icon);
		shape.SetTitle('<p>'+p['num']+' '+p['str']+'</p>');
		//shape.SetDescription('<p><a href="http://www.google.com" target="_blank" style="color:#111;">'+p['price']+'</a></p>');
		shape.SetDescription('<div class="bubble_side"><img src="http://www.kemteck3.com/photos/'+p['listing_num']+'.jpg" border=0 width="100" /></div><div class="bubble_side">'+p['price']+'<br><a href="javascript:void(0)" onclick = "show_detail('+p['listing_num']+',\'details\');" style="color:#111;">View Details</a></div>');
		//shape.SetDescription('<p><img src=\'http://www.kemteck3.com/images/'+p['thumb']+'\' /></p>');
		map.AddShape(shape);
	}

	/* google map */
    function gmap(center_lat,center_lon) {
		
		properties_gmap = new GMap2(document.getElementById("myMap"));
		var mapTypeControl = new GMapTypeControl();
		var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(5,5));		
		properties_gmap.addControl(mapTypeControl, topRight);
		GEvent.addListener(properties_gmap, "dblclick", function() {
			  //map.removeControl(mapTypeControl);
		});
		properties_gmap.addControl(new GSmallMapControl());
		properties_gmap.setCenter(new GLatLng(center_lat,center_lon), 10);
    	properties_gmap.setZoom(16);
		/* 
		var baseIcon = new GIcon();
		baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
		baseIcon.iconSize = new GSize(20, 34);
		baseIcon.shadowSize = new GSize(37, 34);
		baseIcon.iconAnchor = new GPoint(9, 34);
		baseIcon.infoWindowAnchor = new GPoint(9, 2);
		baseIcon.infoShadowAnchor = new GPoint(18, 25);
		
		bubble = "<div class='google_map_head'>test</div><div class='google_map_body'>lorum ipsum. lorum ipsum. lorum ipsum. lorum ipsum. lorum ipsum. lorum ipsum. lorum ipsum. lorum ipsum. lorum ipsum. lorum ipsum. </div>";
		
		var letteredIcon = new GIcon(baseIcon);
		letteredIcon.image = "http://www.google.com/mapfiles/marker.png";
		
		var point = new GLatLng(center_lat,center_lon);
		marker = new GMarker(point);
		
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(bubble);
		});		
		properties_gmap.addOverlay(marker);		
		*/
	}
	function properties_add_pin(lat,lon,bubble){
		//bubble = "<h3>test</h3>";
		var baseIcon = new GIcon();
		baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
		baseIcon.iconSize = new GSize(20, 34);
		baseIcon.shadowSize = new GSize(37, 34);
		baseIcon.iconAnchor = new GPoint(9, 34);
		baseIcon.infoWindowAnchor = new GPoint(9, 2);
		baseIcon.infoShadowAnchor = new GPoint(18, 25);
		
		var letteredIcon = new GIcon(baseIcon);
		letteredIcon.image = "http://www.google.com/mapfiles/marker.png";
		
		var point = new GLatLng(lat,lon);
		marker = new GMarker(point);
		
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(bubble);
		});		
		properties_gmap.addOverlay(marker);		
	}
	function call(i){
             marker.openInfoWindowHtml(i);
	}

// END map functionality
/**************************************************************************/



