﻿$.fn.extend({ "fancyvalidate": function(options) {
    var validateOptions = {
        errorPlacement: function(error, element) {
            error.appendTo(element.nextAll("div"));
        },
        highlight: function(element, errorClass) {
            $(element).nextAll("img").removeClass("conf_qstn_ok").addClass("conf_qstn_error");
            $(element).parent("div").prev("label").removeClass("conf_qstn_ok_txt").addClass("conf_qstn_error_txt");
            $(element).addClass("val_invalid");
        },
        unhighlight: function(element, errorClass) {
            $(element).nextAll("img").removeClass("conf_qstn_error").addClass("conf_qstn_ok");
            $(element).nextAll("div").hide();
            $(element).removeClass("val_invalid");
            $(element).parent("div").prev("label").addClass("conf_qstn_ok_txt").removeClass("conf_qstn_error_txt");
        }
    };
    this.validate($.extend(validateOptions, options));
    $("input:not(:button,:submit,:image,:reset), select, textarea", this).focus(function() {
        if ($(this).hasClass("val_invalid")) {
            $(this).nextAll("div").css("display", "inline");
        }
    }).blur(function() {
        $(this).nextAll("div").hide();
    });
    return this;
}
});

