/*

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

*/


	
// Set Variables	
	var site	=	'http://www.securehomesllc.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()
{
	document.write("<label>&nbsp;</label>");
	document.write("<div id=\"jscaptcha\"  style=\"border: 1px solid #f90; width: 150px; \" class=\"formClass\">");
	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 class=\"formTxt\">Enter Numbers from the Image</label>");
	document.write("<label>&nbsp;</label>");
	document.write("<input type=\"text\" class=\"formClass\"  name=\"jscaptchaInput\">");
	document.write("<label>&nbsp;</label>");
	
	
}

function jscaptchaSubmit(frm)
{
	var error	=	"";
	
	
	
	if(document.getElementById('name').value == '' )
	{
			error	= 'Please Provide Name.\n';
	}
	
		
	if(frm.email.value == '')
	{
		error	= error+'Please Provide Valid Email.\n';
	}
	if(frm.msg.value == '')
	{
		error	= error+'Please Provide Comments.\n';
	}
	
	if(frm.jscaptchaInput.value != captcha)
	{
		error	= error+'Please Provide Valid Security Value';
	}	
	
	if(error)
	{
		alert(error);
		valid = false;	
	}
	else
	{
		valid = true;
	}
	return valid;
}
