/*
 * CAPTCHA FOR /feedback
 */

 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('images/image.php');
		return false;
	});
*/	

// CHANGE THIS LINE TO WHATEVER THE CURRENT FORM ID IS ( found in site/forms/XXX.tpl2 )
	$("#data_form_register_travel_planner_form").validate({
		rules: {
			captcha: {
				required: true,
                captcha: $('#captcha').val()
			},
            Email: { required: true, email: true },
            FirstName: { required: true, minlength: 2 },
            ZipCode: { required: true, minlength: 5 },
            Password: {required: true, minlength: 5},
            PasswordConfirm: {equalTo: "#Password", required:true, minlength:5},
            TermsAndConditions: {required: true}

		},
		messages: {
			captcha: "Correct captcha is required.",
			TermsAndConditions: "You must agree to the Term and Conditions to register."	
		},
		onkeyup: false
	});

	
});

