﻿// This function was originally created by ppk, www.quirksmode.org 
// Any commented lines are from his original code.
//
// Extra code added by Raf of Ronel Multimedia

function checkMail(theEmailFld)
{
//	var x = document.forms[0].email.value;
	var x = theEmailFld.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	return filter.test(x);


/*	if (filter.test(x)) alert('YES! Correct email address');
	else alert('NO! Incorrect email address'); */
}

function ZIPIsValid () {
	var tempStr="";
	var tempZIP;
	var re = /\s+/;
	
	with ( document.forms[0] ) {
		// Trim whitespace from entered ZIP
		tempZIP=elements["zip"].value.replace(re, "");
		
/*		tempStr+="isNaN = " + isNaN(elements["ZIP"].value) + "\n";
		tempStr+="length = " + elements["ZIP"].value.length + "\n";
		tempStr+="tempZIP = \"" + tempZIP + "\"\n";
		tempStr+="tempZIP length = \"" + tempZIP.length + "\"\n";
		
		alert ( tempStr ); */
		
		// Check if ZIP is a valid integer and length is 5
		if ( (!(isNaN(elements["zip"].value))) && (tempZIP.length == 5) ) {
			// If it is OK, return true
			return true;
		} else {
			// Else, tell user and return false
			elements["zip"].select();
			elements["zip"].focus();
			alert("Please enter a valid 5-digit ZIP code. Click OK to re-enter it.");
			return false;
		}
	}
}