

function carForm()
{

	document.write("<form name='frmCarQry' action='http://www.hotelsfair.in/jsp/HotelsBooking' method='post' target='_blank'>");
	document.write("<table  width='198' bgcolor='#E4F0FC' cellspacing='0' cellpadding='0' border=0 align=center class='setbg'>");
	document.write("<tr><td class='textsize'>&nbsp;Name:</td>");
	document.write("<td class='textsize1'>");
	document.write("<SELECT NAME='title' class='textsize1'>");
	document.write("<OPTION SELECTED VALUE='Mr'>Mr</OPTION>");
	document.write("<OPTION  VALUE='Mrs'>Mrs</OPTION>");
	document.write("<OPTION  VALUE='Ms'>Ms</OPTION>");
	document.write("<OPTION  VALUE='Dr'>Dr</OPTION></SELECT>");
	document.write("<INPUT TYPE='text' NAME='txiName' style='width: 95px' MAXLENGTH='60' class='textsize1'><font color=red>*</font></td></tr>");

	document.write("<tr><td class='textsize'>&nbsp;Email: </td>");
	document.write("<td class='textsize1'><INPUT TYPE='text' NAME='txiEmail' style='width: 146px' MAXLENGTH='70' class='textsize1'><font color=red>*</font>	</td></tr>");
	
	document.write("<tr><td class='textsize' colspan=2>&nbsp;Country:</td></tr>");
	document.write("<tr><td class='textsize1' colspan=2>&nbsp;&nbsp;&nbsp;&nbsp;<SELECT name='selCountry' class='textsize1' style='width: 165px'>");
	document.write("<OPTION selected value='NA'>Select Country</OPTION>");
	document.write("<SCRIPT language=JavaScript> var i=0;");
	document.write("for(i=0;i<countryArray.length;i++) { document.write(\"<option value='\"+countryArray[i]+\"'>\"+countryArray[i]+\"</option>\"); }");
	document.write("</SCRIPT></SELECT><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='txiCountryCode' size=6  value='Country' class='textsize1'></td>");
	document.write("<td  width='20%' align=right><INPUT maxLength=50 name='txiCityCode' size=5  value='City' class='textsize1'></td>");
	document.write("<td width='42%' class='textsize1'><INPUT maxLength=50 name='txiPhone' size=10  value='Phone' class='textsize1'><font color=red>*</font>");
	document.write("</td></tr></table>");
	document.write("</td></tr>");

	document.write("<tr><td class='textsize' colspan=2>&nbsp;Car Preference:</td></tr>");
	document.write("<tr><td class='textsize1' colspan=2>&nbsp;&nbsp;&nbsp;&nbsp;");
	document.write("<SELECT name='selCar' size='1' class='textsize1' style='width: 164px'>");
	document.write("<OPTION selected value='NA'>Select - Car</OPTION>");
	document.write("<SCRIPT language=JavaScript> var i=0;");
	document.write("for(i=0;i<carArray.length;i++) { document.write(\"<option value='\"+carArray[i]+\"'>\"+carArray[i]+\"</option>\"); }");
	document.write("</SCRIPT></SELECT><font color=red>*</font></td></tr>");

	document.write("<tr><td class='textsize' colspan=2>&nbsp;Car Picking Place: </td></tr>");
	document.write("<tr><td class='textsize1' colspan=2>&nbsp;&nbsp;&nbsp;&nbsp;");
	document.write("<INPUT TYPE='text' NAME='place' style='width: 164px' MAXLENGTH='70' class='textsize1'><font color=red>*</font>	</td></tr>");

	document.write("<INPUT TYPE='hidden' name='selTentMonth' value='' />");
	document.write("<INPUT TYPE='hidden' name='selTentDate' value='' />");
	document.write("<INPUT TYPE='hidden' name='selTentYear' value='' />");
	document.write("<INPUT TYPE='hidden' name='selPickHour' value='' />");
	document.write("<INPUT TYPE='hidden' name='selPickMinute' value='' />");
	document.write("<INPUT TYPE='hidden' name='selPickAmPm' value='' />");
	document.write("<INPUT TYPE='hidden' name='selTentMonth1' value='' />");
	document.write("<INPUT TYPE='hidden' name='selTentDate1' value='' />");
	document.write("<INPUT TYPE='hidden' name='selTentYear1' value='' />");
	document.write("<INPUT TYPE='hidden' name='selPickHour1' value='' />");
	document.write("<INPUT TYPE='hidden' name='selPickMinute1' value='' />");
	document.write("<INPUT TYPE='hidden' name='selPickAmPm1' value='' />");
	document.write("<INPUT TYPE='hidden' name='txaQuery' value='' />");


	document.write("<tr><td class='textsize' colspan=2>&nbsp;</td></tr>");
	document.write("<tr><td colspan='2' align='center'>");
	document.write("<INPUT TYPE='hidden' name='action' value='car-form'>");
	document.write("<INPUT TYPE='submit' VALUE='Submit' class='btn' onclick='return carFormValidate(this.form)' class='submitButton' >&nbsp;");
	document.write("<INPUT TYPE='reset' VALUE='Reset' class='btn' class='submitButton'>");
	document.write("</td></tr></table>");
	document.write("</form>	<!-- CAR FORM END ----------------//-->");

}














