
<!--
//Author: Dawa Lama Sherpa 
//Date Created : 07/01/2001
//Date modified : 07/23/2001
//
//Few functions for validating the form. 
//checkPhone will validate phone numbers 
//checkZip will validate zip codes
//checkEmail will validate Email Address
//checkNumeric will check to see if the value is a number or not. 
//CheckSubmit checks to see if any of the required fields are empty or not. 
//


function checkPhone(element)
	{
		
		var re = /^(\(([1-9]\d{2})\)|([1-9]\d{2}))[-\s]?([1-9]\d{2})[-\s]?(\d{4})$/
		//re matches the following patterns
		//The spaces between the numbers are optional. 
		//(xxx) xxx - xxxx
		//(xxx) xxx xxxx
		// xxx xxx - xxxx
		// xxx xxx xxxx
		// xxx-xxx-xxxx
		if (re.test(element.value) || element.value=='')
			return true;
		else
			{
			alert("Please enter a valid phone/fax number\nExample:\n(222) 222 - 2222 \n(222) 222 2222 \n222 222 - 2222\n222 222 2222\n222-222-2222");
			element.focus();
			return false;
			}
	}
	
function checkZip(element)
	{
		var re = /^\d{5}[-\s]?(\d{4})?$/
		//re matches the following patterns
		//The spaces between the numbers are optional. 
		//xxxxx
		//xxxxx-xxxx
		//xxxxx xxxx
		
		if (re.test(element.value) || element.value=='')
			return true;
		else
			{
			alert("Please enter a valid zip code \nExample:\n22222\n2222-2222\n22222 2222 ");
			element.focus();
			return false;
			}
	}//end of function checkZip
	
function checkEmail(element) 
	{
	    var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$"
	    var re = new RegExp(emailReg)
		if (re.test(element.value) || element.value=='')
			return true;
		else
		{
			alert("Please enter a valid Email address");
			element.focus();
			return false;
		}
	}
function checkDate(element) {			
	var reDate = /^\d{1,2}\\\d{1,2}\\\d{2,4}$/;
	if(reDate.test(element.value) || element.value=='') 
	{
		alert("Please enter a valid date.");
		element.focus();
	}//if()	
}//checkDate()
			
function checkNumeric(element)
	{
	if (isNaN(element.value))
		{
			alert("Please enter a numeric value")
			element.focus();
			return false;
		}
	return true;
	}//End of function checkNumeric
	
//CheckSubmit checks for empty fields in the form.
//Input form, Num, titles
//Form is the form being submitted
//Num contains the subscript of form elements which are required
//titles are the name of the fields for display (for netscape)
function checkSubmit(form, Num, titles)
	{
		//form element subscripts which can be NULL
		
		for(var i = 0; i <= (form.elements.length - 2); ++i)
		{
			for (var j = 0; j < Num.length; ++j)
			{
				if (i==(Num[j]))
				//	i = i + 1;
				{
					var temp = form.elements[i];
					if(temp.value == "")
					{
						if (bIsNav)
						{
							alert("Please enter your " + titles[j]);
							temp.focus();
						}
						else 
						{
							var bgcolor;
							bgcolor = "#ff3300"
							alert("Please enter your " + titles[j]);
							//if ((temp.style.getAttribute("bordercolor",0) != bgcolor))
							//{
							//temp.insertAdjacentText("afterEnd", " Please fill out this information");
							//temp.style.setAttribute("bordercolor","#FF3300",  0);
							//}		
							temp.focus();
							
						}
						return false;
					}
				}
			}	
		}
		return true;
	}
//-->