
var length;
	var dom=getObj
function getObj(objID)
{
    if (document.getElementById)
    {
        return document.getElementById(objID);
    }
	else
	    if (document.all)
	    {
	        return document.all[objID];
	    }
	    else
	        if (document.layers)
	        {
	            return document.layers[objID];
	        }
}
function SetMonth()
{	
    SMcurrdate = new Date();
    
    SMcurrdate.setDate(SMcurrdate.getDate());
    var month=new Array(12)
    month[0]="January"
    month[1]="February"
    month[2]="March"
    month[3]="April"
    month[4]="May"
    month[5]="June"
    month[6]="July"
    month[7]="August"
    month[8]="September"
    month[9]="October"
    month[10]="November"
    month[11]="December"
    
    var SMmonth=0;




	var monthyear="";
	var ddlvalue=""

	SMmonth=SMcurrdate.getMonth();
	SMyear=SMcurrdate.getYear();

	for(i=SMmonth;i<12;i++)
	{
	    var optionObject1=new Option(month[i]+", "+SMyear)
	    var optionObject2=new Option(month[i]+", "+SMyear)
	  
	    var optionRank1 = document.selectHotelForm.arrivalMonthYear.options.length
	    var optionRank2 = document.selectHotelForm.departureMonthYear.options.length
	    
	    document.selectHotelForm.arrivalMonthYear.options[optionRank1]=optionObject1
	    document.selectHotelForm.departureMonthYear.options[optionRank2]=optionObject2
	    
	    if(i<10)
	    {
	        ddlvalue="0"+(i)
	    }
	    else
	    {
	        ddlvalue=i
	    }
	    
	    monthyear=SMcurrdate.getYear()+""+ddlvalue;
	   
	    document.selectHotelForm.arrivalMonthYear.options[optionRank1].value=monthyear
	    document.selectHotelForm.departureMonthYear.options[optionRank2].value=monthyear
	   
	}
	
	for(j=0;j<SMmonth;j++)
	{
	    SMnyear=SMcurrdate.getYear()+1
	    var optionObject1=new Option(month[j]+", "+SMnyear)
	    var optionObject2=new Option(month[j]+", "+SMnyear)
	    
	    var optionRank1 = document.selectHotelForm.arrivalMonthYear.options.length
	    var optionRank2 = document.selectHotelForm.departureMonthYear.options.length
	    
	    document.selectHotelForm.arrivalMonthYear.options[optionRank1]=optionObject1
	    document.selectHotelForm.departureMonthYear.options[optionRank2]=optionObject2
	    
        if(j<10)
	    {
	        ddlvalue="0"+(j)
	    }
	    else
	    {
	        ddlvalue=j
	    }
	    monthyear=SMcurrdate.getYear()+1+""+ddlvalue;
	    
	    document.selectHotelForm.arrivalMonthYear.options[optionRank1].value=monthyear
	    document.selectHotelForm.departureMonthYear.options[optionRank2].value=monthyear
	    
	}
	
	SetDate()
	
}



function SetDate()
{
    SDcurrdate = new Date();    
    SDcurrdate.setDate(SDcurrdate.getDate());
    
	var SDday=0;
	SDday=SDcurrdate.getDate();
	
	var SDayear=document.selectHotelForm.arrivalMonthYear.value.substring(0,4)
	var SDamonth=document.selectHotelForm.arrivalMonthYear.value.substring(6,4)
	var Aday=document.selectHotelForm.arrivalDay.value;
	var Dday=document.selectHotelForm.departureDay.value
	var SDindex=document.selectHotelForm.arrivalMonthYear.selectedIndex
    if(SDindex!=0)
    {
	    var SDday=1
    }

    for(l=1;l<document.selectHotelForm.arrivalDay.options.length+1;l++)
    {
        document.selectHotelForm.arrivalDay.remove(l-1)
        l=l-1
    }
    for(l=1;l<document.selectHotelForm.departureDay.options.length+1;l++)
    {      
        document.selectHotelForm.departureDay.remove(l-1)
        l=l-1
    }

    for(j=SDday;j<=31;j++)
	{

        var chdate=new Date(SDayear,SDamonth,j)
        if(j==chdate.getDate())
	    {
	         var AoptionObject=new Option(j)
	         var DoptionObject=new Option(j)
	         
	         var AoptionRank = document.selectHotelForm.arrivalDay.options.length
	         var DoptionRank = document.selectHotelForm.departureDay.options.length
	         
	         document.selectHotelForm.arrivalDay.options[AoptionRank]=AoptionObject
	         document.selectHotelForm.departureDay.options[DoptionRank]=DoptionObject
	         
	         document.selectHotelForm.arrivalDay.options[AoptionRank].value=j
	         document.selectHotelForm.departureDay.options[DoptionRank].value=j
	         
	    }
 
	}
	 if(SDindex!=0)
    {
        document.selectHotelForm.arrivalDay.value=Aday
        document.selectHotelForm.departureDay.value=Dday
        if(document.selectHotelForm.arrivalDay.value!=Aday)
        {
            document.selectHotelForm.arrivalDay.selectedIndex=0
        }
    }
    else
    {
        document.selectHotelForm.departureDay.selectedIndex=1
    }
	length=document.selectHotelForm.arrivalDay.options.length
	 CompareDate()
	   
}