//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************

var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

var mydate=new Date()
var year=mydate.getYear()

if (year < 1000)
year+=1900

var day=mydate.getDay()
var month=mydate.getMonth()

var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds

var dateVal = daym + "-" + montharray[month] + "-" + year
var rtflg=true;
var pkflg=true;
var retmn = 0;
var pickmn = 0;




//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
/*****************************************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 ;
}

function allBlanksAir(form) {
if( (isairFrmName(form) && isairFrmEmail(form)) && (isairFrmCountryCode(form) && isairFrmCityCode(form)) && isairFrmPhone(form) && (isairFrmArrival(form) && isairFrmReturn(form)) && isairFrmPassengers(form)&&selectclass(form)&&selectrouting(form)&&tocity(form)&&tocountry(form)&&fromcountry(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)||(isairFrmPassengers(form)==false)||selectclass(form)==false||selectrouting(form)==false||tocountry(form)==false||tocity(form)==false||fromcountry(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;
	 }
 }


//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
//***************************************** Package Form Validation **************************************/
//*****************************************  cheking for package    **************************************/
//********************************************************************************************************


function packgFormValidate(form) {
var v=allBlankspackage(form)
isgeneralFrmQuery(form)
//isgeneralFrmChildren(form)
//isgeneralFrmAdults(form)
//isgeneralFrmDaysInHands(form)
//isgeneralFrmTentArrival(form)
ishotelFrmCheckOut(form)
ishotelFrmCheckIn(form)

isgeneralFrmPhone(form)
isgeneralFrmCityCode(form)
isgeneralFrmCountryCode(form)
ishotelFrmCountry(form)
ishotelFrmEmail(form)
ishotelFrmName(form)

return v ;
}

