



function flightsForm()
{

	document.write("<form name='frmFlightsQry' action='http://www.hotelsfair.in/jsp/HotelsBooking' method='post'>");

	document.write("<table  width='198' cellspacing='0' cellpadding='0' border=0 align=center class='bgimage' >");

	document.write("<tr><td class='textsize'>&nbsp;Name:</td><td>");
	document.write("<SELECT NAME='title' class='textsize1'>");
	document.write("<OPTION SELECTED VALUE='Mr'>Mr</OPTION><OPTION  VALUE='Mrs'>Mrs</OPTION><OPTION  VALUE='Ms'>Ms</OPTION><OPTION  VALUE='Dr'>Dr</OPTION></SELECT>	");
	document.write("<INPUT TYPE='text' NAME='your_name' style='width: 95px' MAXLENGTH='60' class='textsize1'><font color=red>*</font></td></tr>");

	document.write("<tr><td class='textsize'>&nbsp;Email: </td><td>");
	document.write("<INPUT TYPE='text' NAME='your_email' style='width: 146px' MAXLENGTH='70' class='textsize1'><font color=red>*</font></td></tr>");

	document.write("<tr><td class='textsize'colspan=2>&nbsp;Telephone:</td></tr>");
	document.write("<tr><td colspan=2>");
	document.write("<table border=0 cellspacing=0 cellpadding=1 width=100% align=center><tr>");
	document.write("<td width='38%' align=right><INPUT maxLength=50 name='country_code1' size=6  value='Country' class='textsize1'></td>");
	document.write("<td  width='20%' align=right><INPUT maxLength=50 name='city_code1' size=5  value='City' class='textsize1'></td>");
	document.write("<td width='42%' class='textsize1'><INPUT maxLength=50 name='phone1' size=10  value='Phone' class='textsize1'><font color=red>*</font>");
	document.write("</td></tr></table></td></tr>");

	document.write("<tr><td class='textsize' colspan=2>&nbsp;Departure Date:</td></tr>");
	document.write("<tr><td colspan=2>");
	document.write("<table border=0 width='170' cellspacing=0 cellpadding=0 align=right>");
	document.write("<tr><td  valign=top >");
	document.write("<SELECT NAME='m_arrival' class='textsize1' >");
	document.write("<OPTION VALUE='NA' SELECTED>MM</OPTION>");
	document.write("<SCRIPT language=JavaScript> var i=0;");
	document.write("for(i=0;i<monthArray.length;i++) { document.write(\"<option value='\"+monthArray[i]+\"'>\"+monthArrayShort[i]+\"</option>\"); }");
	document.write("</SCRIPT></SELECT></td>");


	document.write("<td valign=top >");
	document.write("<SELECT NAME='d_arrival' class='textsize1'>");
	document.write("<OPTION VALUE='NA' SELECTED>DD</OPTION>");
	document.write("<SCRIPT language=JavaScript> var i=0;");
	document.write("for(i=0;i<daysArray.length;i++) { document.write(\"<option value='\"+daysArray[i]+\"'>\"+daysArray[i]+\"</option>\"); }");
	document.write("</SCRIPT></SELECT></td>");

	document.write("<td valign=top >");
	document.write("<SELECT NAME='y_arrival' class='textsize1'> ");
	document.write("<OPTION VALUE='NA' SELECTED>YY</OPTION>");
	document.write("<OPTION VALUE='2008'>2008</OPTION>");
	document.write("<OPTION VALUE='2009'>2009</OPTION>");
	document.write("<OPTION VALUE='2010'>2010</OPTION>");
	document.write("<OPTION VALUE='2011'>2011</OPTION>");
	document.write("<OPTION VALUE='2012'>2012</OPTION>");
	document.write("</SELECT>");
	document.write("<font color=red>*</font>");
	document.write("</td></tr></table></td></tr>");
	
	
	
	document.write("<tr><td class='textsize' colspan=2>&nbsp;Return Date:</td></tr>");
	document.write("<tr><td colspan=2>");
	document.write("<table border=0 width='170' cellspacing=0 cellpadding=0 align=right>");
	document.write("<tr><td valign=top >");
	document.write("<SELECT NAME='m_ret_date' class='textsize1' >");
	document.write("<OPTION VALUE='NA' SELECTED>MM</OPTION>");
	document.write("<SCRIPT language=JavaScript> var i=0;");
	document.write("for(i=0;i<monthArray.length;i++) { document.write(\"<option value='\"+monthArray[i]+\"'>\"+monthArrayShort[i]+\"</option>\"); }");
	document.write("</SCRIPT></SELECT></td>");

	document.write("<td valign=top >");
	document.write("<SELECT NAME='d_ret_date' class='textsize1'>");
	document.write("<OPTION VALUE='NA' SELECTED>DD</OPTION>");
	document.write("<SCRIPT language=JavaScript> var i=0;");
	document.write("for(i=0;i<daysArray.length;i++) { document.write(\"<option value='\"+daysArray[i]+\"'>\"+daysArray[i]+\"</option>\"); }");
	document.write("</SCRIPT></SELECT></td>");

	document.write("<td valign=top >");
	document.write("<SELECT NAME='y_ret_date' class='textsize1'>");
	document.write("<OPTION VALUE='NA' SELECTED>YY</OPTION>");
	document.write("<OPTION VALUE='2008'>2008</OPTION>");
	document.write("<OPTION VALUE='2009'>2009</OPTION>");
	document.write("<OPTION VALUE='2010'>2010</OPTION>");
	document.write("<OPTION VALUE='2011'>2011</OPTION>");
	document.write("<OPTION VALUE='2012'>2012</OPTION>");
	document.write("</SELECT><font color=red>*</font></td></tr></table></td></tr>");

	document.write("<tr><td class='textsize' colspan=2>&nbsp;Flying from Country, City:</td></tr>");
	document.write("<tr><td class='textsize1' colspan=2>&nbsp;&nbsp;&nbsp;&nbsp;");
	document.write("<INPUT TYPE='text' NAME='city1' style='width: 164px' MAXLENGTH='70' class='textsize1'><font color=red>*</font>	</td></tr>");
	
	document.write("<tr><td class='textsize' colspan=2>&nbsp;Flying to Country, City:</td></tr>");
	document.write("<tr><td class='textsize1' colspan=2>&nbsp;&nbsp;&nbsp;&nbsp;");
	document.write("<INPUT TYPE='text' NAME='city2' style='width: 164px' MAXLENGTH='70' class='textsize1'><font color=red>*</font>	</td></tr>");
	
	document.write("<tr><td class='textsize' colspan=2>&nbsp;</td></tr>");
	document.write("<INPUT TYPE='hidden' name='adults' value='' />");
	document.write("<INPUT TYPE='hidden' name='travel' value='' />");
	document.write("<INPUT TYPE='hidden' name='selCountry' value='' />");
	document.write("<INPUT TYPE='hidden' name='selCountry1' value='' />");
	document.write("<INPUT TYPE='hidden' name='query' value='' />");

	document.write("<tr><td colspan='2' align='center'>");
	document.write("<INPUT TYPE='hidden' name='action' value='flight-form'>");
	document.write("<INPUT TYPE='submit' VALUE='Submit' onclick='return airFormValidate(this.form)' class='btn' >&nbsp;");
	document.write("<INPUT TYPE='reset' VALUE='Reset' class='btn'></td></tr>");
	document.write("</TABLE><!-- FLIGHTS FORM END //-->");
	document.write("</form>");


}










