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 (document.questionForm != undefined) {
		//Don't fire the generate CAPTCHA code function on the ask a question form (using verify human instead)

	} else {	
		// select a random captcha code 0 - 19
		captchaNumber = randomNumber(20) + 1;
		// 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" />';
		
		if (document.contactForm != undefined) {
		// and the verification box
			document.getElementById('captchaCode').innerHTML = '<label for="captchaCode">Enter the Validation</label><input type="text" name="captchaCode" id="captchaCode" maxlength="10" class="field_full" value="" /> *<br />';
	
		//Update the display of how heard (if refreshing)
			changeHeard();
		} else if (document.registerForm != undefined) {
		// and the verification box
			document.getElementById('captchaCode').innerHTML = '<label for="captchaCode">Enter the Validation</label><input type="text" name="captchaCode" id="captchaCode" maxlength="10" class="field_full" value="" /> *<br />';
	
		} else {
		// and the verification box
			document.getElementById('captchaCode').innerHTML = 'Please enter the validation code below.<br /><input type="text" size="35" name="captchaCode" value="" class="formfield" /> *';
		}
	}
}

function init() {
	// give the DOM time to load
	setTimeout("init2()", 1000);
}

// call the initialisation function when the page loads
window.onload = init();

function verifyHuman(formName) {
	document[formName].h_formValidated.value = 'true'
}


function changeHeard() {
	if (document.contactForm.h_how_heard.value == "Search Engine") {
		document.getElementById("se_selection").style.display = 'block';
	} else {
		document.getElementById("se_selection").style.display = 'none';
	}
	
	if ((document.contactForm.h_how_heard.value == "Newspaper Article") || (document.contactForm.h_how_heard.value == "Magazine Article")) {
		document.getElementById("other").innerHTML = "Enter Article";
		document.getElementById("other_selection").style.display = 'block';	
	} else if (document.contactForm.h_how_heard.value == "Link from a Website") {
		document.getElementById("other").innerHTML = "Enter Website";
		document.getElementById("other_selection").style.display = 'block';	
	} else if (document.contactForm.h_how_heard.value == "Other") {
		document.getElementById("other").innerHTML = "Please Specify";
		document.getElementById("other_selection").style.display = 'block';
	} else {
		document.getElementById("other_selection").style.display = 'none';
	}
}