function allBlankspackage(form) {
if( (ishotelFrmName(form) && ishotelFrmEmail(form)) && (ishotelFrmCountry(form) && isgeneralFrmCountryCode(form)) && (isgeneralFrmCityCode(form) && isgeneralFrmPhone(form)) && ishotelFrmCheckIn(form)&& ishotelFrmCheckOut(form)&& isgeneralFrmQuery(form) ) {
 return true ;
}

if( (ishotelFrmName(form) == false || ishotelFrmEmail(form) == false ) || ( ishotelFrmCountry(form)== false || isgeneralFrmCountryCode(form) == false) || isgeneralFrmCityCode(form) == false || isgeneralFrmPhone(form) == false||ishotelFrmCheckIn(form)==false||ishotelFrmCheckOut(form) == false ||isgeneralFrmQuery(form)==false ) {
composepackage(form)
return false ;
 }
}
function composepackage(form) {
var text = " You entered incorrectly or forgot to fill in ::\n"	
if(ishotelFrmName(form) == false) {
text += "\nYour Name -- must be purely alphabetic"
}
if(ishotelFrmEmail(form) == false) {
text += "\nYour E-mail -- improper/incomplete e-mail ID"
}
if(ishotelFrmCountry(form) == false) {
text += "\nYour Country of Residence -- not selected yet"
}
if(isgeneralFrmCountryCode(form) == false) {
text += "\nCountry Code for Phone -- should be number or blank"
}
if(isgeneralFrmCityCode(form) == false) {
text += "\nArea Code for Phone -- should be a number or blank"
}
if(isgeneralFrmPhone(form) == false) {
text += "\nPhone Number -- should be number or blank"
}
/*if(isgeneralFrmTentArrival(form) == false) {
text += "\nTentative Date for Trip -- cannot be earlier than today"
}
if(isgeneralFrmDaysInHands(form) == false) {
text += "\nDays in Hand -- should be a number or blank"
}
if(isgeneralFrmAdults(form) == false) {
text += "\nNo. of Adults travelling -- should be a number or blank"
}
if(isgeneralFrmChildren(form) == false) {
text += "\nNo. of Children travelling -- should be a number or blank"
}*/
if(ishotelFrmCheckIn(form) == false) {
text += "\nCheck In Date -- cannot be earlier than today"
}
if(ishotelFrmCheckOut(form) == false) {
text += "\nCheck Out Date -- cannot be earlier than check in date"
}
if(isgeneralFrmQuery(form) == false) {
text += "\nBooking/Travel related Query -- should be given briefly"
}
alert(text)
}



////////////////////////////////////////////Common Functions////////////////////////////////////////

function trim(str1)
{
// This function trims any given field value for blank spaces.
 var intCtr=0
 for(intCtr=0;str1.charAt(intCtr)==" ";intCtr++);
 str1=str1.substring(intCtr,str1.length);
 return str1; 
}

function checkforchar(strdate)
{
//This function checks for string values
var validdate = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	
	var strlength = strdate.length;
	for(var i=0; i<=strlength; i++)
	{
		var unitstr = strdate.substr(i,1);
		if (validdate.indexOf(unitstr)==-1)
		{
			return false;
		}
	}
	return true;
}

function checkfornum(str1) 
{
//This function checks for numeric values
 var numstr="1234567890 ,";
 var intctr,intLen;
 intLen=str1.length;
 for(intCtr=0;intCtr <= intLen && numstr.indexOf(str1.charAt(intCtr))>=0 ;intCtr++);
 if(intCtr > intLen)
 {
 return 1;
 }
 else
 {
 return 0;
 }
}

function checkforzero(str1) 
{
//This function checks for all zero with spaces
 var numstr=" 0";
 var intctr,intLen;
 intLen=str1.length;
 for(intCtr=0;intCtr <= intLen && numstr.indexOf(str1.charAt(intCtr))>=0 ;intCtr++);
 if(intCtr > intLen)
 {
 return 1; // return true if all zero and spaces are there
 }
 else
 {
 return 0;//otherwise return false
 }
}

function checkfordate(str1) 
{
//This function checks for date Type of data
 var numstr="1234567890//";
 var intctr,intLen;
 intLen=str1.length;
 for(intCtr=0;intCtr <= intLen && numstr.indexOf(str1.charAt(intCtr))>=0 ;intCtr++);
 if(intCtr > intLen)
 {
 return 1;
 }
 else
 {
 return 0;
 }
}

function GoBack() 
{ 
	history.back(); 
}


