function Validate() 
{
	var errMessage = "";	
	if (document.form1.txtName.value == "")
	{
		errMessage = "Please enter your full name.\n";
		document.form1.txtName.focus();
	}
	
	var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z,A-Z]{2,4}$");	
	if (document.form1.txtEmail.value == "" || !rx.test(document.form1.txtEmail.value))
	{
		errMessage += "Please enter a valid email address. (Like: youremail@domain.com ).\n";
		document.form1.txtEmail.focus();
	}

	/* if "add me as Pashchimi volunteer" checkbox is selected phone number must be entered*/
	/*
	if (document.form1.txtPhone.value == "")
	{
		errMessage += "Please enter a phone number.\n";
	}
	*/
	if (document.form1.txtPhone.value != "") // IF ENTERED ENTER A VALID ONE
	{
		if (document.form1.txtPhone.value.length < 7) {
			errMessage += "Please enter a valid phone number.\n";
			document.form1.txtPhone.focus();
		}
	}
	
	if (document.form1.txtSubject.value == "")
	{
		errMessage += "Please enter a subject line.\n";
		document.form1.txtSubject.focus();
	}
	
	if (document.form1.txtComments.value == "")
	{
		errMessage += "Please enter your comments, feedback or suggestion.\n";
		document.form1.txtComments.focus();
	}
	
	if (errMessage != "" )
	{
		alert("The required information is incomplete or contains errors:\t\t\n" + errMessage);
		return false;
	}
	else
	{
		document.form1.submit();
		return true;
	}
	
}

function FixPhone(s) 
{
	var lphone = document.form1.txtPhone; //(0).elements(s);
	if (lphone.value == "") 
	{
		lphone.value = "";
		return true; // nothing to do
	}
		
	var tempphone = "";
	var i;
	var maxlen = 20; // this is maxmimum input length - same as maxlength="X" value

	//loops through the form field value and removes any non-numeric values like -, ( and ). It will also remove anything that is non-numeric.
	for (tempindex=0; tempindex <= (lphone.value.length - 1); tempindex++)
	{
		i = "";
		i = lphone.value.substring((tempindex), (tempindex + 1));

		switch (i) 
		{
			case "0":
			case "1":
			case "2":
			case "3":
			case "4":
			case "5":
			case "6":
			case "7":
			case "8":
			case "9":
				tempphone = tempphone.concat(i);
				break;
			case " ":
		    case ".":
		    case "(":
		    case ")":
		    case "-":
				tempphone = tempphone.concat("");
				break;
			default:
				// don't take any other values etc.
				tempphone = tempphone.concat("");
				break;
		}
	}
	
	window.status = tempphone;				
	//formats the phone number to 111 111-1111
	if (tempphone.length >= 10 && tempphone.length <= maxlen)
	{
		if(tempphone.substring(0, 1) == "1")
		{
			tempphone = tempphone.substring(1);				
		}
			
		if (tempphone.length > 10 && tempphone.length <= maxlen)
		{
				lphone.value = tempphone.substring(0, 3) + " " + tempphone.substring(3, 6) + "-" + tempphone.substring(6, 10) + " x" + tempphone.substring(10);
		}
		else
		{
			lphone.value = tempphone.substring(0, 3) + " " + tempphone.substring(3, 6) + "-" + tempphone.substring(6, 10);
		}			
			
		lphone.style.background = '#fffff0';
			
	}
	else if (tempphone.length == 0)
	{
		lphone.value = "" ;
		lphone.style.background = '#ff6633';
		document.form1.txtPhone.focus();
		alert("Please enter phone number only in digits.\n (Like. 333 333-4444).");
		return false;
	}
	else
	{
		lphone.value = tempphone.substring(0);
		document.form1.txtPhone.focus();
		alert("Please enter valid phone number with area code: \nPhone number must be 10 to 15 digits\n (Like, 333 333-4444). ");
		return false;
	}
	
	return true;
}  