﻿(function ($) {
    $.fn.clearDefault = function () { return this.each(function () { var default_value = $(this).val(); $(this).focus(function () { if ($(this).val() == default_value) $(this).val(""); }); $(this).blur(function () { if ($(this).val() == "") $(this).val(default_value); }); }); }; $.fn.customdropdown = function () {
        return this.each(function () {
            var _this = $(this); var f = function () { var x = []; $.each(_this.find("option"), function () { x.push("<li data-ddval=" + $(this).attr('value') + ">" + $(this).text() + "</li>"); }); return x.join(""); }
            var dropdown = $('<div class="dropdownlist-wrapper ' + _this.attr("class") + '" />').append($('<div class="caption" />').text(_this.find("option:selected").text())).append($('<ul />').append(f)).insertAfter(_this); _this.hide(); dropdown.find(".caption").click(function () { $(this).next().slideToggle(200); }); dropdown.find("li").click(function () { _this.val($(this).attr("data-ddval")); dropdown.find(".caption").text(_this.find("option:selected").text()); dropdown.find("ul").slideUp(200); $("#dropdownform").submit(); });
        });
    } 
})(jQuery);
