//   Name Of Function                               Discription
//--------------------------------------------------------------------------------------------------------------------
//                                                 message parameter is a alert
//                                                 n parameter is a name of field
//                                                 f parameter is used for the mandatory field or not
//
//   function isPhone(s,message,n,f)               only digits and spaces are allowed. 
//   function isName(s,message,n,f)                only character and spaces are allowed. 
//   function isAllSpaces(s,message)
//   function isProgramNo(s,message,n,f)           only digits and characters are allowed
//   function isAddress(s,message,f)               apostrophes (') and double quotes (\") are not allowed
//   function isCity(s,message,n,f)					atleast 3 characters + isName
//   function isLetters(s,message,n,f)              only accept the a-z and A-Z
//   function isZip(s,message,n,f)
//   function isLetterNumberSpace(s,message,n,f)    only characters , digits and underscore(_) are allowed.
//   function isT1toT2(T1,T2,M1,M2,N1,N2)
//   function isCreditcard(s,message,n,f)		    only accepts digits
//   function isNumericDigit(c)                     only accepts digits
//   function IsLettersNumber(c)                    this function only check character is number or letter
//   function isLoginName(s,message)                only characters and digits are allowed  and includes the isLogin function 
//   function isLoginLen(s,message)
//   function isSpecialChar(s,message1)             to find the special characters including blank spaces
//   function isLoginSpecialChar(s,message1)
//   function isPasswordLen(s,message)
//   function isRePasswordName(s,message)
//   function isAllZeros(s,message)
//   function isLetterDigitSpace(s,message,n,f)		only characters , digits , braces ,dots and space are allowed.
//	 function trim(text)							trim leading and trailing spaces
//   function isLoginName(s,message)                only characters and digits are allowed and First letter of login name should not be digit
//   function isLoginLen(s,message)					determine the length of the field (4 to 20)
//   function isLoginSpecialChar(s,message1)
//   function isEmail(s,message)					
//   function isPasswordLen(s,message)				determine the length of the field
//   function isPasswordName(s,message)				only characters and digits are allowed  (contains two parameter)
//   function isNumberDecimal(s,message,n,f)		only accepts digits and decimal
//	 function sniffTheBrowser()						To detect the browser 
//	 function tcil_page(url)						Takes the user to TCIL sigin / register / signout pages
//	 function input_page(url)						To display the search input pages
//   function validcard(objCardType,objCCNo,objMn,objYr,objCVVNo,objTerms) To Validate Credit Card Info.
//   function validContactCC(objAddress1, objAddress2, objAddress3, objCountry, objOthCountry, objCity, objState, objZip, objEmail, objSTD, objPhone)   To Validate CC Contact Info
//   function validPersonCC(objFName, objMName, objLName)   To Validate CC Contact Person
////////////////////////////////function to increment a date in checout date///////////////
///Change History:
///#1   Moumita         03 Sep 2009     To implement Special Roundtrip Fare
///#2   Amit Kumar      04 May 2010     Automatically selected special RT checkbox 
///#3   Amit Kumar      24 Nov 2009     To Implement Connecting Flights Concept
///#4   Girish kalia    03 Sep 2010     To resolve IE 8 Compatibility issue on production.

function IsValidName(oObject) {
   var strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
   var strChar;
   var blnResult = true;
   var strString=oObject.value;	
   if(strString.length == 0) 
		return false; 
		 
   for (i = 0; i < strString.length && blnResult == true; i++) {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1) {
         blnResult = false;
         }
      }
   return blnResult;
	}
function isDecimal(c)
{
    if (c==".")
     {
       return true     
	 }
   return false
}
function validcard(objCardType,objCCNo,objMn,objYr,objCVVNo)
{

	if(objCardType.options[objCardType.selectedIndex].value == "" )
	{
		alert("Please select a valid credit card ");
		objCardType.focus();
		return false;
	}
	
	if (!isCommonValidate(objCCNo,'Please enter credit card',1,1))
	{
	   	objCCNo.focus();
	    return false;
	}

	if(objCardType.options[objCardType.selectedIndex].value == "VI" && objCCNo.value.length != 16)
	{
		alert("Please enter a valid visa card number");
		objCCNo.value="";
		objCCNo.focus();
		return false;
	}

	if(objCardType.options[objCardType.selectedIndex].value == "CA" && objCCNo.value.length != 16)
	{
		alert("Please enter a valid master card number");
		objCCNo.value="";
		objCCNo.focus();
		return false;
	}

	if(objCardType.options[objCardType.selectedIndex].value == "DL" && objCCNo.length != 14)
	{
		alert("Please enter a valid diners card number");
		objCCNo.value="";
		objCCNo.focus();
		return false;
	}
	
	var strCC=objCCNo.value 
	if (objCardType.value=='2')
	{
		if ((strCC.length < 14) ||  (strCC.length > 14))
		{
			alert("Credit card number should be 14 characters for diners card.")
			objCCNo.focus();
			return false;   
		}
	}
	else
	{
		if ((strCC.length < 16) ||  (strCC.length > 16))
		{
			alert("Credit card number should be 16 characters.")
			objCCNo.focus();
			return false;
		}
				
	}	
	
	var mydate=new Date() 
	var strMonth=mydate.getMonth()+1
	var strYear=mydate.getFullYear()

	if (objYr.options[objYr.selectedIndex].value == eval(strYear))
	{
		if (objMn.options[objMn.selectedIndex].value< eval(strMonth))
		{
			alert("Expiry month for the credit card should be greater than the selected month") 
			objMn.focus();
			return false;    		
		}
	}
	if (objYr.options[objYr.selectedIndex].value < eval(strYear))		
	{ 
		alert("Expiry year for the credit card should not be less than current year");
		objYr.focus();
		return false;
	}
	var card_year, card_month, card_num, card_ccv
	
	card_year = objYr.options[objYr.selectedIndex].value
	card_month = objMn.options[objMn.selectedIndex].value
	cardType = objCardType.options[objCardType.selectedIndex].value
	cvv = objCVVNo.value
	
	if (!isCommonValidate(objCVVNo,'Please enter a valid CVV number',1,1))
	{
		return false;
	}
	var CCVLen=objCVVNo.value;
	if (CCVLen.length < 3)
	{
		alert("CVV number cannot be less than 3 characters");
		objCVVNo.focus();
		return false; 
	}	
	return true;	
	
} 

//Added By Moumita
function validPersonCC(objFName, objMName, objLName)
{
    if (!isCommonValidate(objFName,'Please enter First Name', 4, 1, 1, 'Please enter valid First Name'))
	{
	   	objFName.focus();
	    return false;
	}
	if (!isCommonValidate(objMName,'Please enter Middle Name', 4, 0, 1, 'Please enter valid Middle Name'))
	{
	   	objMName.focus();
	    return false;
	}
	if (!isCommonValidate(objLName,'Please enter Last Name', 4, 1, 1, 'Please enter valid Last Name'))
	{
	   	objLName.focus();
	    return false;
	}
	return true;
}
//Added By Moumita
function validContactCC(objAddress1, objAddress2, objAddress3, objCountry, objOthCountry, objCity, objState, objZip, objEmail, objSTD, objPhone)
{
    if (!isCommonValidate(objAddress1,'Please enter Address 1', 11, 1, 1, 'Please enter valid Address 1'))
	{
	   	objAddress1.focus();
	    return false;
	}
	if (!isCommonValidate(objAddress2,'Please enter Address 2', 11, 0, 1, 'Please enter valid Address 2'))
	{
	   	objAddress2.focus();
	    return false;
	}
	if (!isCommonValidate(objAddress3,'Please enter Address 3', 11, 0, 1, 'Please enter valid Address 3'))
	{
	   	objAddress3.focus();
	    return false;
	}
	if(objCountry.options[objCountry.selectedIndex].value == "" )
	{
		alert("Please select a Country ");
		objCountry.focus();
		return false;
	}
	if((objCountry.options[objCountry.selectedIndex].value == "ZZ") && (!isCommonValidate(objOthCountry,'Please enter Other Country', 5, 1, 1, 'Please enter valid Country')))
	{
	    objOthCountry.focus();
	    return false;
	}
	if (!isCommonValidate(objCity,'Please enter City', 5, 1, 1, 'Please enter valid City'))
	{
	   	objCity.focus();
	    return false;
	}
	if (!isCommonValidate(objState,'Please enter State', 5, 0, 1, 'Please enter valid State'))
	{
	   	objState.focus();
	    return false;
	}
	if (!isCommonValidate(objZip,'Please enter Zip Code', 6, 1, 1, 'Please enter valid Zip Code'))
	{
	   	objZip.focus();
	    return false;
	}
	if (!isCommonValidate(objEmail,'Please enter valid Email Address', 12, 1))
	{
	   	objEmail.focus();
	    return false;
	}
	if (!isCommonValidate(objSTD,'Please enter STD Code', 16, 1, 2, 'Please enter valid STD Code'))
	{
	   	objSTD.focus();
	    return false;
	}
	if (!isCommonValidate(objPhone,'Please enter Phone', 16, 1, 5, 'Please enter valid Phone'))
	{
	   	objPhone.focus();
	    return false;
	}
	return true;
}

function validateDepositAccount(objAmt,objReceipt,BalAmt,dep_Amt)
{
	if (!isCommonValidate(objAmt,'Please enter the amount',3,1))
	{    return false;		}
	if (!isCommonValidate(objReceipt,'Please enter the receipt no',6,0))
	{    return false;		}
	if ( parseFloat(objAmt.value) != parseFloat(dep_Amt))
	{   alert("The amount entered should be equal to the total amount");
		objAmt.focus();   
		return false;		}
	if ( parseFloat(BalAmt) < parseFloat(dep_Amt))
	{   alert("You don't have sufficient amount for the transaction.");
		objAmt.focus();   
		return false;		
	}	
	return true;
}
//only digits and decimal are allowed
function isNumberDecimal(s,message,n,f)
{
   f=f*1
   if (f)
   {
	if (isBlank(s,message))
	{
		s.focus();
		return false;
	}
   }
     for (i = 0; i < s.value.length; i++)
	  {   
		var c = s.value.charAt(i);
			if ( !(isNumericDigit(c) || isDecimal(c) )   )
			{
				 alert("Invalid entry, only digits and decimal are allowed.\nPlease re-enter.");
				 s.focus();
				 s.select();
				return false;
			}

      }
    return true;
}


function isPasswordName(s,message)
{
      PasswordName=s.value
      if (isBlank(s,message))
      {
		s.focus();
		s.select();
		return false;
	  }
	  
	  message1="Invalid entry, only alphabets, digits and underscores are allowed.\nPlease re-enter";
      if (!(isLoginSpecialChar(s,message1)))
      {
         return false;
      }

	  if (isPasswordLen(s,message))
      {
		s.focus();
		s.select();
		return false;
	  }

	  return true;
}

function isPasswordLen(s,message)
{
  loginlen=s.value.length
  if (!(loginlen>=1 && loginlen<=25))
  {
    alert("Password cannot be more than twenty five characters ")
    return true;
  }
  else
  {
    return false; 
  }
  
}
/*
function isEmail(s,message)
{
	alert("in")
	var i,ii;
	var j;
	var k,kk;
    var jj;
    var len;

	if (isBlank(s,message))
	{
		s.focus();
		s.select();
		return false;
	}

    if (s.value.length >0){
		i=s.value.indexOf("@");
		ii=s.value.indexOf("@",i+1);
		j=s.value.indexOf(".",i);
		k=s.value.indexOf(",");
		kk=s.value.indexOf(" ");
		jj=s.value.lastIndexOf(".")+1;
		alert(jj)
		return
		len=s.value.length;
		if ((i>0) && (j>(1+1)) && (k==-1) && (ii==-1) && (kk==-1) &&
			(len-jj >=2) && (len-jj<=3)) {}
		else {
	 		 	alert("Please enter valid Email address")
	 		 	s.focus();
	 		 	s.select();
				return false;
		}
	}
    return true;
}

*/
function isEmail(s,message)
{
	if (isBlank(s,message))
	{
		s.focus();
		s.select();
		return false;
	}
	
	ObjPattern= /^[A-Za-z]\w*([.|-]\w*){0,4}[@]\w+([.]\w{2,4}){1,4}$/gi; //email id
	
	if (!(ObjPattern.test(s.value)))
	{
		alert(message)
		s.focus();
		s.select();
		return false;
	}	
	return true;
}
function isLoginLen(s,message)
{
  loginlen=s.value.length
  if (!(loginlen>0 && loginlen<=26))
  
  {
    alert("Login Id should not be more than twenty five characters ")
    return true;
  }
  else
  {
    return false;  
  }
  
}

function isLoginSpecialChar(s,message1)
{
      s1=s.value
      tt=s.value.length
      for (i = 0; i < tt; i++)
	   {
	    var c = s1.charAt(i);
	    if (!( ((c >= "0") && (c <= "9")) || ((c >= "A") && (c <= "Z")) || ((c >= "a") && (c <= "z")) || (c=="_") ))
	     {
          alert(message1);
          s.focus();
   		  s.select();
		  return false;
	     } 
  	   }
return true;
}

function isLoginName(s,message)
{


      if (isBlank(s,message))
      {
		s.focus();
		s.select();
		return false;
	  }
	  
	  message1="Invalid entry, only alphabets, digits and underscores are allowed.\nPlease re-enter";
      if (!(isLoginSpecialChar(s,message1)))
      {
         return false;
      }

  	  if (isLoginLen(s,message))
      {
		s.focus();
		s.select();
		return false;
	  }
	  if ((s.value.charAt(0)==" "))
	  {
         alert(message1);
	  	 s.focus();
		 s.select();
	 	 return false;
      }
	  else if ((s.value.charAt(0)>="0" && s.value.charAt(0)<="9" ) )
	  {
         alert("First letter of Login Id should not be digit ");
	  	 s.focus();
		 s.select();
	 	 return false;
      }		  
      
	  if ((s.value.charAt(s.value.length-1)=="_"))
	  {
         alert("Last letter of Login Id should not be underscore");
	  	 s.focus();
		 s.select();
	 	 return false;
      }

		  
	  return true;
}



function isName(s,message,n,f)
{
 	s1=s.value
    tt=s.value.length
	f=f*1
	if (f)
	{
		if (isBlank(s,message))
		{
			s.focus();
			s.select();
			return false;
		}
	}
 
    for (i = 0; i < tt; i++)
	{   
	    var c = s1.charAt(i);
	    if (!( (c == " ") || ((c >= "A") && (c <= "Z")) || ((c >= "a") && (c <= "z")) ))
		{
			alert("Invalid entry, only alphabets are allowed.\nPlease re-enter");
			s.focus();
   			s.select();
			return false;
		} 
	}
	return true;
}

function isBlank(s,message)
{
	if ((s.value.length > 0) && (s.value != null) && (s.value != "") && (s.value != " "))
	{
	    if ( isAllSpaces(s,message))
	         return true;	    
		else
		     return false;	    

	}
	alert(message);
	s.focus();
	s.select();
	return true;
}

function isAllSpaces(s,message)
{
	count=0
	slen=s.value.length
	for(i=0;i<=slen-1;i++)
	{
		if (s.value.charAt(i)==" ")
	    { 
			count=count+1
	    }
	}
	if (count!=slen)
	{
		return false;
	}
	else 
	{
		alert(message);
		s.focus();
		s.select();
		return true;	    
    }
   return false;	    
}

function isZip(s,message,n,f)
{
	f=f*1
	if (f)
	{
		if (isBlank(s,message))
		{
			s.focus();
			return false;
		}
	}
	if(s.value!="")
   	{
		retVal=isAllZeros(s,"Only Zero digits are not permitted.")
		if (retVal==true)
		{
			s.focus();
			return false;
		}	
	}
	s1=s.value
	tt=s.value.length
	if (tt>0)
	{
		if (isBlank(s,message))
		{
			s.focus();
			s.select();
			return false;
		}
		for (i = 0; i < tt; i++)
		{   
			// Check that current character is number.
			// only accept digits else alert i.e error
			var c = s1.charAt(i);
			if (!((c >= "0") && (c <= "9")))
			{
				alert("Invalid entry, only digits are allowed.\nPlease re-enter");
				s.focus();
   				s.select();
				return false;
			} 
  		}
	}
	return true;
}

function isAllZeros(s,message)
{
	count=0
    slen=s.value.length
	for(i=0;i<=slen-1;i++)
	{
		if (s.value.charAt(i)=="0")
	    { 
			count=count+1
	    }
	}
	if (count!=slen)
	{
		return false
	}
	else 
	{
		alert(message);
	    s.focus();
  	    s.select();
 	    return true;	    
	}
    return false;	    
}

function selectbox(box,val)
{
	for (i = 0; i < box.options.length; i++)
	{
		if (box.options[i].value == val)
		{
			box.selectedIndex = i;
			break;
		}
	}  
}

function radiobutt(box,val)
{
	for (i=0 ;i < box.length; i++)
	{
		if (box[i].value == val)
		{
		box[i].checked = true;
		break;
		}
	}  
}


function isProgramNo(s,message,n,f)
{
   f=f*1
   if (f)
   {
	if (isBlank(s,message))
	{
		s.focus();
		return false;
	}
   }
     for (i = 0; i < s.value.length; i++)
	  {   
		var c = s.value.charAt(i);
	    if (!IsLettersNumber(c))
		{
			 alert("Invalid entry, only digits and alphabets are allowed.\nPlease re-enter");
	 	 	 s.focus();
			 s.select();
			return false;
		}
      }
    return true
}


