jQuery.fn.selectToUISlider=function(a){function b(a){return a.constructor==Array}function c(a){return"text"==f.tooltipSrc?h[a].text:h[a].value}function d(a){return(a/(h.length-1)*100).toFixed(2)+"%"}var e=jQuery(this),f=jQuery.extend({"labels":3,"tooltip":!0,"tooltipSrc":"text","labelSrc":"value","sliderOptions":null},a),g=function(){var a=[];return e.each(function(){a.push("handle_"+jQuery(this).attr("id"))}),a}(),h=function(){var a=[];return e.eq(0).find("option").each(function(){a.push({"value":jQuery(this).attr("value"),"text":jQuery(this).text()})}),a}(),i=function(){if(e.eq(0).find("optgroup").size()>0){var a=[];return e.eq(0).find("optgroup").each(function(b){a[b]={},a[b].label=jQuery(this).attr("label"),a[b].options=[],jQuery(this).find("option").each(function(){a[b].options.push({"text":jQuery(this).text(),"value":jQuery(this).attr("value")})})}),a}return null}(),j={"step":1,"min":0,"orientation":"horizontal","max":h.length-1,"range":e.length>1,"slide":function(a,b){var d=jQuery(b.handle),e=c(b.value);d.attr("aria-valuetext",e).attr("aria-valuenow",b.value).find(".ui-slider-tooltip .ttContent").text(e);var f=jQuery("#"+d.attr("id").split("handle_")[1]);f.find("option").eq(b.value).attr("selected","selected")},"values":function(){var a=[];return e.each(function(){a.push(jQuery(this).get(0).selectedIndex)}),a}()};f.sliderOptions=a?jQuery.extend(j,a.sliderOptions):j,e.bind("change keyup click",function(){var a=jQuery(this).get(0).selectedIndex,b=jQuery("#handle_"+jQuery(this).attr("id")),c=b.data("handleNum");b.parents(".ui-slider:eq(0)").slider("values",c,a)});var k=jQuery("
");if(e.each(function(a){var b="",d=jQuery("label[for="+jQuery(this).attr("id")+"]"),e=d.size()>0?"Slider control for "+d.text():"",h=d.attr("id")||d.attr("id","label_"+g[a]).attr("id");0==f.tooltip&&(b=' style="display: none;"'),jQuery(''+e+' ').data("handleNum",a).appendTo(k)}),i){var l=0,m=k.append(' ').find(".ui-slider-scale:eq(0)");jQuery(i).each(function(a){m.append('