//overriding with default events.. you are free to write on your own js file and these event will be overrriden


//for mouse pause
var MarkerEventPause=  new henworx.MapCms.MarkerEvent.mousePause(); //call without new

/*Please note that only pause needs to be called via constructor rest are static objects*/
var MarkerEventOver=   henworx.MapCms.MarkerEvent.mouseOver;
var MarkerEventOut =  henworx.MapCms.MarkerEvent.mouseOut;
var MarkerEventClick =   henworx.MapCms.MarkerEvent.mouseClick;
var MarkerEventDoubleClick =  henworx.MapCms.MarkerEvent.mouseDoubleClick;


MarkerEventPause.onMousePause=function(no_pan){
	//MarkerEventPause.loc; the locatioan object
	//MarkerEventPause.marker; the marker
	 henworx.MapCms.Ewindow.hide('immediate'); //hide if old ewindow is open
	_ewindow = new henworx.MapCms.Ewindow(MarkerEventPause.loc,MarkerEventPause.marker,MarkerEventPause.map);
	emblem=MarkerEventPause.loc.emblem.split("*");
	emblem=emblem[0];
	emblem=emblem.replace(" ","_");	
	emblem=emblem.toLowerCase();
	_ewindow.color = emblem;
	//_ewindow.init();
	//_ewindow.setStem(gPluginUrl+"/includes/ewindow/stem_"+emblem+".png",emblem);
	
	//hide if big window is open

	if(typeof(gBigOpenWindow.location)!='undefined'){
		henworx.MapCms.BigWindow.hide();	
	}
	_ewindow.init();
	_ewindow.show();
	if(typeof(no_pan)=='boolean'){
		if(!no_pan){
			_ewindow.pan();
		}
	}else{
		_ewindow.pan();
	}
	
}


MarkerEventOver.onMouseOver=function (_loc,_marker,_map){
	//we must enable pause here if we need it
	henworx.MapCms.Ewindow.cancelHide()
	MarkerEventPause.enable(_loc,_marker,_map)
	gMapCms.currentLocation=_loc;
	//normal functions
	
}


MarkerEventOut.onMouseOut= function (_loc,_marker,_map){
	//since mouse has gone out let's disable pause here
	MarkerEventPause.disable()
	//normal routines
	if(gOpenEWindow){henworx.MapCms.Ewindow.hide();}
	gMapCms.currentLocation=_loc; //we remove _loc only when ewindow is hidden

	
}


MarkerEventClick.onMouseClick= function (_loc,_marker,_map){
	//sclcike occured sopause needs to be cancelled
	MarkerEventPause.disable()
	if(gOpenEWindow){gOpenEWindow.hide('immediate');} //hide if old ewindow is open
	if(typeof(gBigWindows[_loc.id])=='undefined'){
		gBigWindows[_loc.id]= new henworx.MapCms.BigWindow(_loc)
	}
	
	gBigWindows[_loc.id].show(false);
	//set map to center
	_map.panTo(_marker.getLatLng());
	//scroll(0,0);
	//alert(_loc.icon.image)
	//Default Action
	$jQ(".henworx_mapcms_tab_content").hide(); //Hide all content
	$jQ("ul.henworx_mapcms_tabs li:first").addClass("active").show(); //Activate first tab
	$jQ(".henworx_mapcms_tab_content:first").show(); //Show first tab content
	$jQ(".lightbox-2").lightbox({
			    fitToScreen: true,
				fileLoadingImage: gPluginUrl+'/includes/lightbox/images/loading.gif',
				fileBottomNavCloseImage: gPluginUrl+'/includes/lightbox/images/closelabel.gif'
	});
	gMapCms.currentLocation=_loc;
	
	
}





 	
		
		
		