/*
 * CAPTCHA FOR /explore-oc/photos
 */

 jQuery.validator.addMethod("captcha",
                              function (value)
                              {
                                 var AjaxTmp = $.ajax({
                                                       type: "GET",
                                                       url: 'http://ococean.com/assets/js/jquery-validate/captcha/process.php?captcha=' + value,
                                                       async : false
                                 });

                                 if (AjaxTmp.responseText == "true")
                                    return true;
                                 else
                                    return false;
                                 }, "Invalid Captcha.");


$(function(){

	$("#refreshimg").click(function(){
	$.post('newsession.php');
		$("#captchaimage").load('image_req.php');
		return false;
	});
	

// CHANGE THIS LINE TO WHATEVER THE CURRENT FORM ID IS ( found in site/forms/XXX.tpl2 )
	$("#data_form_uploadphoto_request_form").validate({
		rules: {
                        captcha: {
                                required: true,
                                captcha: $('#captcha').val()
                        },
                        Email: { required: true, email: true },
		        TermsAndConditions: {required: true}
               	},
                messages: {
			captcha: "Correct captcha is required."	
		},
		onkeyup: false
	});

	
});
