/**
 * Custom form submission handler; called by submitForm() from forms.js
 *
 * @var myform (form object)
 */
function checkSubmit(myform) {
	
	errorMsg = "";
	name = myform.form_name.value;
	email = myform.form_email.value;
	msg = myform.form_comment.value;
	errorCount = 0;
	
	if (isEmpty(name)) {
		errorCount++;
		errorMsg += "- Include your name\n";
	}
	if (!isEmpty(email) && !isValidEmail(email)) {
		errorCount++;
		errorMsg += "- Include a valid email (optional, but yours seems wrong)\n";
	}
	if (isEmpty(msg)) {
		errorCount++;
		errorMsg += "- Include a comment\n";
	}
	
	if (msg.indexOf('http') > -1) {
		errorCount++;
		errorMsg += "- Sorry, not allowed to post links\n";
	}
	
	if (!isEmpty(errorMsg)) {
		if (errorCount > 1) {
			errorTxt = 'these errors';
		} else {
			errorTxt = 'this error';
		}
		alert("Please fix " + errorTxt + " and submit again:\n" + errorMsg);
		return false;
	} else {
		return true;
	}
}


/************************************************************\
*
*		freeCap v1.4.1 Copyright 2005 Howard Yeend
*		www.puremango.co.uk
*
*    This file is part of freeCap.
*
*    freeCap is free software; you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation; either version 2 of the License, or
*    (at your option) any later version.
*
*    freeCap is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with freeCap; if not, write to the Free Software
*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
*
\************************************************************/

function new_freecap() {
	// loads new freeCap image
	if (document.getElementById) {
		// extract image name from image source (i.e. cut off ?randomness)
		thesrc = document.getElementById("freecap").src;
		thesrc = thesrc.substring(0,thesrc.lastIndexOf(".")+4);
		// add ?(random) to prevent browser/isp caching
		document.getElementById("freecap").src = thesrc+"?"+Math.round(Math.random()*100000);
	} else {
		alert("Sorry, cannot autoreload freeCap image; submit the form and a new freeCap will be loaded");
	}
}
