﻿
/* ------- Validation for Alerts Subscription Form on Homepage ---- */
/* Extra functionality commented out in case of future use */
function validate(f) {

	var v	= ( f ) ? f.emailaddress : null ;

	if ( v ) {

		v 			= v.value;
		var error	= "" ;

		if ( v.length != 0 && v.length > 4 ) {

			if ( v.indexOf("@") == -1 || v.indexOf(".") == -1 ) {

				error = "This is not a valid email address." ;

			}
			if ( v.indexOf(" ") != -1 || v.indexOf("/") != -1 || v.indexOf(",") != -1 || v.indexOf(";") != -1 ) {

				error = "This is not a valid email address." ;

			}

		} else {

			error = "Please enter a valid email address!" ;

		}

		if( error !== "" ) {

			alert( error ) ;

			/*
			if ( !document.getElementById("errorMsg") ) {
				var p	= document.createElement("p");
				p.id 	= "errorMsg";
				subscribeForm	= document.getElementById("subscribeBite");
				subscribeEmail	= document.getElementById("txt_email");
				subscribeForm.insertBefore(p, subscribeEmail);
			} else {
				var p = document.getElementById("errorMsg");
			}
			p.innerHTML = error;
			*/

			return false ;
		}

	}

	return true ;
}