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 init() {
	// select a random captcha code 1 to 20
	captchaNumber = randomNumber(20);
	// add the captcha to the form
	document.getElementById('captchaImage').innerHTML = '<img src="../pics/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('captchaCode').innerHTML = 'Please enter the code in the field below.<br /><input type="text" size="35" name="captchaCode" value="" />';
}

function validateContactForm() {
	oForm = document.contactForm;
	// 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.web-services.co.uk/scripts/response.pl';
		return true;
	} else {
		alert('Please enter the verification code.');
		return false;
	}
}
function validateOrderForm() {
	oForm = document.taborder;
	// 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.web-services.co.uk/scripts/response.pl';
		return true;
	} else {
		alert('Please enter the verification code.');
		return false;
	}
}




// call the initialisation function when the page loads
window.onload = init;
