//   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 to increment a date in checout date///////////////
function isDecimal(c)
{
    if (c==".")
     {
       return true     
	 }
   return false
}

//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)
{
	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 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*[@]\w+([.]\w{1,15}){1,3}$/gi; //email id
	ObjPattern= /^[A-Za-z]\w*([.|-]\w*){0,4}[@]\w+([.]\w{2,3}){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
		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=="_") ))
	     {
          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+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 ((adult.value > 0) && (adult.value > paxnum))
	{
		alert("Total number of Adults travelling cannot be more than " + paxnum+".");
		adult.focus();
		return false;
	}
	
	if ((child.value > 0) && (child.value > paxnum))
	{
		alert("Total number of Children travelling cannot be more than" + paxnum+".");
		child.focus();
		return false;
	}
	
	if (isNaN(child.value))
	{
		alert("Invalid entry, only digits are allowed.\nPlease re-enter");
		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;
		}
	}	
	
	
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)
{

	var yy = eval("document."+frm+".elements['"+chkinY+"'].options[document."+frm+".elements['"+chkinY+"'].selectedIndex].value")

	if (eval("document."+frm+".elements['"+chkinM+"'].selectedIndex")==1)
	{
		if ((eval("document."+frm+".elements['"+chkinD+"'].selectedIndex")>27)&&((yy%4)!=0))////not a leap year
		{	
			eval("document."+frm+".elements['"+chkinD+"'].selectedIndex=0")
			eval("document."+frm+".elements['"+chkinM+"'].selectedIndex=2")
		}
		if ((eval("document."+frm+".elements['"+chkinD+"'].selectedIndex")>28)&&((yy%4)==0))///leap year
	    {
			eval("document."+frm+".elements['"+chkinD+"'].selectedIndex=0")
			eval("document."+frm+".elements['"+chkinM+"'].selectedIndex=2")
			
		}
	}
	if ((eval("document."+frm+".elements['"+chkinM+"'].selectedIndex")==3)||(eval("document."+frm+".elements['"+chkinM+"'].selectedIndex")==5)||(eval("document."+frm+".elements['"+chkinM+"'].selectedIndex")==8)||(eval("document."+frm+".elements['"+chkinM+"'].selectedIndex")==10))
	{
		
		if (eval("document."+frm+".elements['"+chkinD+"'].selectedIndex")==30)
		{
			eval("document."+frm+".elements['"+chkinD+"'].selectedIndex=0")
			eval("document."+frm+".elements['"+chkinM+"'].selectedIndex=document."+frm+".elements['"+chkinM+"'].selectedIndex+1")
		}
	}
	
}

function increment_date(frm,chkinM,chkinD,chkinY,chkoutM,chkoutD,chkoutY)
{
	var ckinm,ckind,ckiny,ckin,ckoutm,ckoutd,ckouty,ckout;
	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,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(eval("document."+frm+".elements['"+chkinY+"']"),ckiny*1)
	}
	
	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=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

		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)
			eval("document."+frm+".elements['"+chkoutM+"'].selectedIndex=currentdate.getMonth()")
			eval("document."+frm+".elements['"+chkoutD+"'].selectedIndex=currentdate.getDate()-1")
			selectbox(eval("document."+frm+".elements['"+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
}
////////////////////////////////////////////////////////////////
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;
}
