function doFocus() {
	if (document.forms[0]) {
		if (document.forms[0].elements[0]) {
			document.forms[0].elements[0].focus();
		}
	}
}
function trim(string) {
	string = string.replace(/^\s+/, "");
	string = string.replace(/\s+$/, "");
	return string;
}


// Strip HTML Tags (form) script- By JavaScriptKit.com (http://www.javascriptkit.com)
// Modified to actually strip tags... even ones begining with whitespace. 
// And I made it look better. Use your semicolons and tabs kids! We're not in the dark ages here!
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// This notice must stay intact for use
function stripHTML(){
	var re= /<(\n|.)+?>/g;
	for (i=0; i<arguments.length; i++)
		arguments[i].value=arguments[i].value.replace(re, " ");
}

//This returns true if all the elements of theForm are filled out.
//It also checks any element name containing the text "email"
//and makes sure the value looks like an email address.
function validate(theForm) {
	if (theForm) {
		for (i = 0; i < theForm.elements.length; i++) {
			var e =	theForm.elements[i];
			
			if (trim(e.value) == "") {
				alert("Please fill out the form completely.");
				return false;
			}
			
			//make sure the email address looks right
			if (e.name.toLowerCase().search("email") > -1) {
				var d = e.value;
				var at = d.indexOf("@");
				var dot = d.lastIndexOf(".");
				if ((at == -1) || (dot <= at )|| (e.value.length < 6)) {
					alert("Please enter a valid email address.");
					return false;
				}
			}
		}
		return true;
	}
	else
		return false;
}
