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 callbackForm_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);
 }



//E-Mail
if (trimAll(callbackForm.email1.value) == "" || callbackForm.email1.value == "E-mail ID*" )
{
alert("Please enter a value for the \"E-Mail\" field.");
callbackForm.email1.focus();
return (false);
}
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_.@ \t\r\n\f";
var checkStr = callbackForm.email1.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.email1.focus();
return (false);
}
return (true);
}
