/*
 * CAPTCHA FOR /meeting-planners/online-rfp/short-form-rfp
 */

 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_rfp_short_form").validate({
		rules: {
			captcha: {
				required: true,
                                captcha: $('#captcha').val()
			},
                        Email: { required: true, email: true },
                        Organization: { required: true, minlength: 2 },
                        DatesRequested: { required: true, minlength: 2 },
                        FirstName: { required: true, minlength: 2 },
                        LastName: { required: true, minlength: 2 },
                        RepContact: { required: true },
                        UserFile: { required: true },
                        ZipCode: { required: true, minlength: 5 }

		},
		messages: {
			captcha: "Correct captcha is required."	
		},
		onkeyup: false
	});

	
});

