/*----------------------------------------------------
		Version: 1.0
		Author: SD
		Email: webmaster@seanpatrickdyer.net
		Website: http://www.jameswday.com
	----------------------------------------------------*/	

<!--

function validateForm(form) {
	//Determine if this is a valid email address
	//form names: who_txt, where_txt, comments_txt
	if(validateEmailAddress(form.email_txt) == false) {
		//Post an alert box telling the user to put a valid email address in
		alert("Please enter a valid email address!");
		//Focus the form element
		form.email_txt.focus();
		//return a false value to the function
		return false;
	}
	
	//Determine if this input field has any text in it
	if(fieldContainsText(form.user_txt) == false) {
		//Post an alert box telling the user to put a name in
		alert("Please put your name in there!");
		//Focus the form element
		form.user_txt.focus();
		//return a false value to the function
		return false;
	}
	
	//Determine if this input field has any text in it
	if(fieldContainsText(form.comment_txt) == false) {
		//Post an alert box telling the user to put a name in
		alert("Please put your comments in there!");
		//Focus the form element
		form.comment_txt.focus();
		//return a false value to the function
		return false;
	}
	
	return true;
}

function validateEmailAddress(element) {
	//Determine if the input contains the characters @ and a period
	if(element.value.indexOf("@") != "-1" && element.value.indexOf(".") != "-1") {
		//It does, all is ok
		return true;
	} else {
		//Not a valid email address
		return false;
	}
}

function fieldContainsText(element) {
	//Determine if the input has any text in it
	if(element.value == "" || element.value == null) {
		//No text in the input
		return false;
	} else {
		//There's text in the input
		return true;
	}
}

function resetForm() {
	//Define new Array to hold all form fields to clear text from
	var formFields = new Array("form.user_txt", "form.email_txt", "form.comment_txt");
	//Loop through each element in the Array
	for(var i=0; i < formFields.length; i++) {
		//Strip all text from the fields in the Array
		formFields[i].value = "";
	}
	//Let the user know that the form has been cleared...
	alert("Form has been cleared.");
}

function openNewWindow(urlToOpen, windowName, winWidth, winHeight){
	//Get the left and top coordinates of the user's screen
	windowLeft = Math.round((screen.width - winWidth) / 2 );
	windowTop = Math.round((screen.height - winHeight) / 2);
	//Set the various settings of the window
	windowSettings = '"toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=yes,status=no,width='+winWidth+',height='+winHeight+',left='+windowLeft+',top='+windowTop+'"';
	//Open the window using the settings above
	theWindow = window.open(urlToOpen, windowName, windowSettings);
	//Give the window focus
	theWindow.focus();
}

function closeWindow() {
	var closeInterval = setTimeout("window.close()", 3000);
}
//-->