$(function(){
	
	$("#rfimg").bind('click',function() {
		$.post('http://'+location.hostname+'/lib/captcha/newsession.php');
		$("#rfimg").load('http://'+location.hostname+'/lib/captcha/image_req.php');
		return false;
	});
	
	$("#captchaform").validate({
		rules: {
			captcha: {
				required: true,
				remote: "http://"+location.hostname+"/lib/captcha/process.php"
			}
		},
		messages: {
			captcha: "Correct captcha is required. Click the captcha to generate a new one"	
		},
		submitHandler: function() {
			alert("Correct captcha!");
		},
		success: function(label) {
			label.addClass("valid").text("Valid captcha!")
		},
		onkeyup: false
	});
	
});
