function  CheckForDepartDateValidity()
{
	
	 var IndexDep_Day=document.forms[0].dep_date.selectedIndex;
	 var IndexDep_Month=document.forms[0].dep_month.selectedIndex;
	 var IndexDep_Year=document.forms[0].dep_year.selectedIndex;
    
  if (document.forms[0].dep_month.options[IndexDep_Month].value==2) {
   	// Check for leap year
    if ((document.forms[0].dep_year.options[IndexDep_Year].value%4==0)) { // leap year
		if (document.forms[0].dep_date.options[IndexDep_Day].value > 29)
		{
	    	document.forms[0].dep_date.selectedIndex=parseInt('28');
	    	
		}
	 }
	 else { if (document.forms[0].dep_date.options[IndexDep_Day].value > 28) 
	 { 
	      document.forms[0].dep_date.selectedIndex=parseInt('27');
	 
	 }
   }
 } 
  
  if ((document.forms[0].dep_month.options[IndexDep_Month].value==4)||(document.forms[0].dep_month.options[IndexDep_Month].value==6)||(document.forms[0].dep_month.options[IndexDep_Month].value==9)||(document.forms[0].dep_month.options[IndexDep_Month].value==11))
  {
   	 if (document.forms[0].dep_date.options[IndexDep_Day].value > 30) {		
			document.forms[0].dep_date.selectedIndex=IndexDep_Day-1;
		    DPT_Date =document.forms[0].dep_year.options[IndexDep_Year].value + document.forms[0].dep_month.options[IndexDep_Month].value + document.forms[0].dep_date.options[IndexDep_Day-1].value; 
     }
	else
	{
		 DPT_Date =document.forms[0].dep_year.options[IndexDep_Year].value + document.forms[0].dep_month.options[IndexDep_Month].value + document.forms[0].dep_date.options[IndexDep_Day].value; 
	}
  }
  else
  {
	   DPT_Date =document.forms[0].dep_year.options[IndexDep_Year].value + document.forms[0].dep_month.options[IndexDep_Month].value + document.forms[0].dep_date.options[IndexDep_Day].value; 
  }
 }
	   
 function  CheckForArriveDateValidity()
 {
	 var IndexRet_Day=document.forms[0].return_date.selectedIndex;
	 var IndexRet_Month=document.forms[0].return_month.selectedIndex;
	 var IndexRet_Year=document.forms[0].return_year.selectedIndex;
  	
  	
   if (document.forms[0].return_month.options[IndexRet_Month].value==2) {
   	// Check for leap year
    if ((document.forms[0].return_year.options[IndexRet_Year].value%4==0)) { // leap year
		if (document.forms[0].return_date.options[IndexRet_Day].value > 29)
		{
	    	document.forms[0].return_date.selectedIndex=parseInt('28');
	    	
		}
	 }
	 else { if (document.forms[0].return_date.options[IndexRet_Day].value > 28) 
	 { 
	      document.forms[0].return_date.selectedIndex=parseInt('27');
	 
	 }
   }
  }
  	
  	
  	
  	  
	if ((document.forms[0].return_month.options[IndexRet_Month].value==4)||(document.forms[0].return_month.options[IndexRet_Month].value==6)||(document.forms[0].return_month.options[IndexRet_Month].value==9)||(document.forms[0].return_month.options[IndexRet_Month].value==11)) 
	{
	   if (document.forms[0].return_date.options[IndexRet_Day].value > 30) 
	   {		
	    	document.forms[0].return_date.selectedIndex=IndexRet_Day-1;
		    RET_Date =document.forms[0].return_year.options[IndexRet_Year].value + document.forms[0].return_month.options[IndexRet_Month].value + document.forms[0].return_date.options[IndexRet_Day-1].value; 
		}
		else
		{
			 RET_Date =document.forms[0].return_year.options[IndexRet_Year].value + document.forms[0].return_month.options[IndexRet_Month].value + document.forms[0].return_date.options[IndexRet_Day].value; 
		}
	 }
	 else
	 {
		     RET_Date =document.forms[0].return_year.options[IndexRet_Year].value + document.forms[0].return_month.options[IndexRet_Month].value + document.forms[0].return_date.options[IndexRet_Day].value;
		 
	 }
	
}


function Set_Date()
{
		
		
		var DPT_DD = Today_Date.getDate();
    	var DPT_MM = Today_Date.getMonth() + 1;
    	var DPT_YY = Today_Date.getYear();
    	var RET_DD = Today_Date.getDate();
    	var RET_MM = Today_Date.getMonth() + 1;
    	var RET_YY = Today_Date.getFullYear();
    	
    	
    		
    	//On the form launch display today date on depart day, month, and year drop downs
    	for (var i=0; i<document.forms[0].dep_date.options.length; i++) { 
		 if (document.forms[0].dep_date.options[i].value==DPT_DD) { 
				document.forms[0].dep_date.selectedIndex=i; 
		  } 
		 } 
			 
		 for (var i=0; i<document.forms[0].dep_month.options.length; i++) { 
		 if (document.forms[0].dep_month.options[i].value==DPT_MM) { 
			document.forms[0].dep_month.selectedIndex=i; 
		  } 
		 } 
			 
		 for (var i=0; i<document.forms[0].dep_year.options.length; i++) { 
		 if (document.forms[0].dep_year.options[i].value==DPT_YY) { 
				document.forms[0].dep_year.selectedIndex=i; 
		  } 
		 } 
			 
		//On the form launch display today date on return day, month and year drop downs
    	for (var i=0; i<document.forms[0].return_date.options.length; i++) { 
		if (document.forms[0].return_date.options[i].value==RET_DD) { 
		   	document.forms[0].return_date.selectedIndex=i; 
		 } 
		} 
			 
		for (var i=0; i<document.forms[0].return_month.options.length; i++) { 
		if (document.forms[0].return_month.options[i].value==RET_MM) { 
		   document.forms[0].return_month.selectedIndex=i; 
		 } 
		} 
			 
		for (var i=0; i<document.forms[0].return_year.options.length; i++) { 
		if (document.forms[0].return_year.options[i].value==RET_YY) { 
		   	document.forms[0].return_year.selectedIndex=i; 
		 } 
		} 			
}	

function setDepartValues(y,m,d) { 
     if ( m <= 9)
     {
        m = "0" + m;
     }
     if( d <=9)
     {
        d="0" + d;
     }
     
	 document.forms[0].dep_year.value=y; 
	 document.forms[0].dep_month.value=m; 
	 for (var i=0; i<document.forms[0].dep_date.options.length; i++) { 
	  if (document.forms[0].dep_date.options[i].value==d) { 
	  	document.forms[0].dep_date.selectedIndex=i; 
	  } 
	} 
} 

function setReturnValues(y,m,d) { 
	 if ( m <= 9)
     {
        m = "0" + m;
     }	    
     if( d <=9)
     {
        d="0" + d;
     }
	 document.forms[0].return_year.value=y; 
	 document.forms[0].return_month.value=m; 
	 for (var i=0; i<document.forms[0].return_date.options.length; i++) { 
	  if (document.forms[0].return_date.options[i].value==d) { 
	 	document.forms[0].return_date.selectedIndex=i; 
	  } 
	 } 
 } 
function getDateString(y_obj,m_obj,d_obj) { 

     var y = y_obj.options[y_obj.selectedIndex].value; 
     var m = m_obj.options[m_obj.selectedIndex].value; 
 	 var d = d_obj.options[d_obj.selectedIndex].value; 
	 if (y=="" || m=="") { return null; } 
	  if (d=="") { d=1; } 
	     return str= y+'-'+m+'-'+d; 	   
	   
}