function SetDateD()
{
    SDcurrdate = new Date();    
    SDcurrdate.setDate(SDcurrdate.getDate());
    
	var SDday=0;
	SDday=SDcurrdate.getDate();
	
	var SDayear=document.selectHotelForm.departureMonthYear.value.substring(0,4)
	var SDamonth=document.selectHotelForm.departureMonthYear.value.substring(6,4)
	var Dday=document.selectHotelForm.departureDay.value;

	var SAindex=document.selectHotelForm.arrivalMonthYear.selectedIndex
	var SDindex=document.selectHotelForm.departureMonthYear.selectedIndex

    if(SDindex!=0)
    {
	    var SDday=1
    }

    for(l=1;l<document.selectHotelForm.departureDay.options.length+1;l++)
    {      
        document.selectHotelForm.departureDay.remove(l-1)
        l=l-1
    }


    for(j=SDday;j<=31;j++)
	{
        var chdate=new Date(SDayear,SDamonth,j)
        if(j==chdate.getDate())
	    {	       
	         var DoptionObject=new Option(j)
	         var DoptionRank = document.selectHotelForm.departureDay.options.length
	         document.selectHotelForm.departureDay.options[DoptionRank]=DoptionObject
	         document.selectHotelForm.departureDay.options[DoptionRank].value=j
	         
	    }
 
	}
	if(SAindex==SDindex)
	{
	    var value=document.selectHotelForm.arrivalDay.value
	    value++
	    document.selectHotelForm.departureDay.value=value
	}


if(SDindex!=0)
    {
    
        document.selectHotelForm.departureDay.value=Dday
       if(document.selectHotelForm.departureDay.value!=Dday)
        {
            document.selectHotelForm.departureDay.selectedIndex=0
        } 
    }
    else
    {
        document.selectHotelForm.departureDay.selectedIndex=1
    }

}



function CompareDate()
{
    var ddf=getObj("arrivalDay").value;
    var ddt=getObj("departureDay").value;
   
    if ((ddf)<10)
    {
        ddf=("0"+ddf);
    }
    if ((ddt)<10)
    {
        ddt=("0"+ddt);
    }
var amonth=getObj("arrivalMonthYear").value.substring(4,6)
amonth++
var dmonth=getObj("departureMonthYear").value.substring(4,6)
dmonth++
	var dt1= amonth+ "/" + ddf + "/" + getObj("arrivalMonthYear").value.substring(0,4);
	var dt2= dmonth+ "/" + ddt + "/" + getObj("departureMonthYear").value.substring(0,4);


	dtStartDate = new Date(dt1); 
	dtEndDate = new Date(dt2); 
	
	var today = new Date();
	

        var arrdayindex=getObj("arrivalDay").selectedIndex;
		var arrday=getObj("arrivalDay").value
		var arrmonth=getObj("arrivalMonthYear").selectedIndex;
        arrdayindex++
         arrday++
        
	    if (dtEndDate.getTime() <= dtStartDate.getTime())
		{
			
			if(length==arrdayindex)
		    {

		        arrmonth++
                getObj("departureMonthYear").selectedIndex=arrmonth 
                  SetDateD()        
          	}
		    else
		    {
		        getObj("departureMonthYear").value = getObj("arrivalMonthYear").value;
		        getObj("departureDay").value = arrday;
		    }
		}
	
	    if (dtStartDate.getTime() < (today.getTime() - 86400000))
		{
		    var arrday=getObj("arrivalDay").value
		    if(length==arrdayindex)
		    {
		        arrmonth++
                getObj("departureMonthYear").selectedIndex=arrmonth           
            
		    }
		    else
		    {
		        arrday++
		        getObj("departureMonthYear").value = getObj("arrivalMonthYear").value;
		        getObj("departureDay").value = arrday;
		    }
		}
	   
	if (dt1 == '')
		{
		    alert('Please specify a Check In Date.');
		}
	if (dt2 == '')
		{
		    alert('You must enter a Check Out Date');
		}
	

		
		
}


