var d = document;
function ValidateField(objField, blnRequired, blnNum, strFieldName)
{

var blnHold = true;
var strValue = objField.value;
if (blnRequired && strValue.length == 0)
	{
	blnHold = false;
	alert(strFieldName + " was left blank.\nThis field is required for registration");
	objField.focus();
	}
if (blnHold && blnNum == 1 && strValue.length > 0)
	{
//Regular Expression ------  Phone Number
phoneNum='^[(]{0,1}[0-9]{3}[ ]{0,1}[)+-.]{0,1}[ ]{0,1}[0-9]{3}[ ]{0,1}[+-.]{0,1}[ ]{0,1}[0-9]{4}$';
  myReg=new RegExp(phoneNum);

	if(!myReg.test(strValue))
		{
		blnHold = false;
		alert("Area Code and" + strFieldName + " must be numeric,\n Eg.\n (333) 333 - 3333\n 333+333+3333\n 333.333.3333\n 333-333-3333\n 3333333333");
		objField.focus();
		}
	}
if (blnHold && blnNum == 2 && strValue.length > 0)
	{
//Regular Expression ------  E Mail
emails='^[-a-zA-Z0-9_+.]{1,40}[@]{1}[-a-zA-Z0-9_+]{2,40}[.]{0,1}[-a-zA-Z0-9_+]{0,20}[.]{0,1}[-a-zA-Z0-9_+]{0,20}[.]{1}[a-zA-Z]{2,4}$';
  myReg=new RegExp(emails);

	if(!myReg.test(strValue))
		{
		blnHold = false;
		alert(strFieldName + " must be as\n Ex: john@doe.com");
		objField.focus();
		}
	}
if (blnHold && blnNum == 3 && strValue.length > 0)
	{
//Regular Expression ------  Postal Code
Post='^[a-zA-Z]{1}[0-9]{1}[a-zA-Z]{1}[ ]{0,1}[0-9]{1}[a-zA-Z]{1}[0-9]{1}$';
Ptxt= '\nPostal Ex: Z9Z 9Z9';
ors='|';
Zip='^[0-9]{5}$';
Ztxt= '\nZip Ex: 55555';

coder = Post + ors + Zip;exm = Ptxt + Ztxt;
if (d.vari.code.value == "post") { coder = Post;exm = Ptxt;}
if (d.vari.code.value == "zip")  { coder = Zip; exm = Ztxt;}

  myReg=new RegExp(coder);
	if(!myReg.test(strValue))
		{
		blnHold = false;
		alert(strFieldName + " must be authentic " + exm);
		objField.focus();
		}
	}
if (blnHold && blnNum == 4 && strValue.length > 0)
	{
//Regular Expression ------  Number
phoneNum='^[$]{0,1}[\\d]{0,3}[,]{0,1}[\\d]{0,3}[,]{0,1}[\\d]{0,3}[,]{0,1}[\\d]{1,3}[.]{0,1}[\\d]{0,2}$';
  myReg=new RegExp(phoneNum);

	if(!myReg.test(strValue))
		{
		blnHold = false;
		alert(strFieldName + " must be numeric.");
		objField.focus();
		}
	}
return blnHold;
}
