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(20);
	// 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('captchaCode').innerHTML = 'Please enter the validation code in the field below.<br /><input type="text" size="35" name="captchaCode" value="" style="width:304px;" />';
}

function validateContactForm() {
	oForm = document.form1;
	// 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://secure4.spiderscope.com/vs/2603/scripts/sendmail_2005.asp';
		oForm.formValidated.value = 'true';
		return true;
	} else {
		alert('Please enter the verification code.');
		oForm.captchaCode.focus();
		return false;
	}
}
function validatePopupForm() {
	oForm = document.contactPop;
	// 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://secure4.spiderscope.com/vs/2603/scripts/sendmail_2005.asp';
		oForm.formValidated.value = 'true';
		return true;
	} else {
		alert('Please enter the verification code.');
		oForm.captchaCode.focus();
		return false;
	}
}


function init() {
	// give the DOM time to load
	setTimeout("init2()", 1000);
}

// call the initialisation function when the page loads
// window.onload = init();

