// JavaScript Document
function validate_frm()
{
	var frm=document.frm1;
	if (trimAll(frm.txtname.value)=="")
	{	
		alert("Please enter Name.");
		frm.txtname.value="";
		frm.txtname.focus();
		return false;
	}
	
	if(DateCheck(frm.selBDay,frm.selBMonth,frm.selBYear))
	{
		//do nothing
	}
	else
	{
		return false;
	}
	
	if (trimAll(frm.txtemail.value)=="")
    {           
	    alert("Please enter your Email Id.");
        frm.txtemail.value="";
        frm.txtemail.focus();
        return false;
    }
    
	var emailID=document.frm1.txtemail;
    if (emailID.value!="")
    {
	    if (isEmailNew(emailID.value)==false)
		{
	        alert('Invalid Email Id');
            emailID.focus();
            return false
		}
    }
	
	if (trimAll(frm.txtPresentContact.value)=="")
	{           
	    alert("Please enter your Present Contact Number.");
        frm.txtPresentContact.value="";
        frm.txtPresentContact.focus();
        return false;
    }
	
    if(trimAll(frm.txtPresentContact.value)!="")
	{
	    if(isNaN(frm.txtPresentContact.value))
	    {
	        alert("Please enter Numeric Data in Contact Number.");
            frm.txtPresentContact.value="";
			frm.txtPresentContact.focus();
            return false;
        }
		
		 if(!IsInteger(frm.txtPresentContact.value))
	    {
	        alert("Please enter Numeric Data in Contact Number.");
            frm.txtPresentContact.value="";
			frm.txtPresentContact.focus();
            return false;
        }
		if (frm.txtPresentContact.value.length<6)
		{
			alert("Please enter proper Contact Number");
			frm.txtPresentContact.focus();
			return false;
		}
    }
	
	if (trimAll(frm.txtaccountnumber.value)=="")
	{           
	    alert("Please enter your Account Number.");
        frm.txtaccountnumber.value="";
        frm.txtaccountnumber.focus();
        return false;
    }
	
	if (trimAll(frm.txtContactInd.value)=="")
	{           
	    alert("Please enter your Contact Number in India.");
        frm.txtContactInd.value="";
        frm.txtContactInd.focus();
        return false;
    }
	
	if(trimAll(frm.txtContactInd.value)!="")
	{
	    if(isNaN(frm.txtContactInd.value))
	    {
	        alert("Please enter Numeric Data in Contact Number.");
            frm.txtContactInd.value="";
			frm.txtContactInd.focus();
            return false;
        }
		
		 if(!IsInteger(frm.txtContactInd.value))
	    {
	        alert("Please enter Numeric Data in Contact Number.");
            frm.txtContactInd.value="";
			frm.txtContactInd.focus();
            return false;
        }
		if (frm.txtContactInd.value.length<6)
		{
			alert("Please enter proper Contact Number");
			frm.txtContactInd.focus();
			return false;
		}
    }
	
	if (trimAll(frm.txtaddress.value)=="")
    {           
	    alert("Please enter your Address.");
        frm.txtaddress.value="";
        frm.txtaddress.focus();
        return false;
    }
	
	if (trimAll(frm.txtaddress.value)!="")
	{
		if(frm.txtaddress.value<=2)
		{
		   alert("Please enter your Address.");
		   frm.txtaddress.value="";
		   frm.txtaddress.focus();
		   return false;
		}
	}
	
	if (trimAll(frm.txtNoofAdults.value)=="")
    {           
	    alert("Please enter No. of Adults.");
        frm.txtNoofAdults.value="";
        frm.txtNoofAdults.focus();
        return false;
    }
	
	if(trimAll(frm.txtNoofAdults.value)!="")
	{
	    if(isNaN(frm.txtNoofAdults.value))
	    {
	        alert("Please enter Numeric Data.");
            frm.txtNoofAdults.value="";
			frm.txtNoofAdults.focus();
            return false;
        }
		
		 if(!IsInteger(frm.txtNoofAdults.value))
	    {
	        alert("Please enter Numeric Data.");
            frm.txtNoofAdults.value="";
			frm.txtNoofAdults.focus();
            return false;
        }
		if (frm.txtNoofAdults.value<1)
		{
			alert("Please enter proper Number of Adults");
			frm.txtNoofAdults.focus();
			return false;
		}
		if (frm.txtNoofAdults.value>10)
		{
			alert("Maximum 10 people allowed");
			frm.txtNoofAdults.focus();
			return false;
		}
    }
	
	if (trimAll(frm.txtNoofChildren.value)=="")
    {           
	    alert("Please enter No. of Children.");
        frm.txtNoofChildren.value="";
        frm.txtNoofChildren.focus();
        return false;
    }
	
	if(trimAll(frm.txtNoofChildren.value)!="")
	{
	    if(isNaN(frm.txtNoofChildren.value))
	    {
	        alert("Please enter Numeric Data.");
            frm.txtNoofChildren.value="";
			frm.txtNoofChildren.focus();
            return false;
        }
		
		 if(!IsInteger(frm.txtNoofChildren.value))
	    {
	        alert("Please enter Numeric Data.");
            frm.txtNoofChildren.value="";
			frm.txtNoofChildren.focus();
            return false;
        }
		if (frm.txtNoofChildren.value<1)
		{
			alert("Please enter proper Number of Adults");
			frm.txtNoofChildren.focus();
			return false;
		}
		if (frm.txtNoofChildren.value>10)
		{
			alert("Maximum 10 children allowed");
			frm.txtNoofChildren.focus();
			return false;
		}
    }
	
	if (trimAll(frm.txtAirlinename.value)=="")
    {           
	    alert("Please enter Airline Name.");
        frm.txtAirlinename.value="";
        frm.txtAirlinename.focus();
        return false;
    }
	
	if (trimAll(frm.txtFlightNo.value)=="")
    {           
	    alert("Please enter Flight No.");
        frm.txtFlightNo.value="";
        frm.txtFlightNo.focus();
        return false;
    }
	
	if (trimAll(frm.txtFrom.value)=="")
    {           
	    alert("Please enter Flight From");
        frm.txtFrom.value="";
        frm.txtFrom.focus();
        return false;
    }
	
	if (trimAll(frm.txtTo.value)=="")
    {           
	    alert("Please select Flight To.");
        frm.txtTo.value="";
        frm.txtTo.focus();
        return false;
    }
	
	if(DateCheck(frm.selADay,frm.selAMonth,frm.selAYear))
	{
		//do nothing
	}
	else
	{
		return false;
	}
	
	if (trimAll(frm.selATimeHrs.value)=="")
    {           
	    alert("Please select Arrival Time Hours");
        frm.selATimeHrs.value="";
        frm.selATimeHrs.focus();
        return false;
    }
	
	if (trimAll(frm.selATimeMin.value)=="")
    {           
	    alert("Please select Arrival Time Minutes");
        frm.selATimeMin.value="";
        frm.selATimeMin.focus();
        return false;
    }
	
	if(DateCheck(frm.selAppDay,frm.selAppMonth,frm.selAppYear))
	{
		//do nothing
	}
	else
	{
		return false;
	}
		
	if (frm.chkAgree.checked==false)
    {           
	    alert("Please accept the terms and contions before proceeding further.");
        frm.chkAgree.value="";
        frm.chkAgree.focus();
        return false;
    }	
}

