

// init namespace (a utiliser pour eviter toute collision)
if(!MER) {var MER = {};}

MER.fhdyn = {


	lang : FH.getLang(),
	rid: FH.getRid(),
	brand :FH.getBrand(),
	mark:FH.getMark(),
	imgpath:FH.en2gb(FH.getLang()),
	version:FH.getVersion(),
	
	init: function() {
			  if (!FH.context.isMercure){
			  	document.getElementsByTagName('body')[0].className+=" external"
			  }
			  
			  /**retro compatibilité pseudojs**/
			  var d_rfpCriteria;
				var d_isUserLoggedIn = false;
    		function NavBarInfo(isActive,lienBack,lienMoins,lienPlus){this.isActive = isActive;this.lienBack = lienBack;this.lienPlus = lienPlus;this.lienMoins = lienMoins;};
     		var d_lienResa = "", d_imagePath = FH.en2gb(MER.fhdyn.lang), d_brand = MER.fhdyn.brand, d_mark = MER.fhdyn.mark, d_hotelCode = MER.fhdyn.rid;
				
				
				eval(FH.fhdyn.callFhJsp());
				
				if (d_NavBarInfo.isActive) {MER.fhdyn.nav(d_NavBarInfo.lienBack,d_NavBarInfo.lienMoins,d_NavBarInfo.lienPlus);};
				
				MER.fhdyn.resaEngine(d_lienResa);
				
				MER.fhdyn.favorites(d_isUserLoggedIn);
				MER.fhdyn.mapo();
		
				MER.fhdyn.meeting();
				MER.fhdyn.promoweb();
				MER.fhdyn.promopackage();
				MER.fhdyn.thalassa();
		
	},
	
		
	resaEngine : function (d_lienResa){
		
		if (FH.context.isThalassa) {
			src= '/'+FH.en2gb(this.lang)+'/fichehotel/mer/bloc_moteur_tha_fh.htm?v='+this.version+'&rid='+this.rid;
		} else if ( FH.context.isMeetings) {
			src= '/'+FH.en2gb(this.lang)+'/fichehotel/mer/bloc_moteur_mice_fh.htm?v='+this.version+'#rid='+this.rid+'&brand=mer&lang='+this.imgpath;
		} else if (FH.context.isTravelagencies && d_lienResa!="") {
			src= '/'+this.imgpath+'/fichehotel/mer/bloc_moteur_travel_fh.htm?v='+this.version+'#rid='+this.rid+'&brand=mer&lang='+this.imgpath;
		} else if (d_lienResa!="") {
			src= '/'+FH.en2gb(this.lang)+'/fichehotel/mer/bloc_moteur_fh.htm?v='+this.version+'&rid='+this.rid;
	  } else{
			src= '/'+FH.en2gb(this.lang)+'/fichehotel/mer/bloc_moteur_empty_fh.htm?v='+this.version+'#rid='+this.rid;
	  }
	  
	  var ifres = $('iframe_resa');
		ifres.replace('<iframe id="iframe_resa" src="'+src+'"allowtransparency="true" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" style="width:230px; height:210px;"></iframe>');
	  
 		if (d_lienResa!="" && !FH.context.isTravelagencies &&!FH.context.isMeetings)
			$('btn_reservez').innerHTML = '<div class="btn_gris_bg_left"><div class="btn_gris_bg_right"><div class="btn_gris"><span class="btn_bg"><a href="'+d_lienResa+'">'+I18N._('fh','Rates and reservation')+'</a></span></div></div></div>';

	  
	},
	
	nav : function (link_all,link_prev,link_next){
							
			var nav = $("nav_hotel_lien");
			nav.innerHTML='<a href="'+link_all+'"><img src="/imagerie/fichehotel/mer/picto_liste.gif" alt=" " width="9" height="9" />&nbsp;'+I18N._('fh','List of hotels')+'</a>&nbsp;<a href="'+link_prev+'"><img src="/imagerie/fichehotel/mer/fleche_gauche_lien.gif" alt=" " />&nbsp;'+I18N._('fh','Previous hotel')+'</a> &nbsp;<img src="/imagerie/fichehotel/mer/fleche_droite_lien.gif" alt=" " /><a href="'+link_next+'">&nbsp;'+I18N._('fh','Next hotel')+'</a>';
		
	} ,
	
	favorites : function (idt) {
		favHTML ='';
		if (idt){
			favHTML += '<ul><li><a href="javascript:pop_v(\'/managePreferredHotels.svlt?action=addHotel&code_hotel='+this.rid+'&code_chaine='+this.brand+'\',\'450\',\'455\')">'+I18N._('fh','Add to favorites')+'</a></li></ul>';	
		} else {
		favHTML += I18N._('fh','You are not registered');
    favHTML +='<ul><li><a href="javascript:pop_v(\'/'+this.imgpath+'/profil/advantages.shtml\',\'450\',\'623\')">'+I18N._('fh','Avantages')+'</a></li>';
    favHTML +='<li><a href="https://'+document.location.host.replace('www','secure')+'/'+this.imgpath+'/profil/registration.shtml" target="_top">'+I18N._('fh','Register here')+'</a></li>';
    favHTML +='<li><a href="https://'+document.location.host.replace('www','secure')+'/'+this.imgpath+'/profil/login.shtml" target="_top" >'+I18N._('fh','Identify yourself')+'</a></li></ul>';
	}
		$("bloc_outil_hotel_fav").innerHTML = favHTML;
	},

  mapo : function(){
  	try{FH.mapo.init_map('lnk_map');}catch(ee){};
  	try{FH.mapo.init_iti('lnk_iti');}catch(ee){};
  },
  
  
	meeting : function (){
		var lm = $("lnk_meeting");
		if (lm==undefined ){return;}
  	if (FH.context.isMeetings) {
  		try{lm.remove();}catch(e){};
  	} else if (FH.context.isMercure) {
  		return;
  	} else {
  		var lg =(this.lang=="fr" ||this.lang=="en"||this.lang=="de"||this.lang=="pt"||this.lang=="it")?FH.en2gb(this.lang):"gb";
  		lm.href='http://meetings.accorhotels.com/'+lg+'/reservation/bookings.shtml#hotel_ou_ville='+this.rid+'&code_chaine=mer';
  	}
  	
	},

  promoweb : function (){
  	if (FH.context.isThalassa || FH.context.isTravelagencies || FH.context.isMeetings ) {
  		var btn_promoweb = $("btn_promoweb");
		  if (btn_promoweb)btn_promoweb.parentNode.removeChild(btn_promoweb);
  	} else {
  		var lnk_promoweb = $("lnk_promoweb");
  		if (lnk_promoweb) Event.observe(lnk_promoweb, 'click', function(e) {e.stop();pop_v(lnk_promoweb.href,'480px','300px');} );
  	}
  },

	promopackage : function (){
  	if (FH.context.isThalassa || FH.context.isTravelagencies || FH.context.isMeetings ) {
  		try {$("btn_promopackage").remove();} catch(ee){};
  	} 
  },

	thalassa : function (){
		if (!FH.context.isThalassa){return;}
		try {$("btn_thalassa").remove();}catch(ee) {};
		
	}
	
}

FH.fhdyn.init(MER);
