
function trimSpace(x)
{
	var emptySpace = / /g;
	var trimAfter = x.replace(emptySpace,"");
	return(trimAfter);
}


function textValidate(incomingString, defaultValue)
{
	if(trimSpace(incomingString).length <3 || incomingString.search(/[^a-zA-Z\.\s]/g) != -1 || incomingString==defaultValue)
	{
		return false;
	}
	else
		return true;
}
function textValidatecity(incomingString, defaultValue)
{
	if(trimSpace(incomingString).length == 0 || incomingString.search(/[^a-zA-Z\s]/g) != -1 || incomingString==defaultValue)
	{
		return false;
	}
	else
		return true;
}
function isEmail(strEmail)
{
	var strFilter=/^[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}(?:(?:[,;][A-Z0-9\._%-]+@[A-Z0-9\.-]+))?$/i


	if (strFilter.test(strEmail))
		boolResult = true
		
	else
		boolResult = false
		
	return boolResult
}

function validatephone(val) 
{

//checking phone no when it is left blank - arathy
	if(trimSpace(val).length == 0)
	{
		return false;
	}
//ending - 
		
   ///- checking for spl.chars in phoneno
            ///  allows numbers, '-', and spaces.

	flag1=false;
	for(i=0; i < val.length; i++) 
	{
		if ( ( (val.charAt(i) >= "0") && (val.charAt(i) <= "9") ) || (val.charAt(i) == "-") || (val.charAt(i) == "+") )
		{ 
			flag1=false;
		}
		else 
		{
			flag1=true;
			break;
		}   
	}// end of i-loop

		if (flag1) 
		{
			return false;
		}
		
		///finished checking phone1
		return true;
}


function chkAnswer()
{


	if(trimSpace(document.tell.txtName.value)=="")
	{
		alert("Please enter your name (letters only)");
		document.tell.txtName.select();
		document.tell.txtName.focus();
		return false;
	}
	if(!textValidate(trimSpace(document.tell.txtName.value)))
	{
		alert("Please enter your name (three letters minimum)");
		document.tell.txtName.select();
		document.tell.txtName.focus();
		return false;
	}
	if (isEmail(document.tell.txtEmailid.value) == "")
	{
		alert("Please enter a valid E-mail ID");
		document.tell.txtEmailid.select();
		document.tell.txtEmailid.focus();
		return false;
	}
	
	
	if (document.tell.txtEmailid1.value == "")
	{
		alert("Please enter your suggestion for an e-mail ID. Eg: coolhotmail.com");
		document.tell.txtEmailid1.select();
		document.tell.txtEmailid1.focus();
		return false;
	}

/*	if(trimSpace(document.tell.txtComments.value)=="")
	{
		alert("Please enter your Comments (alphabets only)");
		document.tell.txtComments.select();
		document.tell.txtComments.focus();
		return false;
	}*/
	

}

