/* jQuery Nice Select - v1.0 - http://hernansartorio.github.io/jquery-nice-select */
!function(a){a.fn.niceSelect=function(){this.each(function(){var b=a(this);if(!b.next().hasClass("nice-select")){b.after('
');var c=b.next(),d=b.find("option"),e=b.find("option:selected");c.find(".current").html(e.data("display")||e.text()),d.each(function(){var b=a(this).data("display");c.find("ul").append(''+a(this).text()+"")})}}),a(document).off(".nice_select"),a(document).on("click.nice_select",".nice-select",function(b){var c=a(this);a(".nice-select").not(c).removeClass("open"),c.toggleClass("open"),c.hasClass("open")?(c.find(".option"),c.find(".focus").removeClass("focus"),c.find(".selected").addClass("focus")):c.focus()}),a(document).on("click.nice_select",function(b){0===a(b.target).closest(".nice-select").length&&a(".nice-select").removeClass("open").find(".option")}),a(document).on("click.nice_select",".nice-select .option",function(b){var c=a(this),d=c.closest(".nice-select");d.find(".selected").removeClass("selected"),c.addClass("selected");var e=c.data("display")||c.text();d.find(".current").text(e),d.prev("select").val(c.data("value")).trigger("change")}),a(document).on("keydown.nice_select",".nice-select",function(b){var c=a(this),d=a(c.find(".focus")||c.find(".list .option.selected"));if(32==b.keyCode||13==b.keyCode)return c.hasClass("open")?d.trigger("click"):c.trigger("click"),!1;if(40==b.keyCode)return c.hasClass("open")?d.next().length>0&&(c.find(".focus").removeClass("focus"),d.next().addClass("focus")):c.trigger("click"),!1;if(38==b.keyCode)return c.hasClass("open")?d.prev().length>0&&(c.find(".focus").removeClass("focus"),d.prev().addClass("focus")):c.trigger("click"),!1;if(27==b.keyCode)c.hasClass("open")&&c.trigger("click");else if(9==b.keyCode&&c.hasClass("open"))return!1})}}(jQuery);