/*

  JavaScript Captcha Script
   -  2009 Shaun Gill  -
http://www.landingnet.co.uk
http://www.shaungill.co.uk   

http://www.shaungill.co.uk/?cat=13
*/


	
// Set Variables	
	var site	=	'http://www.coralseadreaming.com/';  // 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
	document.write("<div style=\"padding-bottom: 0em;\">");
	document.write("<label>Image code:</label>");
	document.write("<img src=\"" + site + "images/" + first	+ ".gif\" alt=\"\">");
	document.write("<img src=\"" + site + "images/" + second + ".gif\" alt=\"\">");
	document.write("<img src=\"" + site + "images/" + third + ".gif\" alt=\"\">");
	document.write("<img src=\"" + site + "images/" + fourth + ".gif\" alt=\"\">");
	document.write("<img src=\"" + site + "images/" + fith + ".gif\" alt=\"\">");
	document.write("</div>");
	
	
// Display the Input Box
	document.write("<label for=\"jscaptchaInput\">Enter Image Code:</label>");
	document.write("<input type=\"text\" name=\"jscaptchaInput\" style=\"background-color:#FFFFFF; border:1px solid #FFFFFF; padding:3px 4px; width:20%;\">");		
}



function jscaptchaSubmit(frm)
{
	if(frm.jscaptchaInput.value != captcha)
	{
		alert("To successfully send this form enquiry you must correctly enter the Image Code numbers displayed. If you have received this message I\'m afraid the numbers you entered don\'t quite match the actual Image Code. Please double check and try again.");
		valid = false;		
	}
	else
	{
		valid = true;
	}
	return valid;
}
