function trimAll(sString)
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}


function Form_Validator(callbackForm)
{
//First Name
	 if (trimAll(callbackForm.name.value) == "" || callbackForm.name.value == "Name*" )
	 {
	 alert("Please enter a value for the \"Name\" field.");
	 callbackForm.name.focus();
	 return (false);
	 }

 //Telephone
	 if (trimAll(callbackForm.telephone.value) == "" || callbackForm.telephone.value == "Telephone*" )
	 {
	 alert("Please enter a value for the \"Telephone\" field.");
	 callbackForm.telephone.focus();
	 return (false);
	 }
	 var checkOK = "0123456789";
	 var checkStr = callbackForm.telephone.value;
	 var allValid = true;
	 var validGroups = true;
	 for (i = 0; i < checkStr.length; i++)
	 {
	 ch = checkStr.charAt(i);
	 for (j = 0; j < checkOK.length; j++)
	 if (ch == checkOK.charAt(j))
	 break;
	 if (j == checkOK.length)
	 {
	 allValid = false;
	 break;
	 }
	 }
	 if (!allValid)
	 {
	 alert("Please enter only digit in the \"Telephone\" field.");
	 callbackForm.telephone.focus();
	 return (false);
	 }

//'address').value='Communication Address*
	if (trimAll(callbackForm.address.value) == "" || callbackForm.address.value == "Communication Address*" )
	{
	alert("Please enter a value for the \"Communication Address\" field.");
	callbackForm.address.focus();
	return (false);
	}
	if (trimAll(callbackForm.twb.value) == "" || callbackForm.twb.value != "TWBISGOOD" )
	{
	alert("Entered text did not match the image. Please re-enter");
	callbackForm.twb.focus();
	return (false);
	}
	if (trimAll(callbackForm.tbxhigedu.value) == "" || callbackForm.tbxhigedu.value == "Highest Education*" )
	{
	alert("Please enter a value for the \"Highest Education\" field.");
	callbackForm.tbxhigedu.focus();
	return (false);
	}

//E-Mail
	if (trimAll(callbackForm.email.value) == "" || callbackForm.email.value == "E-mail ID*" )
	{
	alert("Please enter a value for the \"E-Mail\" field.");
	callbackForm.email.focus();
	return (false);
	}
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_.@ \t\r\n\f";
	var checkStr = callbackForm.email.value;
	var allValid = true;
	var validGroups = true;
	for (i = 0; i < checkStr.length; i++)
	{
	ch = checkStr.charAt(i);
	for (j = 0; j < checkOK.length; j++)
	if (ch == checkOK.charAt(j))
	break;
	if (j == checkOK.length)
	{
	allValid = false;
	break;
	}
	if (checkStr.indexOf('@') == -1 || checkStr.indexOf('.') == -1 )
	{
	allValid = false;
	break;
	}
	}
	if (!allValid)
	{
	alert("Please enter a valid id in the \"E-Mail \" field.");
	callbackForm.email.focus();
	return (false);
	}
return (true);
}