//only accepts character and number
function IsLettersNumber(c)
{
    if ((c>="0" && c<="9" ) || (c>="a" && c<="z")  || ( c>="A" && c<="Z" ) )
     {
       return true     
	 }

   return false
}


//apostrophes (') and double quotes (\") are not allowed

function isAddress(s,message,f)
{   

	s1=s.value	
	tt=s.value.length
	f=f*1
	if (f)
	{
		if (isBlank(s,message))
		{
		  s.focus();
		  s.select();
		  return false;
		}
	}
	for (i = 0; i < tt; i++)
	{
		var c = s1.charAt(i);
		if ( (c == "'" || c == "\"" ) )
		{
			alert("Invalid entry,  apostrophes (') and double quotes (\") are not allowed.\nPlease re-enter");
			s.focus();
			s.select();
			return false;
		} 
	}

	return true;
}


function isCity(s,message,n,f)
{
	if((trim(s.value)!='') && (s.value.length < 3))
	{
		alert("Please enter the city name or select from the City/Airport Lookup.")
		s.focus();
		s.select();
		return false;
	}
	return isName(s,message,n,f);
}

function isNumericDigit(c)
{
    if (c>="0" && c<="9")
     {
       return true     
	 }
   return false
}

//only digits and spaces are allowed.
function isPhone(s,message,n,f)
{
   f=f*1
   if (f)
   {
	if (isBlank(s,message))
	{
		s.focus();
		return false;
	}
   }
     for (i = 0; i < s.value.length; i++)
	  {   
		var c = s.value.charAt(i);
		if (c !=" ")
		{
			if (!(isNumericDigit(c))  )
			{
				 alert("Invalid entry, only digits are allowed.\nPlease re-enter.");
				 s.focus();
				 s.select();
				return false;
			}
        }
      }
    return true
}

//only characters, digits, braces and dots are allowed.
function isDeliveryOption(s,message,n,f)
{
 	 s1=s.value
     tt=s.value.length
     f=f*1
	if (f)
	{
		if (isBlank(s,message))
		{
			s.focus();
			s.select();
			return false;
		}
	}
     for (i = 0; i < tt; i++)
	   {   
	    var c = s1.charAt(i);
	    if (!( (c == " ") || ((c >= "A") && (c <= "Z")) || ((c >= "a") && (c <= "z")) || ((c >= 0) && (c <= 9)) || (c == "-") || (c == "'")   ))
	     {
		  alert("Invalid entry, only alphabets, digits, hyphens and single quote are allowed.\nPlease re-enter");
          s.focus();
   		  s.select();
		  return false;
	     } 
  	   }
    
	 return true;
}

//only characters, digits, braces and dots are allowed.
function isLetterDigitSpace(s,message,n,f)
{

 	 s1=s.value
     tt=s.value.length
     f=f*1
	if (f)
	{
		if (isBlank(s,message))
		{
			s.focus();
			s.select();
			return false;
		}
	}
     for (i = 0; i < tt; i++)
	   {   
	    var c = s1.charAt(i);
	    if (!( (c == " ") || ((c >= "A") && (c <= "Z")) || ((c >= "a") && (c <= "z")) || ((c >= 0) && (c <= 9)) || (c == ".") || (c == "(") || (c == ")")   ))
	     {
		  alert("Invalid entry, only alphabets, digits, braces and dots are allowed.\nPlease re-enter");
          s.focus();
   		  s.select();
		  return false;
	     } 
  	   }
    
	 return true;
}

function isT1toT2(T1,T2,M1,M2,N1,N2)
{
  M22="Invalid entry, only alphabets and digits are allowed.\nPlease re-enter";

  if ( !(IsLettersNumberSpace(T2,M22)) )
            {
              return false
            }
  if ( (T1.selectedIndex ==0 && T2.value.length>0) )
   {
			alert(M1)
			T1.focus();
 		    return false
   }

  return true

}


function isEmail1(s,message)
{
	var i,ii;
	var j;
	var k,kk;
    var jj;
    var len;

	if (isBlank(s,message))
	{
		s.focus();
		s.select();
		return false;
	}

    if (s.value.length >0){
		i=s.value.indexOf("@");
		ii=s.value.indexOf("@",i+1);
		j=s.value.indexOf(".",i);
		k=s.value.indexOf(",");
		kk=s.value.indexOf(" ");
		jj=s.value.lastIndexOf(".")+1;
		len=s.value.length;
		if ((i>0) && (j>(1+1)) && (k==-1) && (ii==-1) && (kk==-1) &&
			(len-jj >=2) && (len-jj<=3)) {}
		else {
	 		 	alert("Please enter valid E-mail id")
	 		 	s.focus();
	 		 	s.select();
				return false;
		}
	}
    return true;
}

//only characters and spaces are allowed
function isLetters(s,message,n,f)
{ 
   f=f*1
	if (f)
	{
	  if (isBlank(s,message))
	  {
		s.focus();
		s.select();
		return false;
	  }
    }

	s1=s.value
    tt=s.value.length
    if (tt>0)
    {
	  for (i = 0; i < tt; i++)
	   {   
	    var c = s1.charAt(i);
	    if (!(  ((c >= "A") && (c <= "Z")) || ((c >= "a") && (c <= "z")) || (c == " ") ))
	     {
		  alert("Invalid entry, only alphabets are allowed.\nPlease re-enter");
          s.focus();
   		  s.select();
		  return false;
	     } 
  	  }
    }
    return true

}



//only characters , digits and space are allowed.(contains two parameter)
function IsLettersNumberSpace(s,message1)
{
	  s1=s.value
      tt=s.value.length
      for (i = 0; i < tt; i++)
	   {
	    var c = s1.charAt(i);
	    if (!( ((c >= "0") && (c <= "9")) || ((c >= "A") && (c <= "Z")) || ((c >= "a") && (c <= "z")) || (c == " ") ))
	     {
          alert(message1);
          s.focus();
   		  s.select();
		  return false;
	     } 
  	   }
return true
}


function isCreditcardno(s,message,n,f)
{
   f=f*1
   if (f)
   {
	if (isBlank(s,message))
	{
		s.focus();
		return false;
	}
   }
     for (i = 0; i < s.value.length; i++)
	  {   
		var c = s.value.charAt(i);
			if (!(isNumericDigit(c))  )
			{
				 alert("Invalid entry, only digits are allowed.\nPlease re-enter.");
				 s.focus();
				 s.select();
				return false;
			}

      }
    return true
}

function isLoginName(s,message)
{
	// checking whether Login id is Blank or not
      if (isBlank(s,message))
      {
		s.focus();
		s.select();
		return false;
	  }
	  
	// checking whether the login id is having any special characters or not other that a-z A-Z 1-9 and _
	 
	  message1="Invalid entry, only alphabets, digits and underscores are allowed.\nPlease re-enter";
      if (!(isLoginSpecialChar(s,message1)))
      {
         return false;
      }

	// checking the length of Login id to be >4
	
  	  if (isLoginLen(s,message))
      {
		s.focus();
		s.select();
		return false;
	  }

	// checking whether there is any alphabet or not
		
		var flag = false
		var c = '';
		
		for (count = 0; count<s.value.length; count ++)
		{
			if (s.value.charAt(count)==" ")
			{
				alert(message1);
	  			s.focus();
				s.select();
	 			return false;
			}
	
			c = s.value.charAt(count);
			
			if ( ((c >= "A") && (c <= "Z")) || ((c >= "a") && (c <= "z"))	)
			{
				flag = true
			}
		}

		if (flag == false)
		{
         alert("There should be atleast one alphabet in the Login Id.");
	  	 s.focus();
		 s.select();
	 	 return false;
		}


/*	  if ((s.value.charAt(0)==" "))
	  {
         alert(message1);
	  	 s.focus();
		 s.select();
	 	 return false;
      }
	  else if ((s.value.charAt(0)>="0" && s.value.charAt(0)<="9" ) )
	  {
         alert("First letter of Login Id should not be digit or underscore");
	  	 s.focus();
		 s.select();
	 	 return false;
      }		  
  */    
/*	  if ((s.value.charAt(s.value.length-1)=="_"))
	  {
         alert("Last letter of Login Id should not be underscore");
	  	 s.focus();
		 s.select();
	 	 return false;
      }
*/		  
	  return true;
}
/*
function isLoginLen(s,message)
{
  loginlen=s.value.length
  if (!(loginlen>=4 && loginlen<=20))
  {
    alert("Login Id should not be less than four characters ")
    return true
  }
  else
  {
    return false  
  }
  
}
*/

function isLoginSpecialChar(s,message1)
{
      s1=s.value
      tt=s.value.length
      for (i = 0; i < tt; i++)
	   {
	    var c = s1.charAt(i);
	    //if (!( ((c >= "0") && (c <= "9")) || ((c >= "A") && (c <= "Z")) || ((c >= "a") && (c <= "z")) || (c=="_") ))
	    if (!( ((c >= "0") && (c <= "9")) || ((c >= "A") && (c <= "Z")) || ((c >= "a") && (c <= "z")) || (c=="_") || (c==".") ))  
	     {
          alert(message1);
          s.focus();
   		  s.select();
		  return false;
	     } 
  	   }
return true;
}

function isSpecialChar(s,message1)
{
      s1=s.value
      tt=s.value.length
      for (i = 0; i < tt; i++)
	   {
	    var c = s1.charAt(i);
	    if (!( ((c >= "0") && (c <= "9")) || ((c >= "A") && (c <= "Z")) || ((c >= "a") && (c <= "z"))  ))
	     {
          alert(message1);
          s.focus();
   		  s.select();
		  return false;
	     } 
  	   }
return true;
}

/*
function isPasswordLen(s,message)
{
  loginlen=s.value.length
  if (!(loginlen>=4 && loginlen<=20))
  {
    alert("Password should not be less than four characters ")
    return true
  }
  else
  {
    return false  
  }
  
}

*/
function isRePasswordName(s,message)
{
	if (isBlank(s,message))
	{
		s.focus();
		s.select();
		return false;
	}

      if (PasswordName!=s.value)
      {
        alert("Please retype same password")
		s.focus();
		s.select();
		return false;
	  }
	  	  
	  return true;
}


// trim leading and trailing spaces
function trim(text)				// trim leading and trailing spaces
{ 
    while (text.substring(0,1) == ' ')
	{
        text = text.substring(1, text.length);
	}
    while (text.substring(text.length-1,text.length) == ' ') 
	{
        text = text.substring(0, text.length-1);
	}	return text;
} 
////////////////////////////////////////////////////////

function populatevalue(frm,chkinM,chkinD,chkinY,chkoutM,chkoutD,chkoutY,hChkIn,hChkOut,hdiff,module)
{
	if (!validateDate(frm,chkinM,chkinD,chkinY,hChkIn))
	{ return false }
	if (chkoutM!="")
	{
		if (!validateDate(frm,chkoutM,chkoutD,chkoutY,hChkOut))
		{ return false }
		ckinm=eval("document."+frm+".elements['"+chkinM+"'].options[document."+frm+".elements['"+chkinM+"'].selectedIndex].value")
		ckind=eval("document."+frm+".elements['"+chkinD+"'].options[document."+frm+".elements['"+chkinD+"'].selectedIndex].value")
		ckiny=eval("document."+frm+".elements['"+chkinY+"'].options[document."+frm+".elements['"+chkinY+"'].selectedIndex].value")
		ckin=ckinm+"/"+ckind+"/"+ckiny
		
		ckoutm=eval("document."+frm+".elements['"+chkoutM+"'].options[document."+frm+".elements['"+chkoutM+"'].selectedIndex].value")
		ckoutd=eval("document."+frm+".elements['"+chkoutD+"'].options[document."+frm+".elements['"+chkoutD+"'].selectedIndex].value")
		ckouty=eval("document."+frm+".elements['"+chkoutY+"'].options[document."+frm+".elements['"+chkoutY+"'].selectedIndex].value")
		ckout=ckoutm+"/"+ckoutd+"/"+ckouty
		diff=(new Date(ckout).valueOf()-new Date(ckin).valueOf())/86400000
		if (module=="H")
		{
			if (!(diff > 0))
			{
				alert("Check-in date cannot be less than check-out date")
				return false;
			}
		}
		else if(module=="A")
		{	
			if (!(diff >= 0))
			{
				alert("Please check your return date, it must be later than departure date");
				eval("document."+frm+".elements['"+chkoutM+"'].focus()");
				return false;
			}
		}
		else if(module=="C")
		{	
			if (!(diff >= 0))
			{
				alert("Pick-up date cannot be less than drop-off date")
				return false;
			}
		}
		eval("document."+frm+"."+hdiff+".value=diff")
	}
	return true;
}

function popup(city,city1) ////for city lookup
{
	val = eval("document."+city+".value")
	filter  = val.replace(/ /g,"+") ///put + in querystring
	window.open('../common/citylookup.asp?inp=' + filter + '&fieldname=' + city + '&fieldnamehidden='+ city1,'cal','top=240,left=450,WIDTH=450,HEIGHT=200,scrollbars=1,screenX=400, screenY=400, resizable=0');
}
function filltext(a,b)
{
	b.value=a.value
}

function isNumericInteger(str,fldname)
{
	
	if(str.value.charAt(0)==" ")
	{
		alert("Invalid entry, space not allowed")
		str.focus();
		return false;
	}
	
	
	if(isNaN(str.value))
	{
		alert("Invalid entry, only digits are allowed.")
		str.focus();
		return false;
	}
	
	if(str.value !='')
	{
		if (str.value < 0) 
		{
			alert("Invalid entry ,please enter correct number of " + fldname+".");
			str.focus();
			return false;
		}
		strval = str.value
		if(strval.indexOf(".")>=0)
		{
			alert("Invalid entry, please enter correct number of " + fldname +".")
			str.focus();
			return false;
		}
	}
	return true;
}



function checkPassengers(adult,child,infant,paxnum)
{				
	if (adult.value == "")
		   adult.value = 0;

	if (child.value == "")
		   child.value = 0;

	if (infant.value == "")
		   infant.value = 0;		   

	if (isNaN(adult.value))
	{
		alert("Invalid entry, only digits are allowed.\nPlease re-enter");
		adult.focus();
		return false;
	}
	
	if (isNaN(child.value))
	{
		alert("Invalid entry, only digits are allowed.\nPlease re-enter");
		child.focus();
		return false;
	}
				   
	if (isNaN(infant.value))
	{
		alert("Invalid entry, only digits are allowed.\nPlease re-enter");
		infant.focus();
		return false;
	}
		
	if ((adult.value+child.value) < 1 )
	{
		alert("Please enter number of people traveling");
		adult.focus();
		return false;
	}
	
	
	if(!isNumericInteger(adult,'Adult'))
	{
		return false;
	}

	if (child.value!='')
	{ 
		if(!isNumericInteger(child,'Child'))
		{
			return false;
		}
	}

	if (infant.value!='')
	{ 
		if(!isNumericInteger(infant,'Infant'))
		{
			return false;
		}
	}
	
	
	if ((parseInt(adult.value) > 0) && (parseInt(adult.value) > paxnum))
	{		
		alert("Total number of Adults travelling cannot be more than " + paxnum+".");
		adult.focus();
		return false;
	}
	
	if ((parseInt(child.value) > 0) && (parseInt(child.value) > paxnum))
	{
		alert("Total number of Children travelling cannot be more than" + paxnum+".");
		child.focus();
		return false;
	}
	
	/*if (child.value==" " || child.value=="" )
	{
		return true;
	}
	*/
	
    if ( (parseInt(adult.value)+parseInt(child.value)) > paxnum )
	{
		alert("You can't book online if the total passenger exceeds" + paxnum+", which includes both adults and children in single journey.\nYou may reduce the total number of passengers accordingly");
		child.focus();
		return false;
	}
	
	if(infant!="")	
	{
		if (isNaN(infant.value))
		{
			alert("Invalid entry, only digits are allowed.\nPlease re-enter");
			infant.focus();
			return false;
		}
		if (infant.value==" " || infant.value=="" )
		{
			return true;
		}
		
		if ( parseInt(infant.value) > parseInt(adult.value) )
		{
			alert("Number of infants should not exceed number of adults");	
			infant.focus();
			return false;
		}
	
	}	
        if(document.getElementById('frmHomePageLeft_chkConnecting')!=null)
        {
   	        if(document.getElementById('frmHomePageLeft_chkConnecting').checked==true)
	        {	
		        if ( parseInt(child.value) >  0 && parseInt(adult.value) <= 0)
		        {
			        alert("Unaccompanied minor is not allowed in connecting flight");	
			        child.focus();
			        return false;
		        }	        
	        }    
	    }	
	
return true
}

