jQuery.fn.styledSelect=function(a){a=jQuery.extend({selectClass:"styledSelect",openSelectClass:"open",optionClass:"option",selectedOptionClass:"selected",closedOptionClass:"closed",firstOptionClass:"first",lastOptionClass:"last",zIndexApply:false,zIndexStart:250},a);var b=a.zIndexStart;this.each(function(){var h=jQuery(this);var g=jQuery("<div></div>").attr("class",a.selectClass);if(a.zIndexApply){g.css("z-index",b-2)}var d=jQuery("<ul></li>");if(a.zIndexApply){d.css("z-index",b-1)}g.append(d);h.hide(0).after(g);g=h.next();jQuery("option",h).each(function(){if(jQuery(this).attr("value")==undefined){jQuery(this).attr("value",jQuery(this).text())}});var c=function(){jQuery("ul",g).html("");f(h.val(),jQuery(":selected",h).text(),e);g.removeClass(a.openSelectClass);jQuery("ul li",g).removeClass(a.selectedOptionClass).removeClass(a.optionClass).addClass(a.closedOptionClass)};var e=function(){jQuery("ul",g).empty();jQuery("option",h).each(function(j){f(jQuery(this).val(),jQuery(this).text(),i)});g.addClass(a.openSelectClass);jQuery("ul li:first-child",g).addClass(a.firstOptionClass);jQuery("ul li:last-child",g).addClass(a.lastOptionClass)};var i=function(){var j=jQuery(this).attr("rel");h.val(j);h.trigger("change");c()};var f=function(j,m,k){var l=jQuery("<li></li>").attr("rel",j).text(m).click(k).addClass(a.optionClass);if(a.zIndexApply){l.css("z-index",b)}if(h.val()==j){l.addClass(a.selectedOptionClass)}jQuery("ul",g).append(l)};c();h.change(c);b-=3;g.click(function(j){j.stopPropagation()});$("body").click(function(j){c()})});return this};