//********************************************************************************************
//********************************************************************************************
//********************************************************************************************
//********************************************************************************************
//********************************************************************************************
//********************************************************************************************
//********************************************************************************************
//FOR Query
function isgeneralFrmQuery(form) {
form.txaQuery.value=trim(form.txaQuery.value);
if (trim(form.txaQuery.value) == "") {
//form.txaQuery.focus();
return true;
}
else {
			
	 if(checkfornum(form.txaQuery.value)==1)// i. e, it is a pure number that is invalid
		 {
			form.txaQuery.focus();
			return(false);
			}
		qry=trim(form.txaQuery.value);
		if(qry.length <= 6 )// if it is too short
			{
			 form.txaQuery.focus();
			 return(false);
			}	
return true ;
 }
}



 function ishotelFrmCheckOut(form)
{
	if ((form.check_month1.value== "NA") || (form.check_date1.value== "NA") || (form.check_year1.value== "NA"))
	{		
		if(form.check_month1.value== "NA")
		{
			form.check_month1.focus();
			return false;
		}
		if(form.check_date1.value== "NA")
		{
			form.check_date1.focus();
			return false; 
		}
		if(form.check_year1.value== "NA")
		{
			form.check_year1.focus()
			return false;
		}
	}
	else{
		if (ishotelFrmRetDate(form)==false)
		{
			return false;
		}
		else
			return true;
	}
}


function ishotelFrmRetDate(form)
{
	if(form.check_year1.value < form.check_year.value)
	{
		//alert("1")
		//alert("Return Date cannot be Earlier than Picking Date");
		rtflg = false;
		form.check_year1.focus(); 
		return false; //presently used
	}
	else
	{
		for(i=0;i<=montharray.length;i++)
		{
			if (montharray[i]==form.check_month1.value)
			{
				retmn=i+1;
				break;
			}
		}
		for(i=0;i<=montharray.length;i++)
		{
			if (montharray[i]==form.check_month.value)
			{
				pickmn=i+1;
				break;
			}
		}
		//alert(retmn)
		//alert(pickmn)*/
		if((form.check_year1.value == form.check_year.value) && (retmn<pickmn))
		{
			//alert("2")
			//alert("Return Date cannot be Earlier than Picking Date");
			rtflg = false;
			form.check_month1.focus();
			return false;
		}
		else
		{
			if((form.check_year1.value == form.check_year.value) && (retmn==pickmn))
			{
				//alert("hello")
				//alert(form.selOutDate.value)
				//alert(form.d_arrival.value)
				//alert((form.check_date1.value));
				//alert((form.check_date.value));
				if ((form.check_date1.value)< (form.check_date.value))
				{
					//alert("3")
					//alert("Return Date cannot be Earlier than Picking Date");
					
					rtflg = false;
					form.check_date1.focus();
					return false;
				}
				else
					return true;
			}
			else
				return true;
		}
	}
 }



function ishotelFrmCheckIn(form)
{
	if ((form.check_month.value== "NA") || (form.check_date.value== "NA") || (form.check_year.value== "NA"))
	{
		if(form.check_month.value== "NA")
		{
			form.check_month.focus();
			return false;
		}
		if(form.check_date.value== "NA")
			
		{
			form.check_date.focus();
			return false; 
		}
		if(form.check_year.value== "NA")
			form.check_year.focus()
			return false;
	}
	else{
		if (ishotelFrmArrDate(form)==false)
		{
			return false;
		}
		else
			return true;
	}
}

function ishotelFrmArrDate(form)
{
	for(i=0;i<=montharray.length;i++)
	{
		if (montharray[i]==form.check_month.value)
		{
			dgt=i;
			break;
		}
	}
	//alert(dgt)
if(form.check_year.value < year)
{
	//alert("Invalid date. It must be a future date.");
	pkflg = false;
	form.check_year.focus(); 
	return false; //presently used
 } 
 else
	{
		if((form.check_year.value == year) && (dgt < month))
		{
			//alert("Invalid date. It must be a future date.");
			pkflg = false;
			form.check_month.focus();
			return false;
		}
		else
		{
			if((form.check_year.value == year) && (dgt == month))
			{
				if (form.check_date.value < daym)
				{
				//alert("Invalid date. It must be a future date.");
				pkflg = false;
				form.check_date.focus();
				return false;
				}
				else
					return true;
			}
			else
				return true;
		}
	}
 }


