//VALIDATION FOR FORM

function Data(your_name,your_email,country,city_code1,phone1,from_dd,from_mm,from_yy,to_dd,to_mm,to_yy,adults,children,query)
{
	var your_name,your_email,country,city_code1,phone1,from_dd,from_mm,from_yy,to_dd,to_mm,to_yy,adults,children,query;
	
	your_name=theform.your_name.value;
	your_email=theform.your_email.value;
	country=theform.country.value;
	city_code1=theform.city_code1.value;
	phone1=theform.phone1.value;
	from_dd=theform.from_dd.value;
	from_mm=theform.from_mm.value;
	from_yy=theform.from_yy.value;
	to_dd=theform.to_dd.value;
        to_mm=theform.to_mm.value;
	to_yy=theform.to_yy.value;
	adults=theform.adults.value;
   	children=theform.children.value;
        query=theform.query.value;
       

	if(nullValue(your_name)==0||nullValue(your_email)==0 || nullValue(country)==0 || nullValue(city_code1)==0 ||nullValue(phone1)==0 || nullValue(from_dd)==0|| nullValue(from_mm)==0 || nullValue(from_yy)==0 || nullValue(to_dd)==0 || nullValue(to_mm)==0 || nullValue(to_yy)==0)
	{
		//FNAME - UID - EMAIL -----CAN'T BE BLANK
		alert("You Have Left Any Of The COMPULSORY Field Blank!");
		return false;
	}

	
	if(checkEmail(your_email)==0)
	{
		alert("Invalid E-Mail Address");
		document.forms[0].your_email.focus();
		return false;
	}
	if(spaceAlso(country)==0)
	{
		alert("Invalid Country Name Specified!");
		document.forms[0].country.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.


function spaceAlso(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')
			{
				if(temp!='32')
				{
				return 0;
				}
			}
		}
	}
}