if(jQuery){(function(b){b.extend(b.fn,{multiSelect:function(a,d){if(!a){var a={}}if(a.selectAll==undefined){a.selectAll=true}if(a.selectAllText==undefined){a.selectAllText="Select All"}if(a.noneSelected==undefined){a.noneSelected="Select options"}if(a.oneOrMoreSelected==undefined){a.oneOrMoreSelected=a.SelectedTextValue+": %"}if(a.CountValueField==undefined){a.CountValueField="NoSelected"}b(this).each(function(){var g=b(this);var c='<input type="text" readonly="readonly" class="multiSelect" value="" style="cursor: default;" />';c+='<div class="multiSelectOptions" style="position: absolute; z-index: 99999; display: none;">';if(a.selectAll){c+='<label class="selectAll"><input type="checkbox" class="selectAll" />'+a.selectAllText+"</label>"}b(g).find("OPTION").each(function(){if(b(this).val()!=""){c+='<label><input type="checkbox" name="'+b(g).attr("name")+'" value="'+b(this).val()+'"';if(b(this).attr("selected")){c+=' checked="checked"'}c+=" />"+b(this).html()+"</label>"}});c+="</div>";b(g).after(c);b(g).next(".multiSelect").mouseover(function(){b(this).addClass("hover")}).mouseout(function(){b(this).removeClass("hover")}).click(function(){if(b(this).hasClass("active")){b(this).multiSelectOptionsHide()}else{b(this).multiSelectOptionsShow()}return false}).focus(function(){b(this).addClass("focus")}).blur(function(){b(this).removeClass("focus")});if(a.selectAll){var h=true;b(g).next(".multiSelect").next(".multiSelectOptions").find("INPUT:checkbox").not(".selectAll").each(function(){if(!b(this).attr("checked")){h=false}});if(h){b(g).next(".multiSelect").next(".multiSelectOptions").find("INPUT.selectAll").attr("checked",true).parent().addClass("checked")}}b(g).next(".multiSelect").next(".multiSelectOptions").find("INPUT.selectAll").click(function(){if(b(this).attr("checked")==true){b(this).parent().parent().find("INPUT:checkbox").attr("checked",true).parent().addClass("checked")}else{b(this).parent().parent().find("INPUT:checkbox").attr("checked",false).parent().removeClass("checked")}});b(g).next(".multiSelect").next(".multiSelectOptions").find("INPUT:checkbox").click(function(){b(this).parent().parent().multiSelectUpdateSelected(a);b(this).parent().parent().find("LABEL").removeClass("checked").find("INPUT:checked").parent().addClass("checked");b(this).parent().parent().prev(".multiSelect").focus();if(!b(this).attr("checked")){b(this).parent().parent().find("INPUT:checkbox.selectAll").attr("checked",false).parent().removeClass("checked")}if(d){d(b(this))}});b(g).next(".multiSelect").next(".multiSelectOptions").each(function(){b(this).multiSelectUpdateSelected(a);b(this).find("INPUT:checked").parent().addClass("checked")});b(g).next(".multiSelect").next(".multiSelectOptions").find("LABEL").mouseover(function(){b(this).parent().find("LABEL").removeClass("hover");b(this).addClass("hover")}).mouseout(function(){b(this).parent().find("LABEL").removeClass("hover")});b(g).next(".multiSelect").keydown(function(e){if(b(this).next(".multiSelectOptions").is(":visible")){if(e.keyCode==9){b(this).addClass("focus").trigger("click");b(this).focus().next(":input").focus();return true}if(e.keyCode==27||e.keyCode==37||e.keyCode==39){b(this).addClass("focus").trigger("click")}if(e.keyCode==40){if(!b(this).next(".multiSelectOptions").find("LABEL").hasClass("hover")){b(this).next(".multiSelectOptions").find("LABEL:first").addClass("hover")}else{b(this).next(".multiSelectOptions").find("LABEL.hover").removeClass("hover").next("LABEL").addClass("hover");if(!b(this).next(".multiSelectOptions").find("LABEL").hasClass("hover")){b(this).next(".multiSelectOptions").find("LABEL:first").addClass("hover")}}b(this).multiSelectAdjustViewport(b(this));return false}if(e.keyCode==38){if(!b(this).next(".multiSelectOptions").find("LABEL").hasClass("hover")){b(this).next(".multiSelectOptions").find("LABEL:first").addClass("hover")}else{b(this).next(".multiSelectOptions").find("LABEL.hover").removeClass("hover").prev("LABEL").addClass("hover");if(!b(this).next(".multiSelectOptions").find("LABEL").hasClass("hover")){b(this).next(".multiSelectOptions").find("LABEL:last").addClass("hover")}}b(this).multiSelectAdjustViewport(b(this));return false}if(e.keyCode==13||e.keyCode==32){if(b(this).next(".multiSelectOptions").find("LABEL.hover INPUT:checkbox").hasClass("selectAll")){if(b(this).next(".multiSelectOptions").find("LABEL.hover INPUT:checkbox").attr("checked")){b(this).next(".multiSelectOptions").find("INPUT:checkbox").attr("checked",false).parent().removeClass("checked")}else{b(this).next(".multiSelectOptions").find("INPUT:checkbox").attr("checked",true).parent().addClass("checked")}b(this).next(".multiSelectOptions").multiSelectUpdateSelected(a);if(d){d(b(this))}return false}if(b(this).next(".multiSelectOptions").find("LABEL.hover INPUT:checkbox").attr("checked")){b(this).next(".multiSelectOptions").find("LABEL.hover INPUT:checkbox").attr("checked",false);b(this).next(".multiSelectOptions").multiSelectUpdateSelected(a);b(this).next(".multiSelectOptions").find("LABEL").removeClass("checked").find("INPUT:checked").parent().addClass("checked");b(this).next(".multiSelectOptions").find("INPUT:checkbox.selectAll").attr("checked",false).parent().removeClass("checked");if(d){d(b(this))}}else{b(this).next(".multiSelectOptions").find("LABEL.hover INPUT:checkbox").attr("checked",true);b(this).next(".multiSelectOptions").multiSelectUpdateSelected(a);b(this).next(".multiSelectOptions").find("LABEL").removeClass("checked").find("INPUT:checked").parent().addClass("checked");if(d){d(b(this))}}}return false}else{if(e.keyCode==38||e.keyCode==40||e.keyCode==13||e.keyCode==32){b(this).removeClass("focus").trigger("click");b(this).next(".multiSelectOptions").find("LABEL:first").addClass("hover");return false}if(e.keyCode==9){b(this).focus().next(":input").focus();return true}}if(e.keyCode==13){return false}});if(b.fn.bgiframe){b(g).next(".multiSelect").next(".multiSelectOptions").bgiframe()}b(g).remove()})},multiSelectOptionsHide:function(){b(this).removeClass("active").next(".multiSelectOptions").hide()},multiSelectOptionsShow:function(){b(".multiSelect").multiSelectOptionsHide();b(this).next(".multiSelectOptions").find("LABEL").removeClass("hover");b(this).addClass("active").next(".multiSelectOptions").show();var f=b(this).position();b(this).next(".multiSelectOptions").css({top:f.top+b(this).outerHeight()+"px"});b(this).next(".multiSelectOptions").css({left:f.left+"px"});if(b.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var a=0;b(this).next(".multiSelectOptions").children().each(function(){a+=this.offsetHeight});if(a>200){b(this).next(".multiSelectOptions").css({height:"200px"})}}multiSelectCurrent=b(this);var e="";b(this).next(".multiSelectOptions").hover(function(){clearTimeout(e)},function(){e=setTimeout('jQuery(multiSelectCurrent).multiSelectOptionsHide(); $(multiSelectCurrent).unbind("hover");',250)})},multiSelectUpdateSelected:function(f){var a=0,h="";b(this).find("INPUT:checkbox:checked").not(".selectAll").each(function(){a++});if(a==0){b(this).prev("INPUT.multiSelect").val(f.noneSelected)}else{if(f.oneOrMoreSelected=="*"){var g="";b(this).find("INPUT:checkbox:checked").each(function(){if(b(this).parent().text()!=f.selectAllText){g=g+b(this).parent().text()+", "}});g=g.substr(0,g.length-2);b(this).prev("INPUT.multiSelect").val(g)}else{b(this).prev("INPUT.multiSelect").val(f.oneOrMoreSelected.replace("%",a));b("#"+f.CountValueField).val(a)}}},multiSelectAdjustViewport:function(h){var i=0;var j=0,a=0;b(h).next(".multiSelectOptions").find("LABEL").each(function(){if(b(this).hasClass("hover")){j=i;a=b(this).outerHeight();return}i+=b(this).outerHeight()});var k=b(h).next(".multiSelectOptions").scrollTop();var l=b(h).next(".multiSelectOptions").height();b(h).next(".multiSelectOptions").scrollTop(j-((l/2)-(a/2)))}})})(jQuery)};