function setarrivalday()
{
	
	var orig_day=0;
  var date=new Date(document.checkhome.arrivalMonth.value.substring(3,7),document.checkhome.arrivalMonth.value.substring(0,2),document.checkhome.arrivalDate.value);
  //alert(date);
  var year=date.getFullYear();
  var month=date.getMonth();
  var day=date.getDate();
  if(month<10)
  { month="0"+month;
  }
  document.checkhome.arrivalMonth.value=month+"-"+year;
   var mnn=new Array('31','28','31','30','31','30','31','31','30','31','30','31');
var mnl=new Array('31','29','31','30','31','30','31','31','30','31','30','31');
if(document.checkhome.arrivalMonth.value.substring(0,1)==0)
{
var x=document.checkhome.arrivalMonth.value.substring(1,2);
}
else
{
var x=document.checkhome.arrivalMonth.value.substring(0,2);
}
//alert(x);
var group=new Array(12)
for(var i=0;i<12;i++)
group[i]=new Array();
var cy=document.checkhome.arrivalMonth.value.substring(3,7);
//alert(cy)
marr=((cy%4)==0)?mnl:mnn;
for(var i=0;i<12;i++)
{
for(var k=0;k<marr[i];k++)
{
group[i][k]=new Option(k+1,k+1);

}
}
//alert(x)
//alert(group[x].length)
var temp=document.checkhome.arrivalDate;
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null

for (i=0;i<group[x].length;i++)
{
temp.options[i]=new Option(group[x][i].text,group[x][i].value)
}
  //document.booking.arrivalYear.value=year;
  document.checkhome.arrivalDate.value=day;
  
  var dow=date.getDay();
  //alert(dow);
  var word="";
   if(dow==0) word="SUNDAY";
  if(dow==1) word="MONDAY";
  if(dow==2) word="TUESDAY";
  if(dow==3) word="WEDNESDAY";
  if(dow==4) word="THURSDAY";
  if(dow==5) word="FRIDAY";
  if(dow==6) word="SATURDAY";
  document.getElementById("arrival_display").innerHTML=word;
  
  var otherdate=new Date(document.checkhome.departureMonth.value.substring(3,7),document.checkhome.departureMonth.value.substring(0,2),document.checkhome.departureDate.value);
  var otheryear=otherdate.getFullYear();
  var othermonth=otherdate.getMonth();
  if(othermonth<10)
  { othermonth="0"+othermonth;
  }
  var otherday=otherdate.getDate();
  if(otherday<10)
  { otherday="0"+otherday;
  }
  orig_day=day;
  if(day<10)
  { day="0"+day;
  }

  if((otheryear+""+othermonth+""+otherday)<=(year+""+month+""+day))
  { otherdate.setYear(year);
    otherdate.setMonth(month);
    
    otheryear=otherdate.getFullYear();
    othermonth=otherdate.getMonth();
    
    	

	
	if(othermonth<10)
    { othermonth="0"+othermonth;
    }

	if((otheryear+""+othermonth+""+otherday)<=(year+""+month+""+day))
    { otherdate.setDate(orig_day+1);
    }
	
	
  	
	year=otherdate.getFullYear();
    month=otherdate.getMonth();
    day=otherdate.getDate();
    if(month<10)
    { month="0"+month;
    }

	document.checkhome.departureMonth.value=month+"-"+year;
     if(document.checkhome.departureMonth.value.substring(0,1)==0)
{
var x=document.checkhome.departureMonth.value.substring(1,2);
}
else
{
var x=document.checkhome.departureMonth.value.substring(0,2);
}
//alert(x);
var group=new Array(12)
for(var i=0;i<12;i++)
group[i]=new Array();
var cy=document.checkhome.departureMonth.value.substring(3,7);
//alert(cy)
marr=((cy%4)==0)?mnl:mnn;
for(var i=0;i<12;i++)
{
for(var k=0;k<marr[i];k++)
{
group[i][k]=new Option(k+1,k+1);

}
}
//alert(x)
//alert(group[x].length)
var temp=document.checkhome.departureDate;
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null

for (i=0;i<group[x].length;i++)
{
temp.options[i]=new Option(group[x][i].text,group[x][i].value)
}
	//document.checkhome.departureYear.value=year;
    document.checkhome.departureDate.value=day;
	  
	var dow=otherdate.getDay();
    var word="";
     if(dow==0) word="SUNDAY";
  if(dow==1) word="MONDAY";
  if(dow==2) word="TUESDAY";
  if(dow==3) word="WEDNESDAY";
  if(dow==4) word="THURSDAY";
  if(dow==5) word="FRIDAY";
  if(dow==6) word="SATURDAY";

    document.getElementById("departure_display").innerHTML=word;
	
  }

}


