//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
	 _lang = henworx.MapCms.Lang;
	 /*Manuplate emblem*/
	emblem=MarkerEventPause.loc.emblem.split("*");
	emblem=emblem[0];
	emblem=emblem.replace(" ","_");
	emblem=emblem.toLowerCase();
	/*manuplate price level*/
	_price_level_data = '';
	_price_title = '';
	_price_level = MarkerEventPause.loc.customField['pricing-level'];
	_price_array_ = _price_level.split('(');
	if( typeof(_price_array_[1]) != 'undefined'){
		_price_array_[1] = _price_array_[1].replace(')','');
		_price_title = 'title = "'+_price_array_[1]+'"';
	}	 
	_price_value = _price_array_[0].replace(/(^\s*)|(\s*$)/g, "");
	if(_price_value != ''){
		_price_level_data = '<label class="price_level"> <span '+_price_title+'>'+_price_value+'</span></label>';
	}
	_ewindow = new henworx.MapCms.Ewindow(MarkerEventPause.loc,MarkerEventPause.marker,MarkerEventPause.map);
	_ewindow.stemPath=gPluginUrl+"/../../plugins/ruhrmenu/images/stem_ewindow_"+emblem+'.png';
	_ewindow.stemSize=new GSize(220,50);
	_ewindow.stemPointer=new GPoint(-32,2)
	_ewindow.boxPositionX=-0;
	_ewindow.boxPositionY=50;
	_ewindow.color=emblem
	_ewindow.cssClass="ruhrmenu_ewindow"
	_ewindow.closeIcon = '<img src="'+gPluginUrl+'/../../plugins/ruhrmenu/images/icon_close.png'+'" />';
	_ewindow.maxIcon = '<img src="'+gPluginUrl+'/../../plugins/ruhrmenu/images/max.gif'+'" />';
	_ewindow.merkzettelSaveIcon = _lang.getWord('Save to My List');
	_ewindow.merkzettelDeleteIcon = _lang.getWord('Delete from My List');
	_ewindow.locationFormat='#logo# #headshot# #icon# <div class="ewindow_content"> <h1>#title#</h1><address>#street# <br/>#zip-code# #city#  <br/>'+_price_level_data+'</address> <div class="merkzettel-ewindow"> #merkzettel#</div></div>'
	_ewindow.setStem();
	//_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
	if(gBigOpenWindow){return false;}
	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].minIcon = '<img src="'+gPluginUrl+'/../../plugins/ruhrmenu/images/icon_min.gif" class="minimise_big_window" />';
		gBigWindows[_loc.id].closeIcon = '<img src="'+gPluginUrl+'/../../plugins/ruhrmenu/images/icon_close.png" class="cntrl" />';	
		gBigWindows[_loc.id].reLoad()// init data
		*/
	}
	gBigWindows[_loc.id].stem=gPluginUrl+"/../../plugins/ruhrmenu/images/stem_"+_loc.emblem+".png";
	gBigWindows[_loc.id].stemPosition="center bottom";
	gBigWindows[_loc.id].show();
	
	//set map to center
	_map.panTo(_marker.getLatLng());
	scroll(0,0);
	//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_'+gDefaultLang+'.gif',
				strings : { image: _lang.getWord('Image')+' ' , of : _lang.getWord(' of ') , prevLinkText: _lang.getWord('&laquo; Previous') , nextLinkText : _lang.getWord('Next &raquo;'),
							closeTitle : _lang.getWord('close image gallery'), prevLinkTitle : _lang.getWord('previous image'), nextLinkTitle : _lang.getWord('next image')
							}
	});
	gMapCms.currentLocation=_loc;
}
/*
function widgetOverAction(id){
	if(widgetPauseTimer){
		window.clearTimeout(widgetPauseTimer);
	}
	_loc=gMapCms.findLocation(id);
	MarkerEventPause.loc=_loc
	MarkerEventPause.marker=_loc.marker
	MarkerEventPause.map=gMapCms.map
	function widgetPauseAction(){
		 henworx.MapCms.Ewindow.hide('immediate'); //hide if old ewindow is open
		MarkerEventPause.onMousePause(true);
	}
	if(typeof(_loc) != 'undefined')
		widgetPauseTimer=window.setTimeout(widgetPauseAction,800);
}
*/


 	
		
		
		