var monthNames= new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var daysPerMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31);


var checkInDatelink = new CalendarPopup();
checkInDatelink.setReturnFunction("setMultipleValues");


function setMultipleValues(y,m,d) {
displayYear=y-2000;
document.forms[0].p_ayear.value="0"+ displayYear;
document.forms[0].p_dyear.value="0"+ displayYear;

document.forms[0].p_amonth.value=m;
document.forms[0].p_aday.value=d;

if(m==12){
displayYear=y-1999;
document.forms[0].p_dyear.value="0"+ displayYear;
}


future();
}


var checkOutDatelink = new CalendarPopup();
checkOutDatelink.setReturnFunction("setMultipleValues2");

function setMultipleValues2(y,m,d) {

displayYear=y-2000;
document.forms[0].p_dyear.value="0"+ displayYear;
document.forms[0].p_dmonth.value=m;
document.forms[0].p_dday.value=d;
hdate();
}	


function retrieveDate(){
today_date= new Date();
myMonth=today_date.getMonth();
myDate=today_date.getDate();
totalDays=daysPerMonth[myMonth];
myYear=today_date.getYear();
if(myYear<1900){
myYear+=1900;
}
document.forms[0].p_amonth.value=myMonth+1;
days();
document.forms[0].p_aday.options.selectedIndex=myDate-1;
displayYear=myYear-2000;
document.forms[0].p_dyear.options[0].text="0"+displayYear;
document.forms[0].p_ayear.options[0].text="0"+displayYear;
document.forms[0].p_dyear.options[0].value="0"+displayYear;
document.forms[0].p_ayear.options[0].value="0"+displayYear;
displayYear++
document.forms[0].p_dyear.options[1].text="0"+displayYear;
document.forms[0].p_ayear.options[1].text="0"+displayYear;
document.forms[0].p_dyear.options[1].value="0"+displayYear;
document.forms[0].p_ayear.options[1].value="0"+displayYear;
future();
hdate();
}


function future(){
var tday=document.forms[0].p_aday.value;
var tmonth=document.forms[0].p_amonth.value;
var tmonth1=document.forms[0].p_amonth.value-1;
var dpm=daysPerMonth[tmonth1]
if(tday>=dpm){tday='0';
var tmonth=eval(parseInt(tmonth) + 1);
if(tmonth==13){tmonth=1; }
} 
var nday=eval(parseInt(tday) + 1 );
document.forms[0].p_dday.value=nday
document.forms[0].p_dmonth.value=tmonth;


days()
hdate()
}
function days(){
var tmonth=document.forms[0].p_amonth.value-1;
var dpm=daysPerMonth[tmonth]
for(x=1;x<=dpm;x++){
var y=eval(x - 1);
document.forms[0].p_aday.options[y].value=x;
document.forms[0].p_aday.options[y].text=x;
}
for(j=x;j<=31;j++){
var y=eval(j - 1);
document.forms[0].p_aday.options[j].value="";
document.forms[0].p_aday.options[j].text="";
}
days2()
}

function days2(){
var tmonth=document.forms[0].p_dmonth.value-1;
var dpm=daysPerMonth[tmonth]
for(x=1;x<=dpm;x++){
var y=eval(x - 1);
document.forms[0].p_dday.options[y].value=x;
document.forms[0].p_dday.options[y].text=x;
}
for(j=x;j<=31;j++){
var y=eval(j - 1);
document.forms[0].p_dday.options[y].value="";
document.forms[0].p_dday.options[y].text="";
}
}

function hdate(){
document.theForm.checkInDate.value=document.forms[0].p_amonth.value + "/" + document.forms[0].p_aday.value
document.theForm.checkOutDate.value=document.forms[0].p_dmonth.value + "/" + document.forms[0].p_dday.value
}

document.write(getCalendarStyles());