function setdepartureday()
{ 
//alert('afgsdgdfgdf');
  var date=new Date(document.checkhome.departureMonth.value.substring(3,7),document.checkhome.departureMonth.value.substring(0,2),document.checkhome.departureDate.value);
  var year=date.getFullYear();
  var month=date.getMonth();
  var day=date.getDate();
  if(month<10)
  { month="0"+month;
  }

  document.checkhome.departureMonth.value=month+"-"+year;
  if(document.checkhome.departureMonth.value.substring(0,1)==0)
{
var x=document.checkhome.departureMonth.value.substring(1,2);
}
else
{
var x=document.checkhome.departureMonth.value.substring(0,2);
}
//alert(x);
var group=new Array(12)
for(var i=0;i<12;i++)
group[i]=new Array();
var cy=document.checkhome.departureMonth.value.substring(3,7);
//alert(cy)
marr=((cy%4)==0)?mnl:mnn;
for(var i=0;i<12;i++)
{
for(var k=0;k<marr[i];k++)
{
group[i][k]=new Option(k+1,k+1);

}
}
//alert(x)
//alert(group[x].length)
var temp=document.checkhome.departureDate;
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null

for (i=0;i<group[x].length;i++)
{
temp.options[i]=new Option(group[x][i].text,group[x][i].value)
}
  document.checkhome.departureDate.value=day;
  
  var dow=date.getDay();
  var word="";
   if(dow==0) word="SUNDAY";
  if(dow==1) word="MONDAY";
  if(dow==2) word="TUESDAY";
  if(dow==3) word="WEDNESDAY";
  if(dow==4) word="THURSDAY";
  if(dow==5) word="FRIDAY";
  if(dow==6) word="SATURDAY";
  document.getElementById("departure_display").innerHTML=word;
}

function arrival_dates(day, month, year, current_month, current_year)
{ var i;
  var c;
 
  if(month.length<2 && month<10)
  { month="0"+month;
  }
   if(month==00||month==02||month==04||month==06||month==07||month==09||month==11)
	{
		var dmax = 31;			
		        

	}
	else if (month==03||month==05||month==08||month==10)
	{

        	var dmax = 30;		
		  

	}
	else
	{

		if((year%400==0) || (year%400==0 && year%100!=0))
		{

			var dmax = 29;			
			

		}
                else 
                {
                    var dmax = 28;				
                }
		

	}
 
  document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<select id='arrivalDate' name ='FDAY' Style='mar-left:40px;width:44px;height:17px; font:normal 10px Arial, Helvetica, sans-serif;'  onchange='setarrivalday()'>");
  for(i=1;i<=dmax;i++)
  { document.write("<option");
    if(day==i)
    { document.write(" selected");
    }
    document.write(" value='"+i+"'>"+i+"</option>");
  }
  document.write("</select>&nbsp;&nbsp;&nbsp;<select id='arrivalMonth' name='FMONTH' Style='width:90px;height:17px; font:normal 10px Arial, Helvetica, sans-serif;'  onchange='setarrivalday()'>");
  var now_month=current_month-2;
  var now_year=current_year;
  var dmonth;
  i=0;
  for(c=0;c<25;c++)
  { 
  	now_month++;
  	if(now_month>11)
    { now_month=0;
      now_year++;
    }
    dmonth=now_month;
    if(dmonth<10)
    { dmonth="0"+dmonth;
    }
  	document.write("<option");
	if(month==dmonth && year==now_year)
	{ document.write(" selected");
	}
	document.write(" value='"+dmonth+"-"+now_year+"'>");
    if(now_month==0) document.write("JAN");
    if(now_month==1) document.write("FEB");
    if(now_month==2) document.write("MAR");
    if(now_month==3) document.write("APR");
    if(now_month==4) document.write("MAY");
    if(now_month==5) document.write("JUN");
    if(now_month==6) document.write("JUL");
    if(now_month==7) document.write("AUG");
    if(now_month==8) document.write("SEP");
    if(now_month==9) document.write("OCT");
    if(now_month==10) document.write("NOV");
    if(now_month==11) document.write("DEC");
    document.write(" "+now_year+"</option>");
  }
  document.write("</select>");
}

