// JavaScript Document

function hov(loc,cls){
   if(loc.className)
      loc.className=cls;
	  
 }



function chk_flights(obj){
var departing=document.getElementById("calendar3").value;
var returning=document.getElementById("calendar4").value;
if(departing==""){
  alert("Please enter the departure date.");
  return false;

}
//var departing,returning;
if((departing!="")&&(returning!=""))
{
if(!comparedate(departing,returning))
{ 
  alert("The return date can not be before the departure date");
  return false;
}
}

if(obj.departure.options[obj.departure.selectedIndex].value==obj.arrival.options[obj.arrival.selectedIndex].value){
alert("The departure city cann't be the same as the arrival city.");
return false;
}

}

function chk_date(obj){
var r=obj.returndate.value;
var d=obj.departuredate.value;
if(d=="")
{
 alert("Please enter your departure date.");
  return false;
}
if(r!="")
{
if(!comparedate(d,r))
{ 
  alert("The return date can not be before the departure date");
  return false;
}
}
}
function cleardates(obj)
 {
 obj.departuredate.value="";
 obj.returndate.value="";
 }



function comparedate(date1,date2)
{
 var i,j;
 var j1,k1,t1,j2,k2,t2;
 var str1,str2,str3,str4,str5,str6;
 var ar=new Array();
 ar[0]=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
 var number=new Array();
 number[0]=new Array("01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31");
 j1=date1.indexOf(" ");
 str1=date1.substring(0,j1);
 k1=date1.indexOf(",");
 str2=date1.substring(j1+1,k1);
 str3=eval(date1.substring(k1+2,date1.length));
 j2=date2.indexOf(" ");
 str4=date2.substring(0,j2);
 k2=date2.indexOf(",");
 str5=date2.substring(j2+1,k2);
 str6=eval(date2.substring(k2+2,date2.length));
 for(i=0;i<ar[0].length;i++)
 {
   if(str1==ar[0][i])
   break;
 }
 for(j=0;j<ar[0].length;j++)
 {
   if(str4==ar[0][j])
   break;
 }
 
 for(j1=0;j1<number[0].length;j1++)
 {
  if(str2==number[0][j1])
  break;
  }
 for(j2=0;j2<number[0].length;j2++)
 {
  if(str5==number[0][j2])
  break;
 }
 
 if(i>j)
 {
  if(str3>=str6)
  return false;
  else if(str3<str6)
  return true;
  }
 if(i==j)
 {
  if(str3>str6)
  return false;
  else if(str3==str6)
  {
  if(j1<=j2)
  return true;
  else 
  return false;
  }
  else if(str3<str6)
  return true;
 }
 if(i<j)
 {
   if(str3>str6)
   return false;
   else
   return true;
  }   
}
