var captchaCodes = new Array('k3xfn','493v','pqtr2','h6mdwl','9qz7cr',
						  'agfx','xypz7','hfcsl','642ye','n69dwu',
						  'rvdj','wlusz3','6qya','bt4p2','qtbf4',
						  'q69z','crw68','ufbl3q','l2jgkf','kxgqm');
var captchaNumber = false;

function randomNumber(maxNumber){
	index = Math.floor(Math.random() * maxNumber);
	return index;
}

function init2() {
	if(typeof relPath == "undefined") relPath = "";
	// select a random captcha code 1 to 20
	captchaNumber = randomNumber(19);
	// add the captcha to the form
	document.getElementById('captchaImage').innerHTML = '<img src="' + relPath + 'images/codes/'+(captchaNumber)+'.jpg" width="174" height="70" alt="please enter this code in the box below" title="please enter this code in the box below" />';
	// and the verification box
	document.getElementById('captchaCodeLabel').innerHTML = '<font face="Times New Roman,Georgia,Times" size="3">Please enter the validation code in the field below.</font>';
	document.getElementById('captchaCode').innerHTML = '<input type="text" size="40" name="captchaCode" value="" />';
//	document.getElementById('captchaCode').innerHTML = '<p><font face="Times New Roman,Georgia,Times" size="3">Please enter the validation code in the field below.</p><p><input type="text" size="40" name="captchaCode" value="" /></p>';
}

function validateForm() {
	oForm = document.Formone;
	// check the code entered into the captcha box is correct
	if(oForm.captchaCode.value.toLowerCase() == captchaCodes[(captchaNumber-1)]) {
		// change the target of the form
		oForm.action = 'http://www.ednet.co.uk/cgi-bin/user/colfurn_1/formmail.pl';
		oForm.submit();
	} else {
		alert('Please enter the verification code.');
		document.getElementById('captchaCode').focus();
	}
}


function init() {
	// give the DOM time to load
	setTimeout("init2()", 1000);
}

// call the initialisation function when the page loads
window.onload = init();

