function popUpHotelBooking(h)
{
url=self.location;
//prompt(self.location);
window.open("http://www.travelaroundindia.com/cgi-bin/specifichotelfrm.cgi?hotel="+h+"&url="+url+"","dcc","toolbar=no,topmargin=0,leftmargin=0,menubar=no,height=600,width=580,top=20,left=200,scrollbars=yes,location=no,status=yes,resize=yes,alwaysRaised=yes")
//self.close()
}
function validatePopUpHotelBooking(form) {
//prompt("jas val = "+form+"\n")
var v=allblanksHotelPopUp(form)
isHoteltxaQuery(form)
isHotelCountry(form)
isHotelEmail(form)
isHotelName(form)
if( v == true)
	{
		v=confirm("Have You entered \nthe information Correctly !!");
	}
return v;
}

function allblanksHotelPopUp(form) {
if( (isHotelName(form) && isHotelEmail(form)) && (isHotelCountry(form) && isHoteltxaQuery(form)) ) {
 return true ;
}
if( (isHotelName(form) == false || isHotelEmail(form) == false ) || ( isHotelCountry(form) == false || isHoteltxaQuery(form)==false ) ) {
composeHotelPopUp(form);
return false ;
   }
}
function composeHotelPopUp(form) {
var text = " You entered incorrectly or forgot to fill in ::\n"	
if(isHotelName(form) == false) {
text += "\nYour Name -- must be purely alphabetic"
}
if(isHotelEmail(form) == false) {
text += "\nYour E-mail -- improper/incomplete e-mail ID"
}
if(isHotelCountry(form) == false) {
text += "\nYour Country of Residence -- not selected yet"
}
if(isHoteltxaQuery(form) == false) {
text += "\nTopic Comments/txaQuery -- should atleast be a line or blank"
}
alert(text)
}

//for country of residence
function isHotelCountry(form)
{
 if(form.selCountry.value == "-")
	{
	 form.selCountry.focus(); 
	 return false;
	} 
 else
   return true;  
 }

//FOR EMAIL
function isHotelEmail(form) {
if (trim(form.txtEmail.value)== "")
	{
		form.txtEmail.focus();
		return false; // because  it is not optional 
	}
else
	{
		var eid=form.txtEmail.value=trim(form.txtEmail.value);
		if (eid.indexOf(' ')!= -1)
			{
			form.txtEmail.focus();
			return false ; // no spaces
			} 
		if (eid.length < 6 ){
			form.txtEmail.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.txtEmail.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.txtEmail.focus();
						return false ;	
						}
					else
						{
						 if ( (dot + 2 ) < eid.length )
							return true ;
						 else
						    {
							form.txtEmail.focus();
							return false ;
							}
						}
				}
				else // two @ are there
				{
				form.txtEmail.focus();
				return false;
				}
			}	
	form.txtEmail.focus();
	return false ;
	}		

}
//FOR txaQuery
function isHoteltxaQuery(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 ;
   }
}


//FOR NAME
function isHotelName(form) {
if (trim(form.txtName.value) == "") {
form.txtName.focus();
return false ;
}
else {
			form.txtName.value=trim(form.txtName.value);
	     if(checkforchar(form.txtName.value)==0)
		   {
			form.txtName.focus();
			return(false);
			}
return true ;
   }
}

var mylocation = window.location;

function confirm1(country){

if( country!=""){
				 if(country=="null"){
				alert("Please select Your Nationality from the list");
 				return false;
				}	
				}
				}

////////////////////////////// Common Functions are put here ///////////////////////////////////
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 GoBack() { 
			history.back();   
					}
				