//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
/*****************************************Air Form Validation******************************************/
function airFormValidate(form) {
//	alert("Badre Alam...............");

var v=allBlanksAir(form)
//selectrouting(form)
//selectclass(form)
tocity(form)
//tocountry(form)
fromcity(form)
//fromcountry(form)
//isairFrmPassengers(form)
isairFrmReturn(form)
isairFrmArrival(form)
isairFrmPhone(form)
isairFrmCityCode(form)
isairFrmCountryCode(form)
isairFrmEmail(form)
isairFrmName(form)
return v ;


return false;

}

function allBlanksAir(form) {
if( (isairFrmName(form) && isairFrmEmail(form)) && (isairFrmCountryCode(form) && isairFrmCityCode(form)) && isairFrmPhone(form) && (isairFrmArrival(form) && isairFrmReturn(form)) && tocity(form)&& fromcity(form)) {
 return true ;
}

if( (isairFrmName(form) == false || isairFrmEmail(form) == false ) || ( isairFrmCountryCode(form) == false) || (isairFrmCityCode(form) == false || isairFrmPhone(form) == false )||(isairFrmArrival(form) == false || isairFrmReturn(form)== false)||tocity(form)==false || fromcity(form)==false) {
airCompose(form)
return false ;
 }
}



function airCompose(form) {

var text = " You entered incorrectly or forgot to fill in ::\n"	
if(isairFrmName(form) == false) {
text += "\nYour Name -- must be purely alphabetic"
}
if(isairFrmEmail(form) == false) {
text += "\nYour E-mail -- improper/incomplete e-mail ID"
}
if(isairFrmCountryCode(form) == false) {
text += "\nCountry Code for Phone -- should be number or blank"
}
if(isairFrmCityCode(form) == false) {
text += "\nArea Code for Phone -- should be a number or blank"
}
if(isairFrmPhone(form) == false) {
text += "\nPhone Number -- should be number or blank"
}

if(isairFrmArrival(form) == false) {
text += "\nDeparture Date -- cannot be earlier than today"
}
if(isairFrmReturn(form) == false) {
text += "\nReturn Date -- cannot be earlier than departure date"
}

//	if(isairFrmPassengers(form) == false) {
//	text += "\nNo. of Passengers travelling -- should be a number"
//	}
//	if(fromcountry(form)==false)
//	{
//	text +="\nFlying From Country--should not be blank"
//	}
	
	if(fromcity(form)==false)
	{
		text +="\nFlying From City--should not be blank Or Number"
	}
//	if(tocountry(form)==false)
//	{
//		text +="\nFlying to Country--Should not be Blank"
//	}
	if(tocity(form)==false)
	{
		text +="\nFlying to City--Should not be Blank Or Number"
	}
//	if(selectclass(form)==false)
//	{
//	text +="\nClass of Travel--- should not be Blank"
//	}
//	if(selectrouting(form)==false)
//	{
//		text +="\nRouting--- should not be Blank"	// Travel Related Comments
//	}
alert(text)
}

