// FUNCTIONS
function getLocationQS(thisformid){
	var hotelForm=document.forms[thisformid];
	var locstr=hotelForm.city.value;
	var locarr=locstr.split(",");
	var city=locarr[0];
	var state=locarr[1];
	var ihsstring="http://www.ihsadvantage.com/h/hotels/"+city+"/"+state+"/usa?pfs=2960&arrivalMonth="+hotelForm.arrivalMonth.value+"&arrivalDay="+hotelForm.arrivalDay.value+"&departureMonth="+hotelForm.departureMonth.value+"&departureDay="+hotelForm.departureDay.value+"&orderBy=4&showAvailWithList=true";
	location.href=ihsstring;		
}	

function todayQS(thisformid){
    var d=new Date();
    var hotelForm=document.forms[thisformid];
    hotelForm.arrivalMonth.value=parseInt(d.getMonth())+1;
    makeDaysQS("arrival",thisformid);
    hotelForm.arrivalDay.value=d.getDate();
}

function tomorrowQS(thisformid){
    var hotelForm=document.forms[thisformid];
    var dD=new Date();
    dD.setMonth(parseInt(hotelForm.arrivalMonth.value)-1);
    dD.setDate(parseInt(hotelForm.arrivalDay.value));
    var d=new Date();
    if (dD<d) dD.setFullYear(d.getFullYear()+1);
    dD.setDate(dD.getDate()+1);
    hotelForm.departureMonth.value=parseInt(dD.getMonth())+1;
    makeDaysQS("departure",thisformid);
    hotelForm.departureDay.value=dD.getDate();
}

function makeDaysQS(prefix,thisformid){
	var days=new Array("31","28","31","30","31","30","31","31","30","31","30","31");
    var d=new Date();
    var year=d.getFullYear();
    if ((d.getMonth())>1) year++;
    if ((year%4==0)&&((year%100!=0)||(year%400==0))) days[1]++; 

    var hotelForm=document.forms[thisformid];
    var what=prefix+"Month";
    var theseDays=hotelForm[what].selectedIndex;

    var what=prefix+"Day"; 
    // remove all
    while (hotelForm[what].length>0)
    {
    hotelForm[what].remove(hotelForm[what].length-1);
    }
    // add
    for (x=1;x<=days[theseDays];x++){
        var newDay=document.createElement('option');
        newDay.text=x;
        newDay.value=x;
        try {hotelForm[what].add(newDay,null);} catch(ex) {hotelForm[what].add(newDay);};
    };    
}