function Count(text,AllowedLength) 
{
   var maxlength = AllowedLength; // Change number to your max length.
   if (text.value.length > maxlength)
   {
     text.value = text.value.substring(0,maxlength);
     alert(" Only " + AllowedLength + " chars are allowed.");
   }
}

function DateCheck(day,month,year)
{
   if (day.value == "")
   {
      alert("Please Select Day")
      day.focus()
      return false;
   }
   if (month.value == "")
   {
      alert("Please Select Month")
      month.focus()
      return false;
   }
   if (year.value == "")
   {
      alert("Please Select Year")
      year.focus()
      return false;
   }
   if (month.value == "APR" || month.value == "Jun" || month.value == "SEP" || month.value == "NOV")
   {
      if (day.value == "31")
      {
         alert("Month can have 1-30 days only")
         day.focus()
         return false;
      }
   }
   if ((year.value%4) == "0" )
   {
      if (month.value == "FEB")
      {
           if (day.value == "30" || day.value == "31")
           {
              alert("Feb Month can have 1-29 days only in the selected year")
              day.focus()
              return false;
           }
      }
   }
   else
   {
      if (month.value == "FEB")
      {
         if (day.value == "30" || day.value == "31" || day.value == "29" )
         {
             alert("Feb Month can have 1-28 days only in the selected year")
             day.focus()
             return false;
         }
      }
   }
   return true;
}




