function empty_error_code(cookie_name){
	var cookie_date = new Date ( );  // current date & time
	cookie_date.setTime ( cookie_date.getTime() - 1 );
	document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

function validate_form(enter_value_array,default_value_array,form,error_message_array){
	for (x = 0; x < enter_value_array.length; x++){
		var userValue = document.getElementById(enter_value_array[x]).value;
		var defaultValue = document.getElementById(default_value_array[x]).value;
		var form = document.getElementById(form);
		var message = error_message_array[x];
		
		if(userValue == defaultValue){
			alert(message);
			return false
		}else{
			form.submit();
		}

		if(userValue == null){
			alert(message);
			return false
		}else{
			form.submit();
		}
	}
	
	
}

function clear_input_field(field_name,cache_field_name){
	currentValue = document.getElementById(field_name).value;
	cacheValue = document.getElementById(cache_field_name).value;
	if(currentValue == cacheValue){
		document.getElementById(field_name).value = "";
		document.getElementById(field_name).style.color = "#000";
	}
}

function validate_entry_input_field(field_name,cache_field_name){
	currentValue = document.getElementById(field_name).value;
	cacheValue = document.getElementById(cache_field_name).value;
	if(currentValue == ""){
		document.getElementById(field_name).style.color = "#b3b3b3";
		document.getElementById(field_name).value = cacheValue;
	}
	
}

function formKeyAction(e){
	var keynum;
	var keychar;
	var numcheck;
	if(window.event){ //IE
		keynum = e.keyCode;
	}else if(e.which){ // Netscape/Firefox/Opera
		keynum = e.which;
	}
	keychar = String.fromCharCode(keynum);
	if (keynum == 13){ 
		return false;
	}
}

//validates that a string is a positive or negative number
function isNumber(string) {
	var re = /^[-]?\d*\.?\d*$/;
	string = string.toString();
	if (!string.match(re)) {
		return false;
	}
	return true;
}

// validates that a string is 16 characters long
function isLen16(string) {
	var re = /\b.{16}\b/;
	if (!string.match(re)) {
		return false;
	}
	return true;
}

// validates that a string is formatted as an e-mail address
function isEmailAddr(string) {
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if (!string.match(re)) {
		return false;
	}
	return true;
}

// validates that a string is the correct length for a ZIP code.
function isZipLength(string) {
	var re = /\b.{5}\b/;
	if (!string.match(re)) {
		return false;
	}
	return true;
}

