(function(b){var a="";b.fn.dd=function(k){$this=this;k=b.extend({height:120,visibleRows:7,rowHeight:23,showIcon:true,zIndex:9999,style:""},k);var r="";var o={};o.insideWindow=true;o.keyboardAction=false;o.currentKey=null;var F=false;config={postElementHolder:"_msddHolder",postID:"_msdd",postTitleID:"_title",postTitleTextID:"_titletext",postChildID:"_child",postAID:"_msa",postOPTAID:"_msopta",postInputID:"_msinput",postArrowID:"_arrow",postInputhidden:"_inp"};styles={dd:"dd",ddTitle:"ddTitle",arrow:"regionselector_arrow",ddChild:"ddChild",disbaled:0.3};attributes={actions:"onfocus,onblur,onchange,onclick,ondblclick,onmousedown,onmouseup,onmouseover,onmousemove,onmouseout,onkeypress,onkeydown,onkeyup",prop:"size,multiple,disabled,tabindex"};var n=b(this).attr("id");var A=b(this).attr("style");k.style+=(A==undefined)?"":A;var l=b(this).children();F=(b(this).attr("size")>0||b(this).attr("multiple")==true)?true:false;if(F){k.visibleRows=b(this).attr("size")}var u={};e();function D(G){return n+config[G]}function x(H){var G=H;var I=b(G).attr("style");return I}function h(H){var G=b("#"+n+" option:selected");if(G.length>1){for(var I=0;I<G.length;I++){if(H==G[I].index){return true}}}else{if(G.length==1){if(G[0].index==H){return true}}}return false}function c(){var H=l;var G="";var I=D("postAID");var J=D("postOPTAID");H.each(function(O){var Q=H[O];if(Q.nodeName=="OPTGROUP"){G+="<div class='opta'>";G+="<span style='font-weight:bold;font-style:italic; clear:both;'>"+b(Q).attr("label")+"</span>";var M=b(Q).children();M.each(function(V){var X=M[V];var Z=J+"_"+(O)+"_"+(V);var Y=b(X).attr("title");Y=(Y.length==0)?"":'<img src="'+Y+'" align="left" /> ';var W=b(X).text();var aa=b(X).val();var U=(b(X).attr("disabled")==true)?"disabled":"enabled";u[Z]={html:Y+W,value:aa,text:W,index:X.index,id:Z};var T=x(X);if(h(X.index)==true){G+='<a href="javascript:void(0);" class="selected '+U+'"'}else{G+='<a  href="javascript:void(0);" class="'+U+'"'}if(T!=false){G+=' style="'+T+'"'}G+=' id="'+Z+'">';G+=Y+W+"</a>"});G+="</div>"}else{var K=I+"_"+(O);var R=b(Q).attr("title");R=(R.length==0)?"":'<img src="'+R+'" align="left" /> ';var L=b(Q).text();var S=b(Q).val();var N=(b(Q).attr("disabled")==true)?"disabled":"enabled";u[K]={html:R+L,value:S,text:L,index:Q.index,id:K};var P=x(Q);if(h(Q.index)==true){G+='<a href="javascript:void(0);" class="selected '+N+'"'}else{G+='<a  href="javascript:void(0);" class="'+N+'"'}if(P!=false){G+=' style="'+P+'"'}G+=' id="'+K+'">';G+=R+L+"</a>"}});return G}function d(){var I=D("postID");var G=D("postChildID");var H=k.style;sDiv="";sDiv+='<div id="'+G+'" class="'+styles.ddChild+'"';if(!F){sDiv+=(H!="")?' style="'+H+'"':""}else{sDiv+=(H!="")?' style="border-top:1px solid #c3c3c3;display:block;position:relative;'+H+'"':""}sDiv+=">";return sDiv}function p(){var K=D("postTitleID");var I=D("postArrowID");var M=D("postTitleTextID");var J=D("postInputhidden");var H=b("#"+n+" option:selected").text();var L=b("#"+n+" option:selected").attr("title");L=(L.length==0||L==undefined||k.showIcon==false)?"":'<img src="'+L+'" align="left" /> ';var G='<div id="'+K+'" class="'+styles.ddTitle+'"';G+=">";G+='<span id="'+I+'" class="'+styles.arrow+'"></span><span class="textTitle" id="'+M+'">'+L+H+"</span></div>";return G}function e(){var P=false;var J=D("postID");var R=D("postTitleID");var M=D("postTitleTextID");var N=D("postChildID");var Q=D("postArrowID");var L=b("#"+n).width();var K=k.style;if(b("#"+J).length>0){b("#"+J).remove();P=true}var I='<div id="'+J+'" class="'+styles.dd+'"';I+=(K!="")?' style="'+K+'"':"";I+=">";if(!F){I+=p()}I+=d();I+=c();I+="</div>";I+="</div>";if(P==true){var H=D("postElementHolder");b("#"+H).after(I)}else{b("#"+n).after(I)}b("#"+J).css("width",48+"px");b("#"+N).css("width",(46)+"px");if(l.length>k.visibleRows){var O=parseInt(b("#"+N+" a:first").css("padding-bottom"))+parseInt(b("#"+N+" a:first").css("padding-top"));var G=((k.rowHeight)*k.visibleRows)-O;b("#"+N).css("height",G+"px")}if(P==false){B();j(n)}if(b("#"+n).attr("disabled")==true){b("#"+J).css("opacity",styles.disbaled)}else{s();if(!F){b("#"+R).bind("mouseover",function(S){v(1)});b("#"+R).bind("mouseout",function(S){v(0)})}b("#"+N+" a.enabled").bind("click",function(T){T.preventDefault();q(this);if(!F){b("#"+N).unbind("mouseover");f(false);var S=(k.showIcon==false)?b(this).text():b(this).html();z(S);E()}g()});b("#"+N+" a.disabled").css("opacity",styles.disbaled);if(F){b("#"+N).bind("mouseover",function(S){if(!o.keyboardAction){o.keyboardAction=true;b(document).bind("keydown",function(T){var U=T.keyCode;o.currentKey=U;if(U==39||U==40){T.preventDefault();T.stopPropagation();t();g()}if(U==37||U==38){T.preventDefault();T.stopPropagation();i();g()}})}})}b("#"+N).bind("mouseout",function(S){f(false);b(document).unbind("keydown");o.keyboardAction=false;o.currentKey=null});if(!F){b("#"+R).bind("click",function(S){f(false);if(b("#"+N+":visible").length==1){b("#"+N).unbind("mouseover")}else{b("#"+N).bind("mouseover",function(T){f(true)});w()}})}b("#"+R).bind("mouseout",function(S){f(false)})}}function C(G){for(var H in u){if(u[H].index==G){return u[H]}}}function q(M){var K=D("postChildID");if(!F){b("#"+K+" a.selected").removeClass("selected")}var G=b("#"+K+" a.selected").attr("id");if(G!=undefined){var N=(o.oldIndex==undefined||o.oldIndex==null)?u[G].index:o.oldIndex}if(M&&!F){b(M).addClass("selected")}if(F){var L=o.currentKey;if(b("#"+n).attr("multiple")==true){if(L==17){o.oldIndex=u[b(M).attr("id")].index;b(M).toggleClass("selected")}else{if(L==16){b("#"+K+" a.selected").removeClass("selected");b(M).addClass("selected");var I=b(M).attr("id");var H=u[I].index;for(var J=Math.min(N,H);J<=Math.max(N,H);J++){b("#"+C(J).id).addClass("selected")}}else{b("#"+K+" a.selected").removeClass("selected");b(M).addClass("selected");o.oldIndex=u[b(M).attr("id")].index}}}else{b("#"+K+" a.selected").removeClass("selected");b(M).addClass("selected");o.oldIndex=u[b(M).attr("id")].index}}}function j(G){document.getElementById(G).refresh=function(H){b("#"+this.id).dd(k)}}function f(G){o.insideWindow=G}function m(){return o.insideWindow}function s(){var G=D("postID");var H=attributes.actions.split(",");for(var K=0;K<H.length;K++){var I=H[K];var J=b("#"+n).attr(I);if(J!=undefined){switch(I){case"onfocus":b("#"+G).bind("mouseenter",function(L){document.getElementById(n).focus()});break;case"onclick":b("#"+G).bind("click",function(L){document.getElementById(n).onclick()});break;case"ondblclick":b("#"+G).bind("dblclick",function(L){document.getElementById(n).ondblclick()});break;case"onmousedown":b("#"+G).bind("mousedown",function(L){document.getElementById(n).onmousedown()});break;case"onmouseup":b("#"+G).bind("mouseup",function(L){document.getElementById(n).onmouseup()});break;case"onmouseover":b("#"+G).bind("mouseover",function(L){document.getElementById(n).onmouseover()});break;case"onmousemove":b("#"+G).bind("mousemove",function(L){document.getElementById(n).onmousemove()});break;case"onmouseout":b("#"+G).bind("mouseout",function(L){document.getElementById(n).onmouseout()});break}}}}function B(){var G=D("postElementHolder");b("#"+n).after("<div style='height:0px;overflow:hidden;position:absolute;' id='"+G+"'></div>");b("#"+n).appendTo(b("#"+G))}function z(G){var H=D("postTitleTextID");b("#"+H).html(G)}function t(){var L=D("postTitleTextID");var K=D("postChildID");var J=b("#"+K+" a.enabled");for(var M=0;M<J.length;M++){var I=J[M];var N=b(I).attr("id");if(b(I).hasClass("selected")&&M<J.length-1){b("#"+K+" a.selected").removeClass("selected");b(J[M+1]).addClass("selected");var G=b("#"+K+" a.selected").attr("id");if(!F){var H=(k.showIcon==false)?u[G].text:u[G].html;z(H)}if(parseInt((b("#"+G).position().top+b("#"+G).height()))>=parseInt(b("#"+K).height())){b("#"+K).scrollTop((b("#"+K).scrollTop())+b("#"+G).height()+b("#"+G).height())}break}}}function i(){var L=D("postTitleTextID");var K=D("postChildID");var J=b("#"+K+" a.enabled");for(var M=0;M<J.length;M++){var I=J[M];var N=b(I).attr("id");if(b(I).hasClass("selected")&&M!=0){b("#"+K+" a.selected").removeClass("selected");b(J[M-1]).addClass("selected");var G=b("#"+K+" a.selected").attr("id");if(!F){var H=(k.showIcon==false)?u[G].text:u[G].html;z(H)}if(parseInt((b("#"+G).position().top+b("#"+G).height()))<=0){b("#"+K).scrollTop((b("#"+K).scrollTop()-b("#"+K).height())-b("#"+G).height())}break}}}function g(){var M=D("postChildID");var H=b("#"+M+" a.selected");if(H.length==1){var J=b("#"+M+" a.selected").text();var G=b("#"+M+" a.selected").attr("id");if(G!=undefined){var N=u[G].value;document.getElementById(n).selectedIndex=u[G].index}}else{if(H.length>1){var L=b("#"+n+" > option:selected").removeAttr("selected");for(var K=0;K<H.length;K++){var G=b(H[K]).attr("id");var I=u[G].index;document.getElementById(n).options[I].selected="selected"}}}}function w(){var G=D("postChildID");if(a!=""&&G!=a){b("#"+a).slideUp("fast");b("#"+a).css({zIndex:"0"})}if(b("#"+G).css("display")=="none"){r=u[b("#"+G+" a.selected").attr("id")].text;b(document).bind("keydown",function(H){var I=H.keyCode;if(I==39||I==40){H.preventDefault();H.stopPropagation();t()}if(I==37||I==38){H.preventDefault();H.stopPropagation();i()}if(I==27||I==13){E();g()}if(b("#"+n).attr("onkeydown")!=undefined){document.getElementById(n).onkeydown()}});b(document).bind("keyup",function(H){if(b("#"+n).attr("onkeyup")!=undefined){document.getElementById(n).onkeyup()}});b(document).bind("mouseup",function(H){if(m()==false){E()}});b("#"+G).css({zIndex:k.zIndex});b("#"+G).slideDown("fast");if(G!=a){a=G}}}function E(){var G=D("postChildID");b(document).unbind("keydown");b(document).unbind("keyup");b(document).unbind("mouseup");b("#"+G).slideUp("fast",function(H){y();b("#"+G).css({zIndex:"0"})})}function y(){var H=D("postChildID");if(b("#"+n).attr("onchange")!=undefined){var G=u[b("#"+H+" a.selected").attr("id")].text;if(r!=G){document.getElementById(n).onchange()}}if(b("#"+n).attr("onmouseup")!=undefined){document.getElementById(n).onmouseup()}if(b("#"+n).attr("onblur")!=undefined){b(document).bind("mouseup",function(I){b("#"+n).focus();b("#"+n)[0].blur();g();b(document).unbind("mouseup")})}}function v(H){var G=D("postArrowID");if(H==1){b("#"+G).css({backgroundPosition:"0 100%"})}else{b("#"+G).css({backgroundPosition:"0 0"})}}};b.fn.msDropDown=function(d){var c=b(this);for(var e=0;e<c.length;e++){var f=b(c[e]).attr("id");if(d==undefined){b("#"+f).dd()}else{b("#"+f).dd(d)}}}})(jQuery);