/// My CAPTCHA checker used with formcheck.js

var protectMe = function(theForm){
	
		var formEnd = $(theForm).getElement('input[type*=submit]');
		
		var quizArray = [['Two + Three =','5'],['Five + Three = ','8'],['Seven + Four =','11'],['Six + Three =','9'],['One + Two =','3'],['Fifteen - Nine =','6'] ];
		var protector = quizArray.getRandom();
		var theQuestion;
		var theAnswer;
		protector.each(function(item, index){ if(index == 0) theQuestion = item; if(index == 1) theAnswer = item;	});
		
		var spamContent = '<div class="reg-form-field reg-form-message-subject">\n<div id="spam-info" style="padding: 0 0 10px 0;">Below is a simple check to see if you are in fact a human.  Just answer the equation with a number for example: one + one = 2.</div>\n<label id="spam-label" style="float:left; padding: 8px 10px 0px 40px;">' + theQuestion +'</label>\n<input id="spam-input" class="text_input validate[\'captcha[' + theAnswer + ',' + theAnswer + ']\',\'required\']" name="spamcheck" size="3" style="text-align:center;" />\n</div>';

		var spamDiv = new Element('div', {'styles': {'padding':'15px', width: '300px'},'html': spamContent }); 
		spamDiv.inject(formEnd, 'before');

		var myCheck = new FormCheck(theForm, {
			display : {	showErrors: 1,	indicateErrors: 1 },
			alerts : { required: 'You have to fill this one in...', captcha: 'Come on. Prove you\'re human. What is  ' +theQuestion+ ' ?' }
		});
			
};


