lingua="IT";GiornoDellaSettimana=new Array("Dom","Lun","Mar","Mer","Gio","Ven","Sab");NomeDelMese=new Array("Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre");GiornoDellaSettimanaEN=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");NomeDelMeseEN=new Array("January","February","March","April","May","June","July","August","September","October","November","December");function FixYear(anno){if(anno<200)return anno+1900;else return anno}function WeekDay(anno,mese,giorno){var data1=new Date(anno,mese,giorno);if(lingua=="IT")return GiornoDellaSettimana[data1.getDay()];else return GiornoDellaSettimanaEN[data1.getDay()]}function nomeMese(mese){if(lingua=="IT")return NomeDelMese[mese];else return NomeDelMeseEN[mese]}function DaysInMonth(WhichMonth,WhichYear){var DaysInMonth=31;if(WhichMonth==3||WhichMonth==5||WhichMonth==8||WhichMonth==10)DaysInMonth=30;if(WhichMonth==1){if((WhichYear%4==0&&WhichYear%100!=0)||WhichYear%400==0||WhichYear==0)DaysInMonth=29;else DaysInMonth=28}return DaysInMonth}function numMese(NomeMese){if(NomeMese=="Gennaio")return 0;else if(NomeMese=="Febbraio")return 1;else if(NomeMese=="Marzo")return 2;else if(NomeMese=="Aprile")return 3;else if(NomeMese=="Maggio")return 4;else if(NomeMese=="Giugno")return 5;else if(NomeMese=="Luglio")return 6;else if(NomeMese=="Agosto")return 7;else if(NomeMese=="Settembre")return 8;else if(NomeMese=="Ottobre")return 9;else if(NomeMese=="Novembre")return 10;else if(NomeMese=="Dicembre")return 11;else if(NomeMese=="January")return 0;else if(NomeMese=="February")return 1;else if(NomeMese=="March")return 2;else if(NomeMese=="April")return 3;else if(NomeMese=="May")return 4;else if(NomeMese=="June")return 5;else if(NomeMese=="July")return 6;else if(NomeMese=="August")return 7;else if(NomeMese=="September")return 8;else if(NomeMese=="October")return 9;else if(NomeMese=="November")return 10;else if(NomeMese=="December")return 11}function ChangeCheckinMese(){if(!document.getElementById('sd'))return false;if(document.getElementById('sd').options.length>0){GiornoSel=document.getElementById('sd').options[document.getElementById('sd').selectedIndex].text;nGiornoSel=parseInt(GiornoSel.substring(GiornoSel.length-2))}else nGiornoSel=1;document.getElementById('sd').options.length=0;NomeMese=document.getElementById('sm').options[document.getElementById('sm').selectedIndex].text;Anno=2000+parseInt(NomeMese.substring(NomeMese.length-2,NomeMese.length),10);nMese=numMese(NomeMese.substring(0,NomeMese.length-4));var now=new Date();dagiorno=1;if(parseInt(now.getMonth())==parseInt(nMese)&&parseInt(FixYear(now.getYear()))==parseInt(Anno))dagiorno=now.getDate();if(nGiornoSel==31&&Anno==FixYear(now.getYear())+1)nGiornoSel=30;for(i=dagiorno;i<=DaysInMonth(nMese,Anno);i++){var anOption=document.createElement("option");anOption.value=i;anOption.text=WeekDay(Anno,nMese,i)+" "+i;if(i==nGiornoSel){anOption.selected=true;anOption.defaultSelected=true}document.getElementById("sd").options.add(anOption)}CaricaCheckout()}function ChangeCheckinGiorno(){SelNomeMese=document.getElementById('sm').options[document.getElementById('sm').selectedIndex].text;var now=new Date();if(document.getElementById('sd').selectedIndex==document.getElementById('sd').length-1&&document.getElementById('sm').selectedIndex==document.getElementById('sm').length-1){document.getElementById('sd').selectedIndex=document.getElementById('sd').selectedIndex-1}checkin=new Date(parseInt(SelNomeMese.substring(SelNomeMese.length-2),10)+2000,parseInt(numMese(SelNomeMese.substring(0,SelNomeMese.length-4))),parseInt(document.getElementById('sd').options[document.getElementById('sd').selectedIndex].value));checkout=new Date(parseInt(SelNomeMese.substring(SelNomeMese.length-2),10)+2000,parseInt(numMese(SelNomeMese.substring(0,SelNomeMese.length-4))),parseInt(document.getElementById('sd').options[document.getElementById('sd').selectedIndex].value)+1);nUltimoMese=now.getMonth();nUltimoAnno=FixYear(now.getYear())+1;fine=nUltimoAnno*100+nUltimoMese;nMese=checkout.getMonth();Anno=FixYear(checkout.getYear());i=Anno*100+nMese;document.getElementById("em").options.length=0;while(i<fine){var anOption=document.createElement("option");anOption.value=(nMese+1)+"-"+Anno;anOption.text=nomeMese(nMese)+" '"+Anno.toString().substring(2);document.getElementById("em").options.add(anOption);nMese++;if(nMese==12){nMese=0;Anno++}i=Anno*100+nMese}CaricaCheckout()}function ChangeCheckoutMese(){now=new Date();SelNomeMese=document.getElementById('sm').options[document.getElementById('sm').selectedIndex].text;checkin=new Date(parseInt(SelNomeMese.substring(SelNomeMese.length-2),10)+2000,parseInt(numMese(SelNomeMese.substring(0,SelNomeMese.length-4))),parseInt(document.getElementById('sd').options[document.getElementById('sd').selectedIndex].value));SelNomeMese=document.getElementById('em').options[document.getElementById('em').selectedIndex].text;checkout=new Date(parseInt(SelNomeMese.substring(SelNomeMese.length-2),10)+2000,parseInt(numMese(SelNomeMese.substring(0,SelNomeMese.length-4))),parseInt(document.getElementById('ed').options[document.getElementById('ed').selectedIndex].value));if(checkout.getMonth()!==parseInt(numMese(SelNomeMese.substring(0,SelNomeMese.length-4)))){checkout=new Date(parseInt(SelNomeMese.substring(SelNomeMese.length-2),10)+2000,parseInt(numMese(SelNomeMese.substring(0,SelNomeMese.length-4))),1)}nMese=checkout.getMonth();Anno=FixYear(checkout.getYear());document.getElementById("ed").options.length=0;inizio=1;if(checkout.getMonth()==checkin.getMonth())inizio=checkin.getDate()+1;for(i=inizio;i<=DaysInMonth(checkout.getMonth(),FixYear(checkout.getYear()));i++){var anOption=document.createElement("option");anOption.value=i;anOption.text=WeekDay(Anno,nMese,i)+" "+i;if(i==checkout.getDate()){anOption.selected=true;anOption.defaultSelected=true}document.getElementById("ed").options.add(anOption)}};function CaricaCheckout(){SelNomeMese=document.getElementById('sm').options[document.getElementById('sm').selectedIndex].text;var now=new Date();if(document.getElementById('sd').selectedIndex==document.getElementById('sd').length-1&&document.getElementById('sm').selectedIndex==document.getElementById('sm').length-1){document.getElementById('sd').selectedIndex=document.getElementById('sd').selectedIndex-1}checkin=new Date(parseInt(SelNomeMese.substring(SelNomeMese.length-2),10)+2000,parseInt(numMese(SelNomeMese.substring(0,SelNomeMese.length-4))),parseInt(document.getElementById('sd').options[document.getElementById('sd').selectedIndex].value));if(parseInt(document.getElementById('sd').options[document.getElementById('sd').selectedIndex].value)==DaysInMonth(parseInt(numMese(SelNomeMese.substring(0,SelNomeMese.length-4))),parseInt(SelNomeMese.substring(SelNomeMese.length-2),10)+2000)){month_add=parseInt(numMese(SelNomeMese.substring(0,SelNomeMese.length-4)))==12?1:parseInt(numMese(SelNomeMese.substring(0,SelNomeMese.length-4)))+1;year_add=parseInt(SelNomeMese.substring(SelNomeMese.length-2),10)+2000+(parseInt(numMese(SelNomeMese.substring(0,SelNomeMese.length-4)))==12?1:0);day_add=1;checkout=new Date(year_add,month_add,day_add)}else{checkout=new Date(parseInt(SelNomeMese.substring(SelNomeMese.length-2),10)+2000,parseInt(numMese(SelNomeMese.substring(0,SelNomeMese.length-4))),parseInt(document.getElementById('sd').options[document.getElementById('sd').selectedIndex].value)+1)}nUltimoMese=now.getMonth();nUltimoAnno=FixYear(now.getYear())+1;fine=nUltimoAnno*100+nUltimoMese;document.getElementById("em").options.length=0;nMese=checkout.getMonth();Anno=FixYear(checkout.getYear());i=Anno*100+nMese;while(i<fine){var anOption=document.createElement("option");anOption.value=(nMese+1)+"-"+Anno;anOption.text=nomeMese(nMese)+" '"+Anno.toString().substring(2);document.getElementById("em").options.add(anOption);nMese++;if(nMese==12){nMese=0;Anno++}i=Anno*100+nMese}Anno=FixYear(checkout.getYear());nMese=checkout.getMonth();document.getElementById("ed").options.length=0;for(i=checkout.getDate();i<=DaysInMonth(checkout.getMonth(),FixYear(checkout.getYear()));i++){var anOption=document.createElement("option");anOption.value=i;anOption.text=WeekDay(Anno,nMese,i)+" "+i;if(i==checkout.getDate()){anOption.selected=true;anOption.defaultSelected=true}document.getElementById("ed").options.add(anOption)}}function ControlloForm1(Form){nPosti=0;errore=false;num=0;for(i=0;i<Form.elements.length;i++){ele=Form.elements[i];if(ele.name&&ele.name.substr(0,6)=="stanza"&&parseInt(ele.value)>0)nPosti+=parseInt(ele.value)}if(errore){if(lingua=="IT")alert('Formato non valido. Inserire solo valori numerici, grazie.');else alert('Invalid format. Please insert only numbers.');return false}else if(nPosti==0){if(lingua=="IT")alert('Selezionare almeno una camera.');else alert('Select a room please.');return false}else return true}function trim(stringa){while(stringa.substring(0,1)==' '){stringa=stringa.substring(1,stringa.length)}while(stringa.substring(stringa.length-1,stringa.length)==' '){stringa=stringa.substring(0,stringa.length-1)}if(stringa=="")return"0";return stringa}function ControllaFormato(stringa){errore=false;if(stringa.length==0)errore=true;for(i=0;i<stringa.length;i++){car=stringa.substring(i,i+1);if(car!=="0"&&car!=="1"&&car!=="2"&&car!=="3"&&car!=="4"&&car!=="5"&&car!=="6"&&car!="7"&&car!=="8"&&car!=="9"){errore=true}}return!errore}function Ingrandisci(img){document.getElementById('ingrandimento').src=img;return false};function selIn(giorno){var j=giorno.split("-");j[1]=j[1].replace(/^[0]+/g,"");j[0]=j[0].replace(/^[0]+/g,"");ob=document.getElementById('sm');for(i=0;i<ob.length;i++){if(ob.options[i].value==parseInt(j[1])+"-"+j[2])ob.selectedIndex=i}ChangeCheckinMese();ob=document.getElementById('sd');for(i=0;i<ob.length;i++){if(ob.options[i].value==parseInt(j[0]))ob.selectedIndex=i}}function selOut(giorno){var j=giorno.split("-");j[1]=j[1].replace(/^[0]+/g,"");j[0]=j[0].replace(/^[0]+/g,"");ob=document.getElementById('em');for(i=0;i<ob.length;i++){if(ob.options[i].value==parseInt(j[1])+"-"+j[2])ob.selectedIndex=i}ChangeCheckoutMese();ob=document.getElementById('ed');for(i=0;i<ob.length;i++){if(ob.options[i].value==parseInt(j[0]))ob.selectedIndex=i}}function NumericOnly(v){return v.replace(/\D/g,'')}