//FOR PHONE
function isgeneralFrmPhone(form) {
if (trim(form.txiPhone.value) == "") {
form.txiPhone.value=trim(form.txiPhone.value);
return true //because it is optional
}
else {
			form.txiPhone.value=trim(form.txiPhone.value);
	 if(checkfornum(form.txiPhone.value)==0)
		 {
			form.txiPhone.focus();
			return(false);
			}
return true
 }
}

//FOR CITY CODE OF PHONE

function isgeneralFrmCityCode(form) {
if (trim(form.txiCityCode.value) == "") {
form.txiCityCode.value=trim(form.txiCityCode.value);
return true //because it is optional
}
else {
			form.txiCityCode.value=trim(form.txiCityCode.value);
	 if(checkfornum(form.txiCityCode.value)==0)
		 {
			form.txiCityCode.focus();
			return(false);
			}
return true
 }
}

//for country code of phone
function isgeneralFrmCountryCode(form) {
	form.txiCountryCode.value = trim(form.txiCountryCode.value);
 if(checkfornum(form.txiCountryCode.value)==0)
	{
		form.txiCountryCode.focus();
		return false;
	}
	else
		return true;
}

//for country of residence
function ishotelFrmCountry(form)
{
 if(form.your_country.value== "NA")
	{
	 form.your_country.focus();
 return false;
	}
 else
 return true; 
 }

//FOR EMAIL
function ishotelFrmEmail(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 NAME
function ishotelFrmName(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 ;
 }
}


//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
//***********************************		Car Booking Form Validation		  ****************************/
//***********************************  Validation of the form of Car Booking  ****************************/
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************

 //////////////////////////////////////////////////////////////////
function carFormValidate(form) 
{

	var v=allBlanksCar(form)
//	isgeneralFrmQuery(form)
//	carrentime(form)
//	carrendate(form)
//	carpicktime(form)
//	carpickdate(form)
	carplace(form)
	cartype(form)
	isgeneralFrmPhone(form)
	isgeneralFrmCityCode(form)
	isgeneralFrmCountryCode(form)
	isgeneralFrmCountry(form)
	isgeneralFrmEmail(form)
	isgeneralFrmName(form)

	if(v==true)
	{
		v=confirm("Have You Entered Information Correctly!");
	}

	return v ;
}

function allBlanksCar(form) {
	//alert(carpickdate(form));
	//alert(carrendate(form));
	
	//if(isgeneralFrmName(form) && isgeneralFrmEmail(form) && isgeneralFrmCountry(form) && isgeneralFrmCountryCode(form) && isgeneralFrmCityCode(form) && isgeneralFrmPhone(form) && cartype(form)&&carplace(form) && carpickdate(form) && carrendate(form) && isgeneralFrmQuery(form)&&carpicktime(form)&& carrentime(form)) {
	if(isgeneralFrmName(form) && isgeneralFrmEmail(form) && isgeneralFrmCountry(form) && isgeneralFrmCountryCode(form) && isgeneralFrmCityCode(form) && isgeneralFrmPhone(form) && cartype(form)&&carplace(form) ) 
	{
		return true ;
	}

	if( isgeneralFrmName(form) == false || isgeneralFrmEmail(form) == false  ||  isgeneralFrmCountry(form) == false || carplace(form)==false  ) 
	{
		composeCar(form)
		return false ;
	}
}


