/*
Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 2.2.2
*/

(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang,m_oUserAgent=navigator.userAgent.toLowerCase(),m_bOpera=(m_oUserAgent.indexOf('opera')>-1),m_bSafari=(m_oUserAgent.indexOf('safari')>-1),m_bGecko=(!m_bOpera&&!m_bSafari&&m_oUserAgent.indexOf('gecko')>-1),m_bIE7=(!m_bOpera&&m_oUserAgent.indexOf('msie 7')>-1),m_bIE=(!m_bOpera&&m_oUserAgent.indexOf('msie')>-1),m_oButtons={},m_oFocusedButton=null;YAHOO.widget.Button=function(p_oElement,p_oAttributes){var fnSuperClass=YAHOO.widget.Button.superclass.constructor;if(arguments.length==1&&!Lang.isString(p_oElement)&&!p_oElement.nodeName){if(!p_oElement.id){p_oElement.id=Dom.generateId();}
fnSuperClass.call(this,(this._createButtonElement(p_oElement.type)),p_oElement);}
else{var oConfig={element:null,attributes:(p_oAttributes||{})},sTagName;if(Lang.isString(p_oElement)){var oElement=Dom.get(p_oElement);if(oElement){sTagName=oElement.tagName.toUpperCase();if(sTagName==this.TAG_NAME){oConfig.attributes.id=oElement.id;}
else if(sTagName=="INPUT"&&!oConfig.attributes.id){oConfig.attributes.id=Dom.generateId();}
oConfig.attributes.srcelement=oElement;initConfig.call(this,oConfig);if(!oConfig.element){oConfig.element=this._createButtonElement(oConfig.attributes.type);}
fnSuperClass.call(this,oConfig.element,oConfig.attributes);}}
else{sTagName=p_oElement.tagName.toUpperCase();if(sTagName==this.TAG_NAME){if(p_oElement.id){oConfig.attributes.id=p_oElement.id;}
else{oConfig.attributes.id=Dom.generateId();}}
else if(sTagName=="INPUT"&&!oConfig.attributes.id){oConfig.attributes.id=Dom.generateId();}
oConfig.attributes.srcelement=p_oElement;initConfig.call(this,oConfig);if(!oConfig.element){oConfig.element=this._createButtonElement(oConfig.attributes.type);}
fnSuperClass.call(this,oConfig.element,oConfig.attributes);}}};function getFirstElement(p_oElement){var oFirstChild=p_oElement.firstChild;if(oFirstChild){if(oFirstChild.nodeType==1){return oFirstChild;}
else{var oNextSibling=oFirstChild.nextSibling;if(oNextSibling&&oNextSibling.nodeType==1){return oNextSibling;}}}}
function createInputElement(p_sType,p_sName,p_sValue,p_bChecked){var oInput;if(m_bIE){var sInput="<input type=\""+p_sType+"\" name=\""+p_sName+"\"";if(p_bChecked){sInput+=" checked";}
sInput+=">";oInput=document.createElement(sInput);}
else{oInput=document.createElement("input");oInput.name=p_sName;oInput.type=p_sType;if(p_bChecked){oInput.checked=true;}}
oInput.value=p_sValue;return oInput;}
function setAttributesFromSrcElement(p_oElement,p_oAttributes){var me=this;function setAttributeFromDOMAttribute(p_sAttribute){if(!(p_sAttribute in p_oAttributes)){var oAttribute=p_oElement.getAttributeNode(p_sAttribute);if(oAttribute&&("value"in oAttribute)){p_oAttributes[p_sAttribute]=oAttribute.value;}}}
function setFormElementProperties(){setAttributeFromDOMAttribute("type");if(!("disabled"in p_oAttributes)){p_oAttributes.disabled=p_oElement.disabled;}
setAttributeFromDOMAttribute("name");setAttributeFromDOMAttribute("value");setAttributeFromDOMAttribute("title");}
var sSrcElementTagName=p_oElement.tagName.toUpperCase();if(!("label"in p_oAttributes)){var sText=sSrcElementTagName=="INPUT"?p_oElement.value:p_oElement.innerHTML;if(sText&&sText.length>0){p_oAttributes.label=sText;}}
setAttributeFromDOMAttribute("tabindex");setAttributeFromDOMAttribute("accesskey");switch(sSrcElementTagName){case"A":p_oAttributes.type="link";setAttributeFromDOMAttribute("href");setAttributeFromDOMAttribute("target");break;case"INPUT":setFormElementProperties();if(!("checked"in p_oAttributes)){p_oAttributes.checked=p_oElement.checked;}
break;case"BUTTON":setFormElementProperties();var oRootNode=p_oElement.parentNode.parentNode;if(Dom.hasClass(oRootNode,"checked")){p_oAttributes.checked=true;}
if(Dom.hasClass(oRootNode,"disabled")){p_oAttributes.disabled=true;}
p_oElement.removeAttribute("name");p_oElement.removeAttribute("value");p_oElement.setAttribute("type","button");break;}}
function initConfig(p_oConfig){var oAttributes=p_oConfig.attributes,oSrcElement=oAttributes.srcelement,sSrcElementTagName=oSrcElement.tagName.toUpperCase();if(sSrcElementTagName==this.TAG_NAME){p_oConfig.element=oSrcElement;var oFirstChild=getFirstElement(p_oConfig.element);Dom.addClass(oFirstChild,"first-child");if(oFirstChild){var oButton=getFirstElement(oFirstChild);if(oButton){var sButtonTagName=oButton.tagName.toUpperCase();if(sButtonTagName=="A"||sButtonTagName=="BUTTON"){setAttributesFromSrcElement.call(this,oButton,oAttributes);}}}}
else if(sSrcElementTagName=="INPUT"){setAttributesFromSrcElement.call(this,oSrcElement,oAttributes);}}
YAHOO.extend(YAHOO.widget.Button,YAHOO.util.Element,{_button:null,_menu:null,_hiddenField:null,_onclickAttributeValue:null,_activationKeyPressed:false,_activationButtonPressed:false,_hasKeyEventHandlers:false,_hasMouseEventHandlers:false,TAG_NAME:"SPAN",CHECK_ACTIVATION_KEYS:[32],ACTIVATION_KEYS:[13,32],OPTION_AREA_WIDTH:20,CSS_CLASS_NAME:"yuibutton",RADIO_DEFAULT_TITLE:"Unchecked.  Click to check.",RADIO_CHECKED_TITLE:"Checked.  Click to uncheck.",CHECKBOX_DEFAULT_TITLE:"Unchecked.  Click to check.",CHECKBOX_CHECKED_TITLE:"Checked.  Click to uncheck.",MENUBUTTON_DEFAULT_TITLE:"Menu collapsed.  Click to expand.",MENUBUTTON_MENU_VISIBLE_TITLE:"Menu expanded.  Click or press Esc to collapse.",SPLITBUTTON_DEFAULT_TITLE:"Menu collapsed.  Click inside option region or press Ctrl + Shift + M to show the menu.",SPLITBUTTON_OPTION_VISIBLE_TITLE:"Menu expanded.  Press Esc or Ctrl + Shift + M to hide the menu.",SUBMIT_TITLE:"Click to submit form.",_setType:function(p_sType){if(p_sType=="splitbutton"){this.on("option",this._onOption);}},_setLabel:function(p_sLabel){this._button.innerHTML=p_sLabel;},_setTabIndex:function(p_nTabIndex){this._button.tabIndex=p_nTabIndex;},_setTitle:function(p_sTitle){if(this.get("type")!="link"){var sTitle=p_sTitle;if(!sTitle){var sType=this.get("type");switch(sType){case"radio":sTitle=this.RADIO_DEFAULT_TITLE;break;case"checkbox":sTitle=this.CHECKBOX_DEFAULT_TITLE;break;case"menubutton":sTitle=this.MENUBUTTON_DEFAULT_TITLE;break;case"splitbutton":sTitle=this.SPLITBUTTON_DEFAULT_TITLE;break;case"submit":sTitle=this.SUBMIT_TITLE;break;}}
this._button.title=sTitle;}},_setDisabled:function(p_bDisabled){if(this.get("type")!="link"){if(p_bDisabled){if(this.hasFocus()){this.blur();}
this._button.setAttribute("disabled","disabled");this.addClass("disabled");}
else{this._button.removeAttribute("disabled");this.removeClass("disabled");}}},_setAccessKey:function(p_sAccessKey){this._button.accessKey=p_sAccessKey;},_setHref:function(p_sHref){if(this.get("type")=="link"){this._button.href=p_sHref;}},_setTarget:function(p_sTarget){if(this.get("type")=="link"){this._button.setAttribute("target",p_sTarget);}},_setChecked:function(p_bChecked){var sType=this.get("type"),sTitle;if(sType=="checkbox"||sType=="radio"){if(p_bChecked){this.addClass("checked");sTitle=(sType=="radio")?this.RADIO_CHECKED_TITLE:this.CHECKBOX_CHECKED_TITLE;}
else{this.removeClass("checked");sTitle=(sType=="radio")?this.RADIO_DEFAULT_TITLE:this.CHECKBOX_DEFAULT_TITLE;}
this.set("title",sTitle);}},_setMenu:function(p_oMenu){var Menu=YAHOO.widget.Menu,oMenu,me=this;if(!Menu){return false;}
function initMenu(){if(oMenu){oMenu.showEvent.subscribe(this._onMenuShow,this,true);oMenu.hideEvent.subscribe(this._onMenuHide,this,true);oMenu.keyDownEvent.subscribe(this._onMenuKeyDown,this,true);oMenu.renderEvent.subscribe(this._onMenuRender,this,true);oMenu.clickEvent.subscribe(this._onMenuClick,this,true);oMenu.itemAddedEvent.subscribe(this._onMenuItemAdded,this,true);var oSrcElement=oMenu.srcElement;if(oSrcElement&&oSrcElement.tagName.toUpperCase()=="SELECT"){oSrcElement.style.display="none";oSrcElement.parentNode.removeChild(oSrcElement);}
this._menu=oMenu;}
else{this._menu.destroy();this._menu=null;}}
if(p_oMenu instanceof Menu){oMenu=p_oMenu;var aItems=oMenu.getItems(),nItems=aItems.length,oItem;if(nItems>0){var i=nItems-1;do{oItem=aItems[i];if(oItem){oItem.cfg.subscribeToConfigEvent("selected",this._onMenuItemSelected,oItem,this);}}
while(i--);}
initMenu.call(this);}
else if(Lang.isArray(p_oMenu)){this.on("appendTo",function(){oMenu=new Menu(Dom.generateId(),{lazyload:true,itemdata:p_oMenu});initMenu.call(me);});}
else if(Lang.isString(p_oMenu)){Event.onContentReady(p_oMenu,function(){oMenu=new Menu(this,{lazyload:true});initMenu.call(me);});}
else if(p_oMenu&&p_oMenu.nodeName){oMenu=new Menu(p_oMenu,{lazyload:true});initMenu.call(this);}},_setOnClick:function(p_oObject){if(this._onclickAttributeValue&&(this._onclickAttributeValue!=p_oObject)){this.removeListener("click",this._onclickAttributeValue.fn);this._onclickAttributeValue=null;}
if(!this._onclickAttributeValue&&Lang.isObject(p_oObject)&&Lang.isFunction(p_oObject.fn)){this.on("click",p_oObject.fn,p_oObject.obj,p_oObject.scope);this._onclickAttributeValue=p_oObject;}},_createButtonElement:function(p_sType){var sTagName=this.TAG_NAME,oElement=document.createElement(sTagName);oElement.innerHTML="<"+sTagName+" class=\"first-child\">"+
(p_sType=="link"?"<a></a>":"<button type=\"button\"></button>")+"</"+sTagName+">";return oElement;},_isActivationKey:function(p_nKeyCode){var sType=this.get("type"),aKeyCodes=(sType=="checkbox"||sType=="radio")?this.CHECK_ACTIVATION_KEYS:this.ACTIVATION_KEYS,nKeyCodes=aKeyCodes.length;if(nKeyCodes>0){var i=nKeyCodes-1;do{if(p_nKeyCode==aKeyCodes[i]){return true;}}
while(i--);}},_isSplitButtonOptionKey:function(p_oEvent){return(p_oEvent.ctrlKey&&p_oEvent.shiftKey&&Event.getCharCode(p_oEvent)==77);},_addListenersToForm:function(){var oForm=this.getForm();if(oForm){Event.on(oForm,"reset",this._onFormReset,null,this);Event.on(oForm,"submit",this._onFormSubmit,null,this);var oSrcElement=this.get("srcelement");if((m_bIE||m_bGecko)&&(this.get("type")=="submit"||(oSrcElement&&oSrcElement.type=="submit"))){var aListeners=Event.getListeners(oForm,"keydown"),bHasKeyDownListener=false;if(aListeners){var nListeners=aListeners.length;if(nListeners>0){var i=nListeners-1;do{if(aListeners[i].fn==YAHOO.widget.Button.onFormKeyDown){bHasKeyDownListener=true;break;}}
while(i--);}}
if(!bHasKeyDownListener){Event.on(oForm,"keydown",YAHOO.widget.Button.onFormKeyDown,null,this);}}}},_originalMaxHeight:-1,_showMenu:function(p_oEvent){var oMenu=this._menu;if(oMenu){YAHOO.widget.MenuManager.hideVisible();oMenu.cfg.applyConfig({context:[this.get("id"),"tl","bl"],clicktohide:false,constraintoviewport:false,visible:true});oMenu.cfg.fireQueue();if(p_oEvent.type=="mousedown"){Event.stopPropagation(p_oEvent);}
this._menu.focus();var nViewportHeight=Dom.getViewportHeight(),nMenuHeight=oMenu.element.offsetHeight;if((oMenu.cfg.getProperty("y")+nMenuHeight)>nViewportHeight){oMenu.align("bl","tl");var nY=oMenu.cfg.getProperty("y"),nScrollTop=(document.documentElement.scrollTop||document.body.scrollTop);if(nScrollTop>=nY){if(this._originalMaxHeight==-1){this._originalMaxHeight=oMenu.cfg.getProperty("maxheight");}
oMenu.cfg.setProperty("maxheight",(nMenuHeight-((nScrollTop-nY)+20)));oMenu.align("bl","tl");}}
oMenu.cfg.setProperty("constraintoviewport",true);}},_hideMenu:function(){var oMenu=this._menu;if(oMenu&&oMenu.cfg.getProperty("visible")){oMenu.hide();}},_onMouseOver:function(p_oEvent){if(!this._hasMouseEventHandlers){this.on("mouseout",this._onMouseOut);this.on("mousedown",this._onMouseDown);this.on("mouseup",this._onMouseUp);this._hasMouseEventHandlers=true;}
this.addClass("hover");if(this._activationButtonPressed){this.addClass("active");}
if(this._bOptionPressed){this.addClass("activeoption");}},_onMouseOut:function(p_oEvent){this.removeClass("hover");if(this.get("type")!="menubutton"){this.removeClass("active");}
if(this._activationButtonPressed||this._bOptionPressed){Event.on(document,"mouseup",this._onDocumentMouseUp,null,this);}},_onDocumentMouseUp:function(p_oEvent){this._activationButtonPressed=false;this._bOptionPressed=false;var sType=this.get("type");if(sType=="menubutton"||sType=="splitbutton"){this.removeClass((sType=="menubutton"?"active":"activeoption"));this._hideMenu();}
Event.removeListener(document,"mouseup",this._onDocumentMouseUp);},_onMouseDown:function(p_oEvent){if((p_oEvent.which||p_oEvent.button)==1){if(!this.hasFocus()){this.focus();}
var sType=this.get("type");if(sType=="splitbutton"){var oElement=this.get("element"),nX=Event.getPageX(p_oEvent)-Dom.getX(oElement);if((oElement.offsetWidth-this.OPTION_AREA_WIDTH)<nX){this.fireEvent("option",p_oEvent);}
else{this.addClass("active");this._activationButtonPressed=true;}}
else if(sType=="menubutton"){if(this.hasClass("active")){this._hideMenu();this._activationButtonPressed=false;}
else{this._showMenu(p_oEvent);this._activationButtonPressed=true;}}
else{this.addClass("active");this._activationButtonPressed=true;}
if(sType=="splitbutton"||sType=="menubutton"){var me=this;function onMouseUp(){me._hideMenu();me.removeListener("mouseup",onMouseUp);}
this._hideMenuTimerId=window.setTimeout(function(){me.on("mouseup",onMouseUp);},250);}}},_onMouseUp:function(p_oEvent){if(this._hideMenuTimerId){window.clearTimeout(this._hideMenuTimerId);}
var sType=this.get("type");if(sType=="checkbox"||sType=="radio"){this.set("checked",!(this.get("checked")));}
this._activationButtonPressed=false;if(this.get("type")!="menubutton"){this.removeClass("active");}},_onFocus:function(p_oEvent){this.addClass("focus");if(this._activationKeyPressed){this.addClass("active");}
m_oFocusedButton=this;if(!this._hasKeyEventHandlers){var oElement=this._button;Event.on(oElement,"blur",this._onBlur,null,this);Event.on(oElement,"keydown",this._onKeyDown,null,this);Event.on(oElement,"keyup",this._onKeyUp,null,this);this._hasKeyEventHandlers=true;}
this.fireEvent("focus",p_oEvent);},_onBlur:function(p_oEvent){this.removeClass("focus");if(this.get("type")!="menubutton"){this.removeClass("active");}
if(this._activationKeyPressed){Event.on(document,"keyup",this._onDocumentKeyUp,null,this);}
m_oFocusedButton=null;this.fireEvent("blur",p_oEvent);},_onDocumentKeyUp:function(p_oEvent){if(this._isActivationKey(Event.getCharCode(p_oEvent))){this._activationKeyPressed=false;Event.removeListener(document,"keyup",this._onDocumentKeyUp);}},_onKeyDown:function(p_oEvent){if(this.get("type")=="splitbutton"&&this._isSplitButtonOptionKey(p_oEvent)){this.fireEvent("option",p_oEvent);}
else if(this._isActivationKey(Event.getCharCode(p_oEvent))){if(this.get("type")=="menubutton"){this._showMenu(p_oEvent);}
else{this._activationKeyPressed=true;this.addClass("active");}}
var oMenu=this._menu;if(oMenu&&oMenu.cfg.getProperty("visible")&&Event.getCharCode(p_oEvent)==27){oMenu.hide();this.focus();}},_onKeyUp:function(p_oEvent){if(this._isActivationKey(Event.getCharCode(p_oEvent))){var sType=this.get("type");if(sType=="checkbox"||sType=="radio"){this.set("checked",!(this.get("checked")));}
this._activationKeyPressed=false;if(this.get("type")!="menubutton"){this.removeClass("active");}}},_onClick:function(p_oEvent){var sType=this.get("type"),sTitle;switch(sType){case"radio":case"checkbox":if(this.get("checked")){sTitle=(sType=="radio")?this.RADIO_CHECKED_TITLE:this.CHECKBOX_CHECKED_TITLE;}
else{sTitle=(sType=="radio")?this.RADIO_DEFAULT_TITLE:this.CHECKBOX_DEFAULT_TITLE;}
this.set("title",sTitle);break;case"submit":this.submitForm();break;case"reset":var oForm=this.getForm();if(oForm){oForm.reset();}
break;case"menubutton":sTitle=this._menu.cfg.getProperty("visible")?this.MENUBUTTON_MENU_VISIBLE_TITLE:this.MENUBUTTON_DEFAULT_TITLE;this.set("title",sTitle);break;case"splitbutton":var oElement=this.get("element"),nX=Event.getPageX(p_oEvent)-Dom.getX(oElement);if((oElement.offsetWidth-this.OPTION_AREA_WIDTH)<nX){return false;}
else{this._hideMenu();var oSrcElement=this.get("srcelement");if(oSrcElement&&oSrcElement.type=="submit"){this.submitForm();}}
sTitle=this._menu.cfg.getProperty("visible")?this.SPLITBUTTON_OPTION_VISIBLE_TITLE:this.SPLITBUTTON_DEFAULT_TITLE;this.set("title",sTitle);break;}},_onAppendTo:function(p_oEvent){var me=this;window.setTimeout(function(){me._addListenersToForm();},0);},_onFormSubmit:function(p_oEvent){var sType=this.get("type"),oMenuItem=this.get("selectedMenuItem"),oForm=this.getForm();if(sType=="radio"||sType=="checkbox"){this.createHiddenField();}
else if(oMenuItem){var oSrcElement=this._menu.srcElement;if(oSrcElement&&oSrcElement.tagName.toUpperCase()=="SELECT"){oForm.appendChild(oSrcElement);oSrcElement.selectedIndex=oMenuItem.index;}
else{var oValue=(oMenuItem.value===null||oMenuItem.value==="")?oMenuItem.cfg.getProperty("text"):oMenuItem.value;if(oValue){var oField=createInputElement("hidden",(this.get("name")+"_options"),oValue);oForm.appendChild(oField);}}}},_onFormReset:function(p_oEvent){var sType=this.get("type");if(sType=="checkbox"||sType=="radio"){this.resetValue("checked");}
if(this._menu){this.resetValue("selectedMenuItem");}},_onDocumentMouseDown:function(p_oEvent){var oTarget=Event.getTarget(p_oEvent),oButtonElement=this.get("element"),oMenuElement=this._menu.element;if(oTarget!=oButtonElement&&!Dom.isAncestor(oButtonElement,oTarget)&&oTarget!=oMenuElement&&!Dom.isAncestor(oMenuElement,oTarget)){this._hideMenu();Event.removeListener(document,"mousedown",this._onDocumentMouseDown);}},_onOption:function(p_oEvent){if(this.hasClass("activeoption")){this._hideMenu();this._bOptionPressed=false;}
else{this._showMenu(p_oEvent);this._bOptionPressed=true;}},_onMenuShow:function(p_sType,p_aArgs){Event.on(document,"mousedown",this._onDocumentMouseDown,null,this);var sTitle,sClass;if(this.get("type")=="splitbutton"){sTitle=this.SPLITBUTTON_OPTION_VISIBLE_TITLE;sClass="activeoption";}
else{sTitle=this.MENUBUTTON_MENU_VISIBLE_TITLE;sClass="active";}
this.addClass(sClass);this.set("title",sTitle);},_onMenuHide:function(p_sType,p_aArgs){if(this._originalMaxHeight!=-1){this._menu.cfg.setProperty("maxheight",this._originalMaxHeight);}
var sTitle,sClass;if(this.get("type")=="splitbutton"){sTitle=this.SPLITBUTTON_DEFAULT_TITLE;sClass="activeoption";}
else{sTitle=this.MENUBUTTON_DEFAULT_TITLE;sClass="active";}
this.removeClass(sClass);this.set("title",sTitle);if(this.get("type")=="splitbutton"){this._bOptionPressed=false;}},_onMenuKeyDown:function(p_sType,p_aArgs){var oEvent=p_aArgs[0];if(Event.getCharCode(oEvent)==27){this.focus();if(this.get("type")=="splitbutton"){this._bOptionPressed=false;}}},_onMenuRender:function(p_sType,p_aArgs){this.get("element").parentNode.appendChild(this._menu.element);},_onMenuItemSelected:function(p_sType,p_aArgs,p_oItem){this.set("selectedMenuItem",p_oItem);},_onMenuItemAdded:function(p_sType,p_aArgs,p_oItem){var oItem=p_aArgs[0];oItem.cfg.subscribeToConfigEvent("selected",this._onMenuItemSelected,oItem,this);},_onMenuClick:function(p_sType,p_aArgs){var oItem=p_aArgs[1];if(oItem){var oSrcElement=this.get("srcelement");if(oSrcElement&&oSrcElement.type=="submit"){this.submitForm();}
this._hideMenu();}},createHiddenField:function(){if(!this.get("disabled")){var sType=this.get("type"),bCheckable=(sType=="checkbox"||sType=="radio"),oField=createInputElement((bCheckable?sType:(m_bIE?"submit":"hidden")),this.get("name"),this.get("value"),this.get("checked")),oForm=this.getForm();if(oField){if(bCheckable||oField.type=="submit"){oField.style.display="none";}
if(oForm){var oHiddenField=this._hiddenField;if(oHiddenField&&Dom.inDocument(oHiddenField)){oForm.replaceChild(oField,oHiddenField);}
else{oForm.appendChild(oField);}}
this._hiddenField=oField;return oField;}}},submitForm:function(p_oMenuItem){var oForm=this.getForm();if(oForm){var oInput=this.createHiddenField();if(m_bIE){oInput.click();}
else{var oEvent=document.createEvent("HTMLEvents");oEvent.initEvent("submit",true,true);var bSubmitForm=oForm.dispatchEvent(oEvent);if(m_bSafari&&bSubmitForm){oForm.submit();}}}},init:function(p_oElement,p_oAttributes){var sTagName=p_oAttributes.type=="link"?"A":"BUTTON",oSrcElement=p_oAttributes.srcelement;this._button=p_oElement.getElementsByTagName(sTagName)[0];YAHOO.widget.Button.superclass.init.call(this,p_oElement,p_oAttributes);m_oButtons[this.get("id")]=this;this.addClass(this.CSS_CLASS_NAME);if(m_bIE&&!m_bIE7){this.addClass("ie6");}
this.addClass(this.get("type"));Event.on(this._button,"focus",this._onFocus,null,this);this.on("mouseover",this._onMouseOver);this.on("click",this._onClick);this.on("appendTo",this._onAppendTo);var oContainer=this.get("container"),oElement=this.get("element");if(oContainer){if(Lang.isString(oContainer)){var me=this;Event.onContentReady(oContainer,function(){me.appendTo(this);});}
else{this.appendTo(oContainer);}}
else if(!Dom.inDocument(oElement)&&oSrcElement&&oSrcElement.tagName.toUpperCase()=="INPUT"){var oParentNode=oSrcElement.parentNode;if(oParentNode){this.fireEvent("beforeAppendTo",{type:"beforeAppendTo",target:oParentNode});oParentNode.replaceChild(oElement,oSrcElement);this.fireEvent("appendTo",{type:"appendTo",target:oParentNode});}}
else if(Dom.inDocument(oElement)&&oSrcElement.tagName.toUpperCase()=="SPAN"){this._addListenersToForm();}},initAttributes:function(p_oAttributes){var oAttributes=p_oAttributes||{};YAHOO.widget.Button.superclass.initAttributes.call(this,oAttributes);this.setAttributeConfig("type",{value:(oAttributes.type||"button"),validator:Lang.isString,writeOnce:true,method:this._setType});this.setAttributeConfig("label",{value:oAttributes.label,validator:Lang.isString,method:this._setLabel});this.setAttributeConfig("value",{value:oAttributes.value});this.setAttributeConfig("name",{value:oAttributes.name,validator:Lang.isString});this.setAttributeConfig("tabindex",{value:oAttributes.tabindex,validator:Lang.isNumber,method:this._setTabIndex});this.configureAttribute("title",{value:oAttributes.title,validator:Lang.isString,method:this._setTitle});this.setAttributeConfig("disabled",{value:(oAttributes.disabled||false),validator:Lang.isBoolean,method:this._setDisabled});this.setAttributeConfig("href",{value:oAttributes.href,validator:Lang.isString,method:this._setHref});this.setAttributeConfig("target",{value:oAttributes.target,validator:Lang.isString,method:this._setTarget});this.setAttributeConfig("checked",{value:(oAttributes.checked||false),validator:Lang.isBoolean,method:this._setChecked});this.setAttributeConfig("container",{value:oAttributes.container});this.setAttributeConfig("srcelement",{value:oAttributes.srcelement,writeOnce:true});this.setAttributeConfig("menu",{value:null,method:this._setMenu});this.setAttributeConfig("selectedMenuItem",{value:null});this.setAttributeConfig("onclick",{value:oAttributes.onclick,method:this._setOnClick});},focus:function(){if(!this.get("disabled")){this._button.focus();}},blur:function(){if(!this.get("disabled")){this._button.blur();}},hasFocus:function(){return(m_oFocusedButton==this);},isActive:function(){return this.hasClass("active");},getMenu:function(){return this._menu;},getForm:function(){return this._button.form;},getHiddenField:function(){return this._hiddenField;},destroy:function(){var oElement=this.get("element"),oParentNode=oElement.parentNode,oMenu=this._menu;if(oMenu){oMenu.destroy();}
Event.purgeElement(oElement);Event.purgeElement(this._button);Event.removeListener(document,"mouseup",this._onDocumentMouseUp);Event.removeListener(document,"keyup",this._onDocumentKeyUp);Event.removeListener(document,"mousedown",this._onDocumentMouseDown);var oForm=this.getForm();if(oForm){Event.removeListener(oForm,"reset",this._onFormReset);Event.removeListener(oForm,"submit",this._onFormSubmit);}
oParentNode.removeChild(oElement);delete m_oButtons[this.get("id")];},fireEvent:function(p_sType,p_aArgs){if(this.DOM_EVENTS[p_sType]&&this.get("disabled")){return;}
YAHOO.widget.Button.superclass.fireEvent.call(this,p_sType,p_aArgs);},toString:function(){return("Button "+this.get("id"));}});YAHOO.widget.Button.onFormKeyDown=function(p_oEvent){var oTarget=Event.getTarget(p_oEvent),nCharCode=Event.getCharCode(p_oEvent);if(nCharCode==13&&oTarget.tagName&&oTarget.tagName.toUpperCase()=="INPUT"){var sType=oTarget.type;if(sType=="text"||sType=="password"||sType=="checkbox"||sType=="radio"||sType=="file"){function isYUISubmitButton(p_oElement){var sId=p_oElement.id;if(sId){var oButton=m_oButtons[sId];if(oButton){var oSrcElement=oButton.get("srcelement");return(oButton.get("type")=="submit"||(oSrcElement&&oSrcElement.type=="submit"));}}}
var aButtons=Dom.getElementsBy(isYUISubmitButton,this.TAG_NAME,this.getForm()),nButtons=aButtons.length;if(nButtons>0){m_oButtons[aButtons[0].id].submitForm();}}}};YAHOO.widget.Button.addHiddenFieldsToForm=function(p_oForm){var aButtons=Dom.getElementsByClassName("yuibutton","*",p_oForm),nButtons=aButtons.length;if(nButtons>0){var oButton=null,sType=null,oMenuItem=null,oMenu=null;for(var i=0;i<nButtons;i++){oButton=m_oButtons[aButtons[i].id];if(oButton){sType=oButton.get("type");oMenuItem=oButton.get("selectedMenuItem");if(sType=="radio"||sType=="checkbox"){oButton.createHiddenField();}
else if(oMenuItem){oMenu=oButton.getMenu();var oSrcElement=oMenu.srcElement;if(oSrcElement&&oSrcElement.tagName.toUpperCase()=="SELECT"){p_oForm.appendChild(oSrcElement);oSrcElement.selectedIndex=oMenuItem.index;}
else{var oValue=(oMenuItem.value===null||oMenuItem.value==="")?oMenuItem.cfg.getProperty("text"):oMenuItem.value;if(oValue){var oHiddenField=oButton.getHiddenField(),oField=createInputElement("hidden",(oButton.get("name")+"_options"),oValue);if(oHiddenField&&Dom.inDocument(oHiddenField)){p_oForm.replaceChild(oField,oHiddenField);}
else{p_oForm.appendChild(oField);}}}}}}}};})();(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang,Button=YAHOO.widget.Button;m_oButtons={};YAHOO.widget.ButtonGroup=function(p_oElement,p_oAttributes){var fnSuperClass=YAHOO.widget.ButtonGroup.superclass.constructor;if(arguments.length==1&&!Lang.isString(p_oElement)&&!p_oElement.nodeName){if(!p_oElement.id){var sId=Dom.generateId();p_oElement.id=sId;}
fnSuperClass.call(this,(this._createGroupElement()),p_oElement);}
else if(Lang.isString(p_oElement)){var oElement=Dom.get(p_oElement);if(oElement){if(oElement.nodeName.toUpperCase()==this.TAG_NAME){fnSuperClass.call(this,oElement,p_oAttributes);}}}
else{var sNodeName=p_oElement.nodeName;if(sNodeName&&sNodeName==this.TAG_NAME){if(!p_oElement.id){p_oElement.id=Dom.generateId();}
fnSuperClass.call(this,p_oElement,p_oAttributes);}}};YAHOO.extend(YAHOO.widget.ButtonGroup,YAHOO.util.Element,{_buttons:null,TAG_NAME:"DIV",CSS_CLASS_NAME:"yuibuttongroup",_createGroupElement:function(){var oElement=document.createElement(this.TAG_NAME);oElement.className=this.CSS_CLASS_NAME;return oElement;},_setDisabled:function(p_bDisabled){var nButtons=this.getCount();if(nButtons>0){var i=nButtons-1;do{this._buttons[i].set("disabled",p_bDisabled);}
while(i--);}},_onKeyDown:function(p_oEvent){var oTarget=Event.getTarget(p_oEvent),nCharCode=Event.getCharCode(p_oEvent),sId=oTarget.parentNode.parentNode.id,oButton=m_oButtons[sId],nIndex=-1;if(nCharCode==37||nCharCode==38){nIndex=(oButton.index===0)?(this._buttons.length-1):(oButton.index-1);}
else if(nCharCode==39||nCharCode==40){nIndex=(oButton.index===(this._buttons.length-1))?0:(oButton.index+1);}
if(nIndex>-1){this.check(nIndex);this.getButton(nIndex).focus();}},_onAppendTo:function(p_oEvent){var aButtons=this._buttons,nButtons=aButtons.length;for(var i=0;i<nButtons;i++){aButtons[i].appendTo(this.get("element"));}},_onButtonCheckedChange:function(p_oEvent,p_oButton){var bChecked=p_oEvent.newValue,oCheckedButton=this.get("checkedButton");if(bChecked&&oCheckedButton!=p_oButton){if(oCheckedButton){oCheckedButton.set("checked",false,true);}
this.set("checkedButton",p_oButton);this.set("value",p_oButton.get("value"));}
else if(oCheckedButton&&!oCheckedButton.set("checked")){oCheckedButton.set("checked",true,true);}},init:function(p_oElement,p_oAttributes){this._buttons=[];YAHOO.widget.ButtonGroup.superclass.init.call(this,p_oElement,p_oAttributes);var aButtons=this.getElementsByClassName("yuibutton");if(aButtons.length>0){this.addButtons(aButtons);}
function isRadioButton(p_oElement){return(p_oElement.type=="radio");}
aButtons=Dom.getElementsBy(isRadioButton,"input",this.get("element"));if(aButtons.length>0){this.addButtons(aButtons);}
this.on("keydown",this._onKeyDown);this.on("appendTo",this._onAppendTo);var oContainer=this.get("container");if(oContainer){if(Lang.isString(oContainer)){var me=this;Event.onContentReady(oContainer,function(){me.appendTo(this);});}
else{this.appendTo(oContainer);}}},initAttributes:function(p_oAttributes){var oAttributes=p_oAttributes||{};YAHOO.widget.ButtonGroup.superclass.initAttributes.call(this,oAttributes);this.setAttributeConfig("name",{value:oAttributes.name,validator:Lang.isString});this.setAttributeConfig("disabled",{value:(oAttributes.disabled||false),validator:Lang.isBoolean,method:this._setDisabled});this.setAttributeConfig("value",{value:oAttributes.value});this.setAttributeConfig("container",{value:oAttributes.container});this.setAttributeConfig("checkedButton",{value:null});},addButton:function(p_oButton){var oButton;if(p_oButton instanceof Button&&p_oButton.get("type")=="radio"){oButton=p_oButton;}
else if(!Lang.isString(p_oButton)&&!p_oButton.nodeName){p_oButton.type="radio";oButton=new Button(p_oButton);}
else{oButton=new Button(p_oButton,{type:"radio"});}
if(oButton){var nIndex=this._buttons.length,sButtonName=oButton.get("name"),sGroupName=this.get("name");oButton.index=nIndex;this._buttons[nIndex]=oButton;m_oButtons[oButton.get("id")]=oButton;if(sButtonName!=sGroupName){oButton.set("name",sGroupName);}
if(this.get("disabled")){oButton.set("disabled",true);}
if(oButton.get("checked")){this.set("checkedButton",oButton);}
oButton.on("checkedChange",this._onButtonCheckedChange,oButton,this);return oButton;}},addButtons:function(p_aButtons){if(Lang.isArray(p_aButtons)){var nButtons=p_aButtons.length,oButton,aButtons=[];if(nButtons>0){for(var i=0;i<nButtons;i++){oButton=this.addButton(p_aButtons[i]);if(oButton){aButtons[aButtons.length]=oButton;}}
if(aButtons.length>0){return aButtons;}}}},removeButton:function(p_nIndex){var oButton=this.getButton(p_nIndex);if(oButton){this._buttons.splice(p_nIndex,1);delete m_oButtons[oButton.get("id")];oButton.removeListener("checkedChange",this._onButtonCheckedChange);oButton.destroy();var nButtons=this._buttons.length;if(nButtons>0){var i=this._buttons.length-1;do{this._buttons[i].index=i;}
while(i--);}}},getButton:function(p_nIndex){if(Lang.isNumber(p_nIndex)){return this._buttons[p_nIndex];}},getButtons:function(){return this._buttons;},getCount:function(){return this._buttons.length;},focus:function(p_nIndex){var oButton;if(Lang.isNumber(p_nIndex)){oButton=this._buttons[p_nIndex];if(oButton){oButton.focus();}}
else{var nButtons=this.getCount();for(var i=0;i<nButtons;i++){oButton=this._buttons[i];if(!oButton.get("disabled")){oButton.focus();break;}}}},check:function(p_nIndex){var oButton=this.getButton(p_nIndex);if(oButton){oButton.set("checked",true);}},destroy:function(){var nButtons=this._buttons.length,oElement=this.get("element"),oParentNode=oElement.parentNode;if(nButtons>0){var i=this._buttons.length-1;do{this._buttons[i].destroy();}
while(i--);}
Event.purgeElement(oElement);oParentNode.removeChild(oElement);},toString:function(){return("ButtonGroup "+this.get("id"));}});})();YAHOO.register("button",YAHOO.widget.Button,{version:"2.2.2",build:"204"});