initialize=function(js_search,language){function handleTxt(type,args,obj){var dates=args[0];var date=dates[0];var year=date[0],month=date[1],day=date[2];today=new Date();currentMonth=eval(today.getMonth()+1);resta=month-currentMonth;month1=(resta>=1?month-1:month);month1=(month1<10)?"0"+month1:month1;month=(month<10)?"0"+month:month;day=(day<10)?"0"+day:day;var hiddenInDay=document.getElementById(js_search.prefix+"_checkin_day");var hiddenInMonthYear=document.getElementById(js_search.prefix+"_month_year_checkin");hiddenInMonthYear.value=month+"/"+year;js_search.mostrarDias(js_search.prefix+"_month_year_checkin",js_search.prefix+"_inoptions",js_search.prefix+"_checkin_day",js_search.prefix+"_checkin_day",1,1,1,day);hiddenInDay.value=day;checkinDate=month+"/"+day+"/"+year;checkinMonthYear=month+"/"+year;caloutpagedate=month1+"/"+year;calout.cfg.setProperty("pagedate",caloutpagedate);calout.cfg.setProperty("mindate",checkinDate);calout.cfg.setProperty("mindate",checkinDate,false);calout.cfg.setProperty("selected",checkinDate);calout.render();js_search.changeCheckOutDate();js_search.changeNumNights();calin.hide()}function handleTxt2(type,args,obj){var dates=args[0];var date=dates[0];var year=date[0],month=date[1],day=date[2];var hiddenOutDay=document.getElementById(js_search.prefix+"_checkout_day");var hiddenOutMonthYear=document.getElementById(js_search.prefix+"_month_year_checkout");month=(month<10)?"0"+month:month;day=(day<10)?"0"+day:day;hiddenOutMonthYear.value=month+"/"+year;js_search.mostrarDias(js_search.prefix+"_month_year_checkout",js_search.prefix+"_outoptions",js_search.prefix+"_checkout_day",js_search.prefix+"_checkout_day",2,js_search.days_before_checkin,0,day);hiddenOutDay.value=day;js_search.changeNumNights();calout.hide()}function _getDateStrForcalendars(fecha){return eval(fecha.getMonth()+1)+"/"+fecha.getDate()+"/"+fecha.getFullYear()}function _configureCalendar(calendar,fecha_inicial){if(language=="ar"||language=="ja"||language=="zt"){locale_weekdays="long"}else{locale_weekdays="short"}calendar.cfg.setProperty("LOCALE_WEEKDAYS",locale_weekdays);calendar.cfg.setProperty("hide_blank_weeks",true);calendar.cfg.setProperty("START_WEEKDAY",1);var str=_getDateStrForcalendars(fecha_inicial);calendar.cfg.setProperty("mindate",str);calendar.cfg.setProperty("selected",str);var fecha_final=new Date(fecha_inicial);fecha_final.setFullYear(fecha_final.getFullYear()+1);calendar.cfg.setProperty("maxdate",_getDateStrForcalendars(fecha_final));calendar.cfg.setProperty("close",true)}function _addDaysToDate(fecha,dias){t=fecha.getTime();t+=1000*60*60*24*dias;fecha.setTime(t)}var calin=new YAHOO.widget.CalendarGroup("calin",js_search.prefix+"_calinContainer",{pages:2,close:true});var calout=new YAHOO.widget.CalendarGroup("calout",js_search.prefix+"_caloutContainer",{pages:2,close:true});calin.selectEvent.subscribe(handleTxt,calin,true);calout.selectEvent.subscribe(handleTxt2,calout,true);var calin_fecha_inicial=new Date();_addDaysToDate(calin_fecha_inicial,js_search.days_before_checkin);_configureCalendar(calin,calin_fecha_inicial);var calout_fecha_inicial=calin_fecha_inicial;_addDaysToDate(calout_fecha_inicial,1);_configureCalendar(calout,calout_fecha_inicial);localeArrays=getLocaleLabels(language);localeProperties=getLocaleProperties();for(i=0;i<localeArrays.length;i++){calin.cfg.setProperty(localeProperties[i],localeArrays[i]);calout.cfg.setProperty(localeProperties[i],localeArrays[i])}calin.render();calout.render();YAHOO.util.Event.addListener(js_search.prefix+"_show1up","click",calin.show,calin,true);YAHOO.util.Event.addListener(js_search.prefix+"_show2up","click",calout.show,calout,true)};function HotelSearch(){this.HotelSearch=function(){this.days_before_checkin=1};var _getElementValue=function(element_id){if(document.getElementById(element_id)){return document.getElementById(element_id).value}else{alert("El elemento con id "+element_id+" no existe.")}};var _setElementValue=function(element_id,element_value){if(document.getElementById(element_id)){document.getElementById(element_id).value=element_value}else{alert("El elemento con id "+element_id+" no existe.")}};var _getElement=function(element_id){return document.getElementById(element_id)};var _calculateDifference=function(laterdate,earlierdate){var difference=laterdate.getTime()-earlierdate.getTime();var milliseconds_in_day=1000*60*60*24;var daysDifference=Math.round(difference/milliseconds_in_day);return daysDifference};this.changeNumNights=function(){var selm1=_getElement(this.prefix+"_month_year_checkin");var selm2=_getElement(this.prefix+"_month_year_checkout");var sel1=_getElement(this.prefix+"_checkin_day");var sel2=_getElement(this.prefix+"_checkout_day");var nights=_getElement(this.prefix+"_num_nights");checkout_year=selm2.value.substr(3,6);checkout_month=selm2.value.substr(0,2);checkout_day=sel2.value;checkout_date=new Date(checkout_month+"/"+checkout_day+"/"+checkout_year);checkin_year=selm1.value.substr(3,6);checkin_month=selm1.value.substr(0,2);checkin_day=sel1.value;checkin_date=new Date(checkin_month+"/"+checkin_day+"/"+checkin_year);var num_nights=_calculateDifference(checkout_date,checkin_date);if((num_nights<1)||(num_nights>=29)){}else{_setElementValue(this.prefix+"_num_nights",num_nights)}_setElementValue(this.prefix+"_num_nights",num_nights)};var _daysInMonth=function(month,year){var dd=new Date(year,month,0);return dd.getDate()};this.mostrarDias=function(id_campo_meses,targetID,id_campo_dias,name_campo_dias,inicio,dias_mas,check_in,selected_day){var sDay="";if(_getElement(id_campo_dias)!=null){sDay=_getElementValue(id_campo_dias)}if((selected_day!=0)&&(selected_day!="00")){sDay=selected_day}var monthYear=_getElementValue(id_campo_meses);var thismonth=monthYear.slice(0,2);var thisyear=parseInt(monthYear.slice(3,7));var maxdays=_daysInMonth(thismonth,thisyear);var maxdays2=_daysInMonth(thismonth-1,thisyear);var tDate=new Date();if((sDay!="")&&(sDay!="00")){tDate.setDate(sDay)}else{cday=eval(tDate.getDate()+dias_mas);tDate.setDate(cday)}switch(inicio){case 1:if((sDay=="")||(sDay=="00")){var yesterday=tDate.getDate();if(yesterday==eval(maxdays+1)){var today=1;if(thismonth==12){var month=1;var year=eval(thisyear+1)}else{var month=eval(thismonth+1);var year=thisyear}}else{if(yesterday==1){var today=1;if(thismonth==1){var month=1;var year=eval(thisyear+1)}else{var month=eval(thismonth);var year=thisyear}}else{var today=tDate.getDate();var month=thismonth;var year=thisyear}}month=(month<10)?"0"+month:month;_getElement(id_campo_meses).value=month+"/"+year}else{var today=tDate.getDate()}break;case 2:if((sDay=="")||(sDay=="00")){var yesterday=tDate.getDate();if(yesterday==maxdays){var today=1;if(thismonth==12){var month=1;var year=eval(thisyear+1)}else{var month=eval(thismonth);var year=thisyear}}else{if(yesterday==1){var month=thismonth;var today=eval(tDate.getDate()+1);var year=thisyear}else{var today=eval(tDate.getDate()+1);var month=thismonth;var year=thisyear}}month=(month<10)?"0"+month:month;_getElement(id_campo_meses).value=month+"/"+year}else{var today=tDate.getDate()}break}var options="";var selected="";for(x=1;x<=maxdays;x++){if(x<10){xStr="0"+x}else{xStr=x}if(x==today){selected='selected = "selected"'}else{selected=""}options=options+"<option "+selected+" value='"+xStr+"'>"+x+"</option>"}var output="<select name='"+name_campo_dias+"' onchange='";if(check_in==1){output=output+" "+this.my_name+".changeCheckOutDate();"}output=output+" "+this.my_name+".changeNumNights();' ";output=output+"' class='txt05' id='"+id_campo_dias+"'>"+options+"</select>";target=_getElement(targetID);target.innerHTML=output};this.mostrarMeses=function(flag){if((flag=="")||(flag=="00")){var today=new Date();var milisegundos=parseInt(24*60*60*1000*this.days_before_checkin);var tiempo=today.getTime();var total=today.setTime(parseInt(tiempo+milisegundos));var todaymonth=eval(today.getMonth())+1;var todayyear=eval(today.getFullYear());var tiempo=today.getTime();var total=today.setTime(parseInt(tiempo+milisegundos));if(todaymonth.toString().length==1){todaymonth="0"+todaymonth}var tomorrowmonth=today.getMonth()+1;var tomorrowyear=today.getFullYear();if(tomorrowmonth.toString().length==1){tomorrowmonth="0"+tomorrowmonth}var monthyear=todaymonth+"/"+todayyear;var monthyear2=tomorrowmonth+"/"+tomorrowyear;_setElementValue(this.prefix+"_month_year_checkin",monthyear);_setElementValue(this.prefix+"_month_year_checkout",monthyear2)}};var _getTodayDate=function(){current_date=new Date();current_date.setHours(0);current_date.setMinutes(0);current_date.setSeconds(0);return current_date};var _getMyDate=function(day_form_id,monthyear_form_id){dia=document.getElementById(day_form_id).value;mes=document.getElementById(monthyear_form_id).value.substring(0,2);anno=document.getElementById(monthyear_form_id).value.substring(3,7);calculated_date=new Date(anno,mes-1,dia);return(calculated_date.getDate()!=dia?0:calculated_date)};this._validateDatewithSelect=function(check_in_day_form_id,check_in_monthyear_form_id,check_out_day_form_id,check_out_monthyear_form_id){Error=new Array(3);Error=0;var current_date=_getTodayDate();var earlierdate=_getMyDate(check_in_day_form_id,check_in_monthyear_form_id);var laterdate=_getMyDate(check_out_day_form_id,check_out_monthyear_form_id);if(earlierdate==0){Error=1222}else{if(laterdate==0){Error=1525}if(_getElementValue(this.prefix+"_num_nights")<1){Error=427}if(Error==0){daysDifference=_calculateDifference(earlierdate,current_date);if(daysDifference<0){Error=421}if(daysDifference>334){Error=1205}if(earlierdate==laterdate){Error=427}}datesDifference=_calculateDifference(laterdate,earlierdate);if(datesDifference<=0){Error=428}}return Error};this.displayChildren=function(id_habitacion){var habitacion_selected=this.prefix+"_"+id_habitacion+"_hotelsearchroomoccupancy_user_room_type";var age_child_1=this.prefix+"_"+id_habitacion+"_hotelsearchroomoccupancy_edad_1";var age_child_2=this.prefix+"_"+id_habitacion+"_hotelsearchroomoccupancy_edad_2";if((_getElementValue(habitacion_selected)==4)||(_getElementValue(habitacion_selected)==3)||(_getElementValue(habitacion_selected)==7)){_getElement(this.prefix+"_etiqueta_ninyos").style.visibility="visible";_getElement(age_child_1).style.display="block";_getElement(age_child_2).style.display="none"}else{if(_getElementValue(habitacion_selected)==5){_getElement(this.prefix+"_etiqueta_ninyos").style.visibility="visible";_getElement(age_child_1).style.display="block";_getElement(age_child_2).style.display="block"}else{_getElement(this.prefix+"_etiqueta_ninyos").style.visibility="hidden";_getElement(age_child_1).style.display="none";_getElement(age_child_2).style.display="none"}}};this.displayRoomsTypes=function(){var num_habitaciones=_getElementValue(this.prefix+"_num_rooms");for(i=1;i<=this.max_num_rooms;i++){var room_to_show=this.prefix+"_"+i+"_hotelsearchroomoccupancy_habitacion_repeat";var options_of_rooms=this.prefix+"_"+i+"_hotelsearchroomoccupancy_user_room_type";var age_of_babies=this.prefix+"_"+i+"_hotelsearchroomoccupancy_edad_1";var age_of_babies_2=this.prefix+"_"+i+"_hotelsearchroomoccupancy_edad_2";if(i<=num_habitaciones){_getElement(room_to_show).style.display="block";rt=_getElementValue(options_of_rooms);if((rt==4)||(rt==3)||(rt==7)||(rt==5)){_getElement(this.prefix+"_etiqueta_ninyos").style.visibility="visible";_getElement(age_of_babies).style.display="block"}if(rt==5){_getElement(age_of_babies_2).style.display="block"}}else{_getElement(room_to_show).style.display="none";_setElementValue(options_of_rooms,1);_getElement(age_of_babies).style.display="none";_getElement(age_of_babies_2).style.display="none";_setElementValue(age_of_babies,"--");_setElementValue(age_of_babies_2,"--")}}};this._validateEmptyField=function(field_id,not_valid_value,error){var field_value;field_value=_getElementValue(field_id);return(field_value==not_valid_value?error:0)};this._translateFinalTypeOfRoom=function(room_id){var aux=this.prefix+"_"+room_id+"_hotelsearchroomoccupancy_user_room_type";var aux_baby1=this.prefix+"_"+room_id+"_hotelsearchroomoccupancy_edad_1";var aux_baby2=this.prefix+"_"+room_id+"_hotelsearchroomoccupancy_edad_2";var type_of_room_selected=_getElementValue(aux);var type_of_room_translated=type_of_room_selected;if((type_of_room_selected==7)&&((_getElementValue(aux_baby1)=="-1")||(_getElementValue(aux_baby1).value==1))){type_of_room_translated=6}if((type_of_room_selected==3)&&((_getElementValue(aux_baby1)=="-1")||(_getElementValue(aux_baby1)==1))){type_of_room_translated=1}if((type_of_room_selected==5)&&(((_getElementValue(aux_baby1)=="-1")||(_getElementValue(aux_baby1).value==1))||(_getElementValue(aux_baby2).value=="-1")||(_getElementValue(aux_baby2)==1))){if(((_getElementValue(aux_baby1)=="-1")||(_getElementValue(aux_baby1)==1))&&(_getElementValue(aux_baby2)=="-1")||(_getElementValue(aux_baby2)==1)){type_of_room_translated=1}else{type_of_room_translated=3}}return type_of_room_translated};this._validateMaxTypesofRoomsinHotels=function(error){var total_types_of_rooms=7;var max_types_of_rooms=this.prefix+"_max_types_of_rooms";var max_num_rooms=this.prefix+"_max_num_rooms";type_of_rooms=new Array();for(i=1;i<=total_types_of_rooms;i++){type_of_rooms[i]=0}for(i=1;i<=_getElementValue(this.prefix+"_num_rooms");i++){var aux=this.prefix+"_"+i+"_hotelsearchroomoccupancy_room_type";var type_of_room_translated=this._translateFinalTypeOfRoom(i);type_of_rooms[type_of_room_translated]=1}var total_rooms_selected=0;if(type_of_rooms[1]==1){type_of_rooms[4]=0}for(i=1;i<=total_types_of_rooms;i++){total_rooms_selected+=type_of_rooms[i]}return(total_rooms_selected>max_types_of_rooms?error:0)};this._validateChildrenAges=function(not_valid_value,error){var max_num_rooms=this.prefix+"max_num_rooms";var max_num_children_per_room=2;var mensaje=0;var detected=false;for(i=1;i<=_getElementValue(this.prefix+"_num_rooms");i++){var aux=this.prefix+"_"+i+"_hotelsearchroomoccupancy_user_room_type";var room_type=document.getElementById(aux).value;if(!(detected)){if(room_type==5){for(j=1;j<=max_num_children_per_room;j++){if(!(detected)){var aux2=this.prefix+"_"+i+"_hotelsearchroomoccupancy_edad_"+j;mensaje=this._validateEmptyField(aux2,"--",error);if(mensaje==error){detected=true}}}}if((room_type==4)||(room_type==3)||(room_type==7)){var aux2=this.prefix+"_"+i+"_hotelsearchroomoccupancy_edad_1";mensaje=this._validateEmptyField(aux2,"--",error);if(mensaje==error){detected=true}}}}return mensaje};this.changeCheckOutDate=function(){num_nights=_getElementValue(this.prefix+"_num_nights");checkout_date=new Date(_getElementValue(this.prefix+"_month_year_checkin").substr(0,2)+"/"+_getElementValue(this.prefix+"_checkin_day")+"/"+_getElementValue(this.prefix+"_month_year_checkin").substr(3,6)+" 01:00");checkout_date.setTime(checkout_date.getTime()+num_nights*1000*60*60*24);checkoutmonth=checkout_date.getMonth();checkoutmonth++;checkmonth=checkoutmonth.toString();if(checkmonth.length==1){checkmonth="0"+checkmonth}checkoutyear=checkout_date.getFullYear();_setElementValue(this.prefix+"_month_year_checkout",checkmonth+"/"+checkoutyear);this.mostrarDias(this.prefix+"_month_year_checkout",this.prefix+"_outoptions",this.prefix+"_checkout_day",this.prefix+"_checkout_day",num_nights,1,0,0);checkoutday=checkout_date.getDate();checkout=checkoutday.toString();lenday=checkout.length;if(lenday==1){checkout="0"+checkout}_setElementValue(this.prefix+"_checkout_day",checkout)};this.onChangeMonthYear=function(id_campo_meses,targetID,id_campo_dias,name_campo_dias,inicio,dias_mas,check_in){this.mostrarDias(id_campo_meses,targetID,id_campo_dias,name_campo_dias,inicio,dias_mas,check_in,0);if(check_in==1){this.changeCheckOutDate()}else{this.changeNumNights()}};if(this.is_bank_off){this.validateDaysforBankOff=function(check_in_day_form_id,check_in_monthyear_form_id){error=0;var current_date=getTodayDate();var earlierdate=_getMyDate(check_in_day_form_id,check_in_monthyear_form_id);daysDifference=_calculateDifference(earlierdate,current_date);if(daysDifference<=1){error=1222}return error}}this._validateRelease=function(){var current_date=_getTodayDate();var earlierdate=_getMyDate(this.prefix+"_checkin_day",this.prefix+"_month_year_checkin");daysDifference=_calculateDifference(earlierdate,current_date);if(daysDifference<this.days_before_checkin){error=4432}else{error=0}return error};if(this.hotelsearch_show_more_search_options_value){this.mostrar_adicionales=function(){getElement(this.prefix+"adicionales").style.display="block"}}this.validate=function(){mensaje=0;datosOk=false;if(this.validate_search_string_box){var mensaje=this._validateEmptyField(this.prefix+"_town_search_string",this.msgs[4161],"426");if(mensaje==0){var mensaje=this._validateEmptyField(this.prefix+"_town_search_string","","426")}}if(this.zone_page){var mensaje=this._validateEmptyField(this.prefix+"_geounit_id","","426")}if(mensaje==0){var mensaje=this._validateChildrenAges("--","3729")}if(mensaje==0){var mensaje=this._validateMaxTypesofRoomsinHotels("111")}if(mensaje==0){var mensaje=this._validateDatewithSelect(this.prefix+"_checkin_day",this.prefix+"_month_year_checkin",this.prefix+"_checkout_day",this.prefix+"_month_year_checkout")}if(this.bank_off){if(mensaje==0){var mensaje=this.validateDaysforBankOff(this.prefix+"_checkin_day",this.prefix+"_month_year_checkin")}}if(mensaje==0){var mensaje=this._validateRelease()}switch(mensaje){case"111":alert(this.msgs[3371]);break;case 421:alert(this.msgs[421]);break;case"426":alert(this.msgs[426]);break;case 427:alert(this.msgs[427]);break;case 428:alert(this.msgs[428]);break;case 1205:alert(this.msgs[1205]);break;case 1222:alert(this.msgs[4263]);break;case"3729":alert(this.msgs[3729]);break;case 4432:alert(this.msgs[4432]);break;case 2:statement;break;default:document.getElementById("indicator").style.display="block";document.getElementById("boton_enviar").style.display="none";return true}return false};this.clearInput=function(element,valor){if(valor==element.value){element.value=""}}}HFSearch.prototype=new HotelSearch;function HFSearch(){this.hfValidate=function(){a=0;datosOk=false;var a=this._validateEmptyField(this.prefix+"_from_town_search_str",this.msgs[4358],"4427");if(a==0){var a=this._validateEmptyField(this.prefix+"_from_town_search_str","","4427")}if(a==0){var a=this._validateEmptyField(this.prefix+"_to_town_search_str",this.msgs[4161],"4428")}if(a==0){var a=this._validateEmptyField(this.prefix+"_to_town_search_str","","4428")}if(a==0){var b=this.validate()}else{alert(this.msgs[a])}if(a!=0||b==false){return false}else{blockUIAndShowWaiting();return true}}};