﻿function DefaultSelFlightI(BeginCity1)
{
  
   for (z=0;z < document.FrmFlightI.BeginCityI.length ;z++ )
    {
		 if (document.FrmFlightI.BeginCityI.options[z].value==BeginCity1)
    	 {
             document.FrmFlightI.BeginCityI.options[z].selected=true; 
             break;
	     }
    }
}

function DefaultSelFlightIEndCity(BeginCity1)
{
  
   for (z=0;z < document.FrmFlightI.EndCityI.length ;z++ )
    {
		 if (document.FrmFlightI.EndCityI.options[z].value==BeginCity1)
    	 {
             document.FrmFlightI.EndCityI.options[z].selected=true; 
             break;
	     }
    }
}

function CheckFlightFormI()
{
    
   if (trim(FrmFlightI.BeginDate.value)=="")
   {
       alert('Please enter the departure date!');
       FrmFlightI.BeginDate.focus();
       return false;
   }
   
   if (!IsDate(FrmFlightI.BeginDate.value,"-"))
   {
       alert('Wrong format for departure date, the correct format should be:yyyy-mm-dd!');
       FrmFlightI.BeginDate.focus();
       return false;
   }
   
    strdate=new Date;
	y=strdate.getFullYear();
	m=strdate.getMonth()+1;
	d=strdate.getDate();
	datestr=y+"-"+m+"-"+d;
	   
	if (compareDate(datestr,document.FrmFlightI.BeginDate.value,true))
	{
		
		alert("Departure date can not be earlier than today!");
		return false;
		
	} 
	
    if(FrmFlightI.FlightType[1].checked)
	{
		if (!IsDate(FrmFlightI.ReturnDate.value,"-"))
		{
			alert('Date for return trip is  wrong, correct format should be:yyyy-mm-dd!');
			return false;
		}
		   
		if (compareDate(FrmFlightI.BeginDate.value,FrmFlightI.ReturnDate.value,true))
		{
			alert("Return date can not be earlier than Departure date!");
			return false;
		} 	
	}
	    
    return true;
   
}