function composeCar(form) 
{
	var text = " You entered incorrectly or forgot to fill in ::\n"	
	
	if(isgeneralFrmName(form) == false) 
	{
		text += "\nYour Name -- must be purely alphabetic"
	}
	
	if(isgeneralFrmEmail(form) == false) 
	{
		text += "\nYour E-mail -- improper/incomplete e-mail ID"
	}
	
	if(isgeneralFrmCountry(form) == false) 
	{
		text += "\nYour Country of Residence -- not selected yet"
	}
	
	if(isgeneralFrmCountryCode(form) == false) 
	{
		text += "\nCountry Code for Phone -- should be number or blank"
	}

	if(isgeneralFrmCityCode(form) == false) 
	{
		text += "\nArea Code for Phone -- should be a number or blank"
	}
	
	if(isgeneralFrmPhone(form) == false) 
	{
		text += "\nPhone Number -- should be number or blank"
	}
	if(cartype(form)==false)
	{
		text +="\nCar Preference:--Should not be blank"
	}
	if(carplace(form)==false)
	{
		text +="\nCar Picking Place:--Should not be blank or Number"
	}
//		if(carpickdate(form)==false)
//		{
//		text +="\nCar Picking Date can not be Earlier than today"
//		}
//		if(carpicktime(form)==false)
//		{
//		text+="\nCar picking time--Should Not Be Blank"
//		}
//		if(carrendate(form)==false)
//		{
//		text +="\nCar Returning Date can not be Earlier than Picking Date"
//		}
//		if(carrentime(form)==false)
//		{
//		text+="\nCar Returning time--Should Not Be Blank"
//		}
//		if(isgeneralFrmQuery(form) == false) {
//		text += "\nBooking/Travel related Query -- should be given briefly"
//		}
		alert(text)
}



//------------------- checking for car type---------------////////
function cartype(form)
{
 if(trim(form.selCar.value)=="NA")
	{
	 form.selCar.focus();
	 return false;
	}
	else
		return true;
}

function carplace(form)
{
	if(trim(form.place.value)=="NA"||!isNaN(trim(form.place.value)))
	{
		form.place.focus();
		return false;
	}
	else
	return true;
}

//checking for car picking date/////
function carpickdate(form)
 {
	 if(trim(form.selTentDate.value)=="NA"||trim(form.selTentYear.value)=="NA"||trim(form.selTentMonth.value)=="NA")
	 {
		 if(trim(form.selTentMonth.value)=="NA")
		 {
			 form.selTentMonth.focus();
			 return false;
		 }
		 if(trim(form.selTentDate.value)=="NA")
		 {
			 form.selTentDate.focus();
			 return false;
		 }
		 if(trim(form.selTentYear.value)=="NA")
		 {
			 form.selTentYear.focus();
			 return false;
		 }
	 }
	 else
	 {
		 for(i=0;i<=montharray.length;i++)
		{
			if (montharray[i]==form.selTentMonth.value)
			{
				pickmn=i+1;
				break;
			}
		}
		 if(trim(form.selTentYear.value)<year)
		 {
			 form.selTentYear.focus();
			 return false;
		 }
		 else
		 {
			if(trim(form.selTentYear.value)>year)
			 {
				return true;
			 }
		 if(trim(form.selTentYear.value)==year)
			 {
			 if(pickmn<month)
		 {
				
		 	 form.selTentMonth.focus();
			 return false;
	 	 }
		 else
			 {
		 if(pickmn==month)
			{
			 if(form.selTentDate.value<daym)
				 {
			 form.selTentDate.focus();
				 return false;
				 }
				 else
					 return true;
				 }
				 else 
					 return true;
			 }
			 
		}
		
	 }
	 
 }
 }
		 //checking for car return date...../////////

function carrendate(form)
		 {
			 if(trim(form.selTentDate1.value)=="NA"||trim(form.selTentYear1.value)=="NA"||trim(form.selTentMonth1.value)=="NA")
 	 {
		 if(trim(form.selTentMonth1.value)=="NA")
		 {
			 form.selTentMonth1.focus();
			 return false;
		 }
		 if(trim(form.selTentDate1.value)=="NA")
		 {
			 form.selTentDate1.focus();
			 return false;
		 }
		 if(trim(form.selTentYear1.value)=="NA")
		 {
			 form.selTentYear1.focus();
			 return false;
		 }
	 }
	 else
			 {
		 if(trim(form.selTentYear1.value)<trim(form.selTentYear.value))
				 {
			 form.selTentYear1.focus();
			 return false;
				 }
				 else
				 {
					 for(i=0;i<=montharray.length;i++)
		{
			if (montharray[i]==form.selTentMonth1.value)
			{
				retmn=i+1;
				break;
			}
		}
		for(i=0;i<=montharray.length;i++)
		{
			if (montharray[i]==form.selTentMonth.value)
			{
				pickmn=i+1;
				break;
			}
		}
		if(trim(form.selTentYear1.value)>trim(form.selTentYear.value))
					 {
			 return true;
								 }
								 if(trim(form.selTentYear1.value)==trim(form.selTentYear.value))
					 {
						 if(retmn<pickmn)
						 {
							 form.selTentMonth1.focus();
							 return false;

						 }
						 else
						 {
							 if(retmn==pickmn)
							 {
								 if(trim(form.selTentDate1.value)<trim(form.selTentDate.value))
								 {
									 form.selTentDate1.focus();
									 return false;
								 }
								 else
									 return true;
							 }
							 else
								 return true;
						 }
					 }
				 }
			 }
		 }



