<!-- Used to hide Javascript for older browsers
/* 
 * FILENAME:   module.js
 * PURPOSE:    Enable/Disable form componets in Internet Explorer
 * USE:               <SCRIPT src="forms.js"></SCRIPT>
 *                          <INPUT id="id" name="name" type="type" onkeyup=changeall(this)>
 *                          <INPUT disabled type="submit" name="submit">
 *
 * FUNCTION:   validate_form ()
 * PURPOSE:    Check particular fields with the form for certain criteria.
 * USE:        <FORM ... onsubmit="return validate_form()">
 * 
 * FUNCTION:   MaskPhoneNumber()
 * PURPOSE:    Prevent users from entering in invalid text, particularly letters into anumeric field.
 * USE:        <INPUT ... onkeypress="return MaskNumber(this, event)">
 */
 
function redir(username,level)
{
   newlocation = "register.php?menu_username=" + username + "&menu_selected=" + level;
   self.location = newlocation;   
}

function MaskNumber(field,event) {
   /* TODO: Copy/Paste will allow unwanted characters in field. */
	var key, keychar;
	
	if (window.event) key = window.event.keyCode;
	else if (event) key = event.which;
	else return true;
	
	keychar = String.fromCharCode(key);
	
	// Check for special characters like backspace
	// then check for numbers.
	if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27)) return true;
	else if ((("0123456789").indexOf(keychar) > -1)) {
		window.status = "";
		return true;		
	} else {
		window.status = "Field excepts numbers only";
		return false;
	}
}

function TestJavaScriptLoad () {
   alert('Test Complete!');
}

function IsEmpty(s) {
	var whitespace = " \t\n\r";
	var i;
	if ((s == null) || (s.length == 0))
		return true;
		
	for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if (whitespace.indexOf(c) == -1)
			return false;
	}
	return true;
}

function validate_form () {
	
	var aryCheckFields = [
	  [ document.new_registration.FNAME.value,   "Please specify your First Name."   ],
	  [ document.new_registration.LNAME.value,   "Please specify your Last Name."    ],
	  [ document.new_registration.ADDR1.value,   "Please specify a valid Address."   ],
	  [ document.new_registration.CITY.value,    "Please specify a City."            ],
	  [ document.new_registration.STATE.value,   "Please select a State."            ],
	  [ document.new_registration.USERNAME.value,"Please specify a username."        ]
   ];
   
   /* Check to make sure there is something in the field. */
   for (var index = 0; index < aryCheckFields.length; index++) {
      if (aryCheckFields[index][0].length == 0) {
         alert(aryCheckFields[index][1]);
         return false;
      }
   }                                                                          	
	
   /* Verify number fields separately. */
	var s;
	s = document.new_registration.PHONE.value;
	if (s.length != 10) { alert('That is not a valid Phone Number.'); return false; }

	/* s = document.new_registration.FAX.value;
	if (s.length != 10) { alert('That is not a valid Fax Number.'); return false; } */
	
	s = document.new_registration.ZIP.value;
	if (s.length != 5 && s.length != 9) { alert('That is not a valid Postal Code.'); return false; }
	
	/* Verify Password fields separately */
	if ( IsEmpty ( document.new_registration.PASSWORD.value ) ) {
	  alert('You must specify a password.');
	  return false;
	} else {
	   s = document.new_registration.PASSWORD.value;
	   c = document.new_registration.CONFIRM.value;
	   
	   if ( s.length != c.length ) {
	     alert("Passwords don't match!");
	     return false;
	   }
	   
	   for ( i=0; i < s.length; i++ ) {
	     if ( s.charAt(i)!=c.charAt(i) ) {
	        alert("Passwords don't match!");
	        return false;
	     }
	   }
	}
	/* Verify Email Address */
}
-->