jQuery.fn.xselect=function(i){var a={};a.elementClass="xselect";a.valueClass="xselect-value";a.expandClass="xselect-expand";a.nestClass="xselect-nest";a.listClass="xselect-list";var f={};f.elementCssMap={position:"relative"};f.valueCssMap={"white-space":"nowrap"};f.expandCssMap={position:"absolute",cursor:"pointer"};f.nestCssMap={position:"relative"};f.listCssMap={position:"absolute"};f.optionCssMap={cursor:"pointer"};f.toggleText="&#9660;";f.fadeSpeed=200;var m=this;var o=null;var h=null;var k=null;var n=null;var q=null;var e=[];var j=false;var p=function(r){f=jQuery.extend(f,r);m.hide();o=jQuery("<div />").addClass(a.elementClass).insertAfter(m);h=jQuery("<div />").addClass(a.valueClass).appendTo(o);h.find("input").click(function(){c();return false});k=jQuery("<div />").addClass(a.expandClass).html(f.toggleText).appendTo(o);k.click(function(){l();return false});n=jQuery("<div />").addClass(a.nestClass).appendTo(o);q=jQuery("<div />").addClass(a.listClass).appendTo(n).hide();var s=jQuery("<ul />").appendTo(q);m.find("option, optgroup").each(function(u){var t=jQuery("<li />").addClass("i"+(u+1));switch(true){case jQuery(this).filter("option").length>0:jQuery("<div />").addClass("option").attr("index",e.length).text(jQuery(this).text()).appendTo(t);e.push(jQuery(this));break;case jQuery(this).filter("optgroup").length>0:t.addClass("optgroup");jQuery("<div />").addClass("label").text(jQuery(this).text()).appendTo(t);break}t.appendTo(s)});q.find(".option").click(function(){b(parseInt(jQuery(this).attr("index")))});o.find("a, input").attr("focusable","1");q.add(h).add(k).attr("tabindex","-1").attr("focusable","1");o.hover(function(){jQuery(this).attr("mouseover","1")},function(){jQuery(this).attr("mouseover","0")});o.find('*[focusable="1"]').blur(function(){if(o.attr("mouseover")!=="1"){d()}});o.find('*[focusable="1"]').css("outline","none");o.css(f.elementCssMap).hover(function(){jQuery(this).addClass("hover")},function(){jQuery(this).removeClass("hover")});k.css(f.expandCssMap).hover(function(){jQuery(this).addClass("hover")},function(){jQuery(this).removeClass("hover")});n.css(f.nestCssMap).hover(function(){jQuery(this).addClass("hover")},function(){jQuery(this).removeClass("hover")});h.css(f.valueCssMap).hover(function(){jQuery(this).addClass("hover")},function(){jQuery(this).removeClass("hover")});q.css(f.listCssMap).hover(function(){jQuery(this).addClass("hover")},function(){jQuery(this).removeClass("hover")});q.find(".option").css(f.optionCssMap).hover(function(){jQuery(this).addClass("hover")},function(){jQuery(this).removeClass("hover")});g()};var l=function(){j?d():c()};var c=function(){q.animate({opacity:"show",height:"show"},{duration:f.fadeSpeed});j=true};var d=function(){q.animate({opacity:"hide",height:"hide"},{duration:f.fadeSpeed});j=false};var g=function(){b(m.find("option").index(m.find("option:selected")))};var b=function(r){var s=e[r];if(s.get(0).selected!==true){s.get(0).selected=true;m.trigger("change")}m.val(s.attr("value"));h.text(jQuery.trim(s.text()));q.find(".option.active").removeClass("active");q.find(".option").eq(r).addClass("active");d()};jQuery(document).ready(function(){p(i)})};