//cheking for car picking time///////
function carpicktime(form)
{
	if(form.selPickHour.value=="HRS"||form.selPickMinute.value=="MIN")
	{
		if(form.selPickHour.value=="HRS")
		{
			//form.selPickHour.focus();
			return true;
		}
		if(form.selPickMinute.value=="MIN")
		{
			//form.selPickMinute.focus();
			return true;
		}
	}
	else
		return true;
}
//------------------checking for Car Returning Time-------------------////////
function carrentime(form)
{
 if(form.selPickHour1.value=="HRS"||form.selPickMinute1.value=="MIN")
	{
	 if(form.selPickHour1.value=="HRS")
		{
		// form.selPickHour1.focus();
		 return true;
		}
		if(form.selPickMinute1.value=="MIN")
		{
			//form.selPickMinute1.focus();
			return true;
		}
	}
	else
		return true;
}


//for country of residence
function isgeneralFrmCountry(form)
{
 if(form.selCountry.value== "NA")
	{
	 form.selCountry.focus();
 return false;
	}
 else
 return true; 
 }


//FOR EMAIL
function isgeneralFrmEmail(form) {
if (trim(form.txiEmail.value)== "")
	{
		form.txiEmail.focus();
		return false; // because it is not optional 
	}
else
	{
		var eid=form.txiEmail.value=trim(form.txiEmail.value);
		if (eid.indexOf(' ')!= -1)
			{
			form.txiEmail.focus();
			return false ; // no spaces
			} 
		if (eid.length < 6 ){
			form.txiEmail.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.txiEmail.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.txiEmail.focus();
						return false ;	
						}
					else
						{
						 if ( (dot + 2 ) < eid.length )
							return true ;
						 else
						 {
							form.txiEmail.focus();
							return false ;
							}
						}
				}
				else // two @ are there
				{
				form.txiEmail.focus();
				return false;
				}
			}	
	form.txiEmail.focus();
	return false ;
	}		

}


//FOR NAME
function isgeneralFrmName(form) {
if (trim(form.txiName.value) == "") {
form.txiName.focus();
return false
}
else {
			form.txiName.value=trim(form.txiName.value);
	 if(checkforchar(form.txiName.value)== 0)
		 {
			form.txiName.focus();
			return(false);
			}
return true ;
 }
}



//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
/***************************************** Insurance Form Validation *************************************/
function insuranceFormValidate(form) {
	//alert("Badre Alam...............");

var v=allBlanksInsurance(form)
//selectrouting(form)
//selectclass(form)
//tocity(form)
//tocountry(form)
//fromcity(form)
//fromcountry(form)
//isairFrmPassengers(form)

isInsuranceFrmArea(form)
isInsuranceFrmPeriod(form)
isInsuranceFrmDateOfBirth(form)
isInsuranceFrmPhone(form)
isInsuranceFrmCityCode(form)
isInsuranceFrmCountryCode(form)
isairFrmEmail(form)
isInsuranceFrmName(form)


	return v ;
}

