/*

  JavaScript Captcha Script
   -  2009 Shaun Gill  -
http://www.landingnet.co.uk
http://www.shaungill.co.uk   

*/


	
// Set Variables	
	var site	=	'';  // this needs to be the 'root' of the site
	
	var first	=	(Math.floor(Math.random()*10))+'';
	var second	=	(Math.floor(Math.random()*10))+'';
	var third	=	(Math.floor(Math.random()*10))+'';
	var fourth	=	(Math.floor(Math.random()*10))+'';
	var fith	=	(Math.floor(Math.random()*10))+'';
	
	var captcha	=	(first + second + third + fourth + fith);


	
function jscaptcha()
{
// Display the Captcha Images
	var jcapimg ="";
	jcapimg = jcapimg + "<label>&nbsp;</label>";
	jcapimg = jcapimg +"<div id=\"jscaptcha\" style=\"border: none; width: 200px;\">";
	jcapimg = jcapimg + "<img src=\"" + site + "JcapImages/" + first	+ ".gif\" alt=\"\">";
	jcapimg = jcapimg + "<img src=\"" + site + "JcapImages/" + second + ".gif\" alt=\"\">";
	jcapimg = jcapimg + "<img src=\"" + site + "JcapImages/" + third + ".gif\" alt=\"\">";
	jcapimg = jcapimg + "<img src=\"" + site + "JcapImages/" + fourth + ".gif\" alt=\"\">";
	jcapimg = jcapimg + "<img src=\"" + site + "JcapImages/" + fith + ".gif\" alt=\"\">";
	jcapimg = jcapimg + "</div>";
	
	
// Display the Input Box
	jcapimg = jcapimg + "";
	jcapimg = jcapimg + "";
	document.getElementById('jcapid').innerHTML = jcapimg;
	
	
}

function jscaptchaSubmit(frm)
{
	if(frm.jscaptchaInput.value != captcha)
	{
		alert("Please double check the numbers you entered; I\'m afraid they don\'t quite match");
		valid = false;		
	}
	else
	{
		valid = true;
	}
	return valid;
}

function jscaptchaSubmit2(frm)
{
	if(frm.jscaptchaInput.value != captcha)
	{
		valid = false;		
	}
	else
	{
		valid = true;
	}
	return valid;
}