/* Home Dispay object */ 
var displayHome = {
	TagUrlJson : "",
/* initialization functions */
		
	  init : function(){
		  displayHome.initPagePromo();
	 },
 
 
/* bookingEngine : show and hide more criteria */
showRoomOptions :function(){
	     if (jQuery('.roomOptions').is(":visible"))
		{
			jQuery('#engine-criteres').hide();
			jQuery('#more-criteria').slideDown("slow");
            jQuery('#advanced-search').slideDown("slow");
		}
		  
		  jQuery('#engine-criteres a').click(function() {
          if (jQuery('#more-criteria').is(":hidden"))
		  { 
		  			jQuery('#more-criteria').slideDown("slow");
                    jQuery('#advanced-search').slideDown("slow");
                    jQuery('#engine-criteres').hide();
                    jQuery('.roomOptions').slideDown("slow");
               } else { 
                    jQuery('#more-criteria').slideUp("slow");
                    jQuery('#advanced-search').slideUp("slow");
                    jQuery('#engine-criteres').show();
                    jQuery('.roomOptions').slideUp("slow");
               }
          });
		   jQuery('#more-criteria').click(function() {
               if (jQuery('.roomOptions').is(":hidden"))
               {
                    jQuery('.roomOptions').slideDown();
               } else {
                    jQuery('.roomOptions').slideUp("slow");
                    jQuery('#more-criteria').slideUp("slow");
                    jQuery('#advanced-search').slideUp("slow");
                    jQuery('#engine-criteres').slideDown();
               }
           });
	},


/* Home Promos : ajax load promo */
getPagePromo : function(){
		jQuery(".tPromos-tab-noh li a").click(function(){
			jQuery.ajaxSetup ({
				cache: false
			});
			switch(jQuery(this).attr("rel")){
				case "country" : 	displayJson.dataJson="country";
				break;
				case "business" : 	displayJson.dataJson="business";
				break;
				case "world" : 	displayJson.dataJson="world";
				break;
			}
			jQuery(this).parent().addClass("active");
			jQuery(this).parent().siblings("li").removeClass("active"); 
			jQuery('#load').remove();
			jQuery('.tPromos-noh').append('<span id="load"></span>');
			jQuery('#load').fadeIn('normal');
			jQuery('#mycarouselContents').children().remove();
			jQuery("#mycarouselContents").prepend('<ul id="mycarousel" class="jcarousel-skin-tango"></ul>');						
			displayJson.linkJson = "/geoloc/geoloc.cgi?file=/"+jQuery("html").attr("lang")+"/js/home/"+displayJson.dataJson+"-offer.js";
			displayJson.getJson();
			jQuery('#load').fadeOut('normal');
			return false;
		});
	},


/* Home Promos : ajax load Default promo */
initPagePromo : function(){
			jQuery('.tPromos-noh').append('<span id="load"></span>');
			jQuery('#load').fadeIn('normal');
			jQuery('#mycarouselContents').children().remove();
			jQuery("#mycarouselContents").prepend('<ul id="mycarousel" class="jcarousel-skin-tango"></ul>');						
			displayJson.linkJson = "/geoloc/geoloc.cgi?file=/"+jQuery("html").attr("lang")+"/js/home/country-offer.js";
			displayJson.getJson();
			jQuery('#load').fadeOut('normal');
	}
}



var homeBookingEngine;

/* calling jQuery and the other library  */
jQuery.noConflict();
jQuery(document).ready(function(){     
	/* initialization tooltip */
	utils.tooltips.init();  

	displayHome.init();   
	/* initialization popup & popin  */
	popins.init();
	popups();  
    
	homeBookingEngine = new BookingEngine("bookingEngine", "homeBookingEngine", true);
	ajaxRequest._executeByUrl("/bean/getViewBeans.action?beans=SearchCriteriaViewBean|OriginViewBean","validatorInvalidState","homeBookingEngine.success(errors, response); displayHome.showRoomOptions();"); 
            
}); 


