// Clear textfield
function ctf(theText) {
	if (theText.value == theText.defaultValue) {
		theText.value = "";
		theText.style.color = "#000000";
		theText.style.fontWeight = 'bold';
	}
}
// Reset textfield
function rtf(theText) {
	if (theText.value == "") {
		theText.value = theText.defaultValue;
		theText.style.color = "#a7a7a7";
		theText.style.fontWeight = 'normal';
	}
}
// Prevent default searches
function l2s(theForm) {
	if (theForm.q.value == theForm.q.defaultValue) {
		theForm.q.focus();
		return false;
	}
	return true;
}
function validateForm(formElem, good_color, bad_color) 
{
	var inputElem = null;
	var why = '';
	
	inputElem = formElem.Email;
	if( inputElem ) {
		if(!isValidEmail(inputElem.value)) {
			why += " * Your Email Address\n";
			inputElem.style.borderColor = bad_color;
			inputElem.focus();
		}
		else {
			inputElem.style.borderColor = bad_color;
		}
	}
	if( why != "" ) {
		why = "There is an error with your request.\nPlease fill out the following required fields:\n" + why;
		alert(why);
		return false;
	}
	else {
		return true;
	}
}

function isValidEmail(the_email) {
	var emailFilter=/^.+@.+\..{2,3}$/;
	var illegalChars= /[\(\)\<\'\>\,\;\:\\\/\"\[\]]/;
	if (!emailFilter.test(the_email) || the_email.match(illegalChars)) {
		return false;
	}
	return true;
}
