function LZ(a){return(a<0||a>9?"":"0")+a}function setDate(){var c=getTodayDate();var d=getCheckinDate();if(calculateDifference(d,c)<0){var b=LZ((c.getDate()+1))+"-"+LZ((c.getMonth()+1))+"-"+c.getYear();document.get_country.checkin_date.value=b;if(typeof(document.get_country.checkout_date)!="undefined"){var e=new Date();e.setTime(c.getTime()+86400000);var a=LZ((e.getDate()+1))+"-"+LZ((e.getMonth()+1))+"-"+e.getYear();document.get_country.checkout_date.value=a}}}function resetDate(){var c=getTodayDate();var b=getCheckinDate();if(calculateDifference(b,c)<0){var j=c.getDate();var f=c.getMonth();var g=c.getYear();document.get_country.checkin_day.selectedIndex=(j-1);document.get_country.checkin_month.selectedIndex=f;var d=document.get_country.checkin_year;for(var e=0;e<d.options.length;e++){if(d.options[e].value==g){d.selectedIndex=e;break}}if(typeof(document.get_country.checkout_day)!="undefined"){var a=new Date();a.setTime(c.getTime()+86400000);var k=a.getDate();var h=a.getMonth();var l=a.getYear();document.get_country.checkout_day.selectedIndex=(k-1);document.get_country.checkout_month.selectedIndex=h;var d=document.get_country.checkout_year;for(var e=0;e<d.options.length;e++){if(d.options[e].value==l){d.selectedIndex=e;break}}}}}function validateAll(){var a=new Array(3);a[0]=0;a=validateDate();if(a[0]==0){a=validateRooms()}if(a[0]==0){a=validateTown()}if(a[0]==0){a=validateGestor()}return a}function validateSmall(){var b=0;var a=new Array(3);a[0]=0;a=validateDate();if(a[0]==0){if(typeof(document.get_country.apartments)=="undefined"){a=validateRoomsSmall()}}if(a[0]==0){a=validateTown()}if(a[0]==0){if(b==0){document.body.style.cursor="wait";b++;document.get_country.submit()}}return a}function validateDate(){Error=new Array(3);Error[0]=0;var b=getTodayDate();var c=getCheckinDate();var a=getCheckoutDate();if(c==0){Error[0]=1222}else{if(a==0){Error[0]=1525}if(document.get_country.num_nights.value<1){Error[0]=427}if(Error[0]==0){daysDifference=calculateDifference(c,b);if(daysDifference<0){Error[0]=421}if(daysDifference>334){Error[0]=1205}}}return Error}function validateRoomsSmall(){formulario=document.get_country;Error=new Array(3);Error[0]=0;if(formulario.num_rooms.value<1){Error[0]=48}if(Error[0]==0){rooms=new Array();rooms.num_rooms=eval("formulario.num_rooms.value");rooms.room_code=eval("formulario.room_code.value");if(typeof(eval("formulario.age_child1"))!="undefined"){rooms.age_child1=eval("formulario.age_child1.value");rooms.age_child2=eval("formulario.age_child2.value");has_tag_age_children=1}else{rooms.age_child1=0;rooms.age_child2=0;has_tag_age_children=0}if((rooms.room_code==1||rooms.room_code==2||rooms.room_code==6)&&(rooms.age_child1!=0||rooms.age_child2!=0)){tipo="";Error[0]=435;Error[1]=tipo}if((rooms.room_code==3||rooms.room_code==6)&&(rooms.age_child2!=0)){tipo="";Error[0]=439;Error[1]=tipo}}if(Error[0]==0){if((rooms.room_code==3||rooms.room_code==4||rooms.room_code==7)&&(rooms.age_child1==0&&rooms.age_child2!=0&&has_tag_age_children==1)){tipo="";Error[0]=436;Error[1]=tipo}}if(Error[0]==0){if((rooms.room_code==3||rooms.room_code==7)&&(rooms.age_child1<1&&has_tag_age_children==1)){tipo="";Error[0]=1152;Error[1]=tipo}if((rooms.room_code==5)&&(has_tag_age_children==1&&(rooms.age_child1<1||rooms.age_child2<1))){Error[0]=1152}}return Error}function getCheckinDate(){if(typeof(document.get_country.checkin_date)!="undefined"){year=document.get_country.checkin_date.value.substring(6,10);month=document.get_country.checkin_date.value.substring(3,5);day=document.get_country.checkin_date.value.substring(0,2);checkin_date=new Date(year,month-1,day)}else{dia_inicio=document.get_country.checkin_day.value;if(typeof(document.get_country.checkin_month)!="undefined"){mes_inicio=document.get_country.checkin_month.value;anno_inicio=document.get_country.checkin_year.value}else{mes_inicio=document.get_country.check_in_month_year.value.substring(0,2);anno_inicio=document.get_country.check_in_month_year.value.substring(3,7)}checkin_date=new Date(anno_inicio,mes_inicio-1,dia_inicio);if(checkin_date.getDate()!=dia_inicio){checkin_date=0}}return checkin_date}function getCheckoutDate(){if(typeof(document.get_country.checkout_date)!="undefined"){year=document.get_country.checkout_date.value.substring(6,10);month=document.get_country.checkout_date.value.substring(3,5);day=document.get_country.checkout_date.value.substring(0,2);checkout_date=new Date(year,month-1,day)}else{dia_fin=document.get_country.checkout_day.value;if(typeof(document.get_country.checkout_month)!="undefined"){mes_fin=document.get_country.checkout_month.value;anno_fin=document.get_country.checkout_year.value}else{mes_fin=document.get_country.check_out_month_year.value.substring(0,2);anno_fin=document.get_country.check_out_month_year.value.substring(3,7)}checkout_date=new Date(anno_fin,mes_fin-1,dia_fin)}if(checkout_date.getDate()!=dia_fin){return 0}else{return checkout_date}}function getTodayDate(){current_date=new Date();current_date.setHours(0);current_date.setMinutes(0);current_date.setSeconds(0);return current_date}function validateTown(){var a=new Array(3);a[0]=0;if(typeof(document.get_country.coast_code)!="undefined"){if(document.get_country.coast_code.value==""){a[0]=582}}if(typeof(document.get_country.coast_code)=="undefined"){if(document.get_country.country_code.value=="-"){if(document.get_country.town.value==""&&document.get_country.location_code.value==""){a[0]=582}}}if(typeof(document.get_country.zone_code)!="undefined"){if(typeof(document.get_country.location_code)!="undefined"){if(document.get_country.location_code.value==""){a[0]=443}}}if(typeof(document.get_country.apartments)!="undefined"){if(document.get_country.location_code.value==""){a[0]=443}}if(typeof(document.get_country.town)!="undefined"){if(document.get_country.town.value==""){if(typeof(document.get_country.location_code)!="undefined"){}else{a[0]=426}}}if(document.get_country.zone_code.value>0){if(document.get_country.location_code.value==""){a[0]=443}}return a}function validateRooms(){var Error=new Array(3);Error[0]=0;formulario=document.get_country;rooms=new Array();for(x=0;x<3;x++){cadena="";if(x>0){cadena="_"+x}type_rooms=new Array();if(eval("formulario.num_rooms"+cadena)){type_rooms.num_rooms=eval("formulario.num_rooms"+cadena+".value");type_rooms.room_code=eval("formulario.room_code"+cadena+".value");type_rooms.age_child1=eval("formulario.age_child1"+cadena+".value");type_rooms.age_child2=eval("formulario.age_child2"+cadena+".value")}rooms[x]=type_rooms}encontrado=true;for(x=0;x<rooms.length;x++){if(rooms[x]["num_rooms"]!=0||rooms[x]["age_child1"]!=0||rooms[x]["age_child2"]!=0){if(encontrado==false){tipo=x+1;Error[0]=429;Error[1]=tipo}encontrado=true}else{encontrado=false}}if(Error[0]==0){if(rooms[0]["num_rooms"]==0){Error[0]=430}}if(Error[0]==0){for(x=0;x<rooms.length-1;x++){if(rooms[x]["num_rooms"]!=0){for(y=x+1;y<rooms.length;y++){if(rooms[y]["num_rooms"]>0&&rooms[x]["room_code"]==rooms[y]["room_code"]&&rooms[x]["age_child1"]==rooms[y]["age_child1"]&&rooms[x]["age_child2"]==rooms[y]["age_child2"]){tipo1=x+1;tipo2=y+1;Error[0]=431;Error[1]=tipo1;Error[2]=tipo2}}}}}if(Error[0]==0){for(x=0;x<rooms.length;x++){if(rooms[x]["num_rooms"]!=0&&rooms[x]["room_code"]==0){tipo=x+1;Error[0]=438;Error[1]=tipo}if((rooms[x]["room_code"]==1||rooms[x]["room_code"]==2||rooms[x]["room_code"]==6)&&(rooms[x]["age_child1"]!=0||rooms[x]["age_child2"]!=0)){tipo=x+1;Error[0]=435;Error[1]=tipo;datosOk=false}if((rooms[x]["room_code"]==3||rooms[x]["room_code"]==4||rooms[x]["room_code"]==7)&&rooms[x]["age_child1"]==0&&rooms[x]["age_child2"]!=0){tipo=x+1;Error[0]=436;Error[1]=tipo}if((rooms[x]["room_code"]==3||rooms[x]["room_code"]==7)&&(rooms[x]["age_child1"]<1)){tipo=x+1;Error[0]=1152;Error[1]=tipo}if((rooms[x]["room_code"]==5)&&(rooms[x]["age_child1"]<1||rooms[x]["age_child2"]<1)){tipo=x+1;Error[0]=1152;Error[1]=tipo}}}return Error}function validateGestor(){var a=new Array(3);a[0]=0;if(document.get_country.gestor_id!=null){gestor_id=document.get_country.gestor_id.value;if(gestor_id==""){a[0]=1;datosOk=false}}return a}function calculateDifference(b,c){var e=b.getTime()-c.getTime();var a=1000*60*60*24;var d=Math.round(e/a);return d}function changeNumNights(){checkout_date=new Date(document.get_country.check_out_month_year.value.substr(0,2)+"/"+document.get_country.checkout_day.value+"/"+document.get_country.check_out_month_year.value.substr(3,6));checkin_date=new Date(document.get_country.check_in_month_year.value.substr(0,2)+"/"+document.get_country.checkin_day.value+"/"+document.get_country.check_in_month_year.value.substr(3,6));num_nights=calculateDifference(checkout_date,checkin_date);document.get_country.num_nights.value=num_nights}function changeCheckOutDate(){num_nights=document.get_country.num_nights.value;checkout_date=new Date(document.get_country.check_in_month_year.value.substr(0,2)+"/"+document.get_country.checkin_day.value+"/"+document.get_country.check_in_month_year.value.substr(3,6)+" 01:00");checkout_date.setTime(checkout_date.getTime()+num_nights*1000*60*60*24);checkoutday=checkout_date.getDate();checkout=checkoutday.toString();lenday=checkout.length;if(lenday==1){checkout="0"+checkout}document.get_country.checkout_day.value=checkout;checkoutmonth=checkout_date.getMonth();checkoutmonth++;checkmonth=checkoutmonth.toString();if(checkmonth.length==1){checkmonth="0"+checkmonth}checkoutyear=checkout_date.getFullYear();document.get_country.check_out_month_year.value=checkmonth+"/"+checkoutyear}function getDaysInMonth(f){var a=new Number(f.getMonth());var e=new Number(f.getYear());var b=new Date(e,a,28);var c=b.getMonth();var d=27;while(d<=31){temp=b.setDate(d+1);if(c!=b.getMonth()){break}d++}return d}function upToDate(){var f=new Date();var b=1;var a=f.getDate();var e=f.getMonth();var c=f.getFullYear();f.setTime(f.getTime()+1*1000*60*60*24);checkinday=f.getDate();checkin=checkinday.toString();lenday=checkin.length;if(lenday==1){checkin="0"+checkin}document.get_country.checkin_day.value=checkin;checkinmonth=f.getMonth();checkinmonth++;checkmonth=checkinmonth.toString();if(checkmonth.length==1){checkmonth="0"+checkmonth}checkinyear=f.getFullYear();document.get_country.check_in_month_year.value=checkmonth+"/"+checkinyear;if(typeof(document.get_country.checkout_day)!="undefined"){checkout_date=new Date();checkout_date.setTime(checkout_date.getTime()+2*1000*60*60*24);checkoutday=checkout_date.getDate();checkout=checkoutday.toString();lenday=checkout.length;if(lenday==1){checkout="0"+checkout}document.get_country.checkout_day.value=checkout;checkoutmonth=checkout_date.getMonth();checkoutmonth++;checkmonth=checkoutmonth.toString();if(checkmonth.length==1){checkmonth="0"+checkmonth}checkoutyear=checkout_date.getFullYear();document.get_country.check_out_month_year.value=checkmonth+"/"+checkoutyear}}function updateCombos(){iForm=document.forms.get_country;iForm.elements.num_rooms_select.value=iForm.elements.num_rooms.value;iForm.elements.num_adults_select.value=iForm.elements.num_adults.value;iForm.elements.num_children_select.value=iForm.elements.num_children.value}function validateCombos(){iForm=document.forms.get_country;iForm.elements.num_rooms.value=iForm.elements.num_rooms_select.value;iForm.elements.num_adults.value=iForm.elements.num_adults_select.value;iForm.elements.num_children.value=iForm.elements.num_children_select.value};