function departure_dates(day, month, year, current_month, current_year)
{ 

var i;
  var c;
  if(month.length<2 && month<10)
  { month="0"+month;
  }
   if(month==00||month==02||month==04||month==06||month==07||month==09||month==11)
	{
		var dmax = 31;			
		        

	}
	else if (month==03||month==05||month==08||month==10)
	{

        	var dmax = 30;		
		  

	}
	else
	{

		if((year%400==0) || (year%400==0 && year%100!=0))
		{

			var dmax = 29;			
			

		}
                else 
                {
                    var dmax = 28;				
                }
		

	}
 
  document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<select id='departureDate' name ='TDAY' Style='width:44px;height:17px; font:normal 10px Arial, Helvetica, sans-serif;'  onchange='setdepartureday()'>");
  for(i=1;i<=dmax;i++)
  { document.write("<option");
    if(day==i)
    { document.write(" selected");
    }
    document.write(" value='"+i+"'>"+i+"</option>");
  }
  document.write("</select>&nbsp;&nbsp;&nbsp;<select id='departureMonth' name='TMONTH' Style='width:90px;height:17px; font:normal 10px Arial, Helvetica, sans-serif;'  onchange='setdepartureday()'>");
  var now_month=current_month-2;
  var now_year=current_year;
  var dmonth;
  i=0;
  for(c=0;c<25;c++)
  { now_month++;
  	if(now_month>11)
    { now_month=0;
      now_year++;
    }
    dmonth=now_month;
    if(dmonth<10)
    { dmonth="0"+dmonth;
    }
  	document.write("<option");
	if(month==dmonth && year==now_year)
	{ document.write(" selected");
	}
	document.write(" value='"+dmonth+"-"+now_year+"'>");
   if(now_month==0) document.write("JAN");
    if(now_month==1) document.write("FEB");
    if(now_month==2) document.write("MAR");
    if(now_month==3) document.write("APR");
    if(now_month==4) document.write("MAY");
    if(now_month==5) document.write("JUN");
    if(now_month==6) document.write("JUL");
    if(now_month==7) document.write("AUG");
    if(now_month==8) document.write("SEP");
    if(now_month==9) document.write("OCT");
    if(now_month==10) document.write("NOV");
    if(now_month==11) document.write("DEC");
    document.write(" "+now_year+"</option>");
  }
  document.write("</select>");
}

function adults(adults)
{ var i;
  document.write("<select name='adults' class='dd3' style='width:45px'>");
  for(i=1;i<5;i++)
  { document.write("<option value='"+i+"'");
    if(adults==i)
    { document.write(" selected ");
    }
    document.write(">"+i+"</option>");
  }
  document.write("</select>");
}
function children(children)
{ var i;
  document.write("<select name='children' class='dd3' style='width:45px'>");
  for(i=0;i<5;i++)
  { document.write("<option value='"+i+"'");
    if(children==i)
    { document.write(" selected ");
    }
    document.write(">"+i+"</option>");
  }
  document.write("</select>");
}
function rooms(rooms)
{ var i;
  document.write("<select name='rooms' class='dd3' style='width:45px'>");
  for(i=1;i<5;i++)
  { document.write("<option value='"+i+"'");
    if(rooms==i)
    { document.write(" selected ");
    }
    document.write(">"+i+"</option>");
  }
  document.write("</select>");
}
function beds(beds)
{ var i;
  document.write("<select name='beds' class='dd3' style='width:45px'>");
  for(i=1;i<5;i++)
  { document.write("<option value='"+i+"'");
    if(beds==i)
    { document.write(" selected ");
    }
    document.write(">"+i+"</option>");
  }
  document.write("</select>");
}