//VALIDATION FOR FORM

function Data(arrival_date,arrival_month,arrival_year,departure_date,departure_month,departure_year,preference,single_accomodation,double_accomodation,suite_accomodation,extra_bed_double,hotel_name,name,hotel_city,s_country,phone,email)
{
	
var arrival_date,arrival_month,arrival_year,departure_date,departure_month,departure_year,preference,single_accomodation,double_accomodation,suite_accomodation,extra_bed_double,hotel_name,name,hotel_city,s_country,phone,email;
	
	arrival_date=booking.arrival_date.value;
	arrival_month=booking.arrival_month.value;
        arrival_year=booking.arrival_year.value; 
	departure_date=booking.departure_date.value;
	departure_month=booking.departure_month.value;
	departure_year=booking.departure_year.value;
        preference=booking.preference.value; 
	single_accomodation=booking.single_accomodation.value; 
	double_accomodation=booking.double_accomodation.value; 
	suite_accomodation=booking.suite_accomodation.value; 
	extra_bed_double=booking.extra_bed_double.value; 
	hotel_name=booking.hotel_name.value; 
	name=booking.name.value; 
	hotel_city=booking.hotel_city.value; 
	s_country=booking.s_country.value; 
	phone=booking.phone.value; 
	email=booking.email.value; 

	

	if(nullValue(arrival_date)==0||nullValue(arrival_month)==0 || nullValue(arrival_year)==0 || nullValue(departure_date)==0 || nullValue(departure_month)==0||nullValue(departure_year)==0 ||nullValue(name)==0 ||nullValue(hotel_name)==0 ||nullValue(hotel_city)==0 ||nullValue(s_country)==0 ||nullValue(phone)==0 ||nullValue(email)==0)
	{
		//FNAME - UID - EMAIL -----CAN'T BE BLANK
		alert("You Have Left Any Of The COMPULSORY Field Blank!");
		return false;
	}

	
	if(checkEmail(email)==0)
	{
		alert("Invalid E-Mail Address");
		document.forms[0].email.focus();
		return false;
	}

}

//-------------CHECKING ANY NULL VALUE

function nullValue(num)
	{var str;
	str=num;
		if(str == 0)
		{
			return 0; 
		}
		else
		{
			return 1;
		}

	}
//-----------CHECKING FOR ONLY ALPHAETS

function checkOnlyAlpha(char)
{
	var v=char;
	var i;
	i=v.length;
	var ctr,temp,dump;
	for(ctr=0;ctr<=i;ctr++)
	{
		dump=v.charAt(ctr);
		temp=dump.charCodeAt(0);//Returns the Unicode encoding of the specified character.
					//stringObj.charCodeAt(index).(stringObj)A String object or literal. 
					//(index )The zero-based index of the specified character.  
	
		if(temp<'65'||temp>'90')
		{
			if(temp<'97'||temp>'122')
			{
				return 0;
			}
		}
	}
}


//-------------------CHECKING FOR ANY INVALID CAHRACTER VALUE IN THE eMAIL

function checkEmail(char)
{
	var val=char;
	var len=val.length;
	var ctr,temp,cat,dot=0,goForApproval=0,haveJunk=0;
	var atTheRate=0;
	for(ctr=0;ctr<len;ctr++)
	{
		temp=val.charAt(ctr);
		cat=temp.charCodeAt(0);
		if(cat<'65'||cat>'90')
		{
			if(cat<'97'||cat>'122')
			{
				if(cat<'48'||cat>'57')
				{			
					if(cat=='64')	//@ has ASCII value of 64
					{
						atTheRate+=1;
						goForApproval=1;
						haveJunk=0;
					}
					else
					if(cat=='46')	//. has ASCII value of 46
					{
						dot=1;
						goForApproval=1;
						haveJunk=0;
					}
					else
					if(cat=='95')	//_ has ASCII value of 95
					{
						goForApproval=1;
						haveJunk=0;
					}
					else
					{haveJunk=1;break;}			
				}
			}	
		}
	}
	if(goForApproval==1 && haveJunk==0)
	{
		if(atTheRate==1 && dot==1)
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
	else
	if(goForApproval==0 || haveJunk==1)	
	{
		return 0;
	}

}


//------------------------------CHECKING FOR INVALID USER-ID.