function validateDate(frm,chkinM,chkinD,chkinY,hChkIn)
{
	ckinm=eval("document."+frm+".elements['"+chkinM+"'].options[document."+frm+".elements['"+chkinM+"'].selectedIndex].value")
	ckind=eval("document."+frm+".elements['"+chkinD+"'].options[document."+frm+".elements['"+chkinD+"'].selectedIndex].value")
	ckiny=eval("document."+frm+".elements['"+chkinY+"'].options[document."+frm+".elements['"+chkinY+"'].selectedIndex].value")
	ckin=ckinm+"/"+ckind+"/"+ckiny
	var systemdate=new Date()
	var sysdate,diff
	systemdate=((systemdate.getMonth()+1)+"/"+systemdate.getDate()+"/"+systemdate.getFullYear())
	sysdate=new Date(systemdate).valueOf()+86400000*5
	ckin=new Date(ckin).valueOf()
	diff =((ckin-sysdate)/86400000)	
	
	var firstDate = new Date(sysdate)
	var new_day=firstDate.getDate()
	if (new_day < 10)
	{
		new_day="0"+new_day
	}
	var new_mon=firstDate.getMonth()+1
	if (new_mon <10)
	{
		new_mon="0"+new_mon
	}
	var new_year=firstDate.getFullYear()
	new_date=new_day+"/"+new_mon+"/"+new_year

	if (diff < 0)
	{
		alert("Please enter a date that is atleast five days from today's date")
		eval("document."+frm+".elements['"+chkinD+"'].focus()")
		return false;
	}
	/*if (diff > 328)
	{
		alert("Please enter a date that should not exceed 331 days from today's date")
		eval("document."+frm+".elements['"+chkinD+"'].focus()")
		return false;
	}*/
	return true;
}

function check_date(frm,chkinM,chkinD,chkinY)
{
	//alert(frm)
	var yy = document.getElementById(chkinY).options[document.getElementById(chkinY).selectedIndex].value

	if (document.getElementById(chkinM).selectedIndex==1)
	{
		if ((document.getElementById(chkinD).selectedIndex>27)&&((yy%4)!=0))////not a leap year
		{	
			document.getElementById(chkinD).selectedIndex=0
			document.getElementById(chkinM).selectedIndex=2
		}
		if ((document.getElementById(chkinD).selectedIndex>28)&&((yy%4)==0))///leap year
	    {
			document.getElementById(chkinD).selectedIndex=0
			document.getElementById(chkinM).selectedIndex=2
		}
	}
	//alert(eval("document."+frm+".elements['"+chkinM+"'].selectedIndex"))
	if ((document.getElementById(chkinM).selectedIndex==3)||(document.getElementById(chkinM).selectedIndex==5)||(document.getElementById(chkinM).selectedIndex==8)||(document.getElementById(chkinM).selectedIndex==10))
	{
		if (document.getElementById(chkinD).selectedIndex==30)
		{
			document.getElementById(chkinD).selectedIndex=0
			document.getElementById(chkinM).selectedIndex=document.getElementById(chkinM).selectedIndex+1
		}
	}
	
}

function increment_date(chkinM,chkinD,chkinY,chkoutM,chkoutD,chkoutY)
{
	var ckinm,ckind,ckiny,ckin,ckoutm,ckoutd,ckouty,ckout;
	
	ckinm=document.getElementById(chkinM).options[document.getElementById(chkinM).selectedIndex].value
	
	ckind=document.getElementById(chkinD).options[document.getElementById(chkinD).selectedIndex].value
	ckiny=document.getElementById(chkinY).options[document.getElementById(chkinY).selectedIndex].value
	ckin=ckinm+"/"+ckind+"/"+ckiny;
	
	var systemdate=new Date()
	var sysdate,diffy
	systemdate=((systemdate.getMonth()+1)+"/"+systemdate.getDate()+"/"+systemdate.getFullYear())
	sysdate=new Date(systemdate).valueOf()
	ckinin=new Date(ckin).valueOf()
	diffin =((ckinin-sysdate)/86400000)	
	if (diffin < 0)
	{	
		ckiny=ckiny*1+1
		selectbox(document.getElementById(chkinY),ckiny*1)
	}
	//alert(frm)
	check_date(frm,chkinM,chkinD,chkinY)

	ckin=ckinm+"/"+ckind+"/"+ckiny;
	//Modified By Yogendra Jain dated 6 Dec 2001 to incorporate Thomas Cook One Way Trip
	if (chkoutM == "")
	{
	}
	else
	{
		ckoutm=document.getElementById(chkoutM).options[document.getElementById(chkoutM).selectedIndex].value
		ckoutd=document.getElementById(chkoutD).options[document.getElementById(chkoutD).selectedIndex].value
		ckouty=document.getElementById(chkoutY).options[document.getElementById(chkoutY).selectedIndex].value
		ckout=ckoutm+"/"+ckoutd+"/"+ckouty

		var diff,chkindate,chkoutdate
		chkindate=new Date(ckin).valueOf()
		chkoutdate=new Date(ckout).valueOf()
		diff =((chkoutdate-chkindate)/86400000)	

		if (diff < 0)
		{
			checkindateplusone=new Date(ckin).valueOf()
			currentdate=new Date(checkindateplusone)
			document.getElementById(chkoutM).selectedIndex=currentdate.getMonth()
			document.getElementById(chkoutD).selectedIndex=currentdate.getDate()-1
			selectbox(document.getElementById(chkoutY),currentdate.getFullYear())
		}
		check_date(frm,chkoutM,chkoutD,chkoutY)
	}
}
/*
function isEmail(s,message)
{
	var i,ii;
	var j;
	var k,kk;
    var jj;
    var len;

	if (isBlank(s,message))
	{
		s.focus();
		s.select();
		return false;
	}

    if (s.value.length >0){
		i=s.value.indexOf("@");
		ii=s.value.indexOf("@",i+1);
		j=s.value.indexOf(".",i);
		k=s.value.indexOf(",");
		kk=s.value.indexOf(" ");
		jj=s.value.lastIndexOf(".")+1;
		len=s.value.length;
		if ((i>0) && (j>(1+1)) && (k==-1) && (ii==-1) && (kk==-1) &&
			(len-jj >=2) && (len-jj<=3)) {}
		else {
	 		 	alert("Please enter valid E-mail id")
	 		 	s.focus();
	 		 	s.select();
				return false;
		}
	}
	
	
    return true;
}
*/
////////////////////////////////////////////////////////////////////////////

function isvaliddob(frm,dobD,dobM,dobY)
{
	
	var yy = eval("document."+frm+".elements['"+dobY+"'].options[document."+frm+".elements['"+dobY+"'].selectedIndex].value")
	
	if (eval("document."+frm+".elements['"+dobM+"'].selectedIndex")==2)
	{
		if ((eval("document."+frm+".elements['"+dobD+"'].selectedIndex")>28)&&((yy%4)!=0))////not a leap year
		{	
			return false;
		}
		if ((eval("document."+frm+".elements['"+dobD+"'].selectedIndex")>29)&&((yy%4)==0))///leap year
	    {
			return false;
		}
	}
	if ((eval("document."+frm+".elements['"+dobM+"'].selectedIndex")==4)||(eval("document."+frm+".elements['"+dobM+"'].selectedIndex")==6)||(eval("document."+frm+".elements['"+dobM+"'].selectedIndex")==9)||(eval("document."+frm+".elements['"+dobM+"'].selectedIndex")==11))
	{
		if (eval("document."+frm+".elements['"+dobD+"'].selectedIndex")==31)
		{
			return false;
		}
	}
	mm=eval("document."+frm+".elements['"+dobM+"'].options[document."+frm+".elements['"+dobM+"'].selectedIndex].value")
	dd=eval("document."+frm+".elements['"+dobD+"'].options[document."+frm+".elements['"+dobD+"'].selectedIndex].value")
	dobin=mm+"/"+dd+"/"+yy;
	
	var systemdate=new Date()
	var sysdate,diffy
	systemdate=((systemdate.getMonth()+1)+"/"+systemdate.getDate()+"/"+systemdate.getFullYear())
	sysdate=new Date(systemdate).valueOf()
	dobinin=new Date(dobin).valueOf()
	diffin =((dobinin-sysdate)/86400000)	
	if (diffin >= 0)
	{	
		return false;
	}
	     
	return true
}

//only digits and spaces are allowed.
function isDigit(s,message,n,f)
{
   f=f*1
   if (f)
   {
	if (isBlank(s,message))
	{
		s.focus();
		return false;
	}
   }
     for (i = 0; i < s.value.length; i++)
	  {   
		var c = s.value.charAt(i);
		if (!(isNumericDigit(c))  )
		{
			 alert("Invalid entry, only digits are allowed.\nPlease re-enter.");
			 s.focus();
			 s.select();
			return false;
		}
      }
    return true
}

