LI.define("StyledDropdown");
LI.StyledDropdown=function(B,c){function C(){var a,b,g=d.options,c=f.firstChild,h=0,r;if(!D){YAHOO.env.ua.ie&&7>YAHOO.env.ua.ie&&(s=document.createElement("iframe"),s.src="javascript:false;",e.appendChild(s));p=d.options.length;for(h=0;h<p;h++)a=g[h],b=document.createElement("li"),b.innerHTML="\x3cdiv\x3e"+LI.htmlEncode(a.text)+"\x3c/div\x3e",YDom.addClass(b,a.className+" option"),a.selected&&0===k&&(l.innerHTML=LI.htmlEncode(a.text),x=k=h),0===h?YDom.addClass(b,"first"):h+1===r&&YDom.addClass(b,
"last"),c?f.insertBefore(b,c):f.appendChild(b);m=f.getElementsByTagName("li");h=0;for(r=m.length;h<r;h++)m[h]._index=h;D=!0}}c={name:c.name||null,autoPosition:!1===c.autoPosition?!1:!0,align:c.align?c.align:"left",containerClass:c.containerClass?c.containerClass:"styled-dropdown",listClass:c.listClass?c.listClass:null,normalLinkClass:c.normalLinkClass?c.normalLinkClass:"normal-link",openOnHover:c.openOnHover?c.openOnHover:!1,stickyLabel:c.stickyLabel?c.stickyLabel:!1,applyOptionClassToLabel:c.applyOptionClassToLabel?
c.applyOptionClassToLabel:!1};var e=B,d=null,f=null,m=[],l=null,s=null,D=!1,k=0,E=-1,x=0,p=0,u=!1,v=null,q=null,w,y,z,n,t,A,d=Y$("select",e,!0),l=Y$("span.label",e,!0),f=Y$("ul",e,!0);f||(f=document.createElement("ul"),e.appendChild(f));l||(q=c.applyOptionClassToLabel?['\x3cspan class\x3d"label"\x3e\x3cspan class\x3d"',d.options[d.selectedIndex].className,'"\x3e',d.options[d.selectedIndex].text,"\x3c/span\x3e\x3c/span\x3e"].join(""):['\x3cspan class\x3d"label"\x3e\x3cspan\x3e',d.options[d.selectedIndex].text,
"\x3c/span\x3e\x3c/span\x3e"].join(""),q=LI.domify(q),e.insertBefore(q,d));l=Y$("span.label span",e,!0);YDom.addClass(e,c.containerClass);YDom.addClass(f,c.listClass);A=function(){if(!u){var a=YDom.getRegion(f),b=YDom.getRegion(l.parentNode),g,b="right"===c.align?[b.right-f.clientWidth,b.bottom]:[b.left,b.bottom];YDom.addClass(e,"open");c.autoPosition&&YDom.setXY(f,b);YAHOO.env.ua.ie&&7>YAHOO.env.ua.ie&&(a&&(s.style.height=a.height+"px",s.style.width=a.width+"px"),YDom.setXY(s,YDom.getXY(f)));a=YDom.getElementsByClassName("highlighted",
"li",f);b=0;for(g=a.length;b<g;b++)YDom.removeClass(a[b],"highlighted");YDom.addClass(m[d.selectedIndex],"highlighted")}};n=function(){YDom.removeClass(e,"open")};t=function(a){a=a||window.event;var b=d.selectedIndex,c=a.keyCode,e,h,r;e=YDom.getElementsByClassName("selected","li",f);h=0;for(r=e.length;h<r;h++)YDom.removeClass(e[h],"selected");"keydown"===a.type&&(13===c?b=k:40===c&&k>=p-1?b=k+1:38===c&&k>=p&&(b=k-1,d.selectedIndex=p-1));m[b]||(b=k);YDom.addClass(m[b],"selected");k=b;A();"blur"!==
a.type&&w(a)};z=function(){if(!YDom.hasClass(e,"open")&&!c.stickyLabel){l.innerHTML=d.options[d.selectedIndex].text;for(var a=l.className.split(" "),b=a.length,g=0;g<b;g++)0===a[g].indexOf("styled-dropdown-select-")&&YDom.removeClass(l,a[g]);YDom.addClass(l,"styled-dropdown-select-"+d.options[d.selectedIndex].getAttribute("data-li-styled-dropdown-class"))}};w=function(a){a=a||window.event;var b=a.keyCode,g=YEvent.getTarget(a);if("mousedown"===a.type&&(YDom.hasClass(g.parentNode,"disabled")||YDom.hasClass(g,
"disabled")))YEvent.stopEvent(a);else if(YDom.hasClass(g,c.normalLinkClass))n(),g.href&&(g.target?window.open(g.href,g.target).focus():window.location=g.href);else{if(27===b||"blur"===a.type&&k>=p)n(),d.selectedIndex=x;else if("blur"===a.type&&E!==k)y(k);else if(13===b||"mousedown"===a.type){YEvent.stopEvent(a);if("mousedown"===a.type&&YDom.getAncestorByClassName(g,c.containerClass)&&!YDom.hasClass("label")&&!YDom.getAncestorByClassName(g,"label")){if("LI"!==g.nodeName&&(g=YDom.getAncestorByTagName(g,
"li"),!g))return;k=g._index;k<p&&(d.selectedIndex=k)}if(YDom.hasClass(g,"option")||13===b)y(k),LI.Events.fire("focusInputEvent"),n()}z()}};y=function(a){var b;if(a>=p){if(d.selectedIndex=x,b=LI.StyledDropdown.itemSelectEvent.fire(c.name,m[a]),LI.Events&&LI.Events.fire("itemSelectEvent",{name:c.name,option:m[a]}),!1!==b&&(b=Y$("div \x3e a",m[a]),1===b.length)){if(b[0].target)return a=window.open(b[0].href,b[0].target),a.focus(),n(),d.blur(),!1;document.location.href=b[0].href}}else x=a,LI.StyledDropdown.itemSelectEvent.fire(c.name,
d.options[a]),LI.Events&&LI.Events.fire("itemSelectEvent",{name:c.name,option:d.options[a]});E=a;n();d.blur()};q=function(a){a=a||window.event;var b=YEvent.getTarget(a),d=YDom.getElementsByClassName("highlighted","li",f),e,h;e=0;for(h=d.length;e<h;e++)YDom.removeClass(d[e],"highlighted");"mouseover"===a.type&&YDom.getAncestorByClassName(b,c.containerClass)&&("LI"!==b.nodeName&&(b=YDom.getAncestorByTagName(b,"li")),YDom.addClass(b,"highlighted"))};this.disableDropdown=function(){u||(u=!0,YDom.addClass(B,
"disabled"))};this.enableDropdown=function(){u&&(u=!1,YDom.removeClass(B,"disabled"))};this.getSelectedValue=function(){return d.options[d.selectedIndex].value};this.setSelectedValue=function(a,b){C();var c=d.options,e=c.length,h,f;for(f=0;f<e;f++)if(h=c[f],a===h.value){h.selected=!0;b||y(f);YDom.addClass(m[f],"highlighted");l.innerHTML=d.options[d.selectedIndex].text;k=f;z();return}throw a+" is not a valid value.";};YEvent.on(d,"focus",function(a){C();YDom.hasClass(e,"open")||(A(),t(a))});c.stickyLabel||
(YEvent.on(d,"blur",function(a){w(a);n()}),YEvent.on(e,"focus",t),YEvent.on(e,"blur",n));YEvent.on(d,"keydown",t);c.openOnHover&&(YEvent.on(l,"mouseover",function(){d.focus()}),YEvent.on(e,"mouseover",function(){v&&window.clearTimeout(v)}),YEvent.on(e,"mouseout",function(){YDom.hasClass(e,"open")?v=window.setTimeout(function(){d.blur()},250):v&&window.clearTimeout(v)}));YEvent.on(l,"mousedown",function(a){YDom.hasClass(e,"open")?(n(),w(a),d.blur()):(C(),A(),t(a),d.focus())});YEvent.on(d,"change",
t);YEvent.on(f,"mouseover",q);YEvent.on(f,"mouseout",q);YEvent.on(f,"mousedown",w);z();LI.StyledDropdown.loadEvent.fire(c.name);LI.StyledDropdown.itemSelectEvent.fire(c.name,d.options[d.selectedIndex]);LI.Events&&LI.Events.fire("itemSelectEvent",{name:c.name,option:d.options[d.selectedIndex]})};LI.StyledDropdown.loadEvent=new YAHOO.util.CustomEvent("load");LI.StyledDropdown.itemSelectEvent=new YAHOO.util.CustomEvent("itemSelect");LI.define("GhostLabel");
LI.GhostLabel=function(c,b){var a=YDom.get(c.htmlFor),e=a.type,d,g,f=!!("placeholder"in document.createElement("input")&&"placeholder"in document.createElement("textarea")),m=this;b=b||{};b={placeholder:YAHOO&&YAHOO.lang&&YAHOO.lang.trim?YAHOO.lang.trim(b.placeholder||c.firstChild.nodeValue):b.placeholder||c.firstChild.nodeValue,showLabel:b.showLabel||!1,isDefault:b.isDefault||!1};f&&a.setAttribute("placeholder",b.placeholder);var k=function(){!f&&b.placeholder&&""===a.value&&("password"===e&&(d||
(d=document.createElement("input"),d.type="text",d.value=b.placeholder,YDom.addClass(d,"hint"),YDom.addClass(d,"clone-hint"),YDom.addClass(d,YDom.getAttribute(a,"class")),d.setAttribute("tabindex",a.getAttribute("tabindex")),YDom.insertAfter(d,a),g=!0,YEvent.on(d,"focus",h)),g||(YDom.removeClass(d,"ghost-hide"),YDom.removeClass(a,"ghost-show")),YDom.addClass(d,"ghost-show"),YDom.addClass(a,"ghost-hide"),g=!0),YDom.addClass(a,"hint"),"password"!==e&&(a.value=b.placeholder))},h=function(){f||!b.placeholder||
"password"!==e&&a.value!==b.placeholder||!YDom.hasClass(a,"hint")||(d&&"password"===e&&(g&&(YDom.removeClass(d,"ghost-show"),YDom.removeClass(a,"ghost-hide")),YDom.addClass(d,"ghost-hide"),YDom.addClass(a,"ghost-show"),g=!1,a.focus()),"password"!==e&&(a.value=""),YDom.removeClass(a,"hint"))},l=function(){if(f){if(""===a.value)return!0}else if(YDom.hasClass(a,"hint"))return!0;return!1},n=function(){b.isDefault?""===a.value&&(a.value=b.placeholder):h()};(function(){var d=a.form;b.showLabel||LI.hide(c);
if(!f){if("password"!==e)YEvent.on(a,"focus",h);YEvent.on(a,"blur",k);b.placeholder&&a.value===b.placeholder&&(a.value="",YDom.removeClass(a,"hint"));k()}if(d)YEvent.on(d,"submit",n);d&&d.id&&a.id&&LI.GhostLabel.Manager.register(d.id,a.id,m)})();this.showGhostLabel=k;this.hideGhostLabel=h;this.setLabel=function(a){b.placeholder=a};this.getLabel=function(){return b.placeholder};this.updateLabel=function(c){f?a.setAttribute("placeholder",b.placeholder):c?l()&&(a.value=b.placeholder):(a.value=b.placeholder,
YDom.addClass(a,"hint"))};this.isGhostLabelVisible=l};
LI.GhostLabel.Manager={registry:{},register:function(c,b,a){this.registry[c]||(this.registry[c]={});this.registry[c][b]=a},destroy:function(c,b){this.registry[c][b]&&delete this.registry[c][b]},show:function(c){if(this.registry[c])for(var b in this.registry[c])YAHOO.lang.hasOwnProperty(this.registry[c],b)&&this.registry[c][b].showGhostLabel()},hide:function(c){if(this.registry[c])for(var b in this.registry[c])YAHOO.lang.hasOwnProperty(this.registry[c],b)&&this.registry[c][b].hideGhostLabel()}};