//FOR EMAIL
function isairFrmEmail(form) {
if (trim(form.your_email.value)== "")
	{
		form.your_email.focus();
		return false; // because it is not optional 
	}
else
	{
		var eid=form.your_email.value=trim(form.your_email.value);
		if (eid.indexOf(' ')!= -1)
			{
			form.your_email.focus();
			return false ; // no spaces
			} 
		if (eid.length < 6 ){
			form.your_email.focus();
			return false ; // at least j.a@in
			}
		at=eid.indexOf('@', 0); //check from first position ---- 
		if ( at == -1 || at == 0){ //should not be at first place
			form.your_email.focus();
			return false ;
			}
		else
			{
				var at1=eid.indexOf('@', (at + 1)); //looking for another at one place ahead
				if ( at1 == -1 ) // ie only one at is there
				{
					var dot=eid.indexOf('.',(at + 1));//looking for just next value
					if(dot == (at + 1)|| dot== -1){ //if dot is not there or in the next place
						form.your_email.focus();
						return false ;	
						}
					else
						{
						 if ( (dot + 2 ) < eid.length )
							return true ;
						 else
						 {
							form.your_email.focus();
							return false ;
							}
						}
				}
				else // two @ are there
				{
				form.your_email.focus();
				return false;
				}
			}	
	form.your_email.focus();
	return false ;
	}		

}
//FOR PHONE

function isairFrmPhone(form) {
if (trim(form.phone1.value) == "") {
form.phone1.value=trim(form.phone1.value);
return true //because it is optional
}
else {
			form.phone1.value=trim(form.phone1.value);
	 if(checkfornum(form.phone1.value)==0)
		 {
			form.phone1.focus();
			return(false);
			}
return true
 }
}

//FOR CITY CODE OF PHONE

function isairFrmCityCode(form) {
if (trim(form.city_code1.value) == "") {
form.city_code1.value=trim(form.city_code1.value);
return true //because it is optional
}
else {
			form.city_code1.value=trim(form.city_code1.value);
	 if(checkfornum(form.city_code1.value)==0)
		 {
			form.city_code1.focus();
			return(false);
			}
return true
 }
}
//cheking for class of travel

function selectclass(form)
{
	if(form.travel.value=="NA")
	{
		form.travel.focus();
		return false;
	}
}
	//checking for routing....... Travel Related Comments
	function selectrouting(form)
	{
		if(form.query.value=="")
		{
			form.query.focus();
			return true; //false
		}
	}
//for country code of phone
function isairFrmCountryCode(form) 
{
	if (trim(form.country_code1.value) == "") 
	{
		form.country_code1.value=trim(form.country_code1.value);
		return true //because it is optional
	}
	else
	{
		form.country_code1.value=trim(form.country_code1.value);
		if(checkfornum(form.country_code1.value)==0)
		{
			form.country_code1.focus();
			return(false);
		}
		return true
	}
}




//FOR No. of Passengers
function isairFrmPassengers(form) {
if (trim(form.adults.value) == "" ||(form.adults.value)< 1 ) {
form.adults.focus();
return(false); 
}
else {
			//form.adults.value=trim(form.adults.value);
	 if(checkfornum(form.adults.value)==0)
		 {
			form.adults.focus();
			return(false);
			}
return true
 }
}

