//Ext.onReady(function(){ });

function gmapShow(animId,locType){
	var locDiv=Ext.get(animId).parent('.gmapDetails'), x, y;
	var winTitle=locDiv.child('h3').dom.innerHTML, pArr=locDiv.query('p'), 
	topContent='<h3>'+winTitle+'</h3>'+pArr[0].innerHTML+'<br>'+pArr[1].innerHTML;
	if (locType==1){ x=53.344556; y=-6.228403; } else { x=53.341661; y=-6.199808; }
	if (!Ext.getCmp('gmapWin')){
		document.getElementById('map').style.display='';
		var win = new Ext.Window({ layout: 'fit', modal:true, plain:true, resizable:false, closeAction:'hide', constrain: true, autoHeight:true, width:716, 
			id:'gmapWin', title: winTitle, contentEl: 'map'	});
	} 
	try{ Ext.getCmp('gmapWin').setTitle(winTitle); Ext.getCmp('gmapWin').show(animId, function(){ loadMap(topContent, x, y); }); } 
	catch(e){ Ext.Msg.show({ title:'Modal window error', msg: e, buttons: Ext.Msg.OK, icon: Ext.MessageBox.ERROR    }); }
}

function loadMap(info, lat, long){
	if (GBrowserIsCompatible()) { //if the browser is not compatible with Google API
		var bounds = new GLatLngBounds();
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.addControl(new GOverviewMapControl()); 	
		map.enableDoubleClickZoom();
   	map.setCenter(new GLatLng(0,0),0);	//going to dynamically set zoom to markers
		var upoint = new GLatLng(lat, long);
		var marker = new GMarker(upoint);
		GEvent.addListener(marker, "click", function(){ marker.openInfoWindowHtml(info); });
		map.addOverlay(marker);
      bounds.extend(marker.getPoint());	//set bounds according to marker coords
		map.setZoom(map.getBoundsZoomLevel(bounds)-1);	
		map.setCenter(bounds.getCenter());
		marker.openInfoWindowHtml(info);
	}
}


