this.select2=function(){var c=30;var f=-60;var b=function(n,r){var m=document.getElementById(n).orgoptions;var q=$("#"+n);var h=q.val();var p=new Array();for(i=0;i<m.length;i++){if(r==""){p.push($(m[i]).attr("outerHTML"))}else{if(m[i].tagName=="OPTGROUP"){var k=$(m[i]).children();var g=false;var o=false;if(m[i].label.indexOf(r)>=0){o=true}var l=null;if(!k){continue}for(j=0;j<k.length;j++){if(k[j].innerText.indexOf(r)>=0||o){if(!g){g=true;l=$("<optgroup> </optgroup>").attr("label",m[i].label)}if($(k[j]).attr("disabled")){continue}l.append($(k[j]).attr("outerHTML"))}}if(g){p.push($(l).attr("outerHTML"))}}else{if(m[i].innerText.indexOf(r)>=0){if($(m[i]).attr("disabled")){continue}p.push($(m[i]).attr("outerHTML"))}}}}$("#"+n).children().remove();q.append(p.join(" ")).val(h);if(q.val()==null){q.attr("selectedIndex",0)}};var a=function(g){setTimeout(function(){b(g,"");$(document.getElementById(g+"sel2outer")).remove()},100)};var e=function(h){var g=$(h).children();h.orgoptions=g.clone();$(h).after("<span class='select2' targetId='"+h.id+"'>*</span>");$(h).width($(h).width())};select2.sel2create=e;var d=0;$(".sel2sel").each(function(g){if(d<12){e(this);d++}});$(".select2").live("click",function(l){var h=this.getAttribute("targetId");var g=h+"sel2";var k=h+"sel2outer";if(document.getElementById(g)){a(h)}else{$("body").append("<div id='"+k+"' style='position:absolute;background-color:silver;'> <input size='7' name='dummy' id='"+g+"' class='sel2input' targetId='"+h+"' /><span class='select2' style='cursor:default' targetId='"+h+"'>×</span></div>");$("#"+k).css("top",(l.pageY-c)+"px").css("left",(l.pageX+f)+"px").children("input")[0].focus()}});$(".sel2input").live("change",function(h){var g=this.getAttribute("targetId");b(g,this.value)}).live("keyup",function(h){if(h.keyCode==13){var g=this.getAttribute("targetId");$(this).change();$("#"+g).focus()}})};$(document).ready(function(){select2()});