var last_menu=-1,last_offer=-1,last_destination,date_ref="arrival";$(document).ready(function(){if(!($.browser.msie&&$.browser.version=="6.0")){$(".cselect1-select").css("filter","alpha(opacity=0)");$(".cselect1-select").css("opacity","0");$(".cselect1-select").change(function(){var opcion=$(this).children(":selected").text();$(this).parent().children(".cselect1-span").text(opcion)});$(".cselect1-span").each(function(){$(this).text($(this).parent().children(".cselect1-select").children(":selected").text())})}if(!($.browser.msie&&$.browser.version=="6.0")){$(".cselect2-select").css("filter","alpha(opacity=0)");$(".cselect2-select").css("opacity","0");$(".cselect2-select").change(function(){var opcion=$(this).children(":selected").text();$(this).parent().children(".cselect2-span").text(opcion)});$(".cselect2-span").each(function(){$(this).text($(this).parent().children(".cselect2-select").children(":selected").text())})}if(!($.browser.msie&&$.browser.version=="6.0")){$(".cselect3-select").css("filter","alpha(opacity=0)");$(".cselect3-select").css("opacity","0");$(".cselect3-select").change(function(){var opcion=$(this).children(":selected").text();$(this).parent().children(".cselect3-span").text(opcion)});$(".cselect3-span").each(function(){$(this).text($(this).parent().children(".cselect3-select").children(":selected").text())})}if(!($.browser.msie&&$.browser.version=="6.0")){$(".cselect4-select").css("filter","alpha(opacity=0)");$(".cselect4-select").css("opacity","0");$(".cselect4-select").change(function(){var opcion=$(this).children(":selected").text();$(this).parent().children(".cselect4-span").text(opcion)});$(".cselect4-span").each(function(){$(this).text($(this).parent().children(".cselect4-select").children(":selected").text())})}$(".left .menu ul li").bind("click",function(){idx=$(this).prevAll().length;if(last_menu!=-1){$(".center .detail ul li:eq("+last_menu+")").toggle();$(".center .detail ul li:eq("+idx+")").fadeIn(300);$(".left .menu ul li.selected").removeClass("selected")}else $(".center .detail ul li:eq("+idx+")").fadeIn(300);$(this).addClass("selected");last_menu=idx});$(".left .menu ul li:eq(0)").trigger("click");$("#calendar .calendar table tr td").bind("click",function(){if(!$(this).hasClass("availabled"))return;if($(this).find("input[type=hidden]").length!=0){closeDateBox();selDate(date_ref,$(this).find("input[type=hidden]").val())}});$(".room-top").bind("click",function(){$(".room-selected").addClass("room");$(".room-selected").removeClass("room-selected");$(this).parent().eq(0).addClass("room-selected");$(this).parent().eq(0).removeClass("room");$(".room-selected").find(".room-content").slideDown();$(".room").find(".room-content").slideUp()});$(".room-content").hide();$(".room .details-text").hide();$(".room-content:eq(0)").slideDown();$(".details-name a").bind("click",function(){if($(this).hasClass("selected")){$(this).removeClass("selected");$(this).parent().parent().find("img").attr("src","../Content/images/room-detail-down.png"),$(this).parent().parent().find(".details-text").slideUp()}else{$(this).addClass("selected");$(this).parent().parent().find("img").attr("src","../Content/images/room-detail-up.png"),$(this).parent().parent().find(".details-text").slideDown()}return false});if(page=="map"){$(".destinations .items .item").bind("click",function(){last_destination!=undefined&&$(last_destination).removeClass("selected");$(this).addClass("selected");last_destination=this;selDestination(this.id)});$(".destinations .items .item").not(".selected").bind("mouseover",function(){$(this).css({backgroundColor:"#e0e0e0"})});$(".destinations .items .item").not(".selected").bind("mouseout",function(){$(this).css({backgroundColor:"#ffffff"})});$(".scrollable").scrollable({vertical:true,mousewheel:true})}if(page=="gallery"){$("#image_wrap").mouseover(function(){$("#image_wrap .command").show()});$("#image_wrap").mouseout(function(){$("#image_wrap .command").hide()});$("#image_wrap .command-left").click(function(){var thumbIndex=$("#image_wrap img").attr("thumbIndex");thumbIndex%7==0&&$(".scrollable").data("scrollable").prev();var prevIndex=parseInt(thumbIndex)-1;$("#"+prevIndex).click()});$("#image_wrap .command-right").click(function(){var thumbIndex=$("#image_wrap img").attr("thumbIndex"),nextIndex=parseInt(thumbIndex)+1;nextIndex%7==0&&$(".scrollable").data("scrollable").next();$("#"+nextIndex).click()});$(".scrollable").scrollable({circular:endlessGallery});$(".items img").click(function(){if($(this).hasClass("active"))return;var url=$(this).attr("src").replace("_thumb","_medium"),title=$(this).attr("title"),actualHeight=$(this).attr("actualHeight"),actualWidth=$(this).attr("actualWidth"),index=$(this).attr("id"),wrap=$("#image_wrap"),img=new Image;img.onload=function(){wrap.find("img").attr("src",url);wrap.find("img").attr("title",title);wrap.find("img").height(actualHeight);wrap.find("img").width(actualWidth);wrap.find("img").attr("thumbIndex",index)};img.src=url;$(".items img").removeClass("active");$(this).addClass("active")}).filter(".firstImg").click()}if(page=="offers"){$(".offer-min").bind("click",function(){idx=$(this).prevAll().length;if(last_offer!=-1){$(".detail-offer .offer:eq("+last_offer+")").fadeOut(300,function(){$(".detail-offer .offer:eq("+idx+")").fadeIn(300)});$(".offer-min .selected .selection").hide();$(".offer-min .selected").addClass("wraper");$(".offer-min .selected").removeClass("selected")}else $(".detail-offer .offer:eq("+idx+")").fadeIn(300);$(this).children(".wraper").addClass("selected");$(this).children(".wraper").removeClass("wraper");$(this).find(".selection").show();last_offer=idx});$(".offer-min:eq(0)").trigger("click")}});function openRateBox(){$("#background-box").fadeTo(500,.8);$("#box-rates").fadeIn("normal")}function closeRateBox(){$("#background-box").fadeTo(500,0);$("#box-rates").fadeOut("normal",function(){$("#background-box").hide()})}function openDateBox(ref){date_ref=ref;$("#calendar").fadeIn("normal")}function closeDateBox(){$("#calendar").fadeOut("fast")}function selDestination(){}function selDate(ref,date){ref=="arrival"&&$("#arrival").val(date);ref=="departure"&&$("#departure").val(date);ref=="rates-arrive"&&$("#rates-arrive").val(date);ref=="rates-departure"&&$("#rates-departure").val(date)}function createPager(itemShows,itemCount,itemPool,counteinerId,sufix){var pageCount,pageIndex,stringButtonLeft='<div class="command command-left"></div>',stringButtonRight='<div class="command command-right"></div>',stringUL='<div class="pages"><ul></ul></div>';if(!isNaN(itemShows)&&!isNaN(itemCount)&&!isNaN(itemPool)&&itemShows>0&&itemCount>0){var pageOffSet=itemCount%itemShows;pageCount=Math.floor(itemCount/itemShows);if(pageOffSet>0)pageCount=pageCount+1;pager.pageCount=pageCount;var stringLIs=createButtons(itemPool,pageCount,sufix),LI$=$(stringLIs),UL$=$(stringUL);UL$.find("ul").append(LI$);$("#"+counteinerId).append(stringButtonLeft).append(UL$).append(stringButtonRight);$("#"+counteinerId).find("div.command.command-right").bind("click",function(){pager.rightButton(counteinerId,pageCount,itemPool)});$("#"+counteinerId).find("div.command.command-left").bind("click",function(){pager.leftButton(counteinerId,pageCount,itemPool)});$("#"+counteinerId).find('li[pageindex!="jumper"]').bind("click",function(){pager.liClick($(this),counteinerId)})}}function createButtons(itemPool,pageCount,sufix){var listLI="",counter=itemPool>pageCount?pageCount:itemPool;sufix=sufix+"pagerLI";sufixFirst=sufix+" selected";for(i=1;i<=counter;i++)listLI=listLI+'<li class="'+(i==1?sufixFirst:sufix)+'" pageindex="'+i+'"'+(i==1?'first="true"':"")+">"+i+"</li>";if(itemPool<pageCount){listLI=listLI+'<li class="'+sufix+'" pageindex="jumper">...</li>';listLI=listLI+'<li class="'+sufix+'" pageindex="'+pageCount+'" last="true">'+pageCount+"</li>"}return listLI}pager={rightButton:function(counteinerId,pageCount,itemPool){var li$=$("#"+counteinerId).find("li.selected"),prevIndex=li$.attr("pageindex");if(li$.next().attr("pageindex")=="jumper"||li$.attr("pageindex")==pageCount){prevIndex++;if(prevIndex<=pageCount){var newIndex=prevIndex-itemPool+1,liList$=$("#"+counteinerId).find("li");liList$.each(function(){if($(this).attr("pageindex")!="jumper"&&$(this).attr("pageindex")!=pageCount){$(this).attr("pageindex",newIndex);$(this).html(newIndex);newIndex++}})}}else{li$.removeClass("selected");li$.next().addClass("selected")}},leftButton:function(counteinerId){var li$=$("#"+counteinerId).find("li.selected"),prevIndex=li$.attr("pageindex");if(li$.attr("first")=="true"){prevIndex--;if(prevIndex>=1){var newIndex=prevIndex,liList$=$("#"+counteinerId).find("li");liList$.each(function(){if($(this).attr("pageindex")!="jumper"&&$(this).attr("last")!="true"){$(this).attr("pageindex",newIndex);$(this).html(newIndex);newIndex++}})}}else{li$.removeClass("selected");li$.prev().addClass("selected")}},liClick:function(item,counteinerId){$("#"+counteinerId).find("li").removeClass("selected");var li$=$("#"+counteinerId).find("li");if(item.attr("last")!="true")item.addClass("selected");else{item.prev().prev().addClass("selected").html(item.attr("pageindex")).attr("pageindex",item.attr("pageindex"));var prevIndex=item.attr("pageindex"),length=item.siblings().length-2;prevIndex=prevIndex-length;item.siblings().each(function(){if($(this).attr("pageindex")!="jumper"&&$(this).attr("last")!="true"){$(this).attr("pageindex",prevIndex);$(this).html(prevIndex);prevIndex++}})}}};
