var filaMonth;
calendar = new Object();
tr = new Object();
var mesi=new Array();
var days=new Array();
function showCalendar (img, cal, dt, frm,m,y,d) {
if (document.getElementById) {
var c = document.getElementById(cal);
var i = document.getElementById(img);
var f = document.getElementById(frm);
calendar.calfrm = frm;
calendar.cal = c;
calendar.caldt = dt;
calendar.calf = f;
var my = f[dt + '_year_month'].value.split("-");
y=my[0];m=my[1];d=f[ dt + '_monthday'].value;
buildCal(y,m,d);
var l=0; var t=0;
aTag = i;
do {
aTag = aTag.offsetParent;
l += aTag.offsetLeft;
t += aTag.offsetTop;
} while (aTag.offsetParent && aTag.tagName != 'body');
// var left = (i.offsetParent.id!='avmenu' && i.offsetParent.className!='content_city_hotel' ? (i.offsetLeft + l-80) : (i.offsetLeft -80) ) ;
// var top = (i.offsetParent.id!='avmenu' && i.offsetParent.className!='content_city_hotel' ? (i.offsetTop + t + i.offsetHeight + 2) : (i.offsetTop+20) );
var left = i.offsetLeft -80;
var top = i.offsetTop +20;
// alert('i.offsetTop='+i.offsetTop+ ' t='+t+' i.offsetHeight='+i.offsetHeight+ 'l='+l );
c.style.position = "absolute";
c.style.left = left+'px';
c.style.top = top+'px';
c.style.display="block";
}
}
function closeCal() {
calendar.cal.style.display='none';
}
function buildCal(y,m,d){
var daysInMonth=[31,0,31,30,31,30,31,31,30,31,30,31];
td=new Date();
if (!y) y = td.getFullYear();
if (!m) m = td.getMonth()+1;
if (!d) d = td.getDate;
var frm = calendar.calfrm;
var dt = calendar.caldt;
var mDate = new Date(y, m-1, 1);
var firstMonthDay = mDate.getDay();
daysInMonth[1]=(((mDate.getFullYear()%100!=0) && (mDate.getFullYear()%4==0)) || (mDate.getFullYear()%400==0))?29:28;
var today = (y==td.getFullYear() && m==td.getMonth()+1)? td.getDate() : 0;
var t='
';
t+='';
for(dn=0;dn<7;dn++){
var cl = '';
if ((dn%7==5) || (dn%7 == 6)) cl += ' b_calWeekend';
t+=''+days[dn]+' ';
}
t+=' ';
for(i=1;i<=42;i++){
var x = i - (firstMonthDay+6)%7;
if (x > daysInMonth[m-1] || x <1) x = ' ';
var cl = '';
var href = 0;
if ((i%7==0) || (i%7 == 6)) cl += ' b_calWeekend';
if (x>0){
var xDay = new Date(y, m-1, x);
if ((xDay.getFullYear() == y) && (xDay.getMonth()+1 == m)
&& (xDay.getDate() == d))
{ cl += ' b_calSelected' ; href=1}
if ((xDay.getFullYear() == td.getFullYear())
&& (xDay.getMonth() == td.getMonth())
&& (xDay.getDate() == td.getDate()))
{ cl += ' b_calToday'; href=1;}
else {
if (xDay > td){ cl += ' b_calFuture'; href=1; }
else {
if (xDay < td) { cl += ' b_calPast'}
}
}
};
t+='';
if (href){
t+=''+x+' ';
} else {
t+=x;
}
t+=' ';
if(((i)%7==0)&&(i<36)) {
t+=' ';
}
}
t+=' ' + tr.closeCalendar + '
';
document.getElementById("b_calendarInner").innerHTML= t;
}
function prevMonth(y,m) {
if (new Date(y,m-1,1) < td) return;
if (m > 1) {m--} else {m = 12; y--};
buildCal(y,m);
}
function nextMonth(y,m) {
// if ((new Date(y,m-1,1) - td) > 1000*3600*24*300) return;
if (m<12){m++;} else {m=1;y++;}
if (y > td.getFullYear() && m >= td.getMonth() ) return;
buildCal(y,m);
}
function goMonth(m){
var y = td.getFullYear();
if (m < td.getMonth()+1) y++;
buildCal(y,m);
}
function pickDate(y,m,d,dt,frm){
// set form values
var f = calendar.calf;
var dt = calendar.caldt;
f[dt + '_year_month'].value = y + "-" + padZero(m);
f[dt + '_monthday'].value = padZero(d);
if (dt == "checkin"){
checkDateOrder(calendar.calfrm, 'checkin_monthday', 'checkin_year_month', 'checkout_monthday', 'checkout_year_month');
}
closeCal();
}
function checkDateOrder(frm, ci_day, ci_month_year, co_day, co_month_year) {
if (document.getElementById) {
var frm = document.getElementById(frm);
// create date object from checkin values
// set date to 12:00 to avoid problems with one
// date being wintertime and the other summertime
var my = frm[ci_month_year].value.split("-");
var ci = new Date (my[0], my[1]-1, frm[ci_day].value, 12, 0, 0, 0);
// create date object from checkout values
my = frm[co_month_year].value.split("-");
var co = new Date (my[0], my[1]-1, frm[co_day].value, 12, 0, 0, 0);
// if checkin date is at or after checkout date,
// add a day full of milliseconds, and set the
// selectbox values for checkout date to new value
if (ci >= co){
co.setTime(ci.getTime() + 1000 * 60 * 60 * 24);
frm[co_day].value = padZero(co.getDate());
var com = co.getMonth()*1.+1;
frm[co_month_year].value = co.getFullYear() + "-" + padZero(com);
}
}
}
var months = new Array();
function setCalLang(lan){
if(lan=='it'){
if (typeof(err_wrong_ci_date) != 'string') {
err_wrong_ci_date = 'La data di partenza inserita non e\' valida';
}
if (typeof(err_wrong_co_date) != 'string') {
err_wrong_co_date = 'La data di arrivo inserita non e\' valida';
}
if (typeof(err_wrong_ci_90max) != 'string') {
err_wrong_ci_90max = 'La durata massima del soggiorno non puo\' superare i 90 giorni';
}
if (typeof(err_co_before_ci) != 'string') {
err_co_before_ci = 'La data di partenza deve essere precedente a quella di arrivo';
}
months = new Array( "GEN", "FEB", "MAR", "APR", "MAG", "GIU", "LUG", "AGO", "SET", "OTT", "NOV", "DIC" );
mesi = ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'];
days = ['Lu','Ma','Me','Gi','Ve','Sa','Do'];
tr.nextMonth = "Mese successivo";
tr.prevMonth = "Mese precedente";
tr.closeCalendar = "Chiudi calendario";
}else if(lan=='de'){
if (typeof(err_wrong_ci_date) != 'string') {
err_wrong_ci_date = 'Der angegebene Anreisetag ist ungültig.';
}
if (typeof(err_wrong_co_date) != 'string') {
err_wrong_co_date = 'Der angegebene Abreisetag ist ungültig.';
}
if (typeof(err_wrong_ci_90max) != 'string') {
err_wrong_ci_90max = 'Der Aufenthalt kann höchstens 90 Tage dauern.';
}
if (typeof(err_co_before_ci) != 'string') {
err_co_before_ci = 'Der Anreisetag muss vor dem Abreisetag liegen.';
}
months = new Array( "JAN", "FEB", "MAR", "APR", "MAI", "JUN", "JUL", "AUG", "SEP", "OKT", "NOV", "DEZ" );
tr.nextMonth = "Nächster Monat";
tr.prevMonth = "Voriger Monat";
tr.closeCalendar = "Kalender schließen";
mesi = ['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'];
days = ['Mo','Di','Mi','Do','Fr','Sa','So'];
}else if(lan=='es'){
if (typeof(err_wrong_ci_date) != 'string') {
err_wrong_ci_date = 'La fecha de llegada insertada no es válida.';
}
if (typeof(err_wrong_co_date) != 'string') {
err_wrong_co_date = 'La fecha de salida no es válida.';
}
if (typeof(err_wrong_ci_90max) != 'string') {
err_wrong_ci_90max = 'El tiempo de permanencia no puede superar los 90 días.';
}
if (typeof(err_co_before_ci) != 'string') {
err_co_before_ci = 'La fecha de llegada tiene que ser anterior a la fecha de salida.';
}
months = new Array( "ENE", "FEB", "MAR", "ABR", "MAY", "JUN", "JUL", "AGO", "SEP", "OCT", "NOV", "DIC" );
tr.nextMonth = "Mes siguiente";
tr.prevMonth = "Mes anterior";
tr.closeCalendar = "Cerrar calendario";
mesi = ['enero','febrero','marzo','abril','mayo','junio','julio','agosto','septiembre','octubre','noviembre','diciembre'];
days = ['lu','ma','mi','ju','vi','sa','do'];
}
else if(lan=='fr'){
if (typeof(err_wrong_ci_date) != 'string') {
err_wrong_ci_date = 'La date d\'arrivéé insérée n\'est pas valide.';
}
if (typeof(err_wrong_co_date) != 'string') {
err_wrong_co_date = 'La date de départ insérée n\'est pas valide.';
}
if (typeof(err_wrong_ci_90max) != 'string') {
err_wrong_ci_90max = 'La durée du séjour ne peut pas dépasser 90 jours.';
}
if (typeof(err_co_before_ci) != 'string') {
err_co_before_ci = 'La date d\'arrivée doit être antérieure à la date de départ.';
}
months = new Array( "ENE", "FEV", "MAR", "AVR", "MAI", "JUN", "JUL", "AOU", "SEP", "OCT", "NOV", "DEC" );
tr.nextMonth = "Mois suivant";
tr.prevMonth = "Mois précédent";
tr.closeCalendar = "Fermer le calendrier";
mesi = ['janvier','février','mars','avril','mai','juin','juillet','août','septembre','octobre','novembre','décembre'];
days = ['lu','ma','me','je','ve','sa','di'];
}
else if(lan=='zh'){
if (typeof(err_wrong_ci_date) != 'string') {
err_wrong_ci_date = '你输入的入住日期无效。';
}
if (typeof(err_wrong_co_date) != 'string') {
err_wrong_co_date = '你输入的离店日期无效。';
}
if (typeof(err_wrong_ci_90max) != 'string') {
err_wrong_ci_90max = 'The maximum length of your stay cannot exceed 90 days.';
}
if (typeof(err_co_before_ci) != 'string') {
err_co_before_ci = 'The check-in date must be before the check-out date.';
}
months = new Array( "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月" );
tr.nextMonth = "下个月";
tr.prevMonth = "上个月";
tr.closeCalendar = "关闭日历";
mesi = ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'];
days = ['Mo','Tu','We','Th','Fr','Sa','Su'];
}else if (lan=='ro'){
if (typeof(err_wrong_ci_date) != 'string') {
err_wrong_ci_date = 'The check-in date you entered is not valid.';
}
if (typeof(err_wrong_co_date) != 'string') {
err_wrong_co_date = 'The check-out date you entered is not valid.';
}
if (typeof(err_wrong_ci_90max) != 'string') {
err_wrong_ci_90max = 'The maximum length of your stay cannot exceed 90 days.';
}
if (typeof(err_co_before_ci) != 'string') {
err_co_before_ci = 'The check-in date must be before the check-out date.';
}
months = new Array( "IAN", "FEB", "MAR", "APR", "MAI", "IUN", "JUL", "AUG", "SEP", "OCT", "NOI", "DEC" );
tr.nextMonth = "Luna următoare";
tr.prevMonth = " Luna anterioară";
tr.closeCalendar = "închide calendar";
mesi = ['Ianuarie','Februarie','Martie','Aprilie','Mai','Iunie','Iulie','August','Septembrie','Octombrie','Noiembrie','Decembrie'];
days = ['Lu','Ma','Mi','Jo','Vi','Sâ','Du'];
}
else{
if (typeof(err_wrong_ci_date) != 'string') {
err_wrong_ci_date = 'The check-in date you entered is not valid.';
}
if (typeof(err_wrong_co_date) != 'string') {
err_wrong_co_date = 'The check-out date you entered is not valid.';
}
if (typeof(err_wrong_ci_90max) != 'string') {
err_wrong_ci_90max = 'The maximum length of your stay cannot exceed 90 days.';
}
if (typeof(err_co_before_ci) != 'string') {
err_co_before_ci = 'The check-in date must be before the check-out date.';
}
months = new Array( "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" );
tr.nextMonth = "Next month";
tr.prevMonth = "Previous month";
tr.closeCalendar = "Close calendar";
mesi = ['January','February','March','April','May','June','July','August','September','October','November','December'];
days = ['Mo','Tu','We','Th','Fr','Sa','Su'];
}
}
function CheckDate(myf) {
var frm = document.myf;
return _CheckDate(frm)
}
function _CheckDate(myf) {
var today = new Date();
var day = today.getDate();
var month = today.getMonth() + 1 ;
var year = today.getFullYear();
if(!myf)
myf = document.vSearch;
sel_sd = myf.checkin_monthday;
sel_smy = myf.checkin_year_month;
sel_ed = myf.checkout_monthday;
sel_emy = myf.checkout_year_month;
sel_pval = myf.pval;
sel_rval = myf.rval;
if(!((sel_sd.selectedIndex ==0)&&(sel_smy.selectedIndex ==0)&&(sel_ed.selectedIndex ==0)&&(sel_emy.selectedIndex ==0)&& sel_pval != null && (sel_pval.selectedIndex ==0)&&(sel_rval.selectedIndex ==0)))
{
//check-in
var start_day = sel_sd.value;
var tmp_smy = new String(sel_smy.value).split('-');
var start_month = new Number(tmp_smy[1]);
var start_year = new Number(tmp_smy[0]);
var mysd = sel_sd.selectedIndex;
var mysm = tmp_smy[1];
var mysy = tmp_smy[0];
//check-out
var end_day = sel_ed.value;
var tmp_emy = new String(sel_emy.value).split('-');
var end_month = new Number(tmp_emy[1]);
var end_year = new Number(tmp_emy[0]);
var myed = sel_ed.selectedIndex;
var myem = tmp_emy[1];
var myey = tmp_emy[0];
//no check-in
if (mysd == 0 || sel_smy.selectedIndex == 0) {
alert(err_wrong_ci_date);
return false;
}
//no check-out
if (myed == 0 || sel_emy.selectedIndex == 0) {
alert(err_wrong_co_date);
return false;
}
//check-in wrong date
if ( (start_day == 31 && ((start_month == 4) || (start_month == 6) || (start_month == 9) || (start_month == 11)))
|| ((start_day > 29) && (start_month == 2))
|| ((start_year %4 != 0) && (start_month == 2) && (start_day > 28))) {
alert(err_wrong_ci_date);
return false;
}
if (start_month == month && start_year == year && start_day < day){ //check-in before today
alert(err_wrong_ci_date);
return false;
}
//check-out wrong date
if ( (end_day == 31) && ((end_month == 4) || (end_month == 6) || (end_month == 9) || (end_month == 11))
|| ((end_day > 29) && (end_month == 2))
|| ((end_year %4 != 0) && (end_month == 2) && (end_day > 28))) {
alert(err_wrong_co_date);
return false;
}
// extra check on start - end date range
var startDate = new Date(start_year, start_month-1, start_day);
var endDate = new Date(end_year,end_month-1,end_day);
var maxDelta = 90 * 24 * 3600 * 1000; // 3 months
if( endDate.getTime() - startDate.getTime() > maxDelta ) { //max 3 month reservation
alert(err_wrong_ci_90max);
return false;
} else if( endDate.getTime() - startDate.getTime() <= 0 ) { //check-out date before check-in date
alert(err_co_before_ci);
return false;
}
//set html select values
myf.sd.value = start_day;
myf.sm.value = mysm;
myf.sy.value = mysy;
myf.ed.value = end_day;
myf.em.value = myem;
myf.ey.value = myey;
return true;
}
return true;
}
function clearAll( form ) {
form.checkin_monthday.selectedIndex = 0;
form.checkin_year_month.selectedIndex = 0;
form.checkout_monthday.selectedIndex = 0;
form.checkout_year_month.selectedIndex = 0;
form.pval.selectedIndex = 0;
form.rval.selectedIndex = 0;
}
function checkSelNum( cb ) {
if( cb != null && cb.selectedIndex == 0 ) { clearAll(cb.form); return true; }
}
function StartDateCheck( cb ) {
// disabilita il controllo
return;
if( cb != null && cb.selectedIndex == 0 ) { clearAll(cb.form); return true; }
var myf = !cb ? document.vSearch : cb.form;
if(!myf) myf = document.vSearch;
var today = new Date();
var day = today.getDate();
var month = today.getMonth() + 1 ;
var year = today.getFullYear();
var mysd = myf.checkin_monthday.selectedIndex;
if (mysd == 0) { return true; }
var tmp = myf.checkin_year_month.selectedIndex;
if (tmp == 0) { return true; }
var smy = new String(myf.checkin_year_month[tmp].value).split('/');
var mysm = new Number(smy[0]);
var mysy = new Number(smy[1]);
if (mysd == 31) {
if ((mysm == 4) || (mysm == 6) || (mysm == 9) || (mysm == 11)) mysd = 30;
}
if ((mysd > 29) && (mysm == 2)) mysd = 29;
if ((mysy %4 != 0) && (mysm == 2) && (mysd > 28)) mysd = 28;
//bug 2396
if (mysm == month && mysy == year){
if (mysd < day)
mysd = day
}// end bug 2396
myf.checkin_monthday.selectedIndex = mysd;
var myed = mysd + 1;
var myem = mysm;
var myey = mysy;
if (myed > 31) myed = -1;
if (myed == 31) {
if ((myem == 4) || (myem == 6) || (myem == 9) || (myem == 11)) myed = -1;
}
if ((myed > 29) && (myem == 2)) myed = -1;
if ((myey %4 != 0) && (myem == 2) && (myed > 28)) myed = -1;
if (myed == -1) { myed = 1; tmp = tmp + 1; }
if (tmp >= myf.checkout_year_month.options.length) {
myed = myf.checkin_monthday.selectedIndex
tmp = myf.checkin_year_month.selectedIndex;
}
if( myf.checkout_monthday.selectedIndex == 0 && myf.checkout_year_month.selectedIndex == 0 )
{
myf.checkout_monthday.selectedIndex = myed;
myf.checkout_year_month.selectedIndex = tmp;
}
}
function EndDateCheck( cb ) {
// disabilita il controllo
return;
if( cb != null && cb.selectedIndex == 0 ) { clearAll(cb.form); return true; }
var today = new Date();
var day = today.getDate();
var month = today.get = today.getMonth() + 1 ;
var year = today.getFullYear();
if(!cb)
myf = document.vSearch;
else
myf = cb.form;
if(!myf) myf = document.vSearch;
myed = myf.checkout_monthday.selectedIndex;
if (myed == 0) return true;
tmp = myf.checkout_year_month.selectedIndex;
if (tmp == 0) return true;
var emy = new String(myf.checkout_year_month[tmp].value).split('/');
var myem = new Number(emy[0]);
var myey = new Number(emy[1]);
if (myed == 31) {
if ((myem == 4) || (myem == 6) || (myem == 9) || (myem == 11)) myed = 30;
}
if ((myed > 29) && (myem == 2)) myed = 29;
if ((myey %4 != 0) && (myem == 2) && (myed > 28)) myed = 28;
if (myem == month && myey == year){
if (myed < day)
myed = day
}
// extra check on start - end date range
var smy = new String(myf.checkin_year_month.value).split('/');
var sm = new Number(smy[0]);
var sy = new Number(smy[1]);
var sd = myf.checkin_monthday.value;
var startDate = new Date(sy,sm-1,sd);
var endDate = new Date(myey,myem-1,myed);
var maxDelta = 90 * 24 * 3600 * 1000; // 3 months
if( endDate.getTime() - startDate.getTime() > maxDelta ) { //max 3 month reservation
endDate.setTime( startDate.getTime()+maxDelta );
myed = String(endDate.getDate()); while( myed.length < 2 ) myed = String("0") + myed;
myem = String(endDate.getMonth()+1); while( myem.length < 2 ) myem = String("0") + myem;
myey = String(endDate.getFullYear());
// reset month / year combo box
myf.checkout_year_month.value = String(myem) + "/" + myey;
}
myf.checkout_monthday.selectedIndex = myed;
}
function CheckSearchForm(form) {
sel_sd = myf.checkin_monthday.selectedIndex;
sel_smy = myf.checkin_year_month.selectedIndex;
sel_ed = myf.checkout_monthday.selectedIndex;
sel_emy = myf.checkout_year_month.selectedIndex;
sel_pval = myf.pval.selectedIndex;
sel_rval = myf.rval.selectedIndex;
}
function getArgs() {
var args = new Object();
var query = location.search.substring(1);
var pairs = query.split("&");
for(var i = 0; i < pairs.length; i++)
{
var pos = pairs[i].indexOf('=');
if (pos == -1) continue;
var argname = pairs[i].substring(0,pos);
var value = pairs[i].substring(pos+1);
args[argname] = value;
}
return args;
}
function padZero( i ) {
var result = String(i);
while( result.length < 2 ) result = String(0) + result;
return result;
}
function renderOptions(month,lan) {
//alert(' lan='+lan);
if(!lan){
setCalLang('en');
}else{
setCalLang(lan);
}
var now = new Date();
var result = "--- ";
for( i = now.getMonth(); i < 12 + now.getMonth(); i++ ) {
var m = i % 12 +1;
var y = now.getFullYear() + Math.floor(i / 12);
var sel=(month==m ? ' selected ' : '');
// result += "" + months[m-1]+" "+ y + " ";
result += "" + months[m-1]+" "+ y + " ";
}
return result;
}
function set_hidden() {
gd= window.document.vSearch.checkin_monthday.value;
window.document.vSearch.sd.value=gd;
gx= window.document.vSearch.checkin_year_month.value;
gy=gx.substring(0,4); // anno di ci
gm=gx.substring(5,7); // mese di ci
window.document.vSearch.sm.value=gm;
window.document.vSearch.sy.value=gy;
gd1= window.document.vSearch.checkout_monthday.value;
window.document.vSearch.ed.value=gd1;
gx1= window.document.vSearch.checkout_year_month.value;
gy1=gx1.substring(0,4); // anno di co
gm1=gx1.substring(5,7); // mese di co
window.document.vSearch.em.value=gm1;
window.document.vSearch.ey.value=gy1;
}