

function check_captcha() {
	var captcha = $('input#Captcha').val();
	if (captcha == '') return false;
	
	var check = $.ajax({
		type: "POST",
		url: "/index.php",
		data: {ACT: ACT,
				type: "check_captcha",
				captcha: captcha
		},
		async: false
	}).responseText;
	
	$("#captchaSpan span").remove;
	
	if(check == "correct") {
        return true;
    } else {
		$('span#captcha_img').html(check);
        return false;
    }
	return false;
}


function remove_captcha() {
	var captcha = $('input#Captcha').val();
	var captcha_img = $('span#captcha_img').attr('src');
	$.ajax({
		type: "POST",
		url: "/index.php",
		data: {
			ACT: ACT,
			type: "remove_captcha",
			captcha: captcha,
			captcha_img: captcha_img
		},
		async: false
	});
	return;

}

function refresh_captcha() {
	//remove_captcha();
	$('#captchaSpan img').remove();
	var cimg = $.ajax({
		type: "POST",
		url: "/index.php",
		data: {ACT: CACT,
				type: "generate_captcha"
		},
		async: false
	}).responseText;
	$('span#captcha_img').html(cimg);
}

jQuery.validator.addMethod("captcha_validate", function(value, element, params) { 
 return check_captcha();
}, "Your text does not match the image. Please try again.");