//FOR NAME
function isairFrmName(form) {
if (trim(form.your_name.value) == "") {
form.your_name.focus();
return false
}
else {
			form.your_name.value=trim(form.your_name.value);
	 if(checkforchar(form.your_name.value)== 0)
		 {
			form.your_name.focus();
			return(false);
			}
return true ;
 }
}

function isairFrmArrival(form)
{
	if ((form.m_arrival.value== "NA") || (form.d_arrival.value== "NA") || (form.y_arrival.value== "NA"))
	{
		if(form.m_arrival.value== "NA")
		{
			form.m_arrival.focus();
			return false;
		}
		if(form.d_arrival.value== "NA")
		{
			form.d_arrival.focus();
			return false; 
		}
		if(form.y_arrival.value== "NA")
		{
			form.y_arrival.focus();
			return false;
		}
	}
	else{
		if (isairFrmArrDate(form)==false)
		{
			return false;
		}
		else
			return true;
	}
}

function isairFrmArrDate(form)
{
	for(i=0;i<=montharray.length;i++)
	{
		if (montharray[i]==form.m_arrival.value)
		{
			dgt=i;
			break;
		}
	}
	//alert(dgt)
if(form.y_arrival.value < year)
{
	pkflg = false;
	form.y_arrival.focus(); 
	return false; //presently used
 } 
 else
	{
		if((form.y_arrival.value == year) && (dgt < month))
		{
			//alert("Invalid date. It must be a future date.");
			pkflg = false;
			form.m_arrival.focus();
			return false;
		}
		else
		{
			if((form.y_arrival.value == year) && (dgt == month))
			{
				if (form.d_arrival.value < daym)
				{
				//alert("Invalid date. It must be a future date.");
				pkflg = false;
				form.d_arrival.focus();
				return false;
				}
				else
					return true;
			}
		}
	}
 }




function isairFrmReturn(form)
{
	if ((form.m_ret_date.value== "NA") || (form.d_ret_date.value== "NA") || (form.y_ret_date.value== "NA"))
	{
		if(form.m_ret_date.value== "NA")
		{
			form.m_ret_date.focus()
			return false;
		}
		if(form.d_ret_date.value== "NA")
		{
			form.d_ret_date.focus()
			return false; 
		}
		if(form.y_ret_date.value== "NA")
		{
			form.y_ret_date.focus()
			return false;
		}
	}
	else{
		if (isairFrmRetDate(form)==false)
		{
			return false;
		}
		else
			return true;
	}
}

function isairFrmRetDate(form)
{
	if(form.y_ret_date.value < form.y_arrival.value)
	{
		//alert("1")
		//alert("Return Date cannot be Earlier than Picking Date");
		rtflg = false;
		form.y_ret_date.focus(); 
		return false; //presently used
	}
	else
	{
		for(i=0;i<=montharray.length;i++)
		{
			if (montharray[i]==form.m_ret_date.value)
			{
				retmn=i+1;
				break;
			}
		}
		for(i=0;i<=montharray.length;i++)
		{
			if (montharray[i]==form.m_arrival.value)
			{
				pickmn=i+1;
				break;
			}
		}
		//alert(retmn)
		//alert(pickmn)
		if((form.y_ret_date.value == form.y_arrival.value) && (retmn < pickmn))
		{
			//alert("2")
			//alert("Return Date cannot be Earlier than Picking Date");
			rtflg = false;
			form.m_ret_date.focus();
			return false;
		}
		else
		{
			if((form.y_ret_date.value == form.y_arrival.value) && (retmn == pickmn))
			{
				//alert("hello")
				//alert(form.selOutDate.value)
				//alert(form.d_arrival.value)
				if ((form.d_ret_date.value)<(form.d_arrival.value))
				{
					//alert("3")
					//alert("Return Date cannot be Earlier than Picking Date");
					rtflg = false;
					form.d_ret_date.focus();
					return false;
				}
				else
					return true;
			}
		}
	}
 }


 //*****************checking for the from country should not be Blank.........******
 function fromcountry(form)
 {
 if(trim(form.selCountry.value)=="NA")
	 {
 form.selCountry.focus();
	 return false;
	 }
 }
 //checking for the to country for blank...........///
 function fromcity(form)
 {
	 if(trim(form.city1.value)==""||!isNaN(trim(form.city1.value)))
	 {
		 form.city1.focus();
		 return false;
	 }
 }

function tocountry(form)
 {
 if(trim(form.selCountry1.value)=="NA")
	 {
 form.selCountry1.focus();
	 return false;
	 }
 }
 //checking for the to country for blank...........///
 function tocity(form)
 {
	 if(trim(form.city2.value)==""||!isNaN(trim(form.city2.value)))
	 {
		 form.city2.focus();
		 return false;
	 }
 }


//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