function returnfalse(Message,ObjField)
{
	alert(Message);
	ObjField.focus();
	ObjField.select();
	return false;
}
function isCommonValidate(ObjField, BlankMessage, Condition, MandatoryFlag, Minlen, MinMessage, Maxlen, MaxMessage)
{
	var ObjPattern, Message
	ObjField.value=trim(ObjField.value);
	var str=ObjField.value;	
	if (MandatoryFlag*1==1 && str=='')
		return returnfalse(BlankMessage,ObjField);

	if (str != '')
	{
		if(arguments.length > 4)
		{
			if (str.length < Minlen*1)
			{	return returnfalse(MinMessage,ObjField); }
		
			if(arguments.length > 6 && str.length > Maxlen*1)
			{	return returnfalse(MaxMessage,ObjField); }
		}
		switch(Condition*1)
		{ 
			case 1:
					ObjPattern= /^[0-9]+$/gi; //for credit card
					Message="Invalid entry, only digits are allowed.\nPlease re-enter";
					break;
			case 2:
					ObjPattern= /^[0-9 ]+$/gi; //for phone no.
					Message="Invalid entry, only digits and spaces are allowed.\nPlease re-enter";
					break;
			case 3:
					ObjPattern= /^[0-9.]+$/gi; //for rate
					Message="Invalid entry, only digits and decimal are allowed.\nPlease re-enter";
					break;
			case 4:
					ObjPattern= /^[a-zA-Z]+$/gi;//
					Message="Invalid entry, only alphabets are allowed.\nPlease re-enter";
					break;
			case 5:
					ObjPattern= /^[a-zA-Z ]+$/gi;//for name, state
					Message="Invalid entry, only alphabets and spaces are allowed.\nPlease re-enter";
					break;
			case 6:
					ObjPattern= /^[a-zA-Z0-9]+$/gi;//programme no, zip code
					Message="Invalid entry, only alphabets and digits are allowed.\nPlease re-enter";
					break;
			case 7:
					ObjPattern= /^[a-zA-Z0-9 ]+$/gi;//for city
					Message="Invalid entry, only alphabets, digits and spaces are allowed.\nPlease re-enter";
					break;
			case 8:
					ObjPattern= /^[^'\"]+$/gi;
					Message="Invalid entry,  apostrophes (') and double quotes (\") are not allowed.\nPlease re-enter";
					break;
			case 9:
					ObjPattern= /^[a-zA-Z0-9()]+$/gi;//
					Message="Invalid entry, only alphabets, digits and Parentheses are allowed.\nPlease re-enter";
					break;
			case 10:
					ObjPattern= /^[a-zA-Z0-9(). ]+$/gi;//
					Message="Invalid entry, only alphabets, digits, Parentheses, dots and spaces are allowed.\nPlease re-enter";
					break;
			case 11:
					ObjPattern= /^[a-zA-Z0-9()-.,\/ #: ]+$/gi;//
					Message="Invalid entry, only alphabets, digits, Parentheses, comma, hyphens, dots, dash and spaces are allowed.\nPlease re-enter";
					break;
			case 12:
					ObjPattern= /^[A-Za-z]\w*([.|-]\w*){0,4}[@]\w+[A-Za-z-]*([.]\w{2,10}){1,4}$/gi; //email id
					Message="Invalid entry, Please enter correct email address.";
					break;
			case 13: ///login id
					if ((str.charAt(0) == '_')||((str.charAt(0) >= 0)&&(str.charAt(0) <= 9)))
					{
						Message="Invalid entry, first character can not be a number or underscore.\nPlease re-enter";
						return returnfalse(Message,ObjField);
					}
					if (str.charAt(str.length-1) == '_')
					{
						Message="Invalid entry, last character can not be underscore.\nPlease re-enter";
						return returnfalse(Message,ObjField);
					}
					ObjPattern= /^\w+[.]*\w*$/gi; //login id
					Message="Invalid entry, only alphabets, digits, dot and underscores are allowed.\nPlease re-enter";
					break;
			case 14://hexadecimal code
					ObjPattern= /^#[A-Fa-f0-9]{6}$/gi; 
					Message="Invalid entry, Please enter correct Hexadecimal code.";
					break;
			case 15://for address or comments (not to go on host)
					ObjPattern= /^[^'\"<>]+$/gi;
					Message="Invalid entry,  apostrophes ('), double quotes (\"), less then (<) and greater then (>) signs are not allowed.\nPlease re-enter";
					break;
			case 16:
					ObjPattern= /^[0-9]+$/gi; //for queue no.
					Message="Invalid entry, only digits are allowed.\nPlease re-enter";
					break;
			case 17:
					ObjPattern= /^[a-zA-Z0-9-&(). ]+$/gi; //for Agency Name
					Message="Invalid entry, only alphabets, digits, hyphen, space, parenthese, dot and amprasand(&) are allowed.\nPlease re-enter";
					break;
			case 18:
					ObjPattern= /^[0-9-, ]+$/gi; //for Agency Phone
					Message="Invalid entry, only digits, hyphen, space and quoma(,) are allowed.\nPlease re-enter";
					break;
		}
		if (!(ObjPattern.test(str)))
		{	return returnfalse(Message,ObjField); }
		ObjPattern.test(str) ///for netscape error handling
	}
	return true;
}
////////////////////////////////////////////////////////////////
var bMSIE = false;
var browserName
function sniffTheBrowser()
{
    var ua = navigator.userAgent;
    var an = navigator.appName;

    // is it IE?
    bMSIE = (ua.indexOf("MSIE")>=1);
    // else please send your working sniffers for other browsers to michaele@microsoft.com

	if (bMSIE)
        browserName = "IE";
    else if (an == "Netscape")
        browserName = "Netscape";
    else
        browserName = "Not supported";
//	alert(browserName)
}

// *************************************************************
// This function will take the user to TCIL login / register / signout page

function tcil_page(url)
{
	eval('document.tcilform.action="'+url+'"')
	document.tcilform.submit()
}

// **************************************************************
// This function will take the user to search input page as specified in url as parameter

function input_page(url)
{
	eval('document.searchinputform.action="'+url+'"')
	document.searchinputform.submit()
}

// THIS FUNCTION IS USED TO VALIDATE THE DATE OF BIRTH 

function checkbirthdate(frm,chkinM,chkinD,chkinY)
	{
	
		var yy = eval("document."+frm+".elements['"+chkinY+"'].options[document."+frm+".elements['"+chkinY+"'].selectedIndex].value")
		var mm = eval("document."+frm+".elements['"+chkinM+"'].options[document."+frm+".elements['"+chkinM+"'].selectedIndex].value")
		if (eval("document."+frm+".elements['"+chkinM+"'].selectedIndex")==2)
		{
			if ((yy!="")||(mm!=""))
			{
				if ((eval("document."+frm+".elements['"+chkinD+"'].selectedIndex")>28)&&((yy%4)!=0))////not a leap year
				{	
					eval("document."+frm+".elements['"+chkinD+"'].selectedIndex=1")
					eval("document."+frm+".elements['"+chkinM+"'].selectedIndex=3")
				}
				if ((eval("document."+frm+".elements['"+chkinD+"'].selectedIndex")>29)&&((yy%4)==0))///leap year
				{
					eval("document."+frm+".elements['"+chkinD+"'].selectedIndex=1")
					eval("document."+frm+".elements['"+chkinM+"'].selectedIndex=3")
				}
			}
		}
		if ((eval("document."+frm+".elements['"+chkinM+"'].selectedIndex")==4)||(eval("document."+frm+".elements['"+chkinM+"'].selectedIndex")==6)||(eval("document."+frm+".elements['"+chkinM+"'].selectedIndex")==9)||(eval("document."+frm+".elements['"+chkinM+"'].selectedIndex")==11))
		{
			if (eval("document."+frm+".elements['"+chkinD+"'].selectedIndex")==31)
			{
				eval("document."+frm+".elements['"+chkinD+"'].selectedIndex=1")
				eval("document."+frm+".elements['"+chkinM+"'].selectedIndex=document."+frm+".elements['"+chkinM+"'].selectedIndex+1")
			}
		}     
	}
	
	
	
	///This function is used to check and modify the dade format
	function DateCheck(sDate,minperiod)
	{
		var iDateLength
		var iDay
		var sMonth
		var	iYear
		var iFirst
		var iSecond
		var bLeapYear
		var sMessage
		sMessage = "Enter a valid Date in dd/mm/yyyy format."
		iDateLength=sDate.length
	
		if (iDateLength < 5) 
		{
			alert (sMessage)
			return false;
		}
		else 
		{
			iFirst=sDate.indexOf("/")
			if (iFirst=="1")
			{
				iDay="0" + sDate.substring(0,1)
				sDate = sDate.substring(2,iDateLength)
		   	}
			else if (iFirst=="2")
			{
				iDay=sDate.substring(0,2)	
				sDate = sDate.substring(3,iDateLength)
			}
			else
			{
				alert (sMessage)
				return false;
			}
			if (iDay=="00")
			{
				alert (sMessage)
				return false;
			}
			if (isNaN(iDay))
			{
				alert(sMessage)
				return false;
			}
			iSecond=sDate.indexOf("/")
			iDateLength=sDate.length
			if (iSecond=="1")
			{
				smonth="0" + sDate.substring(0,1)
				iYear = sDate.substring(2,iDateLength)
		   	}
			else if (iSecond=="2")
			{
				smonth=sDate.substring(0,2)	
				iYear = sDate.substring(3,iDateLength)
			}
			else
			{
				alert(sMessage)
				return false;
			}
			if (smonth=="00")
			{
				alert(sMessage)
				return false;
			}
			if (isNaN(smonth))
			{
				alert(sMessage)
				return false;
			}
		
			if(iYear.length =="1") 
			{
				iYear="200"+iYear
			}
		
			else if(iYear.length =="2") 
			{
				iYear="20"+iYear
			}
			else if (iYear.length=="4")
			{
				iYear= iYear
			}
			else
			{
				alert(sMessage)
				return false;
			}  	
			if (isNaN(iYear))
			{
				alert(sMessage)
				return false;
			}
		}
		var timeA = new Date(iYear,smonth-1,iDay);
		if(!((timeA.getDate()==iDay) && (timeA.getMonth()==(smonth-1))))
		{
			alert(sMessage)
			return false;
		}
		if (isNaN(minperiod))
			minperiod=0;

		var sysdate=new Date()
		sysdate=((sysdate.getMonth()+1)+"/"+sysdate.getDate()+"/"+sysdate.getFullYear())
		var syscurrdate=new Date(sysdate).valueOf() 
		var minbookperiod=new Date(sysdate).valueOf()+86400000*minperiod

		//Validating Today's date and date diff
		var sDate=smonth+"/"+iDay+"/"+iYear
		var ckin=new Date(sDate).valueOf()
		var diff =((ckin-syscurrdate)/86400000)	
/*		if (diff < 0)
		{
			alert("Date can not be less than today's date.")
			return false;
		}
		if (diff > 331)
		{
			alert("Date should not exceed 331 days from today's date.")
			return false;
		}
*/
		//validating date and and the min booking period
		diff =((ckin-minbookperiod)/86400000)	
/*		if (diff < 0)
		{
			alert("A booking must be made a minimum of " + minperiod + " days in advance.")
			return false;
		}
*/	// Check End
	sDate=iDay+'/'+smonth+'/'+iYear
	return sDate;
}

///////////////////////////////////////////////////Start Flight Search Page Javascript/////////////////////////////////
function fillCalender()
		{
			sniffTheBrowser()
			var Today = new Date().valueOf()
				var firstDate = new Date(Today)
				var day1 = firstDate.getDate()
				var month1 
				month1 = firstDate.getMonth()+1
				var year1 = firstDate.getFullYear()
				month1 = month1.toString()
				day1 = day1.toString()			
				if(day1.length==1)
				{
					day1 = "0"+day1
				}
				if(month1.length==1)
				{
					month1 = "0"+month1
				}
				
			var str_cookie,oval,cval
			//Code Commented By Girish Kalia on 25 May 2010 to stop session mentainence on all POS Search Pages
			/*str_cookie = document.cookie
			index1 = str_cookie.indexOf("igtsAirIndia")
			
			if (index1 >=0)
			{
					
					
				strcookie1 = str_cookie.substr(index1,str_cookie.length)
				index2 = strcookie1.indexOf(";")
				if (index2 >=0)
				{
					strcookie2 = strcookie1.substring(strcookie1.indexOf("=")+1,index2)
				}
				else
				{
					strcookie2 = strcookie1.substring(strcookie1.indexOf("=")+1,strcookie1.length)
				}
				cookies_ary = strcookie2.split('&')
				for(cnt_elements=0;cnt_elements<cookies_ary.length ;cnt_elements++)
				{
					val = cookies_ary[cnt_elements].split('=')
					if (val[0] == "porigincity")
					{
						selectbox(document.frmCalendarSample.cmb_originCity,val[1])
						oval = val[1]
						ChangeOptions("cmb_originCity","cmb_destCity","ArrCity")
					}	
				
					
					if (val[0] == "pdepartdate")
					{	
						document.frmCalendarSample.departdate.value = val[1].substr(5,2)+"/"+val[1].substr(0,2)+"/"+val[1].substr(10,4)
						frmCalendarSample.tbSelYear.value = val[1].substr(10,4)
						frmCalendarSample.tbSelMonth.value = val[1].substr(0,2)
						monthVal1 = frmCalendarSample.tbSelMonth.value
						monthVal1 = monthVal1.toString()			
						if(monthVal1.length==1)
						{
							monthVal1 = "0"+monthVal1
						}
						month_name(monthVal1)
						
						//UpdateCal('yr',frmCalendarSample.tbSelYear.value,'mn',frmCalendarSample.tbSelMonth.value,'page')
						UpdateCal('yr',frmCalendarSample.tbSelYear.value,'mn',frmCalendarSample.tbSelMonth.value,'page')
																	
						dispval.innerText =   month_nm + " " + val[1].substr(10,4)
					}
			
					if (val[0] == "preturndate")
					{
						if(val[1]!="")
						{
							document.frmCalendarSample.returndate.value = val[1].substr(5,2)+"/"+val[1].substr(0,2)+"/"+val[1].substr(10,4)
							frmCalendarSample.tbSelYear2.value = val[1].substr(10,4)
							frmCalendarSample.tbSelMonth2.value = val[1].substr(0,2)	
							monthVal2 = frmCalendarSample.tbSelMonth2.value
							monthVal2 = monthVal2.toString()			
							if(monthVal2.length==1)
							{
								monthVal2 = "0"+monthVal2
							}
							month_name(monthVal2)
							UpdateCal2('yr',frmCalendarSample.tbSelYear2.value,'mn',frmCalendarSample.tbSelMonth2.value,'page')
							dispval2.innerText =   month_nm + " " + val[1].substr(10,4)
						}
						else
						{
							frmCalendarSample.tbSelYear2.value = year1
							frmCalendarSample.tbSelMonth2.value = month1
							monthVal2 = frmCalendarSample.tbSelMonth2.value
							monthVal2 = monthVal2.toString()			
							if(monthVal2.length==1)
							{
								monthVal2 = "0"+monthVal2
							}
							month_name(monthVal2)
							dispval2.innerText =   month_nm + " " + year1							
							document.frmCalendarSample.returndate.value = day1 +"/"+ month1 +"/"+ year1
						}
					}
				
					if (val[0] == "flagfare")
					{
						trip_type = val[1]
						document.frmCalendarSample.flagfare.value = trip_type 
						if (trip_type == "O")
						{
							changetrip(1)		
						}
						else
						{
							changetrip(2)		
						}
						
					}
					if (val[0] == "padus")
					{
						eval("document.frmCalendarSample.txt_adult.value ='" + val[1] +"'")
					}	
					if (val[0] == "pchild")
					{
						eval("document.frmCalendarSample.txt_child.value ='" + val[1] +"'")
					}	
					if (val[0] == "pinfant")
					{
						eval("document.frmCalendarSample.txt_infant.value='" + val[1] +"'")
					}
					if (val[0] == "pclass")
					{
						eval("document.frmCalendarSample.str_class.value='" + val[1] +"'")
					}
					if (val[0] == "pdestcity")
					{
						cval = val[1]
					}			
					
				}
				fillOptions(oval,cval)
				
			}
			else
			{			
				var dCurDate = new Date();
										
				frmCalendarSample.tbSelYear.value = dCurDate.getFullYear();
				frmCalendarSample.tbSelMonth.value = dCurDate.getMonth()+1;
				frmCalendarSample.tbSelYear2.value = dCurDate.getFullYear();
				frmCalendarSample.tbSelMonth2.value = dCurDate.getMonth()+1;
				monthVal1 = frmCalendarSample.tbSelMonth.value
				monthVal2 = frmCalendarSample.tbSelMonth2.value
				
				monthVal1 = monthVal1.toString()			
				if(monthVal1.length==1)
				{
					monthVal1 = "0"+monthVal1
				}
					monthVal2 = monthVal2.toString()			
				
				month_name(monthVal1)	
				////document.getElementById("dispval").innerText = month_nm + " " + dCurDate.getFullYear()
				dispval.innerText =   month_nm + " " + dCurDate.getFullYear()
				
				if(monthVal2.length==1)
				{
					monthVal2 = "0"+monthVal2
				}
				
				month_name(monthVal2)
				////document.getElementById("dispval2").innerText = month_nm + " " + dCurDate.getFullYear()
				dispval2.innerText =   month_nm + " " + dCurDate.getFullYear()
					
				
				document.frmCalendarSample.flagfare.value="O"				
				changetrip(1)
				document.frmCalendarSample.departdate.value = day1 +"/"+ month1 +"/"+ year1
				document.frmCalendarSample.returndate.value = day1 +"/"+ month1 +"/"+ year1
	
			}*/
				var dCurDate = new Date();
										
				frmCalendarSample.tbSelYear.value = dCurDate.getFullYear();
				frmCalendarSample.tbSelMonth.value = dCurDate.getMonth()+1;
				frmCalendarSample.tbSelYear2.value = dCurDate.getFullYear();
				frmCalendarSample.tbSelMonth2.value = dCurDate.getMonth()+1;
				monthVal1 = frmCalendarSample.tbSelMonth.value
				monthVal2 = frmCalendarSample.tbSelMonth2.value
				
				monthVal1 = monthVal1.toString()			
				if(monthVal1.length==1)
				{
					monthVal1 = "0"+monthVal1
				}
					monthVal2 = monthVal2.toString()			
				
				month_name(monthVal1)	
				////document.getElementById("dispval").innerText = month_nm + " " + dCurDate.getFullYear()
				dispval.innerText =   month_nm + " " + dCurDate.getFullYear()
				
				if(monthVal2.length==1)
				{
					monthVal2 = "0"+monthVal2
				}
				
				month_name(monthVal2)
				////document.getElementById("dispval2").innerText = month_nm + " " + dCurDate.getFullYear()
				dispval2.innerText =   month_nm + " " + dCurDate.getFullYear()
					
				
				document.frmCalendarSample.flagfare.value="O"				
				changetrip(1)
				document.frmCalendarSample.departdate.value = day1 +"/"+ month1 +"/"+ year1
				document.frmCalendarSample.returndate.value = day1 +"/"+ month1 +"/"+ year1
		}



			

		function fixdate(str)
			{
				//alert(str)
				strval = eval(str+".value")
				//alert(strval)
				if (strval.indexOf("/")<=0)
				{
					alert("Please enter a valid date in dd/mm/yyyy format")
					eval(str +".focus()");
					dateFlag = false
					return false;
				}
				else
				{				
					str_arr = strval.split("/")
					if(str_arr.length<3)
					{
						alert("Please enter a valid date in dd/mm/yyyy format")
						eval(str +".focus()");
						dateFlag = false
						return false;
					}
					else	
					{
						if(isNaN(str_arr[0]) || isNaN(str_arr[1]) || isNaN(str_arr[2]) )
						{
							alert("Please enter a valid date in dd/mm/yyyy format")
							eval(str +".focus()");
							dateFlag = false
							return false;
						}
						else
						{
							if(str_arr[2].length<4)
							{
								alert("Please enter year in YYYY format")
								eval(str +".focus()");
								dateFlag = false
								return false;
							}
							
							
							if (!DateCheck(eval(str+".value",0)))
							{ 
								eval(str +".focus()");
								dateFlag = false
								return false;
							}
							else
							{
								dateFlag =true
							}
						}
											
					}
				}
			}
			
			function changetrip()
			{				
				
				if (frmCalendarSample.flagfare.value=="O")
				{					
					
					if(browserName == "IE")
						{
						  document.frmCalendarSample.returndate.disabled=true;
						   //Block Added - Change #1 - Start
						     //Enable Special RT fare checkbox on Roundtrip availability
						   if(document.getElementById("chkSpecialRT")!=null)
						   {
					        document.getElementById("chkSpecialRT").disabled = true;
					        document.getElementById("chkSpecialRT").checked = false; 
					       }
					        //Block Added - Change #1 - End   
						}
					if(browserName == "Netscape")
						{
						    document.frmCalendarSample.returndate.readonly=true;
						      //Block Added - Change #1 - Start
					        //Enable Special RT fare checkbox on Roundtrip availability
					       if(document.getElementById("chkSpecialRT")!=null)
						   {
					        document.getElementById("chkSpecialRT").disabled = true;
					        document.getElementById("chkSpecialRT").checked = false; 
					       }
					        //Block Added - Change #1 - End    
						}
						
				}
				else
				{					
					if(browserName == "IE")
						{
						    document.frmCalendarSample.returndate.disabled=false;
						      //Block Added - Change #1 - Start
					        //Enable Special RT fare checkbox on Roundtrip availability
					       if(document.getElementById("chkSpecialRT")!=null)
						   {
					        document.getElementById("chkSpecialRT").disabled = false;
					       }
					        //Block Added - Change #1 - End
						}
					if(browserName == "Netscape")
						{
						    document.frmCalendarSample.returndate.readonly=false;
						      //Block Added - Change #1 - Start
					        //Enable Special RT fare checkbox on Roundtrip availability
					       if(document.getElementById("chkSpecialRT")!=null)
						   {
					        document.getElementById("chkSpecialRT").disabled = false;
					       }
					        //Block Added - Change #1 - End  
						}
						validate_date('departdate')					
				}
			}
			
			
			
			
			
			
			
		function fillOptions(origCityVal,destCityVal)  
			{
			var selectedval
			strArray = "ArrCity"
			strArrayNum="0"
			strArrayVal="jj"
			var alen    = eval(strArray + ".length")
			var listLen = 1;
			//var strKey  = eval("document.frmCalendarSample.cmb_originCity.options[document.frmCalendarSample.cmb_originCity.selectedIndex].value")
			var strKey = origCityVal
			eval("document.frmCalendarSample.cmb_destCity.options.length = 0");
			eval("document.frmCalendarSample.cmb_destCity.options[0] = new Option('Select Destination City','' )");
			for (var i = 0; i < alen; i++) 
			{
			  
			  if (eval(strArray)[i][0] == strKey)
			  {
			  eval("document.frmCalendarSample.cmb_destCity.options[listLen] = new Option(" + strArray + "[i][2], " + strArray + "[i][1]" + " + '|' + " + strArray +"[i][2])");
					if(eval( strArray + "[i][1] =='" +destCityVal+ "'"))
					{
						eval("document.frmCalendarSample.cmb_destCity.selectedIndex = listLen")
					}
			  listLen = listLen + 1;
			  } 
			  //eval("document.frmCalendarSample.cmb_destCity.focus()");
			}
			}
	function ChangeOptions(lstPrimary, lstSecondary, strArray) 
			{			
			var selectedval,strArrayNum, strArrayVal
			strArrayNum="0"
			strArrayVal="jj"
			
			var alen    = eval(strArray + ".length")
			var listLen = 1;
			var strKey  = eval("document.frmCalendarSample." + lstPrimary + ".options[document.frmCalendarSample." + lstPrimary + ".selectedIndex].value")
			//alert(strKey);
			eval("document.frmCalendarSample." + lstSecondary + ".options.length = 0");
			eval("document.frmCalendarSample." + lstSecondary + ".options[0] = new Option('Select Destination City','' )");
			for (var i = 0; i < alen; i++) 
			{			  
			  if (eval(strArray)[i][0] == strKey)
			  {
			  eval("document.frmCalendarSample." + lstSecondary + ".options[listLen] = new Option(" + strArray + "[i][2], " + strArray + "[i][1]" + " + '|'+ " + strArray +"[i][2])");
			  listLen = listLen + 1;
			  } 
			  //eval("document.frmCalendarSample."+lstSecondary+".focus()");
			}
			}
			
			
			
			
			
	function month_name(num)
		{
			if (num == "01")
				month_nm = "Jan"
			if (num == "02")
				month_nm = "Feb"
			if (num == "03")
				month_nm = "Mar"
			if (num == "04")
				month_nm = "Apr"
			if (num == "05")
				month_nm = "May"
			if (num == "06")
				month_nm = "Jun"
			if (num == "07")
				month_nm = "Jul"
			if (num == "08")
				month_nm = "Aug"
			if (num == "09")
				month_nm = "Sep"
			if (num == "10")
				month_nm = "Oct"
			if (num == "11")
				month_nm = "Nov"
			if (num == "12")
				month_nm = "Dec"
				
		}
		
		function fToggleColor(myElement) 
	{
		////return;		
		var toggleColor = "#000000";
		if (myElement.id == "calDateText") 
		{			
			if (myElement.color == toggleColor) 
			{
				myElement.color = "";
			} 
			else 
			{
				myElement.color = toggleColor;
			}
		} 
		else if (myElement.id == "calCell") 
		{
			for (var i in myElement.children) 
			{
				if (myElement.children[i].id == "calDateText") 
				{
					if (myElement.children[i].color == toggleColor) 
					{
						myElement.children[i].color = "";
					} 
					else 
					{
						myElement.children[i].color = toggleColor;
					}
				}
			}
		}
	}
	
	function fSetSelectedDay(myElement)
	{
		if (myElement.id == "calCell") 
		{
			if (!isNaN(parseInt(myElement.children["calDateText"].innerText))) 
			{
				//alert(parseInt(myElement.children["calDateText"].innerText))
				myElement.bgColor = "#D3E9FD";
				objPrevElement.bgColor = "";
				document.all.calSelectedDate.value = parseInt(myElement.children["calDateText"].innerText);
				objPrevElement = myElement;
			}
		}
	}

	function fGetDaysInMonth(iMonth, iYear) 
	{
		var dPrevDate = new Date(iYear, iMonth, 0);
		return dPrevDate.getDate();
	}

	function fBuildCal(iYear, iMonth, iDayStyle) 
	{
		var aMonth = new Array();
		aMonth[0] = new Array(7);
		aMonth[1] = new Array(7);
		aMonth[2] = new Array(7);
		aMonth[3] = new Array(7);
		aMonth[4] = new Array(7);
		aMonth[5] = new Array(7);
		aMonth[6] = new Array(7);
		var dCalDate = new Date(iYear, iMonth-1, 1);
		var iDayOfFirst = dCalDate.getDay();
		var iDaysInMonth = fGetDaysInMonth(iMonth, iYear);
		var iVarDate = 1;
		var i, d, w;
		
		if (iDayStyle == 2) 
		{
			aMonth[0][0] = "Sunday";
			aMonth[0][1] = "Monday";
			aMonth[0][2] = "Tuesday";
			aMonth[0][3] = "Wednesday";
			aMonth[0][4] = "Thursday";
			aMonth[0][5] = "Friday";
			aMonth[0][6] = "Saturday";
		} 
		else if (iDayStyle == 1) 
		{
			aMonth[0][0] = "Sun";
			aMonth[0][1] = "Mon";
			aMonth[0][2] = "Tue";
			aMonth[0][3] = "Wed";
			aMonth[0][4] = "Thu";
			aMonth[0][5] = "Fri";
			aMonth[0][6] = "Sat";
		} 
		else 
		{
			aMonth[0][0] = "S";
			aMonth[0][1] = "M";
			aMonth[0][2] = "T";
			aMonth[0][3] = "W";
			aMonth[0][4] = "T";
			aMonth[0][5] = "F";
			aMonth[0][6] = "S";
		}
		for (d = iDayOfFirst; d < 7; d++) 
		{
			aMonth[1][d] = iVarDate;
			iVarDate++;
		}
		for (w = 2; w < 7; w++) 
		{
			for (d = 0; d < 7; d++) 
			{
				if (iVarDate <= iDaysInMonth) 
				{
					aMonth[w][d] = iVarDate;
					iVarDate++;
				}
			}
		}
		return aMonth;
	}

	function fDrawCal(iYear, iMonth, iCellWidth, iCellHeight, sDateTextSize, sDateTextWeight, iDayStyle) 
	{
		var myMonth;
		myMonth = fBuildCal(iYear, iMonth, iDayStyle);
		document.write("<table border='0'  cellpadding = 0 cellspacing =0>")
		document.write("<tr class=band2 align='center'>");
		document.write("<td align='center' class=smallred height='18'>" + myMonth[0][0] + "</td>");
		document.write("<td align='center' class=smallred height='18'>" + myMonth[0][1] + "</td>");
		document.write("<td align='center' class=smallred height='18'>" + myMonth[0][2] + "</td>");
		document.write("<td align='center' class=smallred height='18'>" + myMonth[0][3] + "</td>");
		document.write("<td align='center' class=smallred height='18'>" + myMonth[0][4] + "</td>");
		document.write("<td align='center' class=smallred height='18'>" + myMonth[0][5] + "</td>");
		document.write("<td align='center' class=smallred height='18'>" + myMonth[0][6] + "</td>");
		document.write("</tr>");
		
		for (w = 1; w < 7; w++) 
		{
			document.write("<tr class=band2 align='center'>")
			for (d = 0; d < 7; d++) 
			{
				document.write("<td align='center' valign='top' width='" + iCellWidth + "' height='" + iCellHeight + "' id=calCell  onMouseOver='fToggleColor(this)' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this)>");
				if (!isNaN(myMonth[w][d])) 
				{
					
					if ((iYear==dCurYear) && (iMonth==dCurMonth) && (dCurDayOfMonth==myMonth[w][d]))
					{					
						document.write("<font id=calDateText color='red' onMouseOver='fToggleColor(this)' style='CURSOR:Hand;FONT-FAMILY:Arial;FONT-SIZE:11px;FONT-WEIGHT:" + sDateTextWeight + "' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this);selectval(this.innerText)>" + myMonth[w][d] + "</font>");
					}
					else
					{	
						document.write("<font id=calDateText color='black' fontSize='9px' onMouseOver='fToggleColor(this)' style='CURSOR:Hand;FONT-FAMILY:Arial;FONT-SIZE:" + sDateTextSize + ";FONT-WEIGHT:" + sDateTextWeight + "' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this);selectval(this.innerText)>" + myMonth[w][d] + "</font>");
					}
				} 
				else 
				{
					document.write("<font id=calDateText onMouseOver='fToggleColor(this)' style='CURSOR:Hand;FONT-FAMILY:Arial;FONT-SIZE:" + sDateTextSize + ";FONT-WEIGHT:" + sDateTextWeight + "' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this);selectval(this.innerText)> </font>");
				}
				document.write("</td>")
			}
			document.write("</tr>");
		}
		document.write("</table>")
	}

	function fUpdateCal(iYear, iMonth) 
	{
		
		myMonth_cal = fBuildCal(iYear, iMonth);
		objPrevElement.bgColor = "";
		document.all.calSelectedDate.value = "";
		

		for (w = 1; w < 7; w++) 
		{
			for (d = 0; d < 7; d++) 
			{
				if (!isNaN(myMonth_cal[w][d])) 
				{
					if ((iYear==dCurYear) && (iMonth==dCurMonth) && (dCurDayOfMonth==myMonth_cal[w][d]))
					{					
						calDateText[((7*w)+d)-7].style.color = "red";	
						calDateText[((7*w)+d)-7].style.fontSize='11px';
					}
					else
					{	
						calDateText[((7*w)+d)-7].style.color = "black";	
						calDateText[((7*w)+d)-7].style.fontSize='9px';
					}
					calDateText[((7*w)+d)-7].innerText = " ";
					calDateText[((7*w)+d)-7].innerText = myMonth_cal[w][d];
				} 
				else 
				{
					calDateText[((7*w)+d)-7].style.color = "black";	
					calDateText[((7*w)+d)-7].style.fontSize='9px'
					calDateText[((7*w)+d)-7].innerText = " ";
				}
				
			}
		}
		
			frmCalendarSample.tbSelYear.value = iYear;
			frmCalendarSample.tbSelMonth.value = iMonth;
			//alert(frmCalendarSample.tbSelYear.value)
			//alert(frmCalendarSample.tbSelMonth.value)
			iMonth = iMonth.toString()			
				if(iMonth.length==1)
				{
					iMonth = "0"+iMonth
				}

			month_name(iMonth)
			////document.getElementById("dispval").innerText =  month_nm + " " + iYear
			dispval.innerText =   month_nm + " " + iYear
			
			//dispval.innerText = iYear + " " + iMonth
				
	}
	

	function UpdateCal(yr, yrVal, mn, mnVal, control)
	{
		
		if(control == "calender")
		{
		
			if ((yr == "yr+")&&(mn == "mn"))
			{
				frmCalendarSample.tbSelYear.value = parseInt(frmCalendarSample.tbSelYear.value) + yrVal;
				frmCalendarSample.tbSelMonth.value = parseInt(frmCalendarSample.tbSelMonth.value) + mnVal;
				fUpdateCal(frmCalendarSample.tbSelYear.value, frmCalendarSample.tbSelMonth.value)
			}
	
			if ((yr == "yr-")&&(mn== "mn"))
			{
				//frmCalendarSample.tbSelYear.value = parseInt(frmCalendarSample.tbSelYear.value) - 1;
				frmCalendarSample.tbSelYear.value = parseInt(frmCalendarSample.tbSelYear.value) - yrVal;
				frmCalendarSample.tbSelMonth.value = parseInt(frmCalendarSample.tbSelMonth.value) + mnVal;
				fUpdateCal(frmCalendarSample.tbSelYear.value, frmCalendarSample.tbSelMonth.value)
			}
	
			if ((yr == "yr")&&(mn == "mn+"))
			{

				if(frmCalendarSample.tbSelMonth.value == "12")
				{
					frmCalendarSample.tbSelYear.value = parseInt(frmCalendarSample.tbSelYear.value) +1
					frmCalendarSample.tbSelMonth.value = 1;
				}
				else
				{
					if (frmCalendarSample.tbSelMonth.value.substr(0,1)=="0")
					{
						frmCalendarSample.tbSelMonth.value = frmCalendarSample.tbSelMonth.value.substr(1,1)
					}
					//frmCalendarSample.tbSelMonth.value = parseInt(frmCalendarSample.tbSelMonth.value) + 1;
					frmCalendarSample.tbSelMonth.value = parseInt(frmCalendarSample.tbSelMonth.value) + mnVal;
					frmCalendarSample.tbSelYear.value  = parseInt(frmCalendarSample.tbSelYear.value) + yrVal
				}				
				fUpdateCal(frmCalendarSample.tbSelYear.value, frmCalendarSample.tbSelMonth.value)
			}
	
			if ((yr == "yr")&&(mn == "mn-"))
			{
				if (frmCalendarSample.tbSelMonth.value.substr(0,1)=="0")
				{
					frmCalendarSample.tbSelMonth.value = frmCalendarSample.tbSelMonth.value.substr(1,1)
				}
				if(frmCalendarSample.tbSelMonth.value == "1")
				{
					frmCalendarSample.tbSelYear.value = parseInt(frmCalendarSample.tbSelYear.value) - 1
					frmCalendarSample.tbSelMonth.value = 12;
				}
				else
				{
					//frmCalendarSample.tbSelMonth.value = parseInt(frmCalendarSample.tbSelMonth.value) - 1;
					frmCalendarSample.tbSelMonth.value = parseInt(frmCalendarSample.tbSelMonth.value) - mnVal;
					frmCalendarSample.tbSelYear.value = parseInt(frmCalendarSample.tbSelYear.value) + yrVal 
				}
				fUpdateCal(frmCalendarSample.tbSelYear.value, frmCalendarSample.tbSelMonth.value)
			}
		}	
		else
		{
			
			if (mnVal.substr(0,1)=="0")
				{
					mnVal = mnVal.substr(1,1)
				}
				
			frmCalendarSample.tbSelMonth.value = parseInt(mnVal);
			frmCalendarSample.tbSelYear.value = parseInt(yrVal); 
			fUpdateCal(frmCalendarSample.tbSelYear.value, frmCalendarSample.tbSelMonth.value)
		}
	}
	function selectval(strday)
	{
		if(strday != 0)
		{
			if(strday.length==1)
			{
				strday = "0"+strday
			}
			if(frmCalendarSample.tbSelMonth.value.length==1)
			{
				strmonth = "0"+frmCalendarSample.tbSelMonth.value
			}
			else
			{
				strmonth = frmCalendarSample.tbSelMonth.value
			}
			frmCalendarSample.departdate.value = strday + "/" + strmonth + "/" + frmCalendarSample.tbSelYear.value
		}
	}
	
	function fToggleColor2(myElement) 
	{
		
		var toggleColor = "black";
		return;
		if (myElement.id == "calDateText2") 
		{
			if (myElement.color == toggleColor) 
			{
				myElement.color = "";
			} 
			else 
			{
				myElement.color = toggleColor;
			}
		} 
		else if (myElement.id == "calCell1") 
		{
			for (var i in myElement.children) 
			{
				if (myElement.children[i].id == "calDateText2") 
				{
					if (myElement.children[i].color == toggleColor) 
					{
						myElement.children[i].color = "";
					} 
					else 
					{
						myElement.children[i].color = toggleColor;
					}
				}
			}
		}
	}
	
	
	function fSetSelectedDay2(myElement)
	{		
		if (myElement.id == "calCell1") 
		{
			if (!isNaN(parseInt(myElement.children["calDateText2"].innerText))) 
			{
				myElement.bgColor = "#D3E9FD";
				//myElement.bgColor = "red";
				objPrevElement2.bgColor = "";
				document.all.calSelectedDate.value = parseInt(myElement.children["calDateText2"].innerText);
				objPrevElement2 = myElement;
			}
		}
	}
	

	function fGetDaysInMonth(iMonth, iYear) 
	{
		var dPrevDate = new Date(iYear, iMonth, 0);
		return dPrevDate.getDate();
	}

	function fBuildCal2(iYear, iMonth, iDayStyle) 
	{
		var bMonth = new Array();
		bMonth[0] = new Array(7);
		bMonth[1] = new Array(7);
		bMonth[2] = new Array(7);
		bMonth[3] = new Array(7);
		bMonth[4] = new Array(7);
		bMonth[5] = new Array(7);
		bMonth[6] = new Array(7);
		var dCalDate = new Date(iYear, iMonth-1, 1);
		var iDayOfFirst = dCalDate.getDay();
		var iDaysInMonth = fGetDaysInMonth(iMonth, iYear);
		var iVarDate = 1;
		var i, d, w;
		
		if (iDayStyle == 2) 
		{
			bMonth[0][0] = "Sunday";
			bMonth[0][1] = "Monday";
			bMonth[0][2] = "Tuesday";
			bMonth[0][3] = "Wednesday";
			bMonth[0][4] = "Thursday";
			bMonth[0][5] = "Friday";
			bMonth[0][6] = "Saturday";
		} 
		else if (iDayStyle == 1) 
		{
			bMonth[0][0] = "Sun";
			bMonth[0][1] = "Mon";
			bMonth[0][2] = "Tue";
			bMonth[0][3] = "Wed";
			bMonth[0][4] = "Thu";
			bMonth[0][5] = "Fri";
			bMonth[0][6] = "Sat";
		} 
		else 
		{
			bMonth[0][0] = "S";
			bMonth[0][1] = "M";
			bMonth[0][2] = "T";
			bMonth[0][3] = "W";
			bMonth[0][4] = "T";
			bMonth[0][5] = "F";
			bMonth[0][6] = "S";
		}
		for (d = iDayOfFirst; d < 7; d++) 
		{
			bMonth[1][d] = iVarDate;
			iVarDate++;
		}
		for (w = 2; w < 7; w++) 
		{
			for (d = 0; d < 7; d++) 
			{
				if (iVarDate <= iDaysInMonth) 
				{
					bMonth[w][d] = iVarDate;
					iVarDate++;
				}
			}
		}
		return bMonth;
	}

	function fDrawCal2(iYear, iMonth, iCellWidth, iCellHeight, sDateTextSize, sDateTextWeight, iDayStyle) 
	{		
		var myMonth1;
		myMonth1 = fBuildCal2(iYear, iMonth, iDayStyle);
		document.write("<table border='0'  cellpadding = 0 cellspacing =0>")
		document.write("<tr class=band2 align='center'>");
		document.write("<td align='center' class=smallred height='18'>" + myMonth1[0][0] + "</td>");
		document.write("<td align='center' class=smallred height='18'>" + myMonth1[0][1] + "</td>");
		document.write("<td align='center' class=smallred height='18'>" + myMonth1[0][2] + "</td>");
		document.write("<td align='center' class=smallred height='18'>" + myMonth1[0][3] + "</td>");
		document.write("<td align='center' class=smallred height='18'>" + myMonth1[0][4] + "</td>");
		document.write("<td align='center' class=smallred height='18'>" + myMonth1[0][5] + "</td>");
		document.write("<td align='center' class=smallred height='18'>" + myMonth1[0][6] + "</td>");
		document.write("</tr>");
		
		for (w = 1; w < 7; w++) 
		{
			document.write("<tr class=band2 align='center'>")
			for (d = 0; d < 7; d++) 
			{
				document.write("<td align='center' valign='middle' width='" + iCellWidth + "' height='" + iCellHeight + "' id=calCell1 onMouseOver='fToggleColor2(this)' onMouseOut='fToggleColor2(this)' onclick='fSetSelectedDay2(this)';>");
				if (!isNaN(myMonth1[w][d])) 
				{
				if ((iYear==dCurYear1) && (iMonth==dCurMonth1) && (dCurDayOfMonth1==myMonth1[w][d]))
					{					
						document.write("<font id=calDateText2 color='red' onMouseOver='fToggleColor2(this)' style='CURSOR:Hand;FONT-FAMILY:Arial;FONT-SIZE:11px;FONT-WEIGHT:" + sDateTextWeight + "' onMouseOut='fToggleColor2(this)' onclick=fSetSelectedDay2(this);selectval2(this.innerText)>" + myMonth1[w][d] + "</font>");
					}
					else
					{	
						document.write("<font id=calDateText2 color='black' fontSize='9px' onMouseOver='fToggleColor2(this)' style='CURSOR:Hand;FONT-FAMILY:Arial;FONT-SIZE:" + sDateTextSize + ";FONT-WEIGHT:" + sDateTextWeight + "' onMouseOut='fToggleColor2(this)' onclick=fSetSelectedDay2(this);selectval2(this.innerText)>" + myMonth1[w][d] + "</font>");
					}
				} 
				else 
				{
					document.write("<font id=calDateText2 onMouseOver='fToggleColor2(this)' style='CURSOR:Hand;FONT-FAMILY:Arial;FONT-SIZE:" + sDateTextSize + ";FONT-WEIGHT:" + sDateTextWeight + "' onMouseOut='fToggleColor2(this)' onclick=fSetSelectedDay2(this);selectval2(this.innerText)> </font>");
				}
				document.write("</td>")
			}
			document.write("</tr>");
		}
		document.write("</table>")
		
			/* Searching the Current Date to initialise the reference to objPrevElement2 */
			for (w = 1; w < 7; w++){
			for (d = 0; d < 7; d++) 
				if(dCurDayOfMonth1==myMonth1[w][d])
					objPrevElement2 = (calDateText2[((7*w)+d)-7].parentElement);
		}

	}

	function fUpdateCal2(iYear, iMonth) 
	{
		myMonth1 = fBuildCal2(iYear, iMonth);
		objPrevElement2.bgColor = "";
		document.all.calSelectedDate.value = "";
		
		for (w = 1; w < 7; w++) 
		{
			for (d = 0; d < 7; d++) 
			{
				if (!isNaN(myMonth1[w][d])) 
				{
					if ((iYear==dCurYear1) && (iMonth==dCurMonth1) && (dCurDayOfMonth1==myMonth1[w][d]))
					{	
						calDateText2[((7*w)+d)-7].style.color = "red";	
						calDateText2[((7*w)+d)-7].style.fontSize='11px';
					}
					else
					{	
						calDateText2[((7*w)+d)-7].style.color = "black";	
						calDateText2[((7*w)+d)-7].style.fontSize='9px';
					}
					//calDateText2[((7*w)+d)-7].innerText = " ";
					calDateText2[((7*w)+d)-7].innerText = myMonth1[w][d];
				} 
				else 
				{
					calDateText2[((7*w)+d)-7].style.color = "black";	
					calDateText2[((7*w)+d)-7].style.fontSize='9px'
					calDateText2[((7*w)+d)-7].innerText = " ";
				}
			}
		}
		
		frmCalendarSample.tbSelYear2.value = iYear;
		frmCalendarSample.tbSelMonth2.value = iMonth;
		iMonth = iMonth.toString()			
		if(iMonth.length==1)
		{
			iMonth = "0"+iMonth
		}

		month_name(iMonth)
		////document.getElementById("dispval2").innerText = month_nm + " " + iYear 
		dispval2.innerText =   month_nm + " " + iYear
		//dispval2.innerText = iYear + " " + iMonth
	
	}


	function UpdateCal2(yr, yrVal, mn, mnVal, control)
	{		
		if(control == "calender")
		{
			if ((yr == "yr+")&&(mn == "mn"))
			{
				//frmCalendarSample.tbSelYear2.value = parseInt(frmCalendarSample.tbSelYear2.value) + 1;
				frmCalendarSample.tbSelYear2.value = parseInt(frmCalendarSample.tbSelYear2.value) + yrVal;
				frmCalendarSample.tbSelMonth2.value = parseInt(frmCalendarSample.tbSelMonth2.value) + mnVal;
				fUpdateCal2(frmCalendarSample.tbSelYear2.value, frmCalendarSample.tbSelMonth2.value)
			}
	
			if ((yr == "yr-")&&(mn== "mn"))
			{
				//frmCalendarSample.tbSelYear2.value = parseInt(frmCalendarSample.tbSelYear2.value) - 1;
				frmCalendarSample.tbSelYear2.value = parseInt(frmCalendarSample.tbSelYear2.value) - yrVal;
				frmCalendarSample.tbSelMonth2.value = parseInt(frmCalendarSample.tbSelMonth2.value) + mnVal;
				fUpdateCal2(frmCalendarSample.tbSelYear2.value, frmCalendarSample.tbSelMonth2.value)
			}
	
			if ((yr == "yr")&&(mn == "mn+"))
			{
				if (frmCalendarSample.tbSelMonth2.value.substr(0,1)=="0")
				{
					frmCalendarSample.tbSelMonth2.value = frmCalendarSample.tbSelMonth2.value.substr(1,1)
				}
				
				if(frmCalendarSample.tbSelMonth2.value == "12")
				{
					frmCalendarSample.tbSelYear2.value = parseInt(frmCalendarSample.tbSelYear2.value) +1
					frmCalendarSample.tbSelMonth2.value = 1;
				}
				else
				{
					//frmCalendarSample.tbSelMonth2.value = parseInt(frmCalendarSample.tbSelMonth2.value) + 1;
					frmCalendarSample.tbSelMonth2.value = parseInt(frmCalendarSample.tbSelMonth2.value) + mnVal;
					frmCalendarSample.tbSelYear2.value  = parseInt(frmCalendarSample.tbSelYear2.value) + yrVal
				}
				fUpdateCal2(frmCalendarSample.tbSelYear2.value, frmCalendarSample.tbSelMonth2.value)
			}
	
			if ((yr == "yr")&&(mn == "mn-"))
			{
				if (frmCalendarSample.tbSelMonth2.value.substr(0,1)=="0")
				{
					frmCalendarSample.tbSelMonth2.value = frmCalendarSample.tbSelMonth2.value.substr(1,1)
				}
				if(frmCalendarSample.tbSelMonth2.value == "1")
				{
					frmCalendarSample.tbSelYear2.value = parseInt(frmCalendarSample.tbSelYear2.value) - 1
					frmCalendarSample.tbSelMonth2.value = 12;
				}
				else
				{
					//frmCalendarSample.tbSelMonth2.value = parseInt(frmCalendarSample.tbSelMonth2.value) - 1;
					frmCalendarSample.tbSelMonth2.value = parseInt(frmCalendarSample.tbSelMonth2.value) - mnVal;
					frmCalendarSample.tbSelYear2.value = parseInt(frmCalendarSample.tbSelYear2.value) + yrVal
				}
				fUpdateCal2(frmCalendarSample.tbSelYear2.value, frmCalendarSample.tbSelMonth2.value)
			}
		}
		else
		{
			
			if (mnVal.substr(0,1)=="0")
			{
				mnVal = mnVal.substr(1,1)
			}
			//alert(mnVal)
			frmCalendarSample.tbSelMonth2.value = parseInt(mnVal);
			frmCalendarSample.tbSelYear2.value = parseInt(yrVal); 
			fUpdateCal2(frmCalendarSample.tbSelYear2.value, frmCalendarSample.tbSelMonth2.value)
		}
	}
	function selectval2(strday)
	{
		if(strday != 0)
		{
			if(strday.length==1)
			{
				strday = "0"+strday
			}
			if(frmCalendarSample.tbSelMonth2.value.length==1)
			{
				strmonth = "0"+frmCalendarSample.tbSelMonth2.value
			}
			else
			{
				strmonth = frmCalendarSample.tbSelMonth2.value
			}
			strYear = frmCalendarSample.tbSelYear2.value
			
			frmCalendarSample.returndate.value = strday + "/" + strmonth + "/" + strYear


		}
	}
	function validate_date(str)
	{
		//alert(str)		
		if(dateFlag == true)
		{
			if(str == "departdate")
			{
				date1 = document.frmCalendarSample.departdate.value
				date1 = date1.split("/")
				document.frmCalendarSample.returndate.value = date1[0] +"/" + date1[1] +"/"+ date1[2]
				frmCalendarSample.tbSelYear.value = date1[2]
				frmCalendarSample.tbSelMonth.value = date1[1]
				UpdateCal('yr',frmCalendarSample.tbSelYear.value,'mn',frmCalendarSample.tbSelMonth.value,'page')
			}
			else
			{
				date1 = document.frmCalendarSample.returndate.value
				date1 = date1.split("/")
				frmCalendarSample.tbSelYear2.value = date1[2]
				frmCalendarSample.tbSelMonth2.value = date1[1]
				UpdateCal2('yr',frmCalendarSample.tbSelYear2.value,'mn',frmCalendarSample.tbSelMonth2.value,'page')
			
			}
		}		
	}
	function validateFlightSearchForm()
			{
				var sessionval
				sessionval = document.frmCalendarSample.userCategoryId.value;
				var Today = new Date(document.frmCalendarSample.validation_date.value).valueOf()
				
			/*	if (sessionval == "2")
				{
					if (!isName(document.frmCalendarSample.txt_fname,'Please enter Callers First Name','First Name',1))
					{ 	return false; }
					if (!isName(document.frmCalendarSample.txt_lname,'Please enter Callers Last Name','Last Name',1))
					{ 	return false; }
				}
			*/					
				
				if (document.frmCalendarSample.cmb_originCity.options[document.frmCalendarSample.cmb_originCity.selectedIndex].value=="")
				{
					alert("Please select a departure city, as we cannot find you a flight without knowing the same.")
					document.frmCalendarSample.cmb_originCity.focus();
					return false;;
				}
				
								
				if (document.frmCalendarSample.cmb_destCity.options[document.frmCalendarSample.cmb_destCity.selectedIndex].value=="")
				{
					alert("Please enter a destination city, as we cannot find you a flight without knowing the same.")
					document.frmCalendarSample.cmb_destCity.focus();
					return false;;
				}
				if(document.frmCalendarSample.cmb_originCity.options[document.frmCalendarSample.cmb_originCity.selectedIndex].value == document.frmCalendarSample.cmb_destCity.options[document.frmCalendarSample.cmb_destCity.selectedIndex].value)
				{
					alert("Origin city and Destination city cannot be same")
					return false;
				}
				
				date1 = document.frmCalendarSample.departdate.value
				
				
				date1 = date1.split("/")
				document.frmCalendarSample.depart_date.value =  date1[1] + "/" + date1[0] + "/" + date1[2]
				
				in_date=new Date(document.frmCalendarSample.depart_date.value).valueOf()
				if(in_date < Today)
				{
					alert("Search is not allowed for dates earlier than current date")
					document.frmCalendarSample.departdate.focus();
					return false;
				}
				
				//alert(document.frmCalendarSample.depart_date.value)
				
				if (!DateCheck(document.frmCalendarSample.departdate.value,0))
					{ 
						document.frmCalendarSample.departdate.focus();
						return false; 
					}
				
				if (document.frmCalendarSample.flagfare.value=="R")
				{
					
					date2 = document.frmCalendarSample.returndate.value
					//document.frmCalendarSample.return_date.value =  date2
					date2 = date2.split("/")
					
					if (!DateCheck(document.frmCalendarSample.returndate.value,0))
					{ 
						document.frmCalendarSample.returndate.focus();
						return false; 
					}
					
					/*					
					if((parseInt(date2[0]) < parseInt(date1[0]))&& (parseInt(date2[1])== parseInt(date1[1])) && (parseInt(date2[2]) == parseInt(date1[2])))
					{
						alert("Return Date cannot be less than Depart Date")
						document.frmCalendarSample.returndate.focus();
						return false;
						//validate_date('departdate')
					}
					
					if((parseInt(date2[1]) < parseInt(date1[1])) && (parseInt(date2[2]) == parseInt(date1[2])))
					{
						alert("Return Date cannot be less than depart date")
						document.frmCalendarSample.returndate.focus();
						return false;
					}
					
					if(parseInt(date2[2]) < parseInt(date1[2])) 
					{
						alert("Return Date cannot be less than depart date")
						document.frmCalendarSample.returndate.focus();
						return false;
					}
					*/				
														
					document.frmCalendarSample.return_date.value =  date2[1] + "/" + date2[0] + "/" + date2[2]
					out_date=new Date(document.frmCalendarSample.return_date.value).valueOf()
					if(out_date < in_date)
					{
						alert("Return Date cannot be less than depart date")
						document.frmCalendarSample.returndate.focus();
						return false;
					}
				}
				
				book_allow_date = document.frmCalendarSample.booking_period.value;
				days_diff = (in_date - Today) 							
				
				if(days_diff > book_allow_date)
				{
					alert("You can't search Departing flights beyond "+document.frmCalendarSample.search_days.value+" days.")
					document.frmCalendarSample.departdate.focus();
					return false;
				}
				
				if (document.frmCalendarSample.flagfare.value=="R")
				{
					days_diff = (out_date - Today)
					if(days_diff > book_allow_date)
					{
						alert("You can't search Return flights beyond "+document.frmCalendarSample.search_days.value+" days.") 
						document.frmCalendarSample.returndate.focus();
						return false;
					}
				
				}
				
				if(!checkPassengers(document.frmCalendarSample.txt_adult,document.frmCalendarSample.txt_child,document.frmCalendarSample.txt_infant,document.frmCalendarSample.max_seats))
				{
					return false;
				}
				if (document.frmCalendarSample.txt_adult.value == "")
				{
					document.frmCalendarSample.txt_adult.value = "0"
				}
				if (document.frmCalendarSample.txt_child.value == "")
				{
					document.frmCalendarSample.txt_child.value = "0"
				}
				if (document.frmCalendarSample.txt_infant.value == "")
				{
					document.frmCalendarSample.txt_infant.value = "0"
				}
				
				//document.frmCalendarSample.str_class.value = document.frmCalendarSample.cmb_class.options[document.frmCalendarSample.cmb_class.selectedIndex].value
				//alert(document.frmCalendarSample.str_class.value)
				if(document.frmCalendarSample.userCategoryId.value==2)
					//fnInputFlightSearch()
					
				return;
			}	
///////////////////////////////////////////////////End Flight Search Page Javascript/////////////////////////////////

//////////////////////Common JS for hidding Href in status bar [Added by Ashish Sayal as on 25-April-2006] //////////

if (navigator.appName=='Netscape'){browser='NS';} 

if (navigator.appName=='Microsoft Internet Explorer'){browser='MSIE';} 

document.onreadystatechange=document_onreadystatechange;

function StatusBar_Hide(obj){ 
 var loc , func;
 //#4Code added by Girish kalia on 03 Sep 2010 for IE 8 Compatibility issue.
 if(obj!=null)
 {
     while(obj.tagName.toUpperCase()!="A") obj=obj.parentElement;     
     if(obj!=null)//#4
         func = obj.getAttribute("link");
     if(func!=null)//#4
     {
         loc = func.search("http://"); 
//         alert(loc)    
//         alert(func)    
         if(loc!=-1)
          window.navigate(func);
         else
          eval(func);
      }
  }
 return false;
}
function document_onreadystatechange()
{
	
	if(browser=='MSIE')
	{
		var colanchor="";
		if(document.readyState=="complete") 
		{
			colanchor = document.getElementsByTagName("A");
			for(i=0;i<colanchor.length;i++)
			{
			 
				anc = colanchor[i];				
				href = anc.getAttribute("href");
				
				if (href!=null && href.indexOf("redirect.asp",0) == -1)
				{
				    if (href.indexOf("mailto:",0) == -1)
				    {
					anc.setAttribute("link",href);
					anc.setAttribute("href","javascript:void(0);");
					anc.attachEvent("onmouseover",function hideit(){window.status="";return true;});
					anc.attachEvent("onmouseout",function hideit(){window.status="";return true;});
				//	anc.attachEvent("onclick",function ctidy(){alert((window.event.srcElement).getAttribute("link"));return true;});
					anc.attachEvent("onclick",function tup(){return(StatusBar_Hide(window.event.srcElement));});
					}
				}
			}
		}
	}
	
	if(browser=='NS'){
		document.captureEvents(Event.MOUSEOVER);
		document.onmouseover=function(event) 
		{
			window.status = "";
			return(true);
		}
	}
}
//////////////////////End of Common JS for hidding Href in status bar//////////////////////////////////////////////////////

///////////////////////////  HOME PAGE VALIDATIONS BLOCK [Added by Tarun Kumar] /////////////////////////////////////////////////////////

/////////////////////////////////// Change Options For Home Page ///////////////////////////////////
			
			function ChangeOptionsHome(lstPrimary, lstSecondary, strArray) 
			{		
				
			var selectedval,strArrayNum, strArrayVal
			strArrayNum="0"
			strArrayVal="jj"
			//alert(frm);
			//alert(lstPrimary)
			//alert(eval("document."+frm));// + lstPrimary)
			var alen    = eval(strArray + ".length")
			var listLen = 1;
			var strKey  = document.getElementById(lstPrimary).options[document.getElementById(lstPrimary).selectedIndex].value
			//alert(strKey);
			document.getElementById(lstSecondary).options.length = 0;
			document.getElementById(lstSecondary).options[0] = new Option('Select Destination City','' );
			    for (var i = 0; i < alen; i++) 
			    {			  
			      if (eval(strArray)[i][0] == strKey)
			      {
			          document.getElementById(lstSecondary).options[listLen] = new Option(eval(strArray)[i][2],eval(strArray)[i][1] + '|'+ eval(strArray)[i][2]);
			          listLen = listLen + 1;
			      } 
			      //eval("document.frmCalendarSample."+lstSecondary+".focus()");
			    }
			}


/////////////////////////////////// Fill Options For Home Page ///////////////////////////////////
			
			function fillOptionsHome(origCityVal,destCityVal)  
			{
			var selectedval
			strArray = "ArrCity"
			strArrayNum="0"
			strArrayVal="jj"
			var alen    = eval(strArray + ".length")
			var listLen = 1;
			//var strKey  = eval("document.frmCalendarSample.cmb_originCity.options[document.frmCalendarSample.cmb_originCity.selectedIndex].value")
			var strKey = origCityVal
			document.getElementById("frmHomePageLeft_cmb_destCity").options.length = 0;
			document.getElementById("frmHomePageLeft_cmb_destCity").options[0] = new Option('Select Destination City','' );
			for (var i = 0; i < alen; i++) 
			{
			  //alert("tarun");
			  if (eval(strArray)[i][0] == strKey)
			  {
			       // alert(eval(strArray)[i][1]);
			        document.getElementById("frmHomePageLeft_cmb_destCity").options[listLen] = new Option(eval(strArray)[i][2],eval(strArray)[i][1] + '|' + eval(strArray)[i][2]);
			         //alert("arun");
					if(eval( strArray + "[i][1] =='" +destCityVal+ "'"))
					{
						document.getElementById("frmHomePageLeft_cmb_destCity").selectedIndex = listLen
					}
			  listLen = listLen + 1;
			  } 
			  //eval("document.frmCalendarSample.cmb_destCity.focus()");
			}
			}


			function updatedate(obj)
			{
				var elem, datestr
				elem = obj.name
				if (elem=="DepartDate")
				{
					datestr = document.forms[frm].frmHomePageLeft_DepartDate.value
					datestr = datestr.split("/")
					eval("document.forms["+frm+"].elements['cmbMonthFrom'].value='" + datestr[1] +"'")
					eval("document.forms["+frm+"].elements['cmbDayFrom'].value= '" + datestr[0] +"'")
					selectbox(document.forms[frm].elements['cmbYearFrom'],datestr[2])
				}
				
				if (elem=="ReturnDate")
				{
					datestr = document.forms[frm].frmHomePageLeft_ReturnDate.value
					datestr = datestr.split("/")
					eval("document.forms["+frm+"].elements['cmbMonthTo'].value='" + datestr[1] +"'")
					eval("document.forms["+frm+"].elements['cmbDayTo'].value= '" + datestr[0] +"'")
					selectbox(document.forms[frm].elements['cmbYearTo'],datestr[2])
				}
			}
			

			/////////////////////////////// Trip Date Home ////////////////////////////////////
			function trip_date(chkinM,chkinD,chkinY,chkoutM,chkoutD,chkoutY)
			{
				
				if (document.getElementById('frmHomePageLeft_flagfare').value == "O")
				{
					
					increment_date(chkinM,chkinD,chkinY,'','','')
					document.getElementById('frmHomePageLeft_DepartDate').value = document.getElementById(chkinD).options[document.getElementById(chkinD).selectedIndex].value+"/"+document.getElementById(chkinM).options[document.getElementById(chkinM).selectedIndex].value +"/"+document.getElementById(chkinY).options[document.getElementById(chkinY).selectedIndex].value
					
				}
				else
				{
					//alert("tarun");
					increment_date(chkinM,chkinD,chkinY,chkoutM,chkoutD,chkoutY)
					document.getElementById('frmHomePageLeft_DepartDate').value = document.getElementById(chkinD).options[document.getElementById(chkinD).selectedIndex].value+"/"+document.getElementById(chkinM).options[document.getElementById(chkinM).selectedIndex].value +"/"+document.getElementById(chkinY).options[document.getElementById(chkinY).selectedIndex].value
					document.getElementById('frmHomePageLeft_ReturnDate').value = document.getElementById(chkoutD).options[document.getElementById(chkoutD).selectedIndex].value+"/"+document.getElementById(chkoutM).options[document.getElementById(chkoutM).selectedIndex].value +"/"+document.getElementById(chkoutY).options[document.getElementById(chkoutY).selectedIndex].value
				}
			}
			
			/////////////////////////// Change Trip Home ///////////////////////////////////////////
			function changetriphome(trip)
			{
				//alert(trip)
				if (trip==1)
				{
					if(browserName == "IE")
					{
						document.getElementById('frmHomePageLeft_cmbMonthTo').disabled=true;
						document.getElementById('frmHomePageLeft_cmbDayTo').disabled=true;
						document.getElementById('frmHomePageLeft_cmbYearTo').disabled=true;
						//Block Added - Change #1 - Start
					    //Enable Special RT fare checkbox on Roundtrip availability
					    if(document.getElementById("frmHomePageLeft_chkSpecialRT")!=null)
					    {    
					     document.getElementById("frmHomePageLeft_chkSpecialRT").disabled = true;
					     document.getElementById("frmHomePageLeft_chkSpecialRT").checked = false; 
					    }
					    //Block Added - Change #1 - End
					}
					else if(browserName == "Netscape")
					{
						document.getElementById('frmHomePageLeft_cmbMonthTo').disabled=true;
						document.getElementById('frmHomePageLeft_cmbDayTo').disabled=true;
						document.getElementById('frmHomePageLeft_cmbYearTo').disabled=true;
//						document.getElementById('frmHomePageLeft_cmbMonthTo').readonly=true;
//						document.getElementById('frmHomePageLeft_cmbDayTo').readonly=true;
//						document.getElementById('frmHomePageLeft_cmbYearTo').readonly=true;

                        //Block Added - Change #1 - Start
					    //Enable Special RT fare checkbox on Roundtrip availability
					    if(document.getElementById("frmHomePageLeft_chkSpecialRT")!=null)
					    {    
					    document.getElementById("frmHomePageLeft_chkSpecialRT").disabled = true;
					    document.getElementById("frmHomePageLeft_chkSpecialRT").checked = false; 
					    }
					    //Block Added - Change #1 - End
					}
					else 
					{
						document.getElementById('frmHomePageLeft_cmbMonthTo').disabled=true;
						document.getElementById('frmHomePageLeft_cmbDayTo').disabled=true;
						document.getElementById('frmHomePageLeft_cmbYearTo').disabled=true;
//						document.getElementById('frmHomePageLeft_cmbMonthTo').readonly=true;
//						document.getElementById('frmHomePageLeft_cmbDayTo').readonly=true;
//						document.getElementById('frmHomePageLeft_cmbYearTo').readonly=true;

                        //Block Added - Change #1 - Start
					    //Enable Special RT fare checkbox on Roundtrip availability
					    if(document.getElementById("frmHomePageLeft_chkSpecialRT")!=null)
					    {    
					    document.getElementById("frmHomePageLeft_chkSpecialRT").disabled = true;
					    document.getElementById("frmHomePageLeft_chkSpecialRT").checked = false; 
					    }
					    //Block Added - Change #1 - End
					}
					document.getElementById('frmHomePageLeft_flagfare').value = "O"
				}
				else
				{
					if(browserName == "IE")
					{
						//alert("tarun");
						//alert(document.getElementById["frmHomePage_cmbMonthTo"]);
						document.getElementById('frmHomePageLeft_cmbMonthTo').disabled=false;
						document.getElementById('frmHomePageLeft_cmbDayTo').disabled=false;
						document.getElementById('frmHomePageLeft_cmbYearTo').disabled=false;
						
							//Block Added - Change #1 - Start
					    //Enable Special RT fare checkbox on Roundtrip availability
					    if(document.getElementById("frmHomePageLeft_chkSpecialRT")!=null)
					    {    
					    document.getElementById("frmHomePageLeft_chkSpecialRT").disabled = false;
					    }
					    //Block Added - Change #1 - End
					}
					if(browserName == "Netscape")
					{
					    document.getElementById('frmHomePageLeft_cmbMonthTo').disabled=false;
						document.getElementById('frmHomePageLeft_cmbDayTo').disabled=false;
						document.getElementById('frmHomePageLeft_cmbYearTo').disabled=false;
//						document.getElementById('frmHomePageLeft_cmbMonthTo').readonly=false;
//						document.getElementById('frmHomePageLeft_cmbDayTo').readonly=false;
//						document.getElementById('frmHomePageLeft_cmbYearTo').readonly=false;

                        //Block Added - Change #1 - Start
					    //Enable Special RT fare checkbox on Roundtrip availability
					    if(document.getElementById("frmHomePageLeft_chkSpecialRT")!=null)
					    {    
					    document.getElementById("frmHomePageLeft_chkSpecialRT").disabled = false;
					    }
					    //Block Added - Change #1 - End
					}
					else
					{
					    document.getElementById('frmHomePageLeft_cmbMonthTo').disabled=false;
						document.getElementById('frmHomePageLeft_cmbDayTo').disabled=false;
						document.getElementById('frmHomePageLeft_cmbYearTo').disabled=false;
						
						//Block Added - Change #1 - Start
					    //Enable Special RT fare checkbox on Roundtrip availability
					    if(document.getElementById("frmHomePageLeft_chkSpecialRT")!=null)
					    {    
					    document.getElementById("frmHomePageLeft_chkSpecialRT").disabled = false;
					    }
					    //Block Added - Change #1 - End
					}
					document.getElementById('frmHomePageLeft_flagfare').value = "R"
					trip_date('frmHomePageLeft_cmbMonthFrom','frmHomePageLeft_cmbDayFrom','frmHomePageLeft_cmbYearFrom','frmHomePageLeft_cmbMonthTo','frmHomePageLeft_cmbDayTo','frmHomePageLeft_cmbYearTo')
				}
				
				if(document.getElementById('frmHomePageLeft_chkConnecting')!=null)
                {   
                    if(document.getElementById('frmHomePageLeft_chkConnecting').checked==true)
	                {
	                    if(document.getElementById("frmHomePageLeft_chkSpecialRT"))
					        document.getElementById("frmHomePageLeft_chkSpecialRT").disabled = true;
	                }
                }
				
			}
			
			/////////////////////////////////////// Home Page Javascript //////////////////////////////////////////////
			function window_onload()
			{
				sniffTheBrowser()
				// SETS THE DEPARTING ON DATES
				var Today = new Date().valueOf()
				var firstDate = new Date(Today)
				var day1 = firstDate.getDate()
				var month1 = firstDate.getMonth()+1
				var year1 = firstDate.getFullYear()
				//alert("AA");
				
				//Code Commented By Girish Kalia on 25 May 2010 to stop session mentainence on all POS Search Pages
				/*var str_cookie,oval,cval				
				str_cookie = document.cookie
				index1 = str_cookie.indexOf("igtsAirIndia")
				//alert(str_cookie)
				if (index1 >=0)
				{
					strcookie1 = str_cookie.substr(index1,str_cookie.length)
					//alert(strcookie1)
					index2 = strcookie1.indexOf(";")
					if (index2 >=0)
					{
						strcookie2 = strcookie1.substring(strcookie1.indexOf("=")+1,index2)
					}
					else
					{
						strcookie2 = strcookie1.substring(strcookie1.indexOf("=")+1,strcookie1.length)
					}
					cookies_ary = strcookie2.split('&')
					for(cnt_elements=0;cnt_elements<cookies_ary.length ;cnt_elements++)
					{
						val = cookies_ary[cnt_elements].split('=')
						
						if (val[0] == "porigincity")
						{
							selectbox(document.getElementById("frmHomePageLeft_cmb_originCity"),val[1])
							oval = val[1]
							ChangeOptionsHome("frmHomePageLeft_cmb_originCity","frmHomePageLeft_cmb_destCity","ArrCity")
						}	
						
							
						if (val[0] == "pdepartdate")
						
						{	
							document.getElementById("frmHomePageLeft_cmbMonthFrom").value=val[1].substr(0,2)
							document.getElementById("frmHomePageLeft_cmbDayFrom").value= val[1].substr(5,2) 
							selectbox(document.getElementById("frmHomePageLeft_cmbYearFrom"),val[1].substr(10,4))
							
							document.getElementById("frmHomePageLeft_DepartDate").value = val[1].substr(0,2)+"/"+val[1].substr(5,2)+"/"+val[1].substr(10,4)
						}
						if ((val[0] == "preturndate")&&(val[1]!=""))
						{
							
							
							document.getElementById("frmHomePageLeft_cmbMonthTo").value=val[1].substr(0,2)
							document.getElementById("frmHomePageLeft_cmbDayTo").value=val[1].substr(5,2)
							selectbox(document.getElementById("frmHomePageLeft_cmbYearTo"),val[1].substr(10,4))
							document.getElementById("frmHomePageLeft_ReturnDate").value = val[1].substr(0,2)+"/"+val[1].substr(5,2)+"/"+val[1].substr(10,4)
						}
						
						if (val[0] == "flagfare")
						{
							
							trip_type = val[1]
							document.getElementById("frmHomePageLeft_flagfare").value = trip_type 
							if (trip_type == "O")
							{
								changetriphome(1)
								document.getElementsByName("rd_trip")[1].checked = true
							}
							else
							{
								changetriphome(2)		
								document.getElementsByName("rd_trip")[0].checked = true
							}
							
						}
						
						//Start: #2 Added
						if (val[0] == "SpecialRT")
						{
						    var IsSpecialRT;
						    IsSpecialRT = val[1];
						    if(IsSpecialRT=="S")
						    {
						        document.getElementById("frmHomePageLeft_chkSpecialRT").checked = true
						    }
						    else
						    {
						        document.getElementById("frmHomePageLeft_chkSpecialRT").checked = false
						    }
						}
						//End: #2 Added	
						
						//Start: #3 Added
				        if (val[0] == "ConnectingFlight")
				        {
				            var IsConnectingFlight;
				            IsConnectingFlight = val[1].split("|");
				            if(IsConnectingFlight[0]=="Y")
				            {
				                  document.getElementById("frmHomePageLeft_chkConnecting").checked = true
				                  document.getElementById('frmHomePageLeft_radTypeofFlightOneStop').disabled=false;
	                              document.getElementById('frmHomePageLeft_radTypeofFlightTwoStop').disabled=false;
	                              document.getElementById("dvStoprOver").style.display="block";
				                if(IsConnectingFlight[1]=="1")
				                {
				                    document.getElementById('frmHomePageLeft_radTypeofFlightOneStop').checked=true;
				                    document.getElementById('frmHomePageLeft_radTypeofFlightTwoStop').checked=false;
				                }
				                else if (IsConnectingFlight[1]=="2")
				                {
				                    document.getElementById('frmHomePageLeft_radTypeofFlightOneStop').checked=false;
				                    document.getElementById('frmHomePageLeft_radTypeofFlightTwoStop').checked=true;
				                }
				                onChangeFlights();
				            }
				            else
				            {
				                if(document.getElementById('frmHomePageLeft_chkConnecting')!=null)
				                {
				                    document.getElementById("frmHomePageLeft_chkConnecting").checked = false
				                    onChangeFlights();
				                 }   
				            }
				        }
    					
				        //End: #3 Added
						    
						if (val[0] == "padus")
						{
							document.getElementById("frmHomePageLeft_txt_adult").value =val[1]
						}	
						if (val[0] == "pchild")
						{
						    document.getElementById("frmHomePageLeft_txt_child").value =val[1]
						}	
						if (val[0] == "pinfant")
						{
							document.getElementById("frmHomePageLeft_txt_infant").value=val[1]
						}
						if (val[0] == "pclass")
						{
							document.getElementById("frmHomePageLeft_str_class").value=val[1]
						}	
						if (val[0] == "pdestcity")
						{
							cval = val[1]
						}	
					}
					
					fillOptionsHome(oval,cval)
					
				}
				else
				{
				    
					document.getElementById("frmHomePageLeft_cmbMonthFrom").selectedIndex=month1-1
					document.getElementById("frmHomePageLeft_cmbDayFrom").selectedIndex=day1-1
					selectbox(document.getElementById("frmHomePageLeft_cmbYearFrom"),year1)
									
					document.getElementById("frmHomePageLeft_cmbMonthTo").selectedIndex=month1-1
					document.getElementById("frmHomePageLeft_cmbDayTo").selectedIndex=day1-1
					selectbox(document.getElementById("frmHomePageLeft_cmbYearTo"),year1)
				
					document.getElementsByName("rd_trip")[1].checked = true
					document.getElementById("frmHomePageLeft_flagfare").value="O"
					changetriphome(1)
					document.getElementById("frmHomePageLeft_DepartDate").value = document.getElementById("frmHomePageLeft_cmbDayFrom").options[document.getElementById("frmHomePageLeft_cmbDayFrom").selectedIndex].value+"/"+document.getElementById("frmHomePageLeft_cmbMonthFrom").options[document.getElementById("frmHomePageLeft_cmbMonthFrom").selectedIndex].value +"/"+document.getElementById("frmHomePageLeft_cmbYearFrom").options[document.getElementById("frmHomePageLeft_cmbYearFrom").selectedIndex].value
					document.getElementById("frmHomePageLeft_ReturnDate").value = document.getElementById("frmHomePageLeft_cmbDayTo").options[document.getElementById("frmHomePageLeft_cmbDayTo").selectedIndex].value+"/"+document.getElementById("frmHomePageLeft_cmbMonthTo").options[document.getElementById("frmHomePageLeft_cmbMonthTo").selectedIndex].value +"/"+document.getElementById("frmHomePageLeft_cmbYearTo").options[document.getElementById("frmHomePageLeft_cmbYearTo").selectedIndex].value
					if(document.getElementById("frmHomePageLeft_chkSpecialRT")!=null)			
					{
					    document.getElementById("frmHomePageLeft_chkSpecialRT").checked = false  //#2 Added
					}
				}*/
				
					document.getElementById("frmHomePageLeft_cmbMonthFrom").selectedIndex=month1-1
					document.getElementById("frmHomePageLeft_cmbDayFrom").selectedIndex=day1-1
					selectbox(document.getElementById("frmHomePageLeft_cmbYearFrom"),year1)
									
					document.getElementById("frmHomePageLeft_cmbMonthTo").selectedIndex=month1-1
					document.getElementById("frmHomePageLeft_cmbDayTo").selectedIndex=day1-1
					selectbox(document.getElementById("frmHomePageLeft_cmbYearTo"),year1)
				
					document.getElementsByName("rd_trip")[1].checked = true
					document.getElementById("frmHomePageLeft_flagfare").value="O"
					changetriphome(1)
					document.getElementById("frmHomePageLeft_DepartDate").value = document.getElementById("frmHomePageLeft_cmbDayFrom").options[document.getElementById("frmHomePageLeft_cmbDayFrom").selectedIndex].value+"/"+document.getElementById("frmHomePageLeft_cmbMonthFrom").options[document.getElementById("frmHomePageLeft_cmbMonthFrom").selectedIndex].value +"/"+document.getElementById("frmHomePageLeft_cmbYearFrom").options[document.getElementById("frmHomePageLeft_cmbYearFrom").selectedIndex].value
					document.getElementById("frmHomePageLeft_ReturnDate").value = document.getElementById("frmHomePageLeft_cmbDayTo").options[document.getElementById("frmHomePageLeft_cmbDayTo").selectedIndex].value+"/"+document.getElementById("frmHomePageLeft_cmbMonthTo").options[document.getElementById("frmHomePageLeft_cmbMonthTo").selectedIndex].value +"/"+document.getElementById("frmHomePageLeft_cmbYearTo").options[document.getElementById("frmHomePageLeft_cmbYearTo").selectedIndex].value
					if(document.getElementById("frmHomePageLeft_chkSpecialRT")!=null)			
					{
					    document.getElementById("frmHomePageLeft_chkSpecialRT").checked = false  //#2 Added
					}
			}
			
			// Added by Amit to set the radio button value on Search Result Page on 15 Apr 09
			function setTrip(strTrip, strDestCity)
            {
            
              if(strTrip == "R")
              {
                  document.getElementsByName("rd_trip")[0].checked = true;
                  document.getElementById('frmHomePageLeft_cmbMonthTo').disabled=false;
				  document.getElementById('frmHomePageLeft_cmbDayTo').disabled=false;
				  document.getElementById('frmHomePageLeft_cmbYearTo').disabled=false;
				  document.getElementById('frmHomePageLeft_flagfare').value = "R"
              }    
              else if(strTrip == "O")
              {
                  document.getElementsByName("rd_trip")[1].checked = true;
                  document.getElementById('frmHomePageLeft_cmbMonthTo').disabled=true;
        		  document.getElementById('frmHomePageLeft_cmbDayTo').disabled=true;
    			  document.getElementById('frmHomePageLeft_cmbYearTo').disabled=true;
                  document.getElementById('frmHomePageLeft_flagfare').value = "O"
 	          }   
              
              //alert(document.getElementById("frmHomePageLeft_cmb_originCity").value);
              ChangeOptionsHome('frmHomePageLeft_cmb_originCity','frmHomePageLeft_cmb_destCity','ArrCity');
              document.getElementById("frmHomePageLeft_cmb_destCity").value = strDestCity;
              
            }

			
			function validateForm()
			{
				
				//alert(isClicked)
				if(isClicked==0)
				{
						var Today = new Date(document.getElementById('frmHomePageLeft_validation_date').value).valueOf()
					//	alert("tarun")						
						if (document.getElementById('frmHomePageLeft_cmb_originCity').options[document.getElementById('frmHomePageLeft_cmb_originCity').selectedIndex].value=="")
						{
							alert("Please select a departure city, we can't find you a flight without knowing from where you're going")
							document.getElementById('frmHomePageLeft_cmb_originCity').focus();
							return false;
						}
						
										
						if (document.getElementById('frmHomePageLeft_cmb_destCity').options[document.getElementById('frmHomePageLeft_cmb_destCity').selectedIndex].value=="")
						{
							alert("Please enter a destination city, we can't find you a flight without knowing where you're going")
							document.getElementById('frmHomePageLeft_cmb_destCity').focus();
							return false;
						}
						if(document.getElementById('frmHomePageLeft_cmb_originCity').options[document.getElementById('frmHomePageLeft_cmb_originCity').selectedIndex].value == document.getElementById('frmHomePageLeft_cmb_destCity').options[document.getElementById('frmHomePageLeft_cmb_destCity').selectedIndex].value)
						{
							alert("Origin city and Destination city cannot be same")
							return false;
						}
						
						document.getElementById('frmHomePageLeft_DepartDate').value = document.getElementById('frmHomePageLeft_cmbMonthFrom').options[document.getElementById('frmHomePageLeft_cmbMonthFrom').selectedIndex].value+"/"+document.getElementById('frmHomePageLeft_cmbDayFrom').options[document.getElementById('frmHomePageLeft_cmbDayFrom').selectedIndex].value +"/"+document.getElementById('frmHomePageLeft_cmbYearFrom').options[document.getElementById('frmHomePageLeft_cmbYearFrom').selectedIndex].value
						
						if (document.getElementById('frmHomePageLeft_flagfare').value=="R")
						{
							document.getElementById('frmHomePageLeft_ReturnDate').value = document.getElementById('frmHomePageLeft_cmbMonthTo').options[document.getElementById('frmHomePageLeft_cmbMonthTo').selectedIndex].value+"/"+document.getElementById('frmHomePageLeft_cmbDayTo').options[document.getElementById('frmHomePageLeft_cmbDayTo').selectedIndex].value +"/"+document.getElementById('frmHomePageLeft_cmbYearTo').options[document.getElementById('frmHomePageLeft_cmbYearTo').selectedIndex].value
						}
						else
						{
							document.getElementById('frmHomePageLeft_ReturnDate').value=document.getElementById('frmHomePageLeft_DepartDate').value 
						}
									
						//alert(document.forms[frm].frmHomePageLeft_txt_adult)					
						if(!checkPassengers(document.getElementById('frmHomePageLeft_txt_adult'),document.getElementById('frmHomePageLeft_txt_child'),document.getElementById('frmHomePageLeft_txt_infant'),document.getElementById('frmHomePageLeft_max_seats').value))
						{
							return false;
						}
						aday = document.getElementById('frmHomePageLeft_cmbDayTo').options[document.getElementById('frmHomePageLeft_cmbDayTo').selectedIndex].value
						amon = document.getElementById('frmHomePageLeft_cmbMonthTo').options[document.getElementById('frmHomePageLeft_cmbMonthTo').selectedIndex].value
						ayear = document.getElementById('frmHomePageLeft_cmbYearTo').options[document.getElementById('frmHomePageLeft_cmbYearTo').selectedIndex].value
						
						dday = document.getElementById('frmHomePageLeft_cmbDayFrom').options[document.getElementById('frmHomePageLeft_cmbDayFrom').selectedIndex].value
						dmon = document.getElementById('frmHomePageLeft_cmbMonthFrom').options[document.getElementById('frmHomePageLeft_cmbMonthFrom').selectedIndex].value
						dyear =document.getElementById('frmHomePageLeft_cmbYearFrom').options[document.getElementById('frmHomePageLeft_cmbYearFrom').selectedIndex].value
						
						var book_allow_date
						out_date = amon +"/" + aday +"/" + ayear
						in_date = dmon +"/" + dday +"/" + dyear 
						
						//alert(document.forms[frm].frmHomePageLeft_flagfare.value);
						//alert(out_date)
						//alert(in_date)
						//alert(document.forms[frm].frmHomePageLeft_DepartDate.value)
						//alert(document.forms[frm].frmHomePageLeft_ReturnDate.value)
						in_date=new Date(in_date).valueOf()
						out_date=new Date(out_date).valueOf()
						days_diff = (in_date - Today) 
						book_allow_date = "31536000000"
						
						if(days_diff > book_allow_date)
						{
							alert("You can't search Departing flights beyond 365 days.") 
							document.getElementById('frmHomePageLeft_cmbDayFrom').focus();
							return false;
						}
							
								
						if (document.getElementById('frmHomePageLeft_flagfare').value=="R")
						{
							days_diff = (out_date - Today)
							if(days_diff > book_allow_date)
							{
								alert("You can't search Return flights beyond 365 days.") 
								document.getElementById('frmHomePageLeft_cmbDayTo').focus();
								return false;
							}
							
							if((out_date - in_date) < 0)
							{
								alert("Return Date can't be less than depart date")
								return false;
							}
						}
						if (document.getElementById('frmHomePageLeft_txt_adult').value == "")
						{
							document.getElementById('frmHomePageLeft_txt_adult').value = "0"
						}
						if (document.getElementById('frmHomePageLeft_txt_child').value == "")
						{
							document.getElementById('frmHomePageLeft_txt_child').value = "0"
						}
						if (document.getElementById('frmHomePageLeft_txt_infant').value == "")
						{
							document.getElementById('frmHomePageLeft_txt_infant').value = "0"
						}
						var obj=document.getElementById("frmHomePageLeft_FlightSearch");
						if(obj)
						{
							isClicked=1
							obj.src=img.src;
							obj.style.cursor="default";
							obj.alt="";
							return true;
						}
					}
					else
					{
						return false;					
					}
			}
    function spaceCheck(ObjField)
    {
	   var ObjPattern,str;
	    
	    if(ObjField.value != "")
	    {
	        ObjField.value  =   trim(ObjField.value);
	        str             =   ObjField.value;
	        ObjPattern      =   /^[a-zA-Z]+$/;//for name, state
    	    
	        if (!(ObjPattern.test(str)))
	        {
	            alert("Invalid entry, Spaces/Numeric Values are not allowed.\nPlease re-enter")
		        return false; 
		    }
	        else
	        {
		        return true;	
		    }
		}
    }	
    function isDate(dtStr)
    {
        var dtCh= '/';
        var daysInMonth =   DaysArray(12)
	    var pos1        =   dtStr.indexOf(dtCh)
	    var pos2        =   dtStr.indexOf(dtCh,pos1+1)
	    var strDay      =   dtStr.substring(0,pos1)
	    var strMonth    =   dtStr.substring(pos1+1,pos2)
	    var strYear     =   dtStr.substring(pos2+1)
	    strYr           =   strYear
	    if (strDay.length<2 ||  strDay.length>2)
	    {		
			    alert("Please Enter Date in DD/MM/YYYY Format")
			    return false;
	    }
	    if (strMonth.length<2 ||  strMonth.length>2)
	    {
			    alert("Please Enter Date in DD/MM/YYYY Format")
			    return false;
	    }
	    if (strYear.length<2 ||  strYear.length>4)
	    {
			    alert("Please Enter Date in DD/MM/YYYY Format")
			    return false
	    }
	
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<1900 || year>2100){
		alert("Please enter a valid 4 digit year between 1900 and 2100 ")
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
    return true
}	

//////////////////////////// FUNCTION TO FIND THE DIFFERENCE BETWEEN TWO DATES AND MATCH WITH 
		//////////////////////////// GIVEN RANGE OF YEAR (USED TO VALIDATE THE INFANT AND CHILD AGES
		function checkYearValidity(TravelDate,DateofBirth,MinRangofYear,MaxRageofYear)
		{
			var dbMon,dbYear,dbday;
			var tdmon,tdYear,tdday;
			var arr;
			var arr1;//Added by Sanjay(Date : 10 Mar 2010)
			var dtCh= '/';
			var dayTravel,monthTravel,yearTravel;
			var dayDOB,monthDOB,yearDOB;
			var strD=new String();
			strD=DateofBirth
			arr=strD.split("/");
			
			//var dbday =parseInt(arr[0]);		// Line commented by Moumita
			//Lines Added By Moumita
			var dbday  = 0;

			if(arr[0] == "09")
				dbday = parseInt(09);
			else if(arr[0] == "08")
				dbday = parseInt(08);
			else
				dbday = parseInt(arr[0]);

			var dbMon=parseInt(arr[1]-1);
			var dbYear=parseInt(arr[2]);
			
			
			strD=TravelDate;
			//arr=strD.split("/"); // Commented by Sanjay(Date : 10 Mar 2010)
			//Added by Sanjay(Date : 10 Mar 2010)
			arr1=strD.split("/");
			if(arr1[0] == "09")
				tdday = parseInt(09);
			else if(arr1[0] == "08")
				tdday = parseInt(08);
			else
				tdday = parseInt(arr1[0]);	
				
			var tdMon=parseInt(arr1[1]-1);// Changed from arr to arr1 by Sanjay(Date : 10 Mar 2010)
			//var tdday=parseInt(arr[0]);// Commented by Sanjay(Date : 10 Mar 2010)
			var tdYear=parseInt(arr1[2]);// Changed from arr to arr1 by Sanjay(Date : 10 Mar 2010)
			
			
	
			var DayDiff = parseInt(tdday) - parseInt(dbday);
			var MonDiff = parseInt(tdMon) - parseInt(dbMon);
			var YearDiff = parseInt(tdYear) - (dbYear);
			
			/*alert("min" + MinRangofYear)
			alert("max" + MaxRageofYear)
			alert("travel"+TravelDate)
			alert("DateofBir"+ DateofBirth )
			alert("days" + DayDiff) 
			alert("Month"+ MonDiff)
			alert ("Year"+ YearDiff)*/
			
			
			if (parseInt(YearDiff)>parseInt(MaxRageofYear) ||  parseInt(YearDiff)<parseInt(MinRangofYear))
			{
				return false;
				
			}
			
			if (YearDiff==MaxRageofYear)
			{
				
				if (MonDiff>0 ) 
				{
										
					return false;
					
				}
				if (MonDiff==0 &&  DayDiff >= 0  )
				{
					
					return false;
				}
				else
				{
					
					return true;
				}
			}
			else if(YearDiff==MinRangofYear)
			{
				if (MonDiff<0 )
				{
										
					return false;
					
				}
				if (MonDiff==0 && DayDiff<0 ) 
				{
										
					return false;
					
				}
				else
				{
					
					return true;
				}
			
				
				
			}
			return true;
}

////////////////////////// Date checking function	


function isInteger(s){ 
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////// END HOME PAGE VALIDATIONS BLOCK ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////


function isValidFlightId(theInput)
{
	var totalHyphen = 0;
	if (theInput != "") 
	{
		for (var i = 0; i <= (theInput.length-1); i++)
		{
			var theChar = theInput.substring(i,i+1);
			if (theChar == "-")
			{
				totalHyphen++;
			}
		}
		
		if (totalHyphen > 1) 
		{
			return false;
		}
		
		var pos = theInput.indexOf("-") ;
		if(pos != -1)
		{
			if(pos == 0) 
			{
				return false;
			}
			else if(pos == (theInput.length-1)) 
			{
				return false;
			}
			else if (theInput.length == 1)
			{
				return false;
			}
		}
			
		for (i=0; i<theInput.length; i++)
		{
			var c = theInput.charAt(i);
			if (!(((c >= "0") && (c <= "9")) || ((c >= "A") && (c <= "Z")) || ((c >= "a") && (c <= "z")) || (c == "-") || (c == " ")))
			{
				return false;
			}
		}		
	}
	return true;
}


//#3 - Start: Added by Amit for connecting flights on 24th Nov 09 
function onChangeFlights() 
{
    if(document.getElementById('frmHomePageLeft_chkConnecting')!=null)
    {
	    if(document.getElementById('frmHomePageLeft_chkConnecting').checked==true)
	    {
	      //Enable radio buttons and set the one stop default radio button
	      document.getElementById('frmHomePageLeft_radTypeofFlightOneStop').disabled=false;
	      document.getElementById('frmHomePageLeft_radTypeofFlightTwoStop').disabled=false;
	      if(document.getElementById('frmHomePageLeft_radTypeofFlightOneStop').checked==false && document.getElementById('frmHomePageLeft_radTypeofFlightTwoStop').checked==false)
	      {
	         document.getElementById('frmHomePageLeft_radTypeofFlightOneStop').checked=true;
	         document.getElementById('frmHomePageLeft_radTypeofFlightTwoStop').checked=false;
	      }
	      //document.getElementById('frmHomePageLeft_radTypeofFlightOneStop').checked=true;
	      //document.getElementById('frmHomePageLeft_radTypeofFlightTwoStop').checked=false;
	      document.getElementById("dvStoprOver").style.display="block";
	       if(document.getElementById("frmHomePageLeft_chkSpecialRT")!=null)
		   {
	        document.getElementById("frmHomePageLeft_chkSpecialRT").disabled = true;
	        document.getElementById("frmHomePageLeft_chkSpecialRT").checked = false; 
	       }
	    }
	    else
	    {
	      //Disable radio buttons and set the radio button unselected
	       document.getElementById('frmHomePageLeft_radTypeofFlightOneStop').checked=false;
	       document.getElementById('frmHomePageLeft_radTypeofFlightTwoStop').checked=false;
	       document.getElementById('frmHomePageLeft_radTypeofFlightOneStop').disabled=true;
	       document.getElementById('frmHomePageLeft_radTypeofFlightTwoStop').disabled=true;
	       document.getElementById("dvStoprOver").style.display="none";
	       if(document.getElementById("frmHomePageLeft_chkSpecialRT")!=null)
		   {
		    if (document.getElementsByName("rd_trip")[0].checked == true)
		    {
	            document.getElementById("frmHomePageLeft_chkSpecialRT").disabled = false;
	            document.getElementById("frmHomePageLeft_chkSpecialRT").checked = false; 	            
	        }
	       }
	    }
	}
}
//#3 - End: Added by Amit for connecting flights on 24th Nov 09 