function allBlanksInsurance(form) 
{

//	if( (isInsuranceFrmName(form) && isairFrmEmail(form) isInsuranceFrmCountryCode(form) && isInsuranceFrmCityCode(form) && isInsuranceFrmPhone(form) ) )
//	{
//		return true ;
//	}

if( isInsuranceFrmName(form)==false || isairFrmEmail(form)==false || isInsuranceFrmCountryCode(form)==false || isInsuranceFrmCityCode(form)==false || isInsuranceFrmPhone(form)==false  || isInsuranceFrmDateOfBirth(form)==false || isInsuranceFrmPeriod(form)==false || isInsuranceFrmArea(form)==false ) {
		
		insuranceCompose(form) 
		return false ;
	}
}



function insuranceCompose(form) {

	var text = " You entered incorrectly or forgot to fill in ::\n"	

	if(isInsuranceFrmName(form) == false) {
		text += "\nYour Name -- must be purely alphabetic"
	}

	if(isairFrmEmail(form) == false) {
		text += "\nYour E-mail -- improper/incomplete e-mail ID"
	}

	if(isInsuranceFrmCountryCode(form) == false) {
		text += "\nCountry Code for Phone -- should be a number "
	}
	if(isInsuranceFrmCityCode(form) == false) {
		text += "\nArea Code for Phone -- should be a number "
	}
	if(isInsuranceFrmPhone(form) == false) {
		text += "\nPhone Number -- should be a number"
	}
	if(isInsuranceFrmDateOfBirth(form) == false ) {
		text += "\nDate of Birth -- Plz. select valid Date of Birth"
	}
	if(isInsuranceFrmPeriod(form) == false) {
		text += "\nPeriod of Travels -- Period of Travels should not be blank"
	}
	if(isInsuranceFrmArea(form) == false) {
		text += "\nArea -- Select Area"
	}

	alert(text)
}


//FOR NAME
function isInsuranceFrmName(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 ;
	}
}

//for country code of phone
function isInsuranceFrmCountryCode(form) 
{
	if (trim(form.country_code.value) == "") 
	{
		form.country_code.value=trim(form.country_code.value);
		form.country_code.focus();
		return false; // return true; because it is optional
	}
	else
	{
		form.country_code.value=trim(form.country_code.value);
		if(checkfornum(form.country_code.value)==0)
		{
			form.country_code.focus();
			return(false);
		}
		return true
	}
}


//FOR CITY CODE OF PHONE
function isInsuranceFrmCityCode(form) 
{
	if (trim(form.city_code.value) == "") 
	{
		form.city_code.value=trim(form.city_code.value);
		form.city_code.focus();
		return false; // return true; because it is optional
	}
	else
	{
		form.city_code.value=trim(form.city_code.value);
		if(checkfornum(form.city_code.value)==0)
		{
			form.city_code.focus();
			return(false);
		}
		return true
	}
}


//FOR PHONE
function isInsuranceFrmPhone(form) 
{
	if (trim(form.phone.value) == "") 
	{
		form.phone.value=trim(form.phone.value);
		form.phone.focus();
		return false; // return true; because it is optional
	}
	else 
	{
		form.phone.value=trim(form.phone.value);
		if(checkfornum(form.phone.value)==0)
		{
			form.phone.focus();
			return(false);
		}
		return true
	}
}


function isInsuranceFrmDateOfBirth(form)
{
	if ((form.m_birth.value== "NA") || (form.d_birth.value== "NA") || (form.y_birth.value== "NA"))
	{
		if(form.m_birth.value== "NA")
		{
			form.m_birth.focus();
			return false;
		}
		if(form.d_birth.value== "NA")
		{
			form.d_birth.focus();
			return false; 
		}
		if(form.y_birth.value== "NA")
		{
			form.y_birth.focus();
			return false;
		}
	}
}


function isInsuranceFrmPeriod(form) 
{
	form.period.value=trim(form.period.value);

	if( form.period.value=="" || form.period.value<1 )
	{		
		form.period.focus();
		return(false); 
	}
	else
	{
//		if(checkfornum(form.period.value)==0)
//		{
//			form.period.focus();
//			return(false);
//		}
		return true;
	 }
}

function isInsuranceFrmArea(form) 
{
	if( form.selArea.value=="NA" )
	{		
		form.selArea.focus();
		return(false); 
	}
	else
	{
		return true;
	}
}
