﻿var ocu=Array();var apartId;var tipoMapa;var calarrVal;var calgoVal;var dateArr;var dateGo;var semSelectingAvail=false;var dateArrTmp;var dateGoTmp;var fpaxVal;var problemLoading=1;var semLoadingImage=0;var vglobalApart={tabActive:0,tabOpened0:true,tabOpened1:false,tabOpened2:false,tabOpened3:false,tabOpened4:false,isOldImage:false,idImageBig:0,activedHoverThumb:false,activeBtnSef:false,coefAumento:1.3,offsetX:50};function tab1(){}function tab2(){}function tab3(){}function initApart(num){apartId=num;menuapp();calarrVal=$("#fcal-arr").val();calgoVal=$("#fcal-go").val();if(imgsarr[0][2]==""){var srcImgIni=$("#gal1 img").attr("src");srcImgIni=srcImgIni.replace(/\s/g,"");var browserName=navigator.appName;if(browserName=="Microsoft Internet Explorer"){srcImgIni=srcImgIni+"?rdimg="+(new Date()).getTime();}$("#gal2 img").attr("src",srcImgIni).load(function(){wdthTmp=Math.floor(vglobalApart.coefAumento*($("#gal1 img").width()));heigthTmp=Math.floor(vglobalApart.coefAumento*($("#gal1 img").height()));$("#gal2 img").attr("width",wdthTmp);$("#gal2 img").attr("height",heigthTmp);});}if(window.location.hash){switch(window.location.hash){case"#comments":vglobalApart.tabActive=3;vglobalApart.tabOpened3=true;vglobalApart.tabOpened0=false;break;}}$("#tabs").tabs({selected:vglobalApart.tabActive});if(vglobalApart.tabOpened0==false){$("#tabDetailButton").click(function(){vglobalApart.tabOpened0=true;initmainGallery();});}else{initmainGallery();}showhideDescriptionImages(2);updateCalendar();$("#hover_beds").tipsy({fallback:$("#hover_beds-hidden").html(),gravity:"e",fade:true,html:true,opacity:1,live:true});$(".help_icon_price").tipsy({fallback:$("#hover_price-hidden").html(),gravity:"ne",fade:true,html:true,opacity:1,live:true});$("#hover_zones").tipsy({fallback:$("#hover_zones-hidden").html(),gravity:"sw",fade:true,html:true,opacity:1});vglobal.dateformatVis="d/mm/yy";calendar("#fcal-arr","callt.gif",0);calendar("#fcal-go","callt.gif",0);$("#fcalformat-arr").click(function(){$("#fcal-arr").datepicker("show");});$("#fcalformat-go").click(function(){$("#fcal-go").datepicker("show");});vglobal.onChangeDates=function(calendardates,calendarId){apartmentCheckDates();$("#datepicker_avail").datepicker("refresh");};var semTabsEqp=0;var bOpenedMap=0;initBigGallery("#gallery2","#gal2");$("#open_map").click(function(){if(!bOpenedMap){$(".bc_map").height(456);$("#open_map").addClass("closemap");$("#map_canvas").height(444);$("#map_panel").height(444);$("#open_map #txt_open_map").html(objDictionary.SearchMap_ReducirMapa);$("#expanded_panel_map").css("visibility","visible");$("#hover_zones").fadeIn("15000",function(){});var iframe=document.getElementById("map_canvas");iframe.src=iframe.src;bOpenedMap=1;}else{$("#hover_zones").hide();$("#expanded_panel_map").css("visibility","hidden");$(".bc_map").height(128);$("#map_canvas").height(116);$("#open_map").removeClass("closemap");$("#map_panel").height(116);$("#open_map #txt_open_map").html(objDictionary.SearchMap_AmpliarMapa);bOpenedMap=0;var iframe=document.getElementById("map_canvas");iframe.src=iframe.src;}});$("#equipments_bar li").click(function(){if(!semTabsEqp){semTabsEqp=1;var idLi=$(this).attr("id");$("#equipments_bar li").removeClass("active");$("#equipments_bar #"+idLi).addClass("active");$(".tab_content_eq").hide();$("#"+idLi+"_ct").fadeIn("slow",function(){semTabsEqp=0;});}});$("#fPax").change(function(){apartmentCheckDates();});if(isAvailable==0){apartmentCheckDates();}timerID=setTimeout("LoadPanoramioGallery()",2000);}var semImg=true;function showImageLayerBigTip(options){$(options.selectorLayer).html('<img src="'+options.srcImage+'" alt="'+options.descriptionImage+'" />');var selectorImage=options.selectorLayer+" img";if($(options.selectorLayer).is(":visible")==false&&vglobalApart.activedHoverThumb){$(options.selectorLayer).show();}var anchoActual=$(selectorImage).width();var altoActual=$(selectorImage).height();var offsetY=Math.floor(altoActual/6);$(options.selectorLayer).css("width",(anchoActual+6)+"px");$(options.selectorLayer).css("height",(altoActual+6)+"px");$(options.selectorLayer).css("top",(options.emouse.pageY-altoActual+offsetY)+"px");$(options.selectorLayer).css("left",(options.emouse.pageX+vglobalApart.offsetX)+"px");}function moveImageLayerBigTip(options){if(vglobalApart.idImageBig!=options.idItemImage){$(options.selectorLayer).html('<img src="'+options.srcImage+'" alt="'+options.descriptionImage+'" />');vglobalApart.idImageBig=options.idItemImage;$(options.selectorLayer).show();}var selectorImage=options.selectorLayer+" img";var anchoActual=$(selectorImage).width();var altoActual=$(selectorImage).height();var offsetY=Math.floor(altoActual/6);$(options.selectorLayer).css("width",(anchoActual+6)+"px");$(options.selectorLayer).css("height",(altoActual+6)+"px");$(options.selectorLayer).css("top",(options.emouse.pageY-altoActual+offsetY)+"px");$(options.selectorLayer).css("left",(options.emouse.pageX+vglobalApart.offsetX)+"px");}function showImageLayerBigTipOld(options){if($(options.selectorLayer).is(":visible")==false&&vglobalApart.activedHoverThumb){$(options.selectorLayer).show();}var selectorImage=options.selectorLayer+" img";$(options.selectorLayer).html('<img src="'+options.srcImage+'" alt="'+options.descriptionImage+'" />');if(vglobal.imagesCacheHash[options.srcImage].cachedImage==1&&vglobal.imagesCacheHash[options.srcImage].widthImage==0){vglobal.imagesCacheHash[options.srcImage].widthImage=$(options.selectorLayer+" img").width();vglobal.imagesCacheHash[options.srcImage].heightImage=$(options.selectorLayer+" img").height();}var anchoActual=Math.floor(vglobal.imagesCacheHash[options.srcImage].widthImage*vglobalApart.coefAumento);var altoActual=Math.floor(vglobal.imagesCacheHash[options.srcImage].heightImage*vglobalApart.coefAumento);$(selectorImage).attr("width",anchoActual);$(selectorImage).attr("height",altoActual);var offsetY=Math.floor(altoActual/6);$(options.selectorLayer).css("width",(anchoActual+6)+"px");$(options.selectorLayer).css("height",(altoActual+6)+"px");$(options.selectorLayer).css("top",(options.emouse.pageY-altoActual+offsetY)+"px");$(options.selectorLayer).css("left",(options.emouse.pageX+vglobalApart.offsetX)+"px");}function moveImageLayerBigTipOld(options){if(vglobalApart.idImageBig!=options.idItemImage){$(options.selectorLayer).html('<img src="'+options.srcImage+'" alt="'+options.descriptionImage+'" />');vglobalApart.idImageBig=options.idItemImage;}var selectorImage=options.selectorLayer+" img";if($(options.selectorLayer).is(":visible")==false&&vglobalApart.activedHoverThumb){$(options.selectorLayer).show();}if(vglobal.imagesCacheHash[options.srcImage].cachedImage==1&&vglobal.imagesCacheHash[options.srcImage].widthImage==0){vglobal.imagesCacheHash[options.srcImage].widthImage=$(options.selectorLayer+" img").width();vglobal.imagesCacheHash[options.srcImage].heightImage=$(options.selectorLayer+" img").height();}var anchoActual=Math.floor(vglobal.imagesCacheHash[options.srcImage].widthImage*vglobalApart.coefAumento);var altoActual=Math.floor(vglobal.imagesCacheHash[options.srcImage].heightImage*vglobalApart.coefAumento);$(options.selectorLayer+" img").attr("width",anchoActual);$(options.selectorLayer+" img").attr("height",altoActual);var selectorImage=options.selectorLayer+" img";if($(options.selectorLayer).is(":visible")==false&&vglobalApart.activedHoverThumb){$(options.selectorLayer).show();}var offsetY=Math.floor(altoActual/6);$(options.selectorLayer).css("width",(anchoActual+6)+"px");$(options.selectorLayer).css("height",(altoActual+6)+"px");$(options.selectorLayer).css("top",(options.emouse.pageY-altoActual+offsetY)+"px");$(options.selectorLayer).css("left",(options.emouse.pageX+vglobalApart.offsetX)+"px");}function showImageNotFoundLayerBigTip(options){vglobalApart.idImageBig=0;$(".loading_tooltip").hide();$("#apt_image_big_tip").hide();$("#apt_image_big_tip").html("");}function initmainGalleryOld(){$("#gal1_min").jcarousel();showhideDescriptionImages(1);$("ul#gal1_min li img").live("click",(function(){$(this).parent().parent().find(".selectedImg").removeClass("selectedImg");$(this).addClass("selectedImg");var arrSource=searchImgArraById($(this).attr("id").split("-")[1]);if(arrSource[0]==-1){}else{var imageSource=rootImgPath+arrSource[1];if(semImg){semImg=false;showImage(imageSource,"#gal1");showImageDescription($(this).attr("alt"),"#description1");showhideDescriptionImages(1);}}}));}function initTooltipImagesCard(){$("ul#gal1_min li img").hover(function(emouse){vglobalApart.activedHoverThumb=true;var idImgTmp=$(this).attr("id").split("-")[1];var arrSource=searchImgArraById(idImgTmp);vglobalApart.idImageBig=0;if(arrSource[0]==-1){}else{var imageSource=arrSource[2];if(semImg){if(imageSource!=""){imageSource=rootImgPath+imageSource;var optionsLoadImage={emouse:emouse,srcImage:imageSource,textErrorLayer:"image not found",cbk_imageloaded:showImageLayerBigTip,cbk_imageNoLoaded:showImageNotFoundLayerBigTip,cbk_imageMoved:moveImageLayerBigTip,selectorLayer:"#apt_image_big_tip",descriptionImage:$(this).attr("alt"),idItemImage:idImgTmp,loadingActive:true};}else{imageSource=arrSource[1];imageSource=rootImgPath+imageSource;var optionsLoadImage={emouse:emouse,srcImage:imageSource,textErrorLayer:"image not found",cbk_imageloaded:showImageLayerBigTipOld,cbk_imageNoLoaded:showImageNotFoundLayerBigTip,cbk_imageMoved:moveImageLayerBigTipOld,selectorLayer:"#apt_image_big_tip",descriptionImage:$(this).attr("alt"),idItemImage:idImgTmp,loadingActive:true};}loadImageAndPosLayer(optionsLoadImage);}}},function(){vglobalApart.idImageBig=0;vglobalApart.activedHoverThumb=false;$(".loading_tooltip").hide();$("#apt_image_big_tip").hide();$("#apt_image_big_tip").html("");});$("ul#gal1_min li img").mousemove(function(emouse){var idImgTmp=$(this).attr("id").split("-")[1];var arrSource=searchImgArraById(idImgTmp);if(arrSource[0]==-1){}else{var imageSource=arrSource[2];if(semImg){if(imageSource!=""){imageSource=rootImgPath+imageSource;var optionsLoadImage={emouse:emouse,srcImage:imageSource,textErrorLayer:"image not found",cbk_imageloaded:showImageLayerBigTip,cbk_imageNoLoaded:showImageNotFoundLayerBigTip,cbk_imageMoved:moveImageLayerBigTip,selectorLayer:"#apt_image_big_tip",descriptionImage:$(this).attr("alt"),idItemImage:idImgTmp,loadingActive:true};}else{imageSource=arrSource[1];imageSource=rootImgPath+imageSource;var optionsLoadImage={emouse:emouse,srcImage:imageSource,textErrorLayer:"image not found",cbk_imageloaded:showImageLayerBigTipOld,cbk_imageNoLoaded:showImageNotFoundLayerBigTip,cbk_imageMoved:moveImageLayerBigTipOld,selectorLayer:"#apt_image_big_tip",descriptionImage:$(this).attr("alt"),idItemImage:idImgTmp,loadingActive:true};}loadImageAndPosLayer(optionsLoadImage);}}});}function initmainGallery(){$("#gal1_min").jcarousel();showhideDescriptionImages(1);initTooltipImagesCard();$("ul#gal1_min li img").click(function(){$(this).parent().parent().find(".selectedImg").removeClass("selectedImg");$(this).addClass("selectedImg");var arrSource=searchImgArraById($(this).attr("id").split("-")[1]);if(arrSource[0]==-1){}else{var imageSource=rootImgPath+arrSource[1];if(semImg){semImg=false;showImage(imageSource,"#gal1");showImageDescription($(this).attr("alt"),"#description1");showhideDescriptionImages(1);}}});}var counterAnim=0;var intervalTime=10;var tempor=null;var totalImages=0;function showhideDescriptionImages(numberIn){if($("#description"+numberIn).html()==""){$("#description"+numberIn).hide();}else{$("#description"+numberIn).show();}}function changeImage(sen){counterAnim+=sen;if(counterAnim==imgsarr.length){counterAnim=0;}else{if(counterAnim<0){counterAnim=imgsarr.length-1;}}var arrSource=imgsarr[counterAnim];var imageSource=arrSource[2];if(imageSource==""){imageSource=rootImgPath+arrSource[1];vglobalApart.isOldImage=true;}else{imageSource=rootImgPath+imageSource;vglobalApart.isOldImage=false;}showImage(imageSource,"#gal2");showImageDescription(arrSource[3],"#description2");showhideDescriptionImages(2);$("#gallery2  li img").removeClass("selectedImg");var tmpSel=counterAnim+1;$("#gallery2  li:nth-child("+tmpSel+") img").addClass("selectedImg");}function changeImageBig(sen){counterAnim+=sen;if(counterAnim==imgsarr.length){counterAnim=0;}else{if(counterAnim<0){counterAnim=imgsarr.length-1;}}var fileImage=Math.floor(counterAnim/7);$(".bc_photos_big_thumbs").scrollTop(fileImage*63);var arrSource=imgsarr[counterAnim];var imageSource=arrSource[2];if(imageSource==""){imageSource=rootImgPath+arrSource[1];vglobalApart.isOldImage=true;}else{imageSource=rootImgPath+imageSource;vglobalApart.isOldImage=false;}var textErrorLayer="file not found";var optionsLoadImage={srcImage:imageSource,textErrorLayer:textErrorLayer,cbk_imageloaded:showImageGal2,cbk_imageMoved:showImageGal2,cbk_imageNoLoaded:showImageGal2NotFoundLayer,selectorLayer:"#gal2",descriptionImage:arrSource[3]};adload(optionsLoadImage.selectorLayer);$(optionsLoadImage.selectorLayer+" img").remove();loadImageAndPosLayer(optionsLoadImage);$("#gallery2  li img").removeClass("selectedImg");var tmpSel=counterAnim+1;$("#gallery2  li:nth-child("+tmpSel+") img").addClass("selectedImg");}function reset(){counterAnim=-1;fin=false;}function automatImages(seg){intervalTime=parseInt(seg);reset();if(isNaN(intervalTime)||intervalTime<=0){alert("Error en el tiempo");}else{tempor=setTimeout("nextImage()",intervalTime);}}function stopImages(){$(".pause_pres").addClass("view_pres");$(".pause_pres").html(regional.ViewPresentation);$(".pause_pres").removeClass("pause_pres");clearTimeout(tempor);}function nextImage(){changeImageBig(1);if(counterAnim<imgsarr.length-1){tempor=setTimeout("nextImage()",intervalTime);}}function iniImagesGallery(idthumb){}function searchImgArraById(idInArr){for(i=0;i<imgsarr.length;i++){if(imgsarr[i][0]==idInArr){return imgsarr[i];break;}}return new Array(-1,-1);}function initBigGallery(idthumb,idBigImageContainer){$(".view_pres").live("click",function(){$(this).removeClass("view_pres");$(this).addClass("pause_pres");$(this).html(regional.PausePresentation);automatImages(2500);});$(".pause_pres").live("click",function(){$(this).removeClass("pause_pres");$(this).addClass("view_pres");$(this).html(regional.ViewPresentation);stopImages();});$("#next_img").click(function(){if(!semLoadingImage){semLoadingImage=1;stopImages();changeImageBig(1);}});$("#prev_img").click(function(){if(!semLoadingImage){semLoadingImage=1;stopImages();changeImageBig(-1);}});$(idthumb+" li img").live("click",function(){if(!semLoadingImage){semLoadingImage=1;stopImages();counterAnim=$(this).parent().parent().index();$(this).parent().parent().parent().find(".selectedImg").removeClass("selectedImg");$(this).addClass("selectedImg");var imageSource=getBigImage($(this).attr("id").split("-")[1]);var textErrorLayer="file not found";var optionsLoadImage={srcImage:imageSource,textErrorLayer:textErrorLayer,cbk_imageloaded:showImageGal2,cbk_imageMoved:showImageGal2,cbk_imageNoLoaded:showImageGal2NotFoundLayer,selectorLayer:"#gal2",descriptionImage:$(this).attr("alt")};adload(optionsLoadImage.selectorLayer);$(optionsLoadImage.selectorLayer+" img").remove();loadImageAndPosLayer(optionsLoadImage);}});}function getBigImage(idInBigImage){var arrSource=searchImgArraById(idInBigImage);var imageSource=arrSource[2];if(arrSource[2]==""){imageSource=rootImgPath+arrSource[1];vglobalApart.isOldImage=true;}else{imageSource=rootImgPath+imageSource;vglobalApart.isOldImage=false;}return imageSource;}function showImageGal2(options){semLoadingImage=0;$(options.selectorLayer).append('<img src="'+options.srcImage+'" alt="'+options.descriptionImage+'" />');if(vglobalApart.isOldImage){if(vglobal.imagesCacheHash[options.srcImage].cachedImage==1&&vglobal.imagesCacheHash[options.srcImage].widthImage==0){vglobal.imagesCacheHash[options.srcImage].widthImage=$("#gal2 img").width();vglobal.imagesCacheHash[options.srcImage].heightImage=$("#gal2 img").height();}var anchoActual=Math.floor(vglobal.imagesCacheHash[options.srcImage].widthImage*vglobalApart.coefAumento);var altoActual=Math.floor(vglobal.imagesCacheHash[options.srcImage].heightImage*vglobalApart.coefAumento);$("#gal2 img").attr("width",anchoActual);$("#gal2 img").attr("height",altoActual);}showImageDescription(options.descriptionImage,"#description2");showhideDescriptionImages(2);}function showImageGal2NotFoundLayer(options){semLoadingImage=0;$(options.selectorLayer).append('<img src=""/imgs/icons/image-notfound.png" alt="'+options.textErrorLayer+'" />');showImageDescription("","#description2");showhideDescriptionImages(2);}function showImage(src,idgal){adload(idgal);$(idgal+" img").remove();var largeImage=new Image();problemLoading=1;$(largeImage).load(function(){semLoadingImage=0;problemLoading=0;$(this).hide();$(idgal).append(this);$(this).fadeIn("slow",remload(idgal));semImg=1;});$(largeImage).attr("src",src);}function showImageDescription(textdesc,idbox){$(idbox).html(textdesc);}function updateCalendar(){$.ajax({type:"POST",url:"/ApartmentSearch.asmx/ApartmentCalendar",data:"{'idApart':"+apartId+"}",contentType:"application/json; charset=utf-8",dataType:"json",cache:false,success:function(results){$.each(results.d.Years,function(i,item){ocu[Number(item.Num)]=Array();for(i=0;i<=11;i++){ocu[Number(item.Num)][i]=item.Months[i];}});if(firstCalendar){firstCalendar=0;createCalendar();}else{$("#datepicker_avail").datepicker("refresh");}},error:function(result){}});}var firstCalendar=1;function updateCalendarMap(){$.ajax({type:"POST",url:"/ApartmentSearch.asmx/ApartmentCalendar",data:"{'idApart':"+apartId+"}",contentType:"application/json; charset=utf-8",dataType:"json",cache:false,success:function(results){$.each(results.d.Years,function(i,item){ocu[Number(item.Num)]=Array();for(i=0;i<=11;i++){ocu[Number(item.Num)][i]=item.Months[i];}});if(firstCalendar){firstCalendar=0;createCalendarCardMap();}else{$("#datepicker_avail").datepicker("refresh");}},error:function(result){}});}function copyToMainDatepicker(currentId){if(dateGoTmp>dateArrTmp){$("#fcal-arr").datepicker("setDate",dateArrTmp);$("#fcal-go").datepicker("setDate",dateGoTmp);showFormatDate("fcal-arr",dateArrTmp);showFormatDate("fcal-go",dateGoTmp);}}function createCalendar(){$("#datepicker_avail").datepicker({numberOfMonths:[3,4],beforeShowDay:cssdays,showButtonPanel:false,onSelect:function(dateText,inst){if(!semSelectingAvail){dateArrTmp=new Date($("#datepicker_avail").datepicker("getDate"));semSelectingAvail=true;}else{if(semSelectingAvail){semSelectingAvail=false;dateGoTmp=new Date($("#datepicker_avail").datepicker("getDate"));var currentId="fcal-go";copyToMainDatepicker(currentId);vglobal.onChangeDates(dateText,currentId);}}}});}function createCalendarCardMap(){var _arrayDate=vglobalServer.currentDate.split("-");var _currentDay=parseInt(_arrayDate[2]);var _currentMonth=parseInt(_arrayDate[1])-1;var _currentYear=parseInt(_arrayDate[0]);$("#datepicker_avail").datepicker({numberOfMonths:[2,2],beforeShowDay:cssdays,minDate:new Date(_currentYear,_currentMonth,_currentDay),showButtonPanel:false});}function cssdays(date){dateArr=new Date($("#fcal-arr").datepicker("getDate"));dateGo=new Date($("#fcal-go").datepicker("getDate"));var isSelectable=false;var cssStyle="u_day";var textDate="";try{var arrd=ocu[Number(date.getFullYear())][Number(date.getMonth())];if(arrd!=null){for(i=0;i<=arrd.BusyDays.length-1;i++){if(arrd.BusyDays[i]!=null){if(date.getDate()==arrd.BusyDays[i].Num){if(semSelectingAvail){if(date.getFullYear()==dateArrTmp.getFullYear()&&date.getMonth()==dateArrTmp.getMonth()&&date.getDate()==dateArrTmp.getDate()){isSelectable=true;cssStyle="range_in_day";textDate="Llegada";}}else{cssStyle="";textDate="";if(date.getFullYear()==dateArr.getFullYear()&&date.getMonth()==dateArr.getMonth()&&date.getDate()==dateArr.getDate()){isSelectable=true;cssStyle="range_in_day";textDate="Llegada";}else{if(date.getFullYear()==dateGo.getFullYear()&&date.getMonth()==dateGo.getMonth()&&date.getDate()==dateGo.getDate()){isSelectable=true;cssStyle="range_out_day";textDate="Salida";}else{if(date>dateArr&&date<dateGo){isSelectable=true;cssStyle="range_day";}}}}if(arrd.BusyDays[i].Type==0){isSelectable=true;cssStyle=cssStyle+" f_day";}else{if(arrd.BusyDays[i].Type==1){isSelectable=true;cssStyle=cssStyle+" o_in_day";}else{if(arrd.BusyDays[i].Type==2){isSelectable=false;cssStyle=cssStyle+" o_day";}else{if(arrd.BusyDays[i].Type==3){isSelectable=true;cssStyle=cssStyle+" o_out_day";}else{if(arrd.BusyDays[i].Type==4){isSelectable=false;cssStyle=cssStyle+" o_day";}}}}}if(textDate==""){return[isSelectable,cssStyle];}else{return[isSelectable,cssStyle,textDate];}}else{}}}}else{}return[isSelectable,cssStyle];}catch(err){return[isSelectable,cssStyle];}}function initApartSearch(num){calendar("#fcal-go","cal.png",0);calendar("#fcal-arr","cal.png",0);menuapp();$("#tabs").tabs();apartId=num;var semTabsEqp=0;vglobalApart.tabOpened0=true;$(".other_apartments").hover(function(){$("#boxOtherApartments").show();},function(){$("#boxOtherApartments").hide();});$(".btn_seefl").hover(function(emouse){vglobalApart.activeBtnSef=true;var textErrorLayer=regional.NoPlano;var optionsLoadImage={emouse:emouse,srcImage:$("#apt_plano img").attr("src"),textErrorLayer:textErrorLayer,cbk_imageloaded:showImageLayer,cbk_imageNoLoaded:showImageNotFoundLayer,cbk_imageMoved:showImageLayer,selectorLayer:"#apt_plano",idItemImage:apartId};loadImageAndPosLayer(optionsLoadImage);},function(){vglobalApart.activeBtnSef=false;$("#apt_plano").hide();if($("#apt_plano").hasClass("notFoundImg")){$("#apt_plano").removeClass("notFoundImg");$("#apt_plano .txtErrorLayer").remove();}});$(".btn_seefl").mousemove(function(emouse){var textErrorLayer=regional.NoPlano;var optionsLoadImage={emouse:emouse,srcImage:$("#apt_plano img").attr("src"),textErrorLayer:textErrorLayer,cbk_imageloaded:showImageLayer,cbk_imageNoLoaded:showImageNotFoundLayer,cbk_imageMoved:showImageLayer,selectorLayer:"#apt_plano",idItemImage:apartId};loadImageAndPosLayer(optionsLoadImage);});$("#show_hide_apt,#show_hide_apt2").click(function(){if(isSliding==0){isSliding=1;if(!isOpenCard){$("#show_hide_apt2").hide();$("#aptbox_card_anim").effect("slide",{direction:"right",easing:"easeOutExpo"},1500,function(){$(this).removeClass("hidct_card");$("#show_hide_apt").show();isOpenCard=true;isSliding=0;});}else{$("#aptbox_card_anim").effect("slide",{direction:"right",easing:"easeOutExpo",mode:"hide",distance:"484"},1500,function(){$(this).removeClass("hidct_card");$("#show_hide_apt2").show();isOpenCard=false;isSliding=0;});}}});$(".show_hide_list_btn,.show_hide_list_btn_show").click(function(){if(isSliding==0){isSliding=1;if(isOpenList){$(".show_hide_list_btn_show").hide();$("#bgresults").effect("slide",{direction:"right",easing:"easeOutExpo",mode:"show"},500,function(){$(this).removeClass("hidct_card");isOpenList=false;isSliding=0;});$("#map").animate({margin:"0px"},"normal",function(){});$("#aptbox_card_anim").animate({right:"214px"},"normal",function(){});$("#show_hide_apt2").animate({right:"211px"},"normal",function(){});}else{$("#bgresults").effect("slide",{direction:"right",easing:"easeOutExpo",mode:"hide",distance:"225"},1500,function(){$(".show_hide_list_btn_show").show();isOpenList=true;isSliding=0;});$("#map").animate({margin:"0px"},"normal",function(){});$("#aptbox_card_anim").animate({right:"0px"},"normal",function(){});$("#show_hide_apt2").animate({right:"0px"},"normal",function(){});}}});function openApartmentList(iditem){if(!isOpenList){isSliding=1;$("#results").effect("slide",{direction:"right",easing:"easeOutExpo"},1500,function(){isOpenList=true;isSliding=0;});}}$("#equipments_bar li").click(function(){if(!semTabsEqp){semTabsEqp=1;var idLi=$(this).attr("id");$("#equipments_bar li").removeClass("active");$("#equipments_bar #"+idLi).addClass("active");$(".tab_content_eq").hide();$("#"+idLi+"_ct").fadeIn("slow",function(){semTabsEqp=0;});}});initmainGalleryOld();}function setDatesApt(item){$(".price-day em").html('<span class="symbol"> '+currencySymbol+" </span>"+item.PreuDiari);$(".total em").html('<span class="symbol"> '+currencySymbol+" </span>"+item.PreuTotal);$(".price-day-pers em").html('<span class="symbol"> '+currencySymbol+" </span>"+item.DailyPersonPrice);$(".total .dayssp").html(item.Days);if(item.hasLastMinute){if($(".prices_card_box").hasClass("prices_card_lastminute")==false){$(".prices_card_box").addClass("prices_card_lastminute");}$(".price-day .no_offerprice").html('<span class="symbol"> '+currencySymbol+" </span>"+item.DailyPriceWithoutLastMinute);$(".total .no_offerprice").html('<span class="symbol"> '+currencySymbol+" </span>"+item.TotalPriceWithoutLastMinute);$(".price-day-pers .no_offerprice").html('<span class="symbol"> '+currencySymbol+" </span>"+item.DailyPersonPriceWithoutLastMinute);$(".dsct_value").html(item.percentLastMinute+"%");}else{if($(".prices_card_box").hasClass("prices_card_lastminute")){$(".prices_card_box").removeClass("prices_card_lastminute");}}if($("#msg_error").is(":visible")){$("#msg_error").hide();}$(".button_book").show();}function updateDates(control){var idCtrl=$(control).attr("id");var arrayIdCtrl=idCtrl.split("-");if(arrayIdCtrl[0]=="month"){var updateMonth=$(control).val();var arrayUpdateMonth=updateMonth.split("-");var year=parseInt(arrayUpdateMonth[0],10);var month=parseInt(arrayUpdateMonth[1],10);var dayCtrl=$("#day-"+arrayIdCtrl[1]);var day=parseInt(dayCtrl.val(),10);var date=new Date(year,month-1);var daysInMonth=28;var dateFound=false;while(!dateFound){date.setDate(daysInMonth+1);var newMonth=date.getMonth()+1;if(newMonth!=month){dateFound=true;}else{daysInMonth++;}}var daysMaxed=day>daysInMonth;dayCtrl.empty();for(var i=1;i<=daysInMonth;i++){var newOptionCtrl=$("<option></option>").attr("value",i).attr("selected",i==day||(daysMaxed&&i==daysInMonth)).text(i);dayCtrl.append(newOptionCtrl);}}}function disableDates(){$(".price-day em").html('<span class="symbol"> '+currencySymbol+" </span>--");$(".total em").html('<span class="symbol"> '+currencySymbol+" </span>--");$(".price-reserve em").html('<span class="symbol"> '+currencySymbol+" </span>--");$(".price-day-pers em").html('<span class="symbol"> '+currencySymbol+" </span>--");$(".button_book").hide();}function apartmentCheckDates(){var txterr="";dateArr=new Date($("#fcal-arr").datepicker("getDate"));dateGo=new Date($("#fcal-go").datepicker("getDate"));fpaxVal=$("#fPax").val();if(dateArr>dateGo){alert(regional.validateDate);}else{calarrVal=$("#fcal-arr").val();calgoVal=$("#fcal-go").val();$.ajax({type:"POST",url:"/ApartmentSearch.asmx/ApartmentCheckDates",data:"{'idApart':'"+apartId+"','idIdioma':'"+ididioma+"','dayIn':'"+calarrVal+"','dayOut':'"+calgoVal+"','personas':'"+fpaxVal+"','codMoneda':'"+currency+"'}",contentType:"application/json; charset=utf-8",dataType:"json",cache:false,success:function(result){var msgErr="";$.each(result.d.Errors,function(i,item){msgErr=msgErr+'<div class="alert_line">'+item.descError+"</div>";});if(msgErr==""){setDatesApt(result.d.ApartPrice);$("#availability_msgs").fadeOut("slow",function(){$("#availability_msgs content_alert").html(msgErr);});$("#fcalformat-arr").removeClass("alert_error_input");$("#fcalformat-go").removeClass("alert_error_input");$("#fPax").removeClass("alert_error_input");}else{$("#availability_msgs").fadeIn("slow",function(){$("#availability_msgs .content_alert").html(msgErr);});$("#fcalformat-arr").addClass("alert_error_input");$("#fcalformat-go").addClass("alert_error_input");disableDates();}},error:function(result){}});}}
