
function AvailabilityPriceManager()
{this.contractEnd="";this.monthNames=null;this.monthNamesLong=null;this.dayNamesShort=null;this.isCalenderScrolling=false;this.isMonthCalenderScrolling=false;this.nbrVisibleMonthCalenderElements=12;this.nbrVisibleCalenderElements=2;this.selectedMonth=0;this.selectedYear=0;this.selectedDate="";this.currentMonthCalIndex=0;this.currentCalIndex=0;this.elementIndexToJumpTo=0;this.nbrCalElements=0;this.nbrMonthCalElements=0;this.availabilityAndPriceServiceURL="";this.dateDurationPricesServiceURL="";this.periodPriceListServiceURL="";this.accommodationCode="";this.storedDuration=0;this.aapPriceResult=null;this.bookingBaseURL="";this.onRequestBaseURL="";this.interhomeNavigation="";this.partnerID="";this.partnerIDExtra="";this.isDurationPriceListVisible=false;this.isPeriodPriceListVisible=false;this.isPeriodePriceListDataLoaded=false;this.specialPeriodTableAdditionalHeight=15;this.msgGlobalCalenderError="";this.msgErrObjectNotBookable="";this.msgErrObjectSoldOut="";this.isDatePreSelected=false;this.Initialize=function()
{this.LoadMonthCalender();this.LoadCalenders();var calenderElements=this.GetCalenderElements();if(calenderElements.length>=2)
{var month=this.GetDatePartFromISODate(this.selectedDate,"month");var year=this.GetDatePartFromISODate(this.selectedDate,"year");this.PopulateCalender(calenderElements.filter("table[month="+month+"][year="+year+"]"));month=parseInt(month)+1;if(month==13)
{month=1;year=parseInt(year)+1;}
this.PopulateCalender(calenderElements.filter("table[month="+month+"][year="+year+"]"));}
this.LoadDurationPriceData();if(this.selectedDate=="")
{this.HideAllCalenders();this.HidePeriodPriceList();}}
this.SetSelectedMonthYear=function(lnkMonth,month,year)
{if(this.selectedMonth!=month||this.selectedYear!=year)
{this.selectedMonth=month;this.selectedYear=year;this.elementIndexToJumpTo=$(lnkMonth).attr("id").replace('lnkMonthCal','');this.AnimateCalender("",this.selectedMonth,this.selectedYear);}
$("#divMonthSliderGateInner").children().css("background-color","");$(lnkMonth).css("background-color","#b5cbe4").next().eq(0).css("background-color","#b5cbe4");return false;}
this.SetArrivalDate=function(calenderIndex,date)
{this.HideAjaxLoader();if(this.selectedDate==date)
return false;this.selectedDate=date;if(calenderIndex>parseInt(this.currentCalIndex))
{this.AnimateCalender('left');}
this.ShowAjaxLoader();this.LoadDurationPriceData();}
this.GetMonthCalenderElementWidth=function()
{return $("#divMonthSliderGateInner").children("a").eq(0).width();}
this.GetCalenderElementWidth=function()
{return $("#divDuplexCalendarGateInner").children("div").eq(0).width();}
this.SetMonthCalenderArrowVisibility=function(btnType,isVisible)
{var displayValue=(isVisible)?"visible":"hidden";if(btnType=='left')
$(".linkMonthSliderButtonLeft").css("visibility",displayValue);else if(btnType=='right')
$(".linkMonthSliderButtonRight").css("visibility",displayValue);}
this.SetCalenderArrowVisibility=function(btnType,isVisible)
{var displayValue=(isVisible)?"visible":"hidden";if(btnType=='left')
$(".linkDuplexCalendarButtonLeft").css("visibility",displayValue);else if(btnType=='right')
$(".linkDuplexCalendarButtonRight").css("visibility",displayValue);}
this.AnimateMonthCalender=function(direction)
{if(this.isMonthCalenderScrolling)
return false;this.isMonthCalenderScrolling=true;var monthCalenderElementWidth=this.GetMonthCalenderElementWidth()+1;if(direction=='right')
{if(this.currentMonthCalIndex==0)
{this.isMonthCalenderScrolling=false;return false;}
$("#divMonthSliderGateInner").animate({"left":"+="+monthCalenderElementWidth+"px"},"fast",function(target){target.isMonthCalenderScrolling=false;}(this));this.currentMonthCalIndex--;}
else if(direction=='left')
{if(this.currentMonthCalIndex==(this.nbrMonthCalElements-this.nbrVisibleMonthCalenderElements))
{this.isMonthCalenderScrolling=false;return false;}
if(this.nbrMonthCalElements<=this.nbrVisibleMonthCalenderElements)
{this.isMonthCalenderScrolling=false;return false;}
$("#divMonthSliderGateInner").animate({"left":"-="+monthCalenderElementWidth+"px"},"fast",function(target){target.isMonthCalenderScrolling=false;}(this));this.currentMonthCalIndex++;}
return false;}
this.AnimateCalender=function(direction,month,year)
{if(this.isCalenderScrolling)
return false;this.isCalenderScrolling=true;var isJumpSearch=false;var calenderElements=this.GetCalenderElements();var calenderElementWidth=this.GetCalenderElementWidth()+2;if(direction!="")
pixelToAnimate=calenderElementWidth;else
{direction=(this.elementIndexToJumpTo>this.currentCalIndex)?'left':'right';pixelToAnimate=(this.elementIndexToJumpTo>this.currentCalIndex)?(this.elementIndexToJumpTo-this.currentCalIndex)*calenderElementWidth:(this.currentCalIndex-this.elementIndexToJumpTo)*calenderElementWidth;this.currentCalIndex=this.elementIndexToJumpTo;isJumpSearch=true;}
if(direction=='right')
{if(this.currentCalIndex==0&&isJumpSearch==false)
{this.isCalenderScrolling=false;return false;}
$("#divDuplexCalendarGateInner").animate({"left":"+="+pixelToAnimate+"px"},"slow",function(target){target.isCalenderScrolling=false;}(this));if(!isJumpSearch)
{this.currentCalIndex--;this.PopulateCalender(calenderElements.eq(this.currentCalIndex));}}
else if(direction=='left')
{if(this.currentCalIndex>(this.nbrCalElements-this.nbrVisibleCalenderElements))
{if(!isJumpSearch)
{this.isCalenderScrolling=false;return false;}}
$("#divDuplexCalendarGateInner").animate({"left":"-="+pixelToAnimate+"px"},"slow",function(target){target.isCalenderScrolling=false;}(this));if(!isJumpSearch)
{this.PopulateCalender(calenderElements.eq(parseInt(this.currentCalIndex)+parseInt(this.nbrVisibleCalenderElements)));this.currentCalIndex++;}}
if(isJumpSearch)
{this.PopulateCalender(calenderElements.eq(this.currentCalIndex));this.PopulateCalender(calenderElements.eq(parseInt(this.currentCalIndex)+1));}
this.MarkMonthCalElement(this.currentCalIndex);return false;}
this.GetContractEnd=function()
{if(this.contractEnd==null||this.contractEnd==""||this.contractEnd.length!=10)
{$("#divBookingTableList").html("<div style='margin-top:10px;'><b>"+this.msgGlobalCalenderError+"</b></div>").next().eq(0).hide();return null;}
var myDate=new Date(parseInt(this.GetDatePartFromISODate(this.contractEnd,"year")),parseInt(this.GetDatePartFromISODate(this.contractEnd,"month"))-1,parseInt(this.GetDatePartFromISODate(this.contractEnd,"day")));if(isNaN(myDate)||myDate<=new Date())
{$("#divBookingTableList").html("<div style='margin-top:10px;'><b>"+this.msgGlobalCalenderError+"</b></div>").next().eq(0).hide();return null;}
return myDate;}
this.OnMonthCalenderLoaded=function()
{var monthCalenderElements=this.GetMonthCalenderElementes();this.nbrMonthCalElements=monthCalenderElements.length;monthCalenderElements.eq(0).css("background-color","#b5cbe4");monthCalenderElements.eq(1).css("background-color","#b5cbe4");}
this.OnCalendersLoaded=function()
{var calenderElements=this.GetCalenderElements();this.nbrCalElements=calenderElements.length;}
this.LoadMonthCalender=function()
{var contractEnd=this.GetContractEnd();if(contractEnd==null)
return false;var now=new Date();now.setDate(1);var idCounter=0;while(!(now.getFullYear()==contractEnd.getFullYear()&&now.getMonth()==contractEnd.getMonth()))
{$("#divMonthSliderGateInner").append("<a id=\"lnkMonthCal"+idCounter+"\" month=\""+(now.getMonth()+1)+"\" year=\""+now.getFullYear()+"\" href=\'#\' onClick=\"return apManager.SetSelectedMonthYear(this,"+now.getMonth()+","+now.getFullYear()+")\"><span>"+this.monthNames[now.getMonth()]+"</span>"+now.getFullYear()+"</a>");now.setMonth(now.getMonth()+1);idCounter++;}
$("#divMonthSliderGateInner").append("<a id=\"lnkMonthCal"+idCounter+"\" month=\""+(now.getMonth()+1)+"\" year=\""+now.getFullYear()+"\" href=\'#\' onClick=\"return apManager.SetSelectedMonthYear(this,"+now.getMonth()+","+now.getFullYear()+")\"><span>"+this.monthNames[now.getMonth()]+"</span>"+now.getFullYear()+"</a>");this.OnMonthCalenderLoaded();}
this.LoadCalenders=function()
{var contractEnd=this.GetContractEnd();if(contractEnd==null)
return false;var now=new Date();now.setDate(1);var idCounter=0;while(!(now.getFullYear()==contractEnd.getFullYear()&&now.getMonth()==contractEnd.getMonth()))
{var calenderContentRaw="<div id=\"divCal"+idCounter+"\" class=\"divDuplexCalendarMonthView\">";calenderContentRaw+="<table id=\"tblCal"+idCounter+"\" class=\"tableDuplexCalendar\" cellspacing=\"1\" month=\""+(parseInt(now.getMonth())+1)+"\" year=\""+now.getFullYear()+"\">";calenderContentRaw+="<caption>"+this.monthNamesLong[now.getMonth()]+" "+now.getFullYear()+"</caption>";calenderContentRaw+="<thead>";calenderContentRaw+="<tr>";for(var i=0;i<7;i++)
calenderContentRaw+="<th>"+this.dayNamesShort[i]+"</th>";calenderContentRaw+="<tr>";calenderContentRaw+="</thead>";calenderContentRaw+="<tbody>";calenderContentRaw+="</tbody>";calenderContentRaw+="</table>";calenderContentRaw+="<div style=\"margin-top:50px;\">Loading</div>";calenderContentRaw+="</div>";$("#divDuplexCalendarGateInner").append(calenderContentRaw);now.setMonth(now.getMonth()+1);idCounter++;}
var calenderContentRaw="<div id=\"divCal"+idCounter+"\" class=\"divDuplexCalendarMonthView\">";calenderContentRaw+="<table id=\"tblCal"+idCounter+"\" class=\"tableDuplexCalendar\" cellspacing=\"1\" month=\""+(parseInt(now.getMonth())+1)+"\" year=\""+now.getFullYear()+"\">";calenderContentRaw+="<caption>"+this.monthNamesLong[now.getMonth()]+" "+now.getFullYear()+"</caption>";calenderContentRaw+="<thead>";calenderContentRaw+="<tr>";for(var i=0;i<7;i++)
calenderContentRaw+="<th>"+this.dayNamesShort[i]+"</th>";calenderContentRaw+="<tr>";calenderContentRaw+="</thead>";calenderContentRaw+="<tbody>";calenderContentRaw+="</tbody>";calenderContentRaw+="</table>";calenderContentRaw+="<div style=\"margin-top:50px;\">Loading</div>";calenderContentRaw+="</div>";$("#divDuplexCalendarGateInner").append(calenderContentRaw);this.OnCalendersLoaded();}
this.PopulateCalender=function(calenderElement)
{if(calenderElement.attr("class")!="tableDuplexCalendar")
return;var calIndex=calenderElement.attr("id").substr(6);if(!calenderElement.attr("isPopulated"))
{var month=parseInt(calenderElement.attr("month"));var year=parseInt(calenderElement.attr("year"));var params={accommodationCode:this.accommodationCode,month:{Year:year,Month:month,Day:1}};$.ajax({type:"POST",contentType:"application/json; charset=utf-8",dataType:"json",url:this.availabilityAndPriceServiceURL,data:JSON.stringify(params),success:function(aapMonth){calenderElement.next().remove();var days="";for(var i=0;i<aapMonth.ws.length;i++)
{days+="<tr>";for(var x=0;x<aapMonth.ws[i].ds.length;x++)
{var cellContent="";var cellAttributes="";switch(aapMonth.ws[i].ds[x].p)
{case"A":cellAttributes=" class='tdArrivalPossible' day=\""+aapMonth.ws[i].ds[x].t1+"\"";cellContent="<a href='#' onClick=\"apManager.SetArrivalDate("+calIndex+", '"+aapMonth.ws[i].ds[x].dt.Year+"-"+aapMonth.ws[i].ds[x].dt.Month+"-"+aapMonth.ws[i].ds[x].dt.Day+"'); return false;\" title='"+aapMonth.ws[i].ds[x].t2+"'>"+aapMonth.ws[i].ds[x].t1+"</a>";break;case"O":break;case"F":cellAttributes=" class='tdArrivalNotPossible' day=\""+aapMonth.ws[i].ds[x].t1+"\"";cellContent=aapMonth.ws[i].ds[x].t1;break;case"N":cellAttributes=" class='tdBooked'";cellContent=aapMonth.ws[i].ds[x].t1;break;}
days+="<td"+cellAttributes+">"+cellContent+"</td>";}
days+="</tr>";}
calenderElement.children("tbody").append(days);calenderElement.attr("isPopulated","yes");},error:function(xhr){}})}}
this.LoadDurationPriceData=function()
{if(this.selectedDate=="")
{$("#divBookingTableList").html("<div style='margin-top:10px;'><b>"+this.msgErrObjectSoldOut+"</b></div>").next().eq(0).hide();return;}
var month=this.GetDatePartFromISODate(this.selectedDate,"month");month=parseInt(month);var year=parseInt(this.GetDatePartFromISODate(this.selectedDate,"year"));var day=parseInt(this.GetDatePartFromISODate(this.selectedDate,"day"));var params={accommodationCode:this.accommodationCode,selectedDate:{Year:year,Month:month,Day:day}};$.ajax({type:"POST",contentType:"application/json; charset=utf-8",dataType:"json",url:this.dateDurationPricesServiceURL,data:JSON.stringify(params),success:this.OnLoadDurationPriceDataSuccess,error:function(xhr){},caller:this})}
this.OnLoadDurationPriceDataSuccess=function(aapPriceResult)
{if(!this.caller.isDatePreSelected)
{var month=this.caller.GetDatePartFromISODate(this.caller.selectedDate,"month");var year=this.caller.GetDatePartFromISODate(this.caller.selectedDate,"year");$("#divMonthSliderGateInner a[month="+month+"][year="+year+"]").click();this.caller.isDatePreSelected=true;}
this.caller.aapPriceResult=aapPriceResult;this.caller.PopulateDurationDDL();this.caller.MarkStartDateOnCalender();this.caller.PopulateFirstDurationPriceRow();this.caller.PopulateDurationPriceList();this.caller.HideAjaxLoader();}
this.ShowAjaxLoader=function()
{$("#divAjaxLoader").css("display","block");}
this.HideAjaxLoader=function()
{$("#divAjaxLoader").css("display","none");}
this.PopulateDurationDDL=function()
{if(this.aapPriceResult!=null)
{$("#ddlCalDuration").children().remove();for(var i=0;i<this.aapPriceResult.durPris.length;i++)
{$("#ddlCalDuration").append("<option value=\""+this.aapPriceResult.durPris[i].d+"\">"+this.aapPriceResult.durPris[i].dT+"</option>");}}
this.PreSelectDurationDDL();}
this.PreSelectDurationDDL=function()
{var isSelected=false;var ddl=$("#ddlCalDuration")[0];if(ddl)
{for(var i=0;i<ddl.options.length;i++)
{if(parseInt(ddl.options[i].value)==this.storedDuration)
{ddl.options[i].setAttribute('selected',true);isSelected=true;this.storedDuration=parseInt(ddl.options[ddl.selectedIndex].value);break;}}
if(!isSelected)
{for(var i=0;i<ddl.options.length;i++)
{if(parseInt(ddl.options[i].value)==7)
{ddl.options[i].setAttribute('selected',true);isSelected=true;this.storedDuration=parseInt(ddl.options[ddl.selectedIndex].value);break;}}}
if(!isSelected&&ddl.options[0]!=null)
this.storedDuration=parseInt(ddl.options[0].value);}
return this.storedDuration;}
this.OnDurationChange=function()
{var ddl=$("#ddlCalDuration")[0];this.storedDuration=parseInt(ddl.options[ddl.selectedIndex].value);this.MarkStartDateOnCalender();this.PopulateFirstDurationPriceRow();}
this.OnKeyUpDurationChange=function()
{if($.browser.mozilla)
this.OnDurationChange();}
this.PopulateFirstDurationPriceRow=function()
{var ddl=$("#ddlCalDuration");var duration=this.storedDuration;var durPrisElement=null;if(this.aapPriceResult!=null&&duration>0)
{for(var i=0;i<this.aapPriceResult.durPris.length;i++)
{if(parseInt(this.aapPriceResult.durPris[i].d)==duration)
{durPrisElement=this.aapPriceResult.durPris[i];break;}}}
if(durPrisElement==null)
{ddl.parent().next().eq(0).html("").append("<nobr>N/A</nobr>");ddl.parent().nextAll().eq(1).children().eq(0).html("").append("N/A");ddl.parent().nextAll().eq(2).children().eq(0).attr("style","visibility:hidden");}
else
{ddl.parent().nextAll().eq(2).children().eq(0).attr("style","visibility:visible");ddl.parent().next().eq(0).html("").append("<nobr>"+durPrisElement.dSE+"</nobr>");var href="";if(durPrisElement.hSP)
{ddl.parent().nextAll().eq(1).children().eq(0).html("").append(durPrisElement.c+"<span style='text-decoration:line-through;'>"+durPrisElement.p+"</span>&nbsp;<span style='color:red;'>"+durPrisElement.sP+"</span>");}
else
ddl.parent().nextAll().eq(1).children().eq(0).html("").append(durPrisElement.c+" "+durPrisElement.p);if(durPrisElement.iB)
{href=this.GetValidBookingURL(durPrisElement.sDt.Year+"-"+durPrisElement.sDt.Month+"-"+durPrisElement.sDt.Day,duration);ddl.parent().nextAll().eq(2).children().eq(0).attr("class","linkBookingButton");}
else
{href=this.GetValidOnRequestURL(durPrisElement.sDt.Year+"-"+durPrisElement.sDt.Month+"-"+durPrisElement.sDt.Day,duration);ddl.parent().nextAll().eq(2).children().eq(0).attr("class","linkAvailablityButton");}
ddl.parent().nextAll().eq(2).children().eq(0).attr("href",href);ddl.parent().nextAll().eq(2).children().eq(0).html(durPrisElement.bT);}}
this.GetValidBookingURL=function(startDate,duration)
{bookingURL=this.bookingBaseURL.replace("{0}",this.accommodationCode);bookingURL=bookingURL.replace("{1}",startDate);bookingURL=bookingURL.replace("{2}",duration);bookingURL=bookingURL.replace("{3}",this.interhomeNavigation);bookingURL=bookingURL.replace("{4}",this.partnerID);bookingURL=bookingURL.replace("{5}",this.partnerIDExtra);return bookingURL;}
this.GetValidOnRequestURL=function(startDate,duration)
{onRequestURL=this.onRequestBaseURL.replace("{0}",this.accommodationCode);onRequestURL=onRequestURL.replace("{1}",startDate);onRequestURL=onRequestURL.replace("{2}",duration);return onRequestURL;}
this.GetCalenderElements=function()
{return $("table[class='tableDuplexCalendar']");}
this.GetMonthCalenderElementes=function()
{return $("#divMonthSliderGateInner").children("a");}
this.MarkMonthCalElement=function(index)
{$("#divMonthSliderGateInner").children().css("background-color","white");$("#lnkMonthCal"+index).css("background-color","#b5cbe4");$("#lnkMonthCal"+(index+1)).css("background-color","#b5cbe4");}
this.MarkStartDateOnCalender=function()
{var dayCellsCal1=$("#tblCal"+this.currentCalIndex+" tbody tr td");var dayCellsCal2=$("#tblCal"+(parseInt(this.currentCalIndex)+1)+" tbody tr td");var startDay=this.GetDatePartFromISODate(this.selectedDate,"day");var ddl=$("#ddlCalDuration")[0];var duration=0;if(ddl.selectedIndex>-1)
duration=parseInt(ddl.options[ddl.selectedIndex].value);var counter=0;if(duration>0)
{var relevantTables
$("table[id*='tblCal'] tbody tr td[class*='tdSelectedDates']").removeClass("tdSelectedDates");for(var i=0;i<dayCellsCal1.length;i++)
{if(counter==duration)
break;if(dayCellsCal1.eq(i).attr("day"))
{if(parseInt(startDay)==parseInt(dayCellsCal1.eq(i).attr("day"))||counter>0)
{dayCellsCal1.eq(i).addClass("tdSelectedDates");counter++;}}}
if(counter!=duration)
{var startDayAlreadySelected=true;if(counter==0)
startDayAlreadySelected=false;for(var i=0;i<dayCellsCal2.length;i++)
{if(counter==duration)
break;if(startDayAlreadySelected)
{if(dayCellsCal2.eq(i).attr("day"))
{dayCellsCal2.eq(i).addClass("tdSelectedDates");counter++;}}
else if(!isNaN(dayCellsCal2.eq(i).attr("day"))&&parseInt(startDay)==parseInt(dayCellsCal2.eq(i).attr("day")))
{dayCellsCal2.eq(i).addClass("tdSelectedDates");startDayAlreadySelected=true;counter++;}}}}}
this.GetDatePartFromISODate=function(ISODate,part)
{var part=part.toLowerCase();var returnValue="";switch(part)
{case"year":returnValue=ISODate.substring(0,4);break;case"month":returnValue=ISODate.substring(5,ISODate.lastIndexOf("-"));if(returnValue.substr(0,1)=="0")
returnValue=returnValue.substr(1,1);break;case"day":returnValue=ISODate.substring(ISODate.lastIndexOf("-")+1);if(returnValue.substr(0,1)=="0")
returnValue=returnValue.substr(1,1);break;}
return returnValue;}
this.PopulateDurationPriceList=function()
{$("#tableBookingTableList tbody tr:gt(0)").remove();for(var i=0;i<this.aapPriceResult.durPris.length;i++)
{if(this.aapPriceResult.durPris[i].d==-1)
{continue;}
durationPriceRow="<tr>";durationPriceRow+="<td>"+this.aapPriceResult.durPris[i].dT+"</td>";durationPriceRow+="<td>"+this.aapPriceResult.durPris[i].dSE+"</td>";if(this.aapPriceResult.durPris[i].hSP)
{durationPriceRow+="<td><strong>"+this.aapPriceResult.durPris[i].c+"<span style='text-decoration:line-through;'>"+this.aapPriceResult.durPris[i].p+"</span>&nbsp;<span style='color:red;'>"+this.aapPriceResult.durPris[i].sP+"</span></strong></td>";}
else
durationPriceRow+="<td><strong>"+this.aapPriceResult.durPris[i].c+" "+this.aapPriceResult.durPris[i].p+"</strong></td>";var href="";if(this.aapPriceResult.durPris[i].iB)
{href=this.GetValidBookingURL(this.aapPriceResult.durPris[i].sDt.Year+"-"+this.aapPriceResult.durPris[i].sDt.Month+"-"+this.aapPriceResult.durPris[i].sDt.Day,this.aapPriceResult.durPris[i].d);durationPriceRow+="<td><a href=\""+href+"\" class=\"linkBookingButton\">"+this.aapPriceResult.durPris[i].bT+"</a></td>";}
else
{href=this.GetValidOnRequestURL(this.aapPriceResult.durPris[i].sDt.Year+"-"+this.aapPriceResult.durPris[i].sDt.Month+"-"+this.aapPriceResult.durPris[i].sDt.Day,this.aapPriceResult.durPris[i].d);durationPriceRow+="<td><a href=\""+href+"\" class=\"linkAvailablityButton\">"+this.aapPriceResult.durPris[i].bT+"</a></td>";}
durationPriceRow+="</tr>";$("#tableBookingTableList tbody").append(durationPriceRow);}
if(this.isDurationPriceListVisible)
this.ArrangeDurationPriceList();}
this.ArrangeDurationPriceList=function()
{var distance=0;if($("#divBookingTableList").height()>$("#tableBookingTableList").height())
{distance=$("#divBookingTableList").height()-$("#tableBookingTableList").height();$("#divBookingTableList").animate({"height":"-="+distance+"px"},"slow");}
else
{distance=$("#tableBookingTableList").height()-$("#divBookingTableList").height();$("#divBookingTableList").animate({"height":"+="+distance+"px"},"slow");}}
this.ShowDurationPriceList=function()
{var distance=$("#tableBookingTableList").height();distance=distance-45;$("#divBookingTableList").animate({"height":"+="+distance+"px"},"slow");this.isDurationPriceListVisible=true;}
this.HideDurationPriceList=function()
{if(this.isDurationPriceListVisible)
{var diff=$("#tableBookingTableList").height();diff=diff-45;$("#divBookingTableList").animate({"height":"-="+diff+"px"},"slow");}
this.isDurationPriceListVisible=false;}
this.SwitchDurationPriceList=function()
{if(this.isDurationPriceListVisible)
this.HideDurationPriceList();else
this.ShowDurationPriceList();}
this.SwitchPeriodPriceList=function()
{var tmpTableHeight=0;if(this.isPeriodPriceListVisible)
{tmpTableHeight=$("#tblPeriodePriceList").height()+this.specialPeriodTableAdditionalHeight;$("#divPeriodePriceList").animate({"height":"-="+tmpTableHeight+"px"},"slow",function(target){target.isPeriodPriceListVisible=false;}(this));}
else
{if(!this.isPeriodePriceListDataLoaded)
this.LoadPeriodPriceListData();else
{tmpTableHeight=$("#tblPeriodePriceList").height()+this.specialPeriodTableAdditionalHeight;$("#divPeriodePriceList").animate({"height":"+="+tmpTableHeight+"px"},"slow",function(target){target.isPeriodPriceListVisible=true;}(this));}}}
this.LoadPeriodPriceListData=function()
{$("#divPeriodePriceList").children().remove();$("#divPeriodePriceList").append("<div style='text-align:center'><strong>LOADING...</strong></div>");$("#divPeriodePriceList").css("height","15px");var month=this.GetDatePartFromISODate(this.selectedDate,"month");month=parseInt(month);var year=parseInt(this.GetDatePartFromISODate(this.selectedDate,"year"));var day=parseInt(this.GetDatePartFromISODate(this.selectedDate,"day"));var params={accommodationCode:this.accommodationCode,selectedDate:{Year:year,Month:month,Day:day},selectedDuration:this.storedDuration};$.ajax({type:"POST",contentType:"application/json; charset=utf-8",dataType:"json",url:this.periodPriceListServiceURL,data:JSON.stringify(params),success:this.OnLoadPeriodPriceListDataSuccess,error:function(xhr){},caller:this})}
this.OnLoadPeriodPriceListDataSuccess=function(periodPriceList)
{$("#divPeriodePriceList").children().remove();$("#divPeriodePriceList").css("height","0px");var content="<table cellspacing='1' id='tblPeriodePriceList' class='Calendar tblPricelist' style='margin-top:13px'>";content+="<tr><td colspan='4' class='tdPricelistDate'><strong>"+periodPriceList.EXText+"</strong></td></tr>";content+="<tr><th class='thPricelist'>"+periodPriceList.PLH1+"</th><th colspan='3' class='thPricelist'>"+periodPriceList.PLH2+"</th></tr>";content+="<tr><th class='DayHeaderStyle'>&nbsp;</th><th class='DayHeaderStyle'>"+periodPriceList.PLHS1+"</th><th class='DayHeaderStyle'>"+periodPriceList.PLHS2+"</th><th class='DayHeaderStyle'>"+periodPriceList.PLHS3+"</th></tr>";for(var i=0;i<periodPriceList.PriceList.length;i++)
{var price=(periodPriceList.PriceList[i].SP!="")?"<span style='text-decoration: line-through;'>"+periodPriceList.PriceList[i].WP+"</span>&nbsp;<span style='color:red'>"+periodPriceList.PriceList[i].SP+"</span>":periodPriceList.PriceList[i].WP;var specialCondition=periodPriceList.PriceList[i].tTi;content+="<tr><td class='tdPeriodePriceTable taCenter' style='white-space:nowrap'>"+periodPriceList.PriceList[i].pT+"</td><td class='tdPeriodePriceTable taCenter'>"+price+"</td><td class='tdPeriodePriceTable taCenter'>"+periodPriceList.PriceList[i].sbText+"</td><td class='tdPeriodePriceTable' style='text-align:right;'><a href='#' onMouseOver=\"return popupManager.OpenTooltipAtPosition(this, '', '"+periodPriceList.PriceList[i].tTi+"', '<div>"+periodPriceList.PriceList[i].tTe+"</div>', null, 200, 100, false)\" onMouseOut=\"return popupManager.CloseAllOpenPopupsAndTooltips()\">"+specialCondition+"</a></td></tr>";}
content+="</table>";$("#divPeriodePriceList").append(content);this.caller.isPeriodePriceListDataLoaded=true;var tmpTableHeight=$("#tblPeriodePriceList").height()+this.caller.specialPeriodTableAdditionalHeight;$("#divPeriodePriceList").animate({"height":"+="+tmpTableHeight+"px"},"slow",function(target){target.isPeriodPriceListVisible=true;}(this.caller));}
this.HidePeriodPriceList=function()
{$("#divPeriodePriceListBlock").remove();}
this.HideAllCalenders=function()
{$("#divMonthSlider").hide();$("#divDuplexCalendar").hide();}}