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

(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang;YAHOO.widget.Toolbar=function(el,attrs){if(Lang.isObject(arguments[0])&&!Dom.get(el).nodeType){var attrs=el;}
var local_attrs=(attrs||{});var oConfig={element:null,attributes:local_attrs}
if(Lang.isString(el)&&Dom.get(el)){oConfig.element=Dom.get(el);}else if(Lang.isObject(el)&&Dom.get(el)&&Dom.get(el).nodeType){oConfig.element=Dom.get(el);}
if(!oConfig.element){oConfig.element=document.createElement('DIV');oConfig.element.id=Dom.generateId();if(local_attrs.container&&Dom.get(local_attrs.container)){Dom.get(local_attrs.container).appendChild(oConfig.element);}}
if(!oConfig.element.id){oConfig.element.id=((Lang.isString(el))?el:Dom.generateId());}
var cont=document.createElement('DIV');oConfig.attributes.cont=cont;Dom.addClass(cont,'yui-toolbar-subcont')
oConfig.element.appendChild(cont);oConfig.attributes.element=oConfig.element;oConfig.attributes.id=oConfig.element.id;YAHOO.widget.Toolbar.superclass.constructor.call(this,oConfig.element,oConfig.attributes);}
function _addMenuClasses(ev,na,o){Dom.addClass(this.element,'yui-toolbar-'+o.get('value')+'-menu');if(Dom.hasClass(o._button.parentNode.parentNode,'yui-toolbar-select')){Dom.addClass(this.element,'yui-toolbar-select-menu');}
var items=this.getItems();for(var i=0;i<items.length;i++){Dom.addClass(items[i].element,'yui-toolbar-'+o.get('value')+'-'+((items[i].value)?items[i].value.replace(/ /g,'-').toLowerCase():items[i]._oText.nodeValue.replace(/ /g,'-').toLowerCase()));Dom.addClass(items[i].element,'yui-toolbar-'+o.get('value')+'-'+((items[i].value)?items[i].value.replace(/ /g,'-'):items[i]._oText.nodeValue.replace(/ /g,'-')));}
this._setWidth();};YAHOO.extend(YAHOO.widget.Toolbar,YAHOO.util.Element,{dd:null,_colorData:{'#111111':'Obsidian','#2D2D2D':'Dark Gray','#434343':'Shale','#5B5B5B':'Flint','#737373':'Gray','#8B8B8B':'Concrete','#A2A2A2':'Gray','#B9B9B9':'Titanium','#000000':'Black','#D0D0D0':'Light Gray','#E6E6E6':'Silver','#FFFFFF':'White','#BFBF00':'Pumpkin','#FFFF00':'Yellow','#FFFF40':'Banana','#FFFF80':'Pale Yellow','#FFFFBF':'Butter','#525330':'Raw Siena','#898A49':'Mildew','#AEA945':'Olive','#7F7F00':'Paprika','#C3BE71':'Earth','#E0DCAA':'Khaki','#FCFAE1':'Cream','#60BF00':'Cactus','#80FF00':'Chartreuse','#A0FF40':'Green','#C0FF80':'Pale Lime','#DFFFBF':'Light Mint','#3B5738':'Green','#668F5A':'Lime Gray','#7F9757':'Yellow','#407F00':'Clover','#8A9B55':'Pistachio','#B7C296':'Light Jade','#E6EBD5':'Breakwater','#00BF00':'Spring Frost','#00FF80':'Pastel Green','#40FFA0':'Light Emerald','#80FFC0':'Sea Foam','#BFFFDF':'Sea Mist','#033D21':'Dark Forrest','#438059':'Moss','#7FA37C':'Medium Green','#007F40':'Pine','#8DAE94':'Yellow Gray Green','#ACC6B5':'Aqua Lung','#DDEBE2':'Sea Vapor','#00BFBF':'Fog','#00FFFF':'Cyan','#40FFFF':'Turquoise Blue','#80FFFF':'Light Aqua','#BFFFFF':'Pale Cyan','#033D3D':'Dark Teal','#347D7E':'Gray Turquoise','#609A9F':'Green Blue','#007F7F':'Seaweed','#96BDC4':'Green Gray','#B5D1D7':'Soapstone','#E2F1F4':'Light Turquoise','#0060BF':'Summer Sky','#0080FF':'Sky Blue','#40A0FF':'Electric Blue','#80C0FF':'Light Azure','#BFDFFF':'Ice Blue','#1B2C48':'Navy','#385376':'Biscay','#57708F':'Dusty Blue','#00407F':'Sea Blue','#7792AC':'Sky Blue Gray','#A8BED1':'Morning Sky','#DEEBF6':'Vapor','#0000BF':'Deep Blue','#0000FF':'Blue','#4040FF':'Cerulean Blue','#8080FF':'Evening Blue','#BFBFFF':'Light Blue','#212143':'Deep Indigo','#373E68':'Sea Blue','#444F75':'Night Blue','#00007F':'Indigo Blue','#585E82':'Dockside','#8687A4':'Blue Gray','#D2D1E1':'Light Blue Gray','#6000BF':'Neon Violet','#8000FF':'Blue Violet','#A040FF':'Violet Purple','#C080FF':'Violet Dusk','#DFBFFF':'Pale Lavender','#302449':'Cool Shale','#54466F':'Dark Indigo','#655A7F':'Dark Violet','#40007F':'Violet','#726284':'Smoky Violet','#9E8FA9':'Slate Gray','#DCD1DF':'Violet White','#BF00BF':'Royal Violet','#FF00FF':'Fuchsia','#FF40FF':'Magenta','#FF80FF':'Orchid','#FFBFFF':'Pale Magenta','#4A234A':'Dark Purple','#794A72':'Medium Purple','#936386':'Cool Granite','#7F007F':'Purple','#9D7292':'Purple Moon','#C0A0B6':'Pale Purple','#ECDAE5':'Pink Cloud','#BF005F':'Hot Pink','#FF007F':'Deep Pink','#FF409F':'Grape','#FF80BF':'Electric Pink','#FFBFDF':'Pink','#451528':'Purple Red','#823857':'Purple Dino','#A94A76':'Purple Gray','#7F003F':'Rose','#BC6F95':'Antique Mauve','#D8A5BB':'Cool Marble','#F7DDE9':'Pink Granite','#C00000':'Apple','#FF0000':'Fire Truck','#FF4040':'Pale Red','#FF8080':'Salmon','#FFC0C0':'Warm Pink','#441415':'Sepia','#82393C':'Rust','#AA4D4E':'Brick','#800000':'Brick Red','#BC6E6E':'Mauve','#D8A3A4':'Shrimp Pink','#F8DDDD':'Shell Pink','#BF5F00':'Dark Orange','#FF7F00':'Orange','#FF9F40':'Grapefruit','#FFBF80':'Canteloupe','#FFDFBF':'Wax','#482C1B':'Dark Brick','#855A40':'Dirt','#B27C51':'Tan','#7F3F00':'Nutmeg','#C49B71':'Mustard','#E1C4A8':'Pale Tan','#FDEEE0':'Marble'},_colorPicker:null,STR_COLLAPSE:'Collapse Toolbar',STR_SPIN_LABEL:'Spin Button with value {VALUE}. Use Control Shift Up Arrow and Control Shift Down arrow keys to increase or decrease the value.',STR_SPIN_UP:'Click to increase the value of this input',STR_SPIN_DOWN:'Click to decrease the value of this input',_titlebar:null,_disabled:null,browser:YAHOO.env.ua,_buttonList:null,_buttonGroupList:null,_sep:null,_sepCount:null,_dragHandle:null,_toolbarConfigs:{renderer:true},CLASS_CONTAINER:'yui-toolbar-container',CLASS_DRAGHANDLE:'yui-toolbar-draghandle',CLASS_SEPARATOR:'yui-toolbar-separator',CLASS_DISABLED:'yui-toolbar-disabled',CLASS_PREFIX:'yui-toolbar',init:function(p_oElement,p_oAttributes){YAHOO.widget.Toolbar.superclass.init.call(this,p_oElement,p_oAttributes);},initAttributes:function(attr){YAHOO.widget.Toolbar.superclass.initAttributes.call(this,attr);var el=this.get('element');this.addClass(this.CLASS_CONTAINER);this.setAttributeConfig('buttons',{value:[],writeOnce:true,method:function(data){for(var i in data){if(Lang.hasOwnProperty(data,i)){if(data[i].type=='separator'){this.addSeparator();}else if(data[i].group!=undefined){this.addButtonGroup(data[i]);}else{this.addButton(data[i]);}}}}});this.setAttributeConfig('disabled',{value:false,method:function(disabled){if(!Lang.isObject(this._disabled)){this._disabled={};}
if(disabled){this.addClass(this.CLASS_DISABLED);this.set('draggable',false);}else{this.removeClass(this.CLASS_DISABLED);if(this._configs.draggable._initialConfig.value){this.set('draggable',true);}}
var len=this._buttonList.length;for(var i=0;i<len;i++){if(disabled){if(this._buttonList[i].get('disabled')){this._disabled[i]=true;}else{this._disabled[i]=null;}
this.disableButton(this._buttonList[i].get('id'));}else{var _button=this._buttonList[i];var _check=_button._configs.disabled._initialConfig.value;if(this._disabled[i]){_check=true;}
if(!_check){this.enableButton(_button.get('id'));}}}}});this.setAttributeConfig('grouplabels',{value:true,writeOnce:true});this.setAttributeConfig('cont',{value:attr.cont,readOnly:true});this.setAttributeConfig('collapse',{value:false});this.setAttributeConfig('titlebar',{value:false,method:function(titlebar){if(titlebar){if(this._titlebar&&this._titlebar.parentNode){this._titlebar.parentNode.removeChild(this._titlebar);}
this._titlebar=document.createElement('DIV');Dom.addClass(this._titlebar,this.CLASS_PREFIX+'-titlebar');if(Lang.isString(titlebar)){var h2=document.createElement('h2');h2.tabIndex='-1';h2.innerHTML=titlebar;this._titlebar.appendChild(h2);}
if(this.get('collapse')){var collapse=document.createElement('SPAN');collapse.innerHTML='X';collapse.title=this.STR_COLLAPSE;Dom.addClass(collapse,'collapse');this._titlebar.appendChild(collapse);Event.addListener(collapse,'click',function(){if(Dom.getStyle(this.get('cont'),'display')=='none'){Dom.setStyle(this.get('cont'),'display','block');Dom.removeClass(collapse,'collapsed');this.fireEvent('toolbarExpanded',{type:'toolbarExpanded',target:this});}else{Dom.setStyle(this.get('cont'),'display','none');Dom.addClass(collapse,'collapsed');this.fireEvent('toolbarCollapsed',{type:'toolbarCollapsed',target:this});}},this,true);}
if(this.get('draggable')){this.dd=new YAHOO.util.DD(this.get('id'));this.dd.setHandleElId(this._titlebar);Dom.addClass(this._titlebar,'draggable');}
if(this.get('firstChild')){this.insertBefore(this._titlebar,this.get('firstChild'));}else{this.appendChild(this._titlebar);}}else if(this._titlebar){if(this._titlebar&&this._titlebar.parentNode){this._titlebar.parentNode.removeChild(this._titlebar);}}}});this.setAttributeConfig('draggable',{value:(attr.draggable||false),method:function(draggable){var el=this.get('element');if(draggable&&!this.get('titlebar')){if(!this._dragHandle){this._dragHandle=document.createElement('SPAN');this._dragHandle.innerHTML='|';this._dragHandle.setAttribute('title','Click to drag the toolbar');this._dragHandle.id=this.get('id')+'_draghandle';Dom.addClass(this._dragHandle,this.CLASS_DRAGHANDLE);if(this.get('cont').hasChildNodes()){this.get('cont').insertBefore(this._dragHandle,this.get('cont').firstChild);}else{this.get('cont').appendChild(this._dragHandle);}
this.dd=new YAHOO.util.DD(this.get('id'));this.dd.setHandleElId(this._dragHandle.id);}}else{if(this._dragHandle){this._dragHandle.parentNode.removeChild(this._dragHandle);this._dragHandle=null;this.dd=null;}}
if(this._titlebar){if(draggable){this.dd=new YAHOO.util.DD(this.get('id'));this.dd.setHandleElId(this._titlebar);Dom.addClass(this._titlebar,'draggable');}else{Dom.removeClass(this._titlebar,'draggable');if(this.dd){this.dd.unreg();this.dd=null;}}}},validator:function(value){var ret=true;if(!YAHOO.util.DD){ret=false;}
return ret;}});},addButtonGroup:function(oGroup){if(!this.get('element')){this._queue[this._queue.length]=['addButtonGroup',arguments];return false;}
if(!this.hasClass(this.CLASS_PREFIX+'-grouped')){this.addClass(this.CLASS_PREFIX+'-grouped');}
var div=document.createElement('DIV');Dom.addClass(div,this.CLASS_PREFIX+'-group');Dom.addClass(div,this.CLASS_PREFIX+'-group-'+oGroup.group);if(oGroup.label&&this.get('grouplabels')){var label=document.createElement('h3');label.innerHTML=oGroup.label;div.appendChild(label);}
this.get('cont').appendChild(div);var ul=document.createElement('ul');div.appendChild(ul);if(!this._buttonGroupList){this._buttonGroupList={};}
this._buttonGroupList[oGroup.group]=ul;for(var i=0;i<oGroup.buttons.length;i++){var li=document.createElement('li');ul.appendChild(li);if((oGroup.buttons[i].type!=undefined)&&oGroup.buttons[i].type=='separator'){this.addSeparator(li);}else{oGroup.buttons[i].container=li;this.addButton(oGroup.buttons[i]);}}},addButtonToGroup:function(oButton,group,after){var groupCont=this._buttonGroupList[group];var li=document.createElement('li');oButton.container=li;this.addButton(oButton,after);groupCont.appendChild(li);},addButton:function(oButton,after){if(!this.get('element')){this._queue[this._queue.length]=['addButton',arguments];return false;}
if(!this._buttonList){this._buttonList=[];}
this._configs.buttons.value[this._configs.buttons.value.length]=oButton;if(!oButton.container){oButton.container=this.get('cont');}
if((oButton.type=='menu')||(oButton.type=='split')||(oButton.type=='select')){if(Lang.isArray(oButton.menu)){for(var i in oButton.menu){if(Lang.hasOwnProperty(oButton.menu,i)){var funcObject={fn:function(ev,x,oMenu){if(!oButton.menucmd){oButton.menucmd=oButton.value;}
oButton.value=((oMenu.value)?oMenu.value:oMenu._oText.nodeValue);},scope:this}
oButton.menu[i].onclick=funcObject;}}}}
var _oButton={};for(var i in oButton){if(Lang.hasOwnProperty(oButton,i)){if(!this._toolbarConfigs[i]){_oButton[i]=oButton[i];}}}
if(oButton.type=='select'){_oButton.type='menu';}
if(oButton.type=='spin'){_oButton.type='push';}
if(_oButton.type=='color'){_oButton=this._makeColorButton(_oButton);}
if(_oButton.menu){if(oButton.menu instanceof YAHOO.widget.Overlay){oButton.menu.showEvent.subscribe(function(){this._button=_oButton;});}else{for(var i=0;i<_oButton.menu.length;i++){if(!_oButton.menu[i].value){_oButton.menu[i].value=_oButton.menu[i].text;}}
if(this.browser.webkit){_oButton.focusmenu=false;}}}
var tmp=new YAHOO.widget.Button(_oButton);if(this.get('disabled')){tmp.set('disabled',true);}
if(!oButton.id){oButton.id=tmp.get('id');}
if(after){var el=tmp.get('element');var nextSib=null;if(after.get){nextSib=after.get('element').nextSibling;}else if(after.nextSibling){nextSib=after.nextSibling;}
if(nextSib){nextSib.parentNode.insertBefore(el,nextSib);}}
tmp.addClass(this.CLASS_PREFIX+'-'+tmp.get('value'));var icon=document.createElement('span');icon.className=this.CLASS_PREFIX+'-icon';tmp.get('element').insertBefore(icon,tmp.get('firstChild'));var a=document.createElement('a');a.innerHTML=tmp._button.innerHTML;a.href='#';Event.on(a,'click',function(ev){Event.stopEvent(ev);});tmp._button.parentNode.replaceChild(a,tmp._button);tmp._button=a;if(oButton.type=='select'){tmp.addClass(this.CLASS_PREFIX+'-select');}
if(oButton.type=='spin'){if(!Lang.isArray(oButton.range)){oButton.range=[10,100];}
this._makeSpinButton(tmp,oButton);}
tmp.get('element').setAttribute('title',tmp.get('label'));if(oButton.type!='spin'){if(_oButton.menu instanceof YAHOO.widget.Overlay){var showPicker=function(ev){var exec=true;if(ev.keyCode&&(ev.keyCode==9)){exec=false;}
if(exec){this._colorPicker._button=oButton.value;var menuEL=tmp.getMenu().element;if(menuEL.style.visibility=='hidden'){tmp.getMenu().show();}else{tmp.getMenu().hide();}}
YAHOO.util.Event.stopEvent(ev);};tmp.on('mousedown',showPicker,oButton,this);tmp.on('keydown',showPicker,oButton,this);}else if((oButton.type!='menu')&&(oButton.type!='select')){tmp.on('keypress',this._buttonClick,oButton,this);tmp.on('mousedown',function(ev){this._buttonClick(ev,oButton);YAHOO.util.Event.stopEvent(ev);},oButton,this);}else{tmp.on('mousedown',function(ev){YAHOO.util.Event.stopEvent(ev);});tmp.on('click',function(ev){YAHOO.util.Event.stopEvent(ev);});var self=this;tmp.getMenu().mouseDownEvent.subscribe(function(ev,args){var oMenu=args[1];YAHOO.util.Event.stopEvent(args[0]);tmp._onMenuClick(args[0],tmp);if(!oButton.menucmd){oButton.menucmd=oButton.value;}
oButton.value=((oMenu.value)?oMenu.value:oMenu._oText.nodeValue);self._buttonClick.call(self,args[1],oButton);tmp._hideMenu();return false;});tmp.getMenu().clickEvent.subscribe(function(ev,args){YAHOO.util.Event.stopEvent(args[0]);});}}else{tmp.on('mousedown',function(ev){YAHOO.util.Event.stopEvent(ev);});tmp.on('click',function(ev){YAHOO.util.Event.stopEvent(ev);});}
if(this.browser.ie){tmp.DOM_EVENTS.focusin=true;tmp.DOM_EVENTS.focusout=true;tmp.on('focusin',function(ev){YAHOO.util.Event.stopEvent(ev);},oButton,this);tmp.on('focusout',function(ev){YAHOO.util.Event.stopEvent(ev);},oButton,this);tmp.on('click',function(ev){YAHOO.util.Event.stopEvent(ev);},oButton,this);}
if(this.browser.webkit){tmp.hasFocus=function(){return true;}}
this._buttonList[this._buttonList.length]=tmp;if((oButton.type=='menu')||(oButton.type=='split')||(oButton.type=='select')){if(Lang.isArray(oButton.menu)){var menu=tmp.getMenu();menu.renderEvent.subscribe(_addMenuClasses,tmp);if(oButton.renderer){menu.renderEvent.subscribe(oButton.renderer,tmp);}}}
return oButton;},addSeparator:function(cont,after){if(!this.get('element')){this._queue[this._queue.length]=['addSeparator',arguments];return false;}
var sepCont=((cont)?cont:this.get('cont'));if(!this.get('element')){this._queue[this._queue.length]=['addSeparator',arguments];return false;}
if(this._sepCount==null){this._sepCount=0;}
if(!this._sep){this._sep=document.createElement('SPAN');Dom.addClass(this._sep,this.CLASS_SEPARATOR);this._sep.innerHTML='|';}
var _sep=this._sep.cloneNode(true);this._sepCount++;Dom.addClass(_sep,this.CLASS_SEPARATOR+'-'+this._sepCount);if(after){var nextSib=null;if(after.get){nextSib=after.get('element').nextSibling;}else if(after.nextSibling){nextSib=after.nextSibling;}else{nextSib=after;}
if(nextSib){if(nextSib==after){nextSib.parentNode.appendChild(_sep);}else{nextSib.parentNode.insertBefore(_sep,nextSib);}}}else{sepCont.appendChild(_sep);}
return _sep;},_createColorPicker:function(id){if(Dom.get(id+'_colors')){Dom.get(id+'_colors').parentNode.removeChild(Dom.get(id+'_colors'));}
var picker=document.createElement('div');picker.className='yui-toolbar-colors';picker.id=id+'_colors';picker.style.display='none';Event.on(window,'load',function(){document.body.appendChild(picker);},this,true);this._colorPicker=picker;var html='';for(var i in this._colorData){if(Lang.hasOwnProperty(this._colorData,i)){html+='<a style="background-color: '+i+'" href="#">'+i.replace('#','')+'</a>';}}
html+='<span><em>X</em><strong></strong></span>';picker.innerHTML=html;var em=picker.getElementsByTagName('em')[0];var strong=picker.getElementsByTagName('strong')[0];Event.on(picker,'mouseover',function(ev){var tar=Event.getTarget(ev);if(tar.tagName.toLowerCase()=='a'){em.style.backgroundColor=tar.style.backgroundColor;strong.innerHTML=this._colorData['#'+tar.innerHTML]+'<br>'+tar.innerHTML;}},this,true);Event.on(picker,'focus',function(ev){Event.stopEvent(ev);});Event.on(picker,'click',function(ev){Event.stopEvent(ev);});Event.on(picker,'mousedown',function(ev){Event.stopEvent(ev);var tar=Event.getTarget(ev);if(tar.tagName.toLowerCase()=='a'){this.fireEvent('colorPickerClicked',{type:'colorPickerClicked',target:this,button:this._colorPicker._button,color:tar.innerHTML,colorName:this._colorData['#'+tar.innerHTML]});this.getButtonByValue(this._colorPicker._button).getMenu().hide();}},this,true);},_resetColorPicker:function(){var em=this._colorPicker.getElementsByTagName('em')[0];var strong=this._colorPicker.getElementsByTagName('strong')[0];em.style.backgroundColor='transparent';strong.innerHTML='';},_makeColorButton:function(_oButton){if(!this._colorPicker){this._createColorPicker(this.get('id'));}
_oButton.type='color';_oButton.menu=new YAHOO.widget.Overlay(this.get('id')+'_'+_oButton.value+'_menu',{visbile:false,position:'absolute'});_oButton.menu.setBody('');_oButton.menu.render(this.get('cont'));_oButton.menu.beforeShowEvent.subscribe(function(){_oButton.menu.cfg.setProperty('zindex',5);_oButton.menu.cfg.setProperty('context',[this.getButtonById(_oButton.id).get('element'),'tl','bl']);this._resetColorPicker();var _p=this._colorPicker;if(_p.parentNode){_p.parentNode.removeChild(_p);}
_oButton.menu.setBody('');_oButton.menu.appendToBody(_p);this._colorPicker.style.display='block';},this,true);return _oButton;},_makeSpinButton:function(_button,oButton){_button.addClass(this.CLASS_PREFIX+'-spinbutton');var self=this,_par=_button._button.parentNode.parentNode,range=oButton.range,_b1=document.createElement('a'),_b2=document.createElement('a');_b1.href='#';_b2.href='#';_b1.className='up';_b1.title=this.STR_SPIN_UP;_b1.innerHTML=this.STR_SPIN_UP;_b2.className='down';_b2.title=this.STR_SPIN_DOWN;_b2.innerHTML=this.STR_SPIN_DOWN;_par.appendChild(_b1);_par.appendChild(_b2);var label=YAHOO.lang.substitute(this.STR_SPIN_LABEL,{VALUE:_button.get('label')});_button.set('title',label);var cleanVal=function(value){value=((value<range[0])?range[0]:value);value=((value>range[1])?range[1]:value);return value;};var br=this.browser;var tbar=false;var strLabel=this.STR_SPIN_LABEL;if(this._titlebar&&this._titlebar.firstChild){tbar=this._titlebar.firstChild;}
var _intUp=function(ev){YAHOO.util.Event.stopEvent(ev);if(!_button.get('disabled')&&(ev.keyCode!=9)){var value=parseInt(_button.get('label'));value++;value=cleanVal(value);_button.set('label',''+value);var label=YAHOO.lang.substitute(strLabel,{VALUE:_button.get('label')});_button.set('title',label);if(!br.webkit&&tbar){}
self._buttonClick(ev,oButton);}};var _intDown=function(ev){YAHOO.util.Event.stopEvent(ev);if(!_button.get('disabled')&&(ev.keyCode!=9)){var value=parseInt(_button.get('label'));value--;value=cleanVal(value);_button.set('label',''+value);var label=YAHOO.lang.substitute(strLabel,{VALUE:_button.get('label')});_button.set('title',label);if(!br.webkit&&tbar){}
self._buttonClick(ev,oButton);}};var _intKeyUp=function(ev){if(ev.keyCode==38){_intUp(ev);}else if(ev.keyCode==40){_intDown(ev);}else if(ev.keyCode==107&&ev.shiftKey){_intUp(ev);}else if(ev.keyCode==109&&ev.shiftKey){_intDown(ev);}};_button.on('keydown',_intKeyUp,this,true);Event.on(_b1,'mousedown',function(ev){Event.stopEvent(ev);},this,true);Event.on(_b2,'mousedown',function(ev){Event.stopEvent(ev);},this,true);Event.on(_b1,'click',_intUp,this,true);Event.on(_b2,'click',_intDown,this,true);},_buttonClick:function(ev,info){var doEvent=true;if(ev&&ev.type=='keypress'){if(ev.keyCode==9){doEvent=false;}else if((ev.keyCode==13)||(ev.keyCode==0)||(ev.keyCode==32)){}else{doEvent=false;}}
if(doEvent){if(info.value){this.fireEvent(info.value+'Click',{type:info.value+'Click',target:this.get('element'),button:info});}
if(info.menucmd){this.fireEvent(info.menucmd+'Click',{type:info.menucmd+'Click',target:this.get('element'),button:info});}
this.fireEvent('buttonClick',{type:'buttonClick',target:this.get('element'),button:info});if(info.type=='select'){var button=this.getButtonById(info.id);var txt=info.value;for(var i=0;i<info.menu.length;i++){if(info.menu[i].value==info.value){txt=info.menu[i].text;break;}}
button.set('label','<span class="yui-toolbar-'+info.menucmd+'-'+(info.value).replace(/ /g,'-').toLowerCase()+'">'+txt+'</span>');var _items=button.getMenu().getItems();for(var m=0;m<_items.length;m++){if(_items[m].value.toLowerCase()==info.value.toLowerCase()){_items[m].cfg.setProperty('checked',true);}else{_items[m].cfg.setProperty('checked',false);}}}}
if(ev){Event.stopEvent(ev);}},getButtonById:function(id){var len=this._buttonList.length;for(var i=0;i<len;i++){if(this._buttonList[i].get('id')==id){return this._buttonList[i];}}
return false;},getButtonByValue:function(value){var _buttons=this.get('buttons');var len=_buttons.length;for(var i=0;i<len;i++){if(_buttons[i].group!=undefined){for(var m=0;m<_buttons[i].buttons.length;m++){if((_buttons[i].buttons[m].value==value)||(_buttons[i].buttons[m].menucmd==value)){return this.getButtonById(_buttons[i].buttons[m].id);}
if(_buttons[i].buttons[m].menu){for(var s=0;s<_buttons[i].buttons[m].menu.length;s++){if(_buttons[i].buttons[m].menu[s].value==value){return this.getButtonById(_buttons[i].buttons[m].id);}}}}}else{if((_buttons[i].value==value)||(_buttons[i].menucmd==value)){return this.getButtonById(_buttons[i].id);}
if(_buttons[i].menu){for(var s=0;s<_buttons[i].menu.length;s++){if(_buttons[i].menu[s].value==value){return this.getButtonById(_buttons[i].id);}}}}}
return false;},getButtonByIndex:function(index){if(this._buttonList[index]){return this._buttonList[index];}else{return false;}},getButtons:function(){return this._buttonList;},disableButton:function(button){if(Lang.isString(button)){var button=this.getButtonById(button);}
if(Lang.isNumber(button)){var button=this.getButtonByIndex(button);}
if(button instanceof YAHOO.widget.Button){button.set('disabled',true);}else{return false;}},enableButton:function(button){if(Lang.isString(button)){var button=this.getButtonById(button);}
if(Lang.isNumber(button)){var button=this.getButtonByIndex(button);}
if(button instanceof YAHOO.widget.Button){button.set('disabled',false);}else{return false;}},selectButton:function(button,value){if(button){if(Lang.isString(button)){var button=this.getButtonById(button);}
if(Lang.isNumber(button)){var button=this.getButtonByIndex(button);}
if(button instanceof YAHOO.widget.Button){button.addClass('yui-button-selected');button.addClass('yui-button-'+button.get('value')+'-selected');if(value){var _items=button.getMenu().getItems();for(var m=0;m<_items.length;m++){if(_items[m].value==value){_items[m].cfg.setProperty('checked',true);button.set('label','<span class="yui-toolbar-'+button.get('value')+'-'+(value).replace(/ /g,'-').toLowerCase()+'">'+_items[m]._oText.nodeValue+'</span>');}else{_items[m].cfg.setProperty('checked',false);}}}}else{return false;}}},deselectButton:function(button){if(Lang.isString(button)){var button=this.getButtonById(button);}
if(Lang.isNumber(button)){var button=this.getButtonByIndex(button);}
if(button instanceof YAHOO.widget.Button){button.removeClass('yui-button-selected');button.removeClass('yui-button-'+button.get('value')+'-selected');button.removeClass('yui-button-hover');}else{return false;}},deselectAllButtons:function(){var len=this._buttonList.length;for(var i=0;i<len;i++){this.deselectButton(this._buttonList[i]);}},destroyButton:function(button){if(Lang.isString(button)){var button=this.getButtonById(button);}
if(Lang.isNumber(button)){var button=this.getButtonByIndex(button);}
if(button instanceof YAHOO.widget.Button){var id=button.get('id');button.destroy();var len=this._buttonList.length;for(var i=0;i<len;i++){if(this._buttonList[i].get('id')==id){this._buttonList[i]=null;}}}else{return false;}},destroy:function(){this.get('element').innerHTML='';this.get('element').className='';for(var i in this){if(Lang.hasOwnProperty(this,i)){this[i]=null;}}
return true;},toString:function(){return'Toolbar (#'+this.get('element').id+') with '+this._buttonList.length+' buttons.';}});})();(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang,DD=YAHOO.util.DD,Toolbar=YAHOO.widget.Toolbar;YAHOO.widget.Editor=function(el,attrs){var oConfig={element:null,attributes:(attrs||{})}
if(Lang.isString(el)){oConfig.attributes.textarea=Dom.get(el);}
var element_cont=document.createElement('DIV');oConfig.attributes.element_cont=new YAHOO.util.Element(element_cont,{id:oConfig.attributes.textarea.id+'_container'});oConfig.attributes.element_cont.setStyle('display','none');oConfig.element=oConfig.attributes.textarea;var div=document.createElement('div');oConfig.attributes.element_cont.appendChild(div);if(!oConfig.attributes.toolbar_cont){oConfig.attributes.toolbar_cont=document.createElement('DIV');oConfig.attributes.toolbar_cont.id=oConfig.attributes.textarea.id+'_toolbar';div.appendChild(oConfig.attributes.toolbar_cont);}
if(!oConfig.attributes.iframe){oConfig.attributes.iframe=_createIframe(oConfig.attributes.textarea.id);var editorWrapper=document.createElement('DIV');editorWrapper.appendChild(oConfig.attributes.iframe.get('element'));div.appendChild(editorWrapper);}
Event.onDOMReady(function(){this.DOMReady=true;this.fireQueue();},this,true);YAHOO.widget.Editor.superclass.constructor.call(this,oConfig.element,oConfig.attributes);}
function _cleanClassName(str){return str.replace(/ /g,'-').toLowerCase();}
function _createIframe(id){var ifrmID=id+'_editor';var ifrmDom=document.createElement('iframe');ifrmDom.id=ifrmID;var config={border:'0',frameBorder:'0',marginWidth:'0',marginHeight:'0',leftMargin:'0',topMargin:'0',allowTransparency:'true',width:'100%',src:'javascript:false'}
for(var i in config){if(Lang.hasOwnProperty(config,i)){ifrmDom.setAttribute(i,config[i]);}}
var ifrm=new YAHOO.util.Element(ifrmDom);ifrm.setStyle('zIndex','-1');return ifrm;}
YAHOO.extend(YAHOO.widget.Editor,YAHOO.util.Element,{DOMReady:null,_selection:null,_mask:null,_showingHiddenElements:null,currentWindow:null,currentEvent:null,operaEvent:null,currentFont:null,currentElement:[],dompath:null,beforeElement:null,afterElement:null,invalidHTML:{form:true,input:true,button:true,select:true,link:true,html:true,body:true,script:true,style:true,textarea:true},toolbar:null,_contentTimer:null,_contentTimerCounter:0,_disabled:['createlink','forecolor','backcolor','fontname','fontsize','superscript','subscript','removeformat','heading','indent','outdent'],_alwaysDisabled:{},_alwaysEnabled:{hiddenelements:true},_semantic:{'bold':true,'italic':true,'underline':true},_tag2cmd:{'b':'bold','strong':'bold','i':'italic','em':'italic','u':'underline','blockquote':'formatblock','sup':'superscript','sub':'subscript','img':'insertimage','a':'createlink','ul':'insertunorderedlist','ol':'insertorderedlist','indent':'indent','outdent':'outdent'},_getDoc:function(){var value=false;if(this.get){if(this.get('iframe')){if(this.get('iframe').get){if(this.get('iframe').get('element')){try{if(this.get('iframe').get('element').contentWindow){if(this.get('iframe').get('element').contentWindow.document){value=this.get('iframe').get('element').contentWindow.document;}}}catch(e){}}}}}
return value;},_getWindow:function(){return this.get('iframe').get('element').contentWindow;},_focusWindow:function(onLoad){if(this.browser.webkit){if(onLoad){this._getSelection().setBaseAndExtent(this._getDoc().body,0,this._getDoc().body,1);this._getSelection().collapse(false);}else{this._getSelection().setBaseAndExtent(this._getDoc().body,1,this._getDoc().body,1);this._getSelection().collapse(false);}
this._getWindow().focus();if(this._getDoc().queryCommandEnabled('insertimage')){this.browser.webkit3=true;}}else{this._getWindow().focus();}},_hasSelection:function(){var sel=this._getSelection();var range=this._getRange();var hasSel=false;if(this.browser.ie||this.browser.opera){if(range.text){hasSel=true;}
if(range.html){hasSel=true;}}else{if((sel!='')&&(sel!=undefined)){hasSel=true;}}
return hasSel;},_getSelection:function(){var _sel=null;if(this._getDoc()&&this._getWindow()){if(this._getDoc().selection){_sel=this._getDoc().selection;}else{_sel=this._getWindow().getSelection();}
if(this.browser.webkit){if(_sel.baseNode){this._selection=new Object();this._selection.baseNode=_sel.baseNode;this._selection.baseOffset=_sel.baseOffset;this._selection.extentNode=_sel.extentNode;this._selection.extentOffset=_sel.extentOffset;}else if(this._selection!=null){_sel=this._getWindow().getSelection();_sel.setBaseAndExtent(this._selection.baseNode,this._selection.baseOffset,this._selection.extentNode,this._selection.extentOffset);this._selection=null;}}}
return _sel;},_getRange:function(sel){var sel=this._getSelection();if(sel==null){return null;}
if(this.browser.webkit&&!sel.getRangeAt){var _range=this._getDoc().createRange();try{_range.setStart(sel.anchorNode,sel.anchorOffset);_range.setEnd(sel.focusNode,sel.focusOffset);}catch(e){_range=this._getWindow().getSelection()+'';}
return _range;}
if(this.browser.ie||this.browser.opera){return sel.createRange();}
if(sel.rangeCount>0){return sel.getRangeAt(0);}
return null;},_setDesignMode:function(state){try{this._getDoc().designMode=state;}catch(e){}},_toggleDesignMode:function(){var _dMode=this._getDoc().designMode,_state='on';if(_dMode=='on'){_state='off';}
this._setDesignMode(_state);return _state;},_initEditor:function(){if(this.browser.ie){this._getDoc().body.style.margin='0';}
this._setDesignMode('on');this.toolbar.on('buttonClick',this._handleToolbarClick,this,true);Event.addListener(this._getDoc(),'mouseup',this._handleMouseUp,this,true);Event.addListener(this._getDoc(),'mousedown',this._handleMouseDown,this,true);Event.addListener(this._getDoc(),'click',this._handleClick,this,true);Event.addListener(this._getDoc(),'dblclick',this._handleDoubleClick,this,true);Event.addListener(this._getDoc(),'keypress',this._handleKeyPress,this,true);Event.addListener(this._getDoc(),'keyup',this._handleKeyUp,this,true);Event.addListener(this._getDoc(),'keydown',this._handleKeyDown,this,true);this.toolbar.set('disabled',false);this.fireEvent('editorContentLoaded',{type:'editorLoaded',target:this});if(this.get('dompath')){var self=this;window.setTimeout(function(){self._writeDomPath.call(self);},150);}},_checkLoaded:function(){this._contentTimerCounter++;if(this._contentTimer){window.clearTimeout(this._contentTimer);}
if(this._contentTimerCounter>250){alert('ERROR: Body Did Not load');return false;}
if(this._getDoc()&&this._getDoc().body&&(this._getDoc().body._rteLoaded==true)){this._initEditor();}else{var self=this;this._contentTimer=window.setTimeout(function(){self._checkLoaded.call(self);},20);}},_setInitialContent:function(){var title=this.STR_TITLE;var html=this.get('html');html=html.replace('{TITLE}',title);html=html.replace('{CONTENT}',this.get('textarea').value);html=html.replace('{CSS}',this.get('css'));html=html.replace('{HIDDEN_CSS}',this.get('hiddencss'));this._getDoc().open();this._getDoc().write(html);this._getDoc().close();this._checkLoaded();},_setMarkupType:function(action){switch(this.get('markup')){case'css':this._setEditorStyle(true);break;case'default':this._setEditorStyle(false);break;case'semantic':if(this._semantic[action]){this._setEditorStyle(false);}else{this._setEditorStyle(true);}
break;}},_setEditorStyle:function(stat){try{this._getDoc().execCommand('useCSS',false,!stat);}catch(ex){}},_getSelectedElement:function(){var doc=this._getDoc();if(this.browser.ie){var range=this._getRange(),elm=null;if(range){elm=range.item?range.item(0):range.parentElement();if(elm==doc.body){elm=null;}}}else{var sel=this._getSelection(),range=this._getRange(),elm=null;if(!sel||!range){return null;}
if(sel!=''){if(sel.anchorNode&&(sel.anchorNode.nodeType==3)){if(sel.anchorNode.parentNode){elm=sel.anchorNode.parentNode;}
if(sel.anchorNode.nextSibling!=sel.focusNode.nextSibling){elm=sel.anchorNode.nextSibling;}}
if(elm&&elm.tagName&&(elm.tagName.toLowerCase()=='br')){elm=null;}
if(!elm){elm=range.commonAncestorContainer;if(!range.collapsed){if(range.startContainer==range.endContainer){if(range.startOffset-range.endOffset<2){if(range.startContainer.hasChildNodes()){elm=range.startContainer.childNodes[range.startOffset];}}}}}
if(!elm){if(this.currentEvent){}}}}
if(!elm&&(this.currentElement[0]||this.currentEvent)){if(this.currentEvent&&(this.currentEvent.keyCode==undefined)&&Event.getTarget(this.currentEvent)){elm=Event.getTarget(this.currentEvent);}else if(this.currentEvent&&(this.currentEvent.keyCode!=undefined)&&Event.getTarget(this.currentEvent)){}else{elm=this.currentElement[0];}}else if((elm==this._getDoc().body)&&this.currentElement[0]&&!this._hasSelection()){elm=this.currentElement[0];}
if(this.browser.opera||this.browser.webkit){if(this.currentEvent&&!elm){elm=Event.getTarget(this.currentEvent);}}
if(!elm||!elm.tagName){elm=doc.body;}
if(elm&&elm.tagName&&elm.tagName.toLowerCase()=='html'){elm=doc.body;}
return elm;},_getDomPath:function(){var el=this._getSelectedElement();var domPath=[];while(el!=null){if(el.ownerDocument!=this._getDoc()){return false;}
if(el.nodeName&&(el.nodeType==1)){domPath[domPath.length]=el;}
if(el.nodeName.toUpperCase()=="BODY"){break;}
el=el.parentNode;}
if(domPath.length==0){if(this._getDoc()&&this._getDoc().body){domPath[0]=this._getDoc().body;}}
return domPath.reverse();},_writeDomPath:function(){var path=this._getDomPath(),pathArr=[];for(var i=0;i<path.length;i++){var tag=path[i].tagName.toLowerCase();if((tag=='ol')&&(path[i].type)){tag+=':'+path[i].type;}
if(Dom.hasClass(path[i],'yui-tag')){tag=path[i].getAttribute('tag');}
if((this.get('markup')=='semantic')){switch(tag){case'b':tag='strong';break;case'i':tag='em';break;}}
if(!Dom.hasClass(path[i],'yui-non')){if(Dom.hasClass(path[i],'yui-tag')){var pathStr=tag;if(tag=='a'){if(path[i].getAttribute('href')){pathStr+=':'+path[i].getAttribute('href').replace('mailto:','').replace('http:/'+'/','').replace('https:/'+'/','');}}}else{var classPath=((path[i].className!='')?'.'+path[i].className.replace(/ /g,'.'):'');if((classPath.indexOf('yui')!=-1)||(classPath.toLowerCase().indexOf('apple-style-span')!=-1)){classPath='';}
var pathStr=tag+((path[i].id)?'#'+path[i].id:'')+classPath;}
if(pathStr.length>10){pathStr=pathStr.substring(0,10)+'...';}
pathArr[pathArr.length]=pathStr;}}
var str=pathArr.join(' '+this.SEP_DOMPATH+' ');if(this.dompath.innerHTML!=str){this.dompath.innerHTML=str;}},_fixNodes:function(){for(var i in this.invalidHTML){if(Lang.hasOwnProperty(this.invalidHTML,i)){var tags=this._getDoc().body.getElementsByTagName(i);for(var h=0;h<tags.length;h++){if(tags[h].parentNode){tags[h].parentNode.removeChild(tags[h]);}}}}
var as=this._getDoc().body.getElementsByTagName('a');if(as.length){for(var i=0;i<as.length;i++){var el=this._getDoc().createElement('span');Dom.addClass(el,'yui-tag-a');Dom.addClass(el,'yui-tag');el.innerHTML=as[i].innerHTML;el.setAttribute('tag','a');el.setAttribute('href',as[i].getAttribute('href'));if(as[i].getAttribute('target')!=null){el.setAttribute('target',as[i].getAttribute('target'));}
as[i].parentNode.replaceChild(el,as[i]);as[i]=null;}}
var imgs=this._getDoc().getElementsByTagName('img');Dom.addClass(imgs,'yui-img');for(var i=0;i<imgs.length;i++){if(imgs[i].getAttribute('href',2)){var url=imgs[i].getAttribute('src',2);if((url!='')&&((url.indexOf('file:/')!=-1)||(url.indexOf(':\\')!=-1))){Dom.addClass(imgs[i],this.CLASS_LOCAL_FILE);}else{Dom.removeClass(imgs[i],this.CLASS_LOCAL_FILE);}}}
var fakeAs=this._getDoc().body.getElementsByTagName('span');for(var i=0;i<fakeAs.length;i++){if(fakeAs[i].getAttribute('href',2)){var url=fakeAs[i].getAttribute('href',2);if((url!='')&&((url.indexOf('file:/')!=-1)||(url.indexOf(':\\')!=-1))){Dom.addClass(fakeAs[i],this.CLASS_LOCAL_FILE);}else{Dom.removeClass(fakeAs[i],this.CLASS_LOCAL_FILE);}}}},_showHidden:function(){if(this._showingHiddenElements){this._showingHiddenElements=false;this.toolbar.deselectButton(this.toolbar.getButtonByValue('hiddenelements'));Dom.removeClass(this._getDoc().body,this.CLASS_HIDDEN);}else{this._showingHiddenElements=true;Dom.addClass(this._getDoc().body,this.CLASS_HIDDEN);this.toolbar.selectButton(this.toolbar.getButtonByValue('hiddenelements'));}},_setCurrentEvent:function(ev){if(ev&&ev.type){}
this.currentEvent=ev;},_handleClick:function(ev){this._setCurrentEvent(ev);if(this.currentWindow){this.closeWindow();}
if(!this.browser.webkit){this.nodeChange();}},_handleMouseUp:function(ev){this._setCurrentEvent(ev);if(this.browser.opera){var sel=Event.getTarget(ev);if(sel&&sel.tagName&&(sel.tagName.toLowerCase()=='img')){this.nodeChange();var self=this;if(this.operaEvent){clearTimeout(this.operaEvent);this.operaEvent=null;this._handleDoubleClick(ev);}else{this.operaEvent=window.setTimeout(function(){self.operaEvent=false;},200);}}}
if(this.browser.webkit||this.browser.opera){if(this.browser.webkit){Event.stopEvent(ev);}}
this.nodeChange();this.fireEvent('editorMouseUp',{type:'editorMouseUp',target:this,ev:ev});},_handleMouseDown:function(ev){this._setCurrentEvent(ev);var sel=Event.getTarget(ev);if(sel&&sel.tagName&&(sel.tagName.toLowerCase()=='img')){if(this.browser.webkit){this.nodeChange();Event.stopEvent(ev);}}
this.fireEvent('editorMouseDown',{type:'editorMouseDown',target:this,ev:ev});},_handleDoubleClick:function(ev){this._setCurrentEvent(ev);var sel=Event.getTarget(ev);if(sel&&sel.tagName&&(sel.tagName.toLowerCase()=='img')){this.currentElement[0]=sel;this.toolbar.fireEvent('insertimageClick',{type:'insertimageClick',target:this.toolbar});this.fireEvent('afterExecCommand',{type:'afterExecCommand',target:this});}else if(sel&&sel.getAttribute&&sel.getAttribute('tag')&&(sel.getAttribute('tag').toLowerCase()=='a')){this.currentElement[0]=sel;this.toolbar.fireEvent('createlinkClick',{type:'createlinkClick',target:this.toolbar});this.fireEvent('afterExecCommand',{type:'afterExecCommand',target:this});}
this.nodeChange();this.fireEvent('editorDoubleClick',{type:'editorDoubleClick',target:this,ev:ev});},_handleKeyUp:function(ev){this._setCurrentEvent(ev);switch(ev.keyCode){case 37:case 38:case 39:case 40:case 46:case 8:case 65:case 27:if((ev.keyCode==27)&&this.currentWindow){this.closeWindow();}
this.nodeChange();break;}
this.fireEvent('editorKeyUp',{type:'editorKeyUp',target:this,ev:ev});},_handleKeyPress:function(ev){this._setCurrentEvent(ev);this.fireEvent('editorKeyPress',{type:'editorKeyPress',target:this,ev:ev});},_handleKeyDown:function(ev){this._setCurrentEvent(ev);if(this.currentWindow){this.closeWindow();}
var doExec=false;var action=null;if(ev.shiftKey&&ev.ctrlKey){doExec=true;}
switch(ev.keyCode){case 84:if(ev.shiftKey&&ev.ctrlKey){this.toolbar._titlebar.firstChild.focus();Event.stopEvent(ev);doExec=false;}
break;case 27:if(ev.shiftKey){this.afterElement.focus();Event.stopEvent(ev);exec=false;}
break;case 219:action='justifyleft';break;case 220:action='justifycenter';break;case 221:action='justifyright';break;case 76:if(this._hasSelection()){this.execCommand('createlink','');this.toolbar.fireEvent('createlinkClick',{type:'createlinkClick',target:this.toolbar});this.fireEvent('afterExecCommand',{type:'afterExecCommand',target:this});doExec=false;}
break;case 66:action='bold';break;case 73:action='italic';break;case 85:action='underline';break;case 9:if(this.browser.safari){this._getDoc().execCommand('inserttext',false,'\t');Event.stopEvent(ev);}
break;case 13:if(this.browser.ie){var _range=this._getRange();var tar=this._getSelectedElement();if(tar&&tar.tagName&&(tar.tagName.toLowerCase()!='li')){if(_range){_range.pasteHTML('<br>');_range.collapse(false);_range.select();}
Event.stopEvent(ev);}}}
if(doExec&&action){this.execCommand(action,null);Event.stopEvent(ev);this.nodeChange();}
this.fireEvent('editorKeyDown',{type:'editorKeyDown',target:this,ev:ev});},nodeChange:function(){this._fixNodes();this.fireEvent('beforeNodeChange',{type:'beforeNodeChange',target:this});if(this.get('dompath')){this._writeDomPath();}
if(!this.get('disabled')){if(this.STOP_NODE_CHANGE){this.STOP_NODE_CHANGE=false;return false;}else{var sel=this._getSelection();var range=this._getRange();for(var i=0;i<this._disabled.length;i++){var _button=this.toolbar.getButtonByValue(this._disabled[i]);if(_button&&_button.get){if(!this._hasSelection()){this.toolbar.disableButton(_button.get('id'));}else{if(!this._alwaysDisabled[this._disabled[i]]){this.toolbar.enableButton(_button.get('id'));}}
if(!this._alwaysEnabled[this._disabled[i]]){this.toolbar.deselectButton(_button);}}}
for(var i=0;i<this.toolbar._buttonList.length;i++){if(!this._alwaysEnabled[this.toolbar._buttonList[i].get('value')]){this.toolbar.deselectButton(this.toolbar._buttonList[i]);}}
var path=this._getDomPath();var olType=null;for(var i=0;i<path.length;i++){var tag=path[i].tagName.toLowerCase();if(path[i].getAttribute('tag')){var tag=path[i].getAttribute('tag').toLowerCase();}
var cmd=this._tag2cmd[tag];if(path[i].style.fontWeight.toLowerCase()=='bold'){cmd='bold';}
if(path[i].style.fontStyle.toLowerCase()=='italic'){cmd='italic';}
if(path[i].style.textDecoration.toLowerCase()=='underline'){cmd='underline';}
if(tag=='ol'){if(path[i].type){olType=path[i].type;}else{olType='A';}}
if(cmd){if(!Lang.isArray(cmd)){cmd=[cmd];}
for(var j=0;j<cmd.length;j++){var button=this.toolbar.getButtonByValue(cmd[j]);this.toolbar.selectButton(button);this.toolbar.enableButton(button);}}
switch(path[i].style.textAlign.toLowerCase()){case'left':case'right':case'center':case'justify':var alignType=path[i].style.textAlign.toLowerCase();if(path[i].style.textAlign.toLowerCase()=='justify'){alignType='full';}
var button=this.toolbar.getButtonByValue('justify'+alignType);this.toolbar.selectButton(button);this.toolbar.enableButton(button);break;}}
var fn_button=this.toolbar.getButtonByValue('fontname');if(fn_button){var family=fn_button._configs.label._initialConfig.value;fn_button.set('label','<span class="yui-toolbar-fontname-'+_cleanClassName(family)+'">'+family+'</span>');this._updateMenuChecked('fontname',family);}
var fs_button=this.toolbar.getButtonByValue('fontsize');if(fs_button){fs_button.set('label',fs_button._configs.label._initialConfig.value);}
var hd_button=this.toolbar.getButtonByValue('heading');if(hd_button){hd_button.set('label',hd_button._configs.label._initialConfig.value);this._updateMenuChecked('heading','none');}}}
this.fireEvent('afterNodeChange',{type:'afterNodeChange',target:this});},_updateMenuChecked:function(button,value,tbar){if(!tbar){tbar=this.toolbar;}
var _button=tbar.getButtonByValue(button);var _menuItems=_button.getMenu().getItems();if(_menuItems.length==0){_button.getMenu()._onBeforeShow();_menuItems=_button.getMenu().getItems();}
for(var i=0;i<_menuItems.length;i++){_menuItems[i].cfg.setProperty('checked',false);if(_menuItems[i].value==value){_menuItems[i].cfg.setProperty('checked',true);}}},_handleToolbarClick:function(ev){var value='';var str='';var cmd=ev.button.value;if(ev.button.menucmd){value=cmd;cmd=ev.button.menucmd;}
if(this.STOP_EXEC_COMMAND){this.STOP_EXEC_COMMAND=false;return false;}else{this.execCommand(cmd,value);}
Event.stopEvent(ev);},_setupAfterElement:function(){if(!this.afterElement){this.afterElement=document.createElement('h2');this.afterElement.className='yui-editor-skipheader';this.afterElement.tabIndex='-1';this.afterElement.innerHTML=this.STR_LEAVE_EDITOR;this.get('element_cont').get('firstChild').appendChild(this.afterElement);}},EDITOR_PANEL_ID:'yui-editor-panel',SEP_DOMPATH:'<',STR_LEAVE_EDITOR:'You have left the Rich Text Editor.',STR_BEFORE_EDITOR:'This text field can contain stylized text and graphics. To cycle through all formatting options, use the keyboard shortcut Control + Shift + T to place focus on the toolbar and navigate between option heading names. <h4>Common formatting keyboard shortcuts:</h4><ul><li>Control Shift B sets text to bold</li> <li>Control Shift I sets text to italic</li> <li>Control Shift U underlines text</li> <li>Control Shift [ aligns text left</li> <li>Control Shift | centers text</li> <li>Control Shift ] aligns text right</li> <li>Control Shift L adds an HTML link</li> <li>To exit this text editor use the keyboard shortcut Control Shift ESC.</li></ul>',STR_CLOSE_WINDOW:'Close Window',STR_CLOSE_WINDOW_NOTE:'To close this window use the Escape key',STR_TITLE:'Rich Text Area.',STR_IMAGE_HERE:'Image Url Here',STR_IMAGE_PROP_TITLE:'Image Options',STR_IMAGE_URL:'Image Url',STR_IMAGE_TITLE:'Description',STR_IMAGE_SIZE:'Size',STR_IMAGE_ORIG_SIZE:'Original Size',STR_IMAGE_COPY:'<span class="tip"><span class="icon icon-info"></span><strong>Note:</strong>To move this image just highlight it, cut, and paste where ever you\'d like.</span>',STR_IMAGE_PADDING:'Padding',STR_IMAGE_BORDER:'Border',STR_IMAGE_TEXTFLOW:'Text Flow',STR_LOCAL_FILE_WARNING:'<span class="tip"><span class="icon icon-warn"></span><strong>Note:</strong>This image/link points to a file on your computer and will not be accessible to others on the internet.</span>',STR_LINK_PROP_TITLE:'Link Options',STR_LINK_PROP_REMOVE:'Remove link from text',STR_LINK_URL:'Link URL',STR_LINK_NEW_WINDOW:'Open in a new window.',STR_LINK_TITLE:'Description',STOP_EXEC_COMMAND:false,STOP_NODE_CHANGE:false,CLASS_HIDDEN:'hidden',CLASS_LOCAL_FILE:'warning-localfile',CLASS_CONTAINER:'yui-editor-container',CLASS_EDITABLE:'yui-editor-editable',CLASS_EDITABLE_CONT:'yui-editor-editable-container',CLASS_PREFIX:'yui-editor',browser:YAHOO.env.ua,init:function(p_oElement,p_oAttributes){YAHOO.widget.Editor.superclass.init.call(this,p_oElement,p_oAttributes);this.get('element_cont').addClass(this.CLASS_CONTAINER);Dom.addClass(this.get('iframe').get('parentNode'),this.CLASS_EDITABLE_CONT);this.get('iframe').addClass(this.CLASS_EDITABLE);},initAttributes:function(attr){YAHOO.widget.Editor.superclass.initAttributes.call(this,attr);var self=this;this.setAttributeConfig('textarea',{value:attr.textarea,writeOnce:true});this.setAttributeConfig('height',{value:attr.height||Dom.getStyle(self.get('textarea'),'height'),writeOnce:true});this.setAttributeConfig('width',{value:attr.width||Dom.getStyle(this.get('textarea'),'width'),writeOnce:true});this.setAttributeConfig('blankimage',{value:attr.blankimage||this._getBlankImage()});this.setAttributeConfig('hiddencss',{value:attr.hiddencss||'.hidden div,.hidden p,.hidden span,.hidden img { border: 1px dotted #ccc; } .hidden .yui-non { border: none; } .hidden img { padding: 2px; }',writeOnce:true});this.setAttributeConfig('css',{value:attr.css||'body { padding: 7px; background-color: #fff; font:13px/1.22 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small; } span.yui-tag-a { color: blue; text-decoration: underline; } span.yui-tag-blockquote { margin: 1em; display: block; } span.yui-tag-indent { margin-left: 1em; display: block; } .warning-localfile { border-bottom: 1px dashed red !important; }',writeOnce:true});this.setAttributeConfig('html',{value:attr.html||'<!DOCTYPE HTML PUBLIC "-/'+'/W3C/'+'/DTD HTML 4.01/'+'/EN" "http:/'+'/www.w3.org/TR/html4/strict.dtd"><html><head><title>{TITLE}</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><style>{CSS}</style><style>{HIDDEN_CSS}</style></head><body onload="document.body._rteLoaded = true;">{CONTENT}</body></html>',writeOnce:true});this.setAttributeConfig('handleSubmit',{value:false,writeOnce:true,method:function(exec){if(exec){var ta=this.get('textarea');if(ta.form){Event.addListener(ta.form,'submit',function(){this.saveHTML();},this,true);}}}});this.setAttributeConfig('iframe',{value:null,writeOnce:true});this.setAttributeConfig('disabled',{value:false,method:function(disabled){if(disabled){if(!this._mask){this._setDesignMode('off');this.toolbar.set('disabled',true);this._mask=document.createElement('DIV');Dom.setStyle(this._mask,'height','100%');Dom.setStyle(this._mask,'width','100%');Dom.setStyle(this._mask,'position','absolute');Dom.setStyle(this._mask,'top','0');Dom.setStyle(this._mask,'left','0');Dom.setStyle(this._mask,'opacity','.5');Dom.addClass(this._mask,'yui-editor-masked');this.get('iframe').get('parentNode').appendChild(this._mask);}}else{if(this._mask){this._mask.parentNode.removeChild(this._mask);this._mask=null;this.toolbar.set('disabled',false);this._setDesignMode('on');this._focusWindow();}}}});this.setAttributeConfig('element_cont',{value:null,writeOnce:true});this.setAttributeConfig('toolbar_cont',{value:null,writeOnce:true});this.setAttributeConfig('toolbar',{value:attr.toolbar||{collapse:true,titlebar:'Text Editing Tools',draggable:false,buttons:[{group:'fontstyle',label:'Font Name and Size',buttons:[{type:'select',label:'Arial',value:'fontname',disabled:true,menu:[{text:'Arial',checked:true},{text:'Arial Black'},{text:'Comic Sans MS'},{text:'Courier New'},{text:'Lucida Console'},{text:'Tahoma'},{text:'Times New Roman'},{text:'Trebuchet MS'},{text:'Verdana'}]},{type:'spin',label:'13',value:'fontsize',range:[9,75],disabled:true}]},{type:'separator'},{group:'textstyle',label:'Font Style',buttons:[{type:'push',label:'Bold CTRL + SHIFT + B',value:'bold'},{type:'push',label:'Italic CTRL + SHIFT + I',value:'italic'},{type:'push',label:'Underline CTRL + SHIFT + U',value:'underline'},{type:'separator'},{type:'push',label:'Subscript',value:'subscript',disabled:true},{type:'push',label:'Superscript',value:'superscript',disabled:true},{type:'separator'},{type:'color',label:'Font Color',value:'forecolor',disabled:true},{type:'color',label:'Background Color',value:'backcolor',disabled:true},{type:'separator'},{type:'push',label:'Remove Formatting',value:'removeformat',disabled:true},{type:'push',label:'Hidden Elements',value:'hiddenelements'}]},{type:'separator'},{group:'alignment',label:'Alignment',buttons:[{type:'push',label:'Align Left CTRL + SHIFT + [',value:'justifyleft'},{type:'push',label:'Align Center CTRL + SHIFT + |',value:'justifycenter'},{type:'push',label:'Align Right CTRL + SHIFT + ]',value:'justifyright'},{type:'push',label:'Justify',value:'justifyfull'}]},{type:'separator'},{group:'parastyle',label:'Paragraph Style',buttons:[{type:'select',label:'Normal',value:'heading',disabled:true,menu:[{text:'Normal',value:'none',checked:true},{text:'Header 1',value:'h1'},{text:'Header 2',value:'h2'},{text:'Header 3',value:'h3'},{text:'Header 4',value:'h4'},{text:'Header 5',value:'h5'},{text:'Header 6',value:'h6'}]}]},{type:'separator'},{group:'indentlist',label:'Indenting and Lists',buttons:[{type:'push',label:'Indent',value:'indent',disabled:true},{type:'push',label:'Outdent',value:'outdent',disabled:true},{type:'push',label:'Create an Unordered List',value:'insertunorderedlist'},{type:'push',label:'Create an Ordered List',value:'insertorderedlist'}]},{type:'separator'},{group:'insertitem',label:'Insert Item',buttons:[{type:'push',label:'HTML Link CTRL + SHIFT + L',value:'createlink',disabled:true},{type:'push',label:'Insert Image',value:'insertimage'}]}]},writeOnce:true,method:function(toolbar){}});this.setAttributeConfig('animate',{value:false,validator:function(value){var ret=true;if(!YAHOO.util.Anim){ret=false;}
return ret;}});this.setAttributeConfig('panel',{value:null,writeOnce:true,validator:function(value){var ret=true;if(!YAHOO.widget.Panel){ret=false;}
return ret;}});this.setAttributeConfig('localFileWarning',{value:true});this.setAttributeConfig('dompath',{value:false,method:function(dompath){if(dompath&&!this.dompath){this.dompath=document.createElement('DIV');this.dompath.id=this.get('id')+'_dompath';Dom.addClass(this.dompath,'dompath');this.get('element_cont').get('firstChild').appendChild(this.dompath);if(this.get('iframe')){this._writeDomPath();}}else if(!dompath&&this.dompath){this.dompath.parentNode.removeChild(this.dompath);this.dompath=null;}
this._setupAfterElement();}});this.setAttributeConfig('markup',{value:'semantic',validator:function(markup){switch(markup.toLowerCase()){case'semantic':case'css':case'default':return true;break;}
return false;}});this.on('afterRender',function(){this._renderPanel();});},_getBlankImage:function(){if(!this.DOMReady){this._queue[this._queue.length]=['_getBlankImage',arguments];return'';}
var div=document.createElement('div');div.style.position='absolute';div.style.top='-9999px';div.style.left='-9999px';div.className=this.CLASS_PREFIX+'-blankimage';document.body.appendChild(div);var img=YAHOO.util.Dom.getStyle(div,'background-image');img=img.replace('url(','').replace(')','').replace(/"/g,'');this.set('blankimage',img);return img;},_handleFontSize:function(o){var button=this.toolbar.getButtonById(o.button.id);var value=button.get('label')+'px';this.execCommand('fontsize',value);this.STOP_EXEC_COMMAND=true;},_handleColorPicker:function(o){var cmd=o.button;var value='#'+o.color;if((cmd=='forecolor')||(cmd=='backcolor')){this.execCommand(cmd,value);}},_handleAlign:function(o){var button=this.toolbar.getButtonById(o.button.id);var cmd=null;for(var i=0;i<o.button.menu.length;i++){if(o.button.menu[i].value==o.button.value){cmd=o.button.menu[i].value;}}
var value=this._getSelection();this.execCommand(cmd,value);this.STOP_EXEC_COMMAND=true;},_handleAfterNodeChange:function(){var path=this._getDomPath();for(var i=0;i<path.length;i++){var elm=path[i],tag=elm.tagName.toLowerCase(),family=null,fontsize=null,validFont=false;if(elm.getAttribute('tag')){tag=elm.getAttribute('tag');}
family=elm.getAttribute('face');if(Dom.getStyle(elm,'font-family')){family=Dom.getStyle(elm,'font-family');}
var fn_button=this.toolbar.getButtonByValue('fontname');if(fn_button){for(var b=0;b<fn_button._configs.menu.value.length;b++){if(family&&fn_button._configs.menu.value[b].text.toLowerCase()==family.toLowerCase()){validFont=true;family=fn_button._configs.menu.value[b].text;}}
if(!validFont){family=fn_button._configs.label._initialConfig.value;}
fn_button.set('label','<span class="yui-toolbar-fontname-'+_cleanClassName(family)+'">'+family+'</span>');this._updateMenuChecked('fontname',family);}
var fs_button=this.toolbar.getButtonByValue('fontsize');if(fs_button){fontsize=parseInt(Dom.getStyle(elm,'fontSize'));if((fontsize==null)||isNaN(fontsize)){fontsize=fs_button._configs.label._initialConfig.value;}
fs_button.set('label',''+fontsize);}
if(tag.substring(0,1)=='h'){var hd_button=this.toolbar.getButtonByValue('heading');if(hd_button){for(var b=0;b<hd_button._configs.menu.value.length;b++){if(hd_button._configs.menu.value[b].value.toLowerCase()==tag){hd_button.set('label',hd_button._configs.menu.value[b].text);}}
this._updateMenuChecked('heading',tag);}}}
if(elm&&elm.tagName&&(elm.tagName.toLowerCase()!='body')){this.toolbar.enableButton(fn_button);this.toolbar.enableButton(fs_button);}},_handleInsertImageClick:function(){this.on('afterExecCommand',function(){var el=this.currentElement[0],title='',src='',align='',height=75,width=75,padding=0,blankimage=false,win=new YAHOO.widget.EditorWindow('insertimage',{width:'415px'});if(!el){el=this._getSelectedElement();}
if(el){if(el.getAttribute('src')){src=el.getAttribute('src',2);if(src.indexOf(this.get('blankimage'))!=-1){src=this.STR_IMAGE_HERE;blankimage=true;}}
if(el.getAttribute('alt',2)){title=el.getAttribute('alt',2);}
if(el.getAttribute('title',2)){title=el.getAttribute('title',2);}
height=parseInt(el.height);width=parseInt(el.width);if(el.style.height){height=parseInt(el.style.height);}
if(el.style.width){width=parseInt(el.style.width);}
if(el.style.margin){padding=parseInt(el.style.margin);}
if(!el._height){el._height=height;}
if(!el._width){el._width=width;}
var oheight=el._height;var owidth=el._width;}
if(!win.cache){var str='<label for="insertimage_url"><strong>'+this.STR_IMAGE_URL+':</strong> <input type="text" id="insertimage_url" value="'+src+'" size="40"></label>';var body=document.createElement('div');body.innerHTML=str;var tbarCont=document.createElement('div');tbarCont.id='img_toolbar';body.appendChild(tbarCont);var str2='<label for="insertimage_title"><strong>'+this.STR_IMAGE_TITLE+':</strong> <input type="text" id="insertimage_title" value="'+title+'" size="40"></label>';var div=document.createElement('div');div.innerHTML=str2;body.appendChild(div);win.cache=body;}else{body=win.cache;}
var tbar=new YAHOO.widget.Toolbar(tbarCont,{buttons:[{group:'padding',label:this.STR_IMAGE_PADDING+':',buttons:[{type:'spin',label:''+padding,value:'padding',range:[0,50]}]},{type:'separator'},{group:'border',label:this.STR_IMAGE_BORDER+':',buttons:[{type:'select',label:'Border Size',value:'bordersize',menu:[{text:'none',value:'0',checked:true},{text:'----',value:'1'},{text:'----',value:'2'},{text:'----',value:'3'},{text:'----',value:'4'},{text:'----',value:'5'}]},{type:'select',label:'Border Type',value:'bordertype',disabled:true,menu:[{text:'----',value:'solid',checked:true},{text:'----',value:'dashed'},{text:'----',value:'dotted'}]},{type:'color',label:'Border Color',value:'bordercolor',disabled:true}]},{type:'separator'},{group:'textflow',label:this.STR_IMAGE_TEXTFLOW+':',buttons:[{type:'push',label:'Left',value:'left'},{type:'push',label:'Inline',value:'inline'},{type:'push',label:'Block',value:'block'},{type:'push',label:'Right',value:'right'}]}]});var bsize='0';var btype='solid';if(el.style.borderLeftWidth){bsize=parseInt(el.style.borderLeftWidth);}
if(el.style.borderLeftStyle){btype=el.style.borderLeftStyle;}
var bs_button=tbar.getButtonByValue('bordersize');var bSizeStr=((parseInt(bsize)>0)?'----':'none');bs_button.set('label','<span class="yui-toolbar-bordersize-'+bsize+'">'+bSizeStr+'</span>');this._updateMenuChecked('bordersize',bsize,tbar);var bs_button=tbar.getButtonByValue('bordertype');bs_button.set('label','<span class="yui-toolbar-bordertype-'+btype+'">----</span>');this._updateMenuChecked('bordertype',btype,tbar);if(parseInt(bsize)>0){tbar.enableButton(tbar.getButtonByValue('bordertype'));tbar.enableButton(tbar.getButtonByValue('bordercolor'));}
var cont=tbar.get('cont');var hw=document.createElement('div');hw.className='yui-toolbar-group yui-toolbar-group-padding height-width';hw.innerHTML='<h3>'+this.STR_IMAGE_SIZE+':</h3>';var orgSize='';if((height!=oheight)||(width!=owidth)){orgSize='<span class="info">'+this.STR_IMAGE_ORIG_SIZE+'<br>'+owidth+' x '+oheight+'</span>';}
hw.innerHTML+='<span><input type="text" size="3" value="'+width+'" id="insertimage_width"> x <input type="text" size="3" value="'+height+'" id="insertimage_height"></span>'+orgSize;cont.insertBefore(hw,cont.firstChild);Event.onAvailable('insertimage_width',function(){Event.on('insertimage_width','blur',function(){var value=parseInt(Dom.get('insertimage_width').value);if(value>5){el.style.width=value+'px';this.moveWindow();}},this,true);},this,true);Event.onAvailable('insertimage_height',function(){Event.on('insertimage_height','blur',function(){var value=parseInt(Dom.get('insertimage_height').value);if(value>5){el.style.height=value+'px';this.moveWindow();}},this,true);},this,true);if(el.align=='right'){tbar.selectButton(tbar.getButtonByValue('right'));}else if(el.align=='left'){tbar.selectButton(tbar.getButtonByValue('left'));}else if(el.style.display=='block'){tbar.selectButton(tbar.getButtonByValue('block'));}else{tbar.selectButton(tbar.getButtonByValue('inline'));}
if(parseInt(el.style.marginLeft)>0){tbar.getButtonByValue('padding').set('label',''+parseInt(el.style.marginLeft));}
if(el.style.borderSize){tbar.selectButton(tbar.getButtonByValue('bordersize'));tbar.selectButton(tbar.getButtonByValue(parseInt(el.style.borderSize)));}
tbar.on('colorPickerClicked',function(o){var size='1',type='solid',color='black';if(el.style.borderLeftWidth){size=parseInt(el.style.borderLeftWidth);}
if(el.style.borderLeftStyle){type=el.style.borderLeftStyle;}
if(el.style.borderLeftColor){color=el.style.borderLeftColor;}
var borderString=size+'px '+type+' #'+o.color;el.style.border=borderString;},this.toolbar,true);tbar.on('buttonClick',function(o){var value=o.button.value;if(o.button.menucmd){value=o.button.menucmd}
var size='1',type='solid',color='black';if(el.style.borderLeftWidth){size=parseInt(el.style.borderLeftWidth);}
if(el.style.borderLeftStyle){type=el.style.borderLeftStyle;}
if(el.style.borderLeftColor){color=el.style.borderLeftColor;}
switch(value){case'bordersize':var borderString=parseInt(o.button.value)+'px '+type+' '+color;el.style.border=borderString;if(parseInt(o.button.value)>0){tbar.enableButton(tbar.getButtonByValue('bordertype'));tbar.enableButton(tbar.getButtonByValue('bordercolor'));}else{tbar.disableButton(tbar.getButtonByValue('bordertype'));tbar.disableButton(tbar.getButtonByValue('bordercolor'));}
break;case'bordertype':var borderString=size+'px '+o.button.value+' '+color;el.style.border=borderString;break;case'right':case'left':tbar.deselectAllButtons();el.style.display='';el.align=o.button.value;break;case'inline':tbar.deselectAllButtons();el.style.display='';el.align='';break;case'block':tbar.deselectAllButtons();el.style.display='block';el.align='center';break;case'padding':var _button=tbar.getButtonById(o.button.id);el.style.margin=_button.get('label')+'px';break;}
tbar.selectButton(tbar.getButtonByValue(o.button.value));this.moveWindow();},this,true);win.setHeader(this.STR_IMAGE_PROP_TITLE);win.setBody(body);if((this.browser.webkit&&!this.browser.webkit3)||this.browser.opera){var str=this.STR_IMAGE_COPY;win.setFooter(str);}
this.openWindow(win);Event.onAvailable('insertimage_url',function(){window.setTimeout(function(){YAHOO.util.Dom.get('insertimage_url').focus();if(blankimage){YAHOO.util.Dom.get('insertimage_url').select();}},50);if(this.get('localFileWarning')){Event.on('insertimage_url','blur',function(){var url=Dom.get('insertimage_url');if((url.value!='')&&((url.value.indexOf('file:/')!=-1)||(url.value.indexOf(':\\')!=-1))){Dom.addClass(url,'warning');var str=this.STR_LOCAL_FILE_WARNING;this.get('panel').setFooter(str);}else{Dom.removeClass(url,'warning');this.get('panel').setFooter(' ');if((this.browser.webkit&&!this.browser.webkit3)||this.browser.opera){var str=this.STR_IMAGE_COPY;this.get('panel').setFooter(str);}
if(url&&url.value&&(url.value!=this.STR_IMAGE_HERE)){this.currentElement[0].setAttribute('src',url.value);var img=new Image();var self=this;window.setTimeout(function(){YAHOO.util.Dom.get('insertimage_height').value=img.height;YAHOO.util.Dom.get('insertimage_width').value=img.width;if(!self.currentElement[0]._height){self.currentElement[0]._height=img.height;}
if(!self.currentElement[0]._width){self.currentElement[0]._width=img.width;}
self.moveWindow();},200);img.src=url.value;}}},this,true);}},this,true);});},_handleInsertImageWindowClose:function(){var url=Dom.get('insertimage_url');var title=Dom.get('insertimage_title');var el=this.currentElement[0];if(url&&url.value&&(url.value!=this.STR_IMAGE_HERE)){el.setAttribute('src',url.value);el.setAttribute('title',title.value);el.setAttribute('alt',title.value);}else{el.parentNode.removeChild(el);}},_handleCreateLinkClick:function(){this.on('afterExecCommand',function(){var win=new YAHOO.widget.EditorWindow('createlink',{width:'300px'});var el=this.currentElement[0],url='',title='',target='',localFile=false;if(el){if(el.getAttribute('href')!=null){url=el.getAttribute('href');if((url!='')&&((url.indexOf('file:/')!=-1)||(url.indexOf(':\\')!=-1))){var str=this.STR_LOCAL_FILE_WARNING;win.setFooter(str);localFile=true;}else{win.setFooter(' ');}}
if(el.getAttribute('title')!=null){title=el.getAttribute('title');}
if(el.getAttribute('target')!=null){target=el.getAttribute('target');}}
var str='<label for="createlink_url"><strong>'+this.STR_LINK_URL+':</strong> <input type="text" name="createlink_url" id="createlink_url" value="'+url+'"'+((localFile)?' class="warning"':'')+'></label>';str+='<label for="createlink_target"><strong>&nbsp;</strong><input type="checkbox" name="createlink_target_" id="createlink_target" value="_blank"'+((target)?' checked':'')+'> '+this.STR_LINK_NEW_WINDOW+'</label>';str+='<label for="createlink_title"><strong>'+this.STR_LINK_TITLE+':</strong> <input type="text" name="createlink_title" id="createlink_title" value="'+title+'"></label>';var body=document.createElement('div');body.innerHTML=str;var unlinkCont=document.createElement('div');unlinkCont.className='removeLink';var unlink=document.createElement('a');unlink.href='#';unlink.innerHTML=this.STR_LINK_PROP_REMOVE;unlink.title=this.STR_LINK_PROP_REMOVE;Event.on(unlink,'click',function(ev){Event.stopEvent(ev);this.execCommand('unlink');this.closeWindow();},this,true);unlinkCont.appendChild(unlink);body.appendChild(unlinkCont);win.setHeader(this.STR_LINK_PROP_TITLE);win.setBody(body);Event.onAvailable('createlink_url',function(){window.setTimeout(function(){try{YAHOO.util.Dom.get('createlink_url').focus();}catch(e){}},50);Event.on('createlink_url','blur',function(){var url=Dom.get('createlink_url');if((url.value!='')&&((url.value.indexOf('file:/')!=-1)||(url.value.indexOf(':\\')!=-1))){Dom.addClass(url,'warning');var str=this.STR_LOCAL_FILE_WARNING;this.get('panel').setFooter(str);}else{Dom.removeClass(url,'warning');this.get('panel').setFooter(' ');}},this,true);},this,true);this.openWindow(win);});},_handleCreateLinkWindowClose:function(){var url=Dom.get('createlink_url');var target=Dom.get('createlink_target');var title=Dom.get('createlink_title');var el=this.currentElement[0];if(url&&url.value){var urlValue=url.value;if((urlValue.indexOf(':/'+'/')==-1)&&(urlValue.substring(0,1)!='/')&&(urlValue.substring(0,6).toLowerCase()!='mailto')){if((urlValue.indexOf('@')!=-1)&&(urlValue.substring(0,6).toLowerCase()!='mailto')){urlValue='mailto:'+urlValue;}else{urlValue='http:/'+'/'+urlValue;}}
el.setAttribute('href',urlValue);if(target.checked){el.setAttribute('target',target.value);}else{el.setAttribute('target','');}
el.setAttribute('title',((title.value)?title.value:''));}else{el.removeAttribute('tag');Dom.removeClass(el,'yui-tag-a');Dom.removeClass(el,'yui-tag');Dom.addClass(el,'yui-non');}
this.nodeChange();},render:function(){if(!this.DOMReady){this._queue[this._queue.length]=['render',arguments];return false;}
var self=this;var tbarConf=this.get('toolbar');tbarConf.disabled=true;this.toolbar=new Toolbar(this.get('toolbar_cont'),tbarConf);this.fireEvent('toolbarLoaded',{type:'toolbarLoaded',target:this.toolbar});this.toolbar.on('toolbarCollapsed',function(){if(this.currentWindow){this.moveWindow();}},this,true);this.toolbar.on('toolbarExpanded',function(){if(this.currentWindow){this.moveWindow();}},this,true);this.toolbar.on('fontsizeClick',function(o){this._handleFontSize(o);},this,true);this.toolbar.on('colorPickerClicked',function(o){this._handleColorPicker(o);},this,true);this.toolbar.on('alignClick',function(o){this._handleAlign(o);},this,true);this.on('afterNodeChange',function(){this._handleAfterNodeChange();},this,true);this.toolbar.on('insertimageClick',function(){this._handleInsertImageClick();},this,true);this.on('windowinsertimageClose',function(){this._handleInsertImageWindowClose();},this,true);this.toolbar.on('createlinkClick',function(){this._handleCreateLinkClick();},this,true);this.on('windowcreatelinkClose',function(){this._handleCreateLinkWindowClose();},this,true);this.get('parentNode').replaceChild(this.get('element_cont').get('element'),this.get('element'));if(!this.beforeElement){this.beforeElement=document.createElement('h2');this.beforeElement.className='yui-editor-skipheader';this.beforeElement.tabIndex='-1';this.beforeElement.innerHTML=this.STR_BEFORE_EDITOR;this.get('element_cont').get('firstChild').insertBefore(this.beforeElement,this.toolbar.get('nextSibling'));}
Dom.setStyle(this.get('textarea'),'display','none');this.get('element_cont').appendChild(this.get('element'));this.get('element_cont').setStyle('display','block');this.get('element_cont').setStyle('width',this.get('width'));Dom.setStyle(this.get('iframe').get('parentNode'),'height',this.get('height'));this.get('iframe').setStyle('width','100%');this.get('iframe').setStyle('height','100%');var self=this;window.setTimeout(function(){self._setInitialContent.call(self);},10);this.fireEvent('afterRender',{type:'afterRender',target:this});},execCommand:function(action,value){this.fireEvent('beforeExecCommand',{type:'beforeExecCommand',target:this,args:arguments});if(this.STOP_EXEC_COMMAND){this.STOP_EXEC_COMMAND=false;return false;}
this._setMarkupType(action);if(this.browser.ie){this._getWindow().focus();}
var exec=true;var _sel=this._getSelection();var _range=this._getRange();var _selEl=this._getSelectedElement();if(_selEl){_sel=_selEl;}
switch(action.toLowerCase()){case'heading':if(this.browser.ie){action='formatblock';}
if(value=='none'){if((_sel&&_sel.tagName&&(_sel.tagName.toLowerCase().substring(0,1)=='h'))||(_sel&&_sel.parentNode&&_sel.parentNode.tagName&&(_sel.parentNode.tagName.toLowerCase().substring(0,1)=='h'))){if(_sel.parentNode.tagName.toLowerCase().substring(0,1)=='h'){_sel=_sel.parentNode;}
var _span=this._getDoc().createElement('span');_span.className='yui-non';_span.innerHTML=_sel.innerHTML;_sel.parentNode.replaceChild(_span,_sel);}
exec=false;}else{if(this.browser.ie||this.browser.webkit||this.browser.opera){this._createCurrentElement(value);exec=false;}}
break;case'backcolor':if(this.browser.gecko||this.browser.opera){this._setEditorStyle(true);action='hilitecolor';}
break;case'hiddenelements':this._showHidden();exec=false;break;case'unlink':var el=this.currentElement[0];el.removeAttribute('title');el.removeAttribute('tag');el.removeAttribute('target');el.removeAttribute('href');YAHOO.util.Dom.addClass(el,'yui-non');YAHOO.util.Dom.removeClass(el,'yui-tag-a');YAHOO.util.Dom.removeClass(el,'yui-tag');exec=false;break;case'createlink':var el=this._getSelectedElement();if(!el||(el.getAttribute('tag')!='a')){this._createCurrentElement('a');}else{this.currentElement[0]=el;}
exec=false;break;case'insertimage':if(value==''){value=this.get('blankimage');}
var el=this._getSelectedElement();if(el&&el.tagName&&(el.tagName.toLowerCase()=='img')){this.currentElement[0]=el;exec=false;}else{if(this._getDoc().queryCommandEnabled(action)){this._getDoc().execCommand('insertimage',false,value);var imgs=this._getDoc().getElementsByTagName('img');for(var i=0;i<imgs.length;i++){if(!YAHOO.util.Dom.hasClass(imgs[i],'yui-img')){YAHOO.util.Dom.addClass(imgs[i],'yui-img');this.currentElement[0]=imgs[i];}}
exec=false;}else{this._createCurrentElement('img');var _img=this._getDoc().createElement('img');_img.setAttribute('src',value);YAHOO.util.Dom.addClass(_img,'yui-img');this.currentElement[0].parentNode.replaceChild(_img,this.currentElement[0]);this.currentElement[0]=_img;exec=false;}}
break;case'inserthtml':if(this.browser.webkit&&!this._getDoc().queryCommandEnabled(action)){this._createCurrentElement('img');var _span=this._getDoc().createElement('span');_span.innerHTML=value;this.currentElement[0].parentNode.replaceChild(_span,this.currentElement[0]);exec=false;}else if(this.browser.ie){var _range=this._getRange();if(_range.item){_range.item(0).outerHTML=value;}else{_range.pasteHTML(value);}
exec=false;}
break;case'removeformat':if(this.browser.webkit&&!this._getDoc().queryCommandEnabled(action)){this._createCurrentElement('span');YAHOO.util.Dom.addClass(this.currentElement[0],'yui-non');var re=/<\S[^><]*>/g;var str=this.currentElement[0].innerHTML.replace(re,'');var _txt=this._getDoc().createTextNode(str);this.currentElement[0].parentNode.parentNode.replaceChild(_txt,this.currentElement[0].parentNode);exec=false;}
break;case'superscript':case'subscript':if(this.browser.webkit){var tag=action.toLowerCase().substring(0,3);this._createCurrentElement(tag);if(this.currentElement[0].parentNode.tagName.toLowerCase()==tag){var span=this._getDoc().createElement('span');span.innerHTML=this.currentElement[0].innerHTML;YAHOO.util.Dom.addClass(span,'yui-non');this.currentElement[0].parentNode.parentNode.replaceChild(span,this.currentElement[0].parentNode);}else{var _sub=this._getDoc().createElement(tag);_sub.innerHTML=this.currentElement[0].innerHTML;this.currentElement[0].parentNode.replaceChild(_sub,this.currentElement[0]);}
exec=false;}
break;case'formatblock':value='blockquote';if(this.browser.webkit){this._createCurrentElement('blockquote');if(YAHOO.util.Dom.hasClass(this.currentElement[0].parentNode,'yui-tag-blockquote')){var span=this._getDoc().createElement('span');span.innerHTML=this.currentElement[0].innerHTML;YAHOO.util.Dom.addClass(span,'yui-non');this.currentElement[0].parentNode.parentNode.replaceChild(span,this.currentElement[0].parentNode);}
exec=false;}else{var tar=Event.getTarget(this.currentEvent);if(tar&&tar.tagName&&(tar.tagName.toLowerCase()=='blockquote')){var span=this._getDoc().createElement('span');span.innerHTML=tar.innerHTML;YAHOO.util.Dom.addClass(span,'yui-non');tar.parentNode.replaceChild(span,tar);exec=false;}}
break;case'indent':case'outdent':this._createCurrentElement(action.toLowerCase());if(this.currentElement[0].parentNode){if(action.toLowerCase()=='outdent'){if(YAHOO.util.Dom.hasClass(this.currentElement[0].parentNode,'yui-tag-indent')){var span=this._getDoc().createElement('span');span.innerHTML=this.currentElement[0].innerHTML;YAHOO.util.Dom.addClass(span,'yui-non');this.currentElement[0].parentNode.parentNode.replaceChild(span,this.currentElement[0].parentNode);}}}
exec=false;break;case'insertorderedlist':case'insertunorderedlist':var tag=((action.toLowerCase()=='insertorderedlist')?'ol':'ul');if((this.browser.webkit&&!this._getDoc().queryCommandEnabled(action))){var selEl=this._getSelectedElement();if((selEl.tagName.toLowerCase()=='li')&&(selEl.parentNode.tagName.toLowerCase()==tag)){var el=selEl.parentNode;var list=this._getDoc().createElement('span');YAHOO.util.Dom.addClass(list,'yui-non');var str='';var lis=el.getElementsByTagName('li');for(var i=0;i<lis.length;i++){str+=lis[i].innerHTML+'<br>';}
list.innerHTML=str;}else{this._createCurrentElement(tag.toLowerCase());var el=this.currentElement[0];var list=this._getDoc().createElement(tag);if(tag=='ol'){list.type=value;}
var li=this._getDoc().createElement('li');li.innerHTML=el.innerHTML+'&nbsp;';list.appendChild(li);}
el.parentNode.replaceChild(list,el);exec=false;}else{var el=this._getSelectedElement();if((el.tagName.toLowerCase()=='li')&&(el.parentNode.tagName.toLowerCase()==tag)||(this.browser.ie&&this._getRange().parentElement&&this._getRange().parentElement.tagName&&(this._getRange().parentElement.tagName.toLowerCase()=='li'))){if(this.browser.ie){exec=false;var str='';var lis=el.parentNode.getElementsByTagName('li');for(var i=0;i<lis.length;i++){str+=lis[i].innerHTML+'<br>';}
var newEl=this._getDoc().createElement('span');newEl.innerHTML=str;el.parentNode.parentNode.replaceChild(newEl,el.parentNode);}else{this.nodeChange();this._getDoc().execCommand(action,'',el.parentNode);this.nodeChange();}}
if(this.browser.opera){var self=this;window.setTimeout(function(){var lis=self._getDoc().getElementsByTagName('li');for(var i=0;i<lis.length;i++){if(lis[i].innerHTML.toLowerCase()=='<br>'){lis[i].parentNode.parentNode.removeChild(lis[i].parentNode);}}},30);}
if(this.browser.ie&&exec){var html='';if(this._getRange().html){html='<li>'+this._getRange().html+'</li>';}else{html='<li>'+this._getRange().text+'</li>';}
this._getRange().pasteHTML('<'+tag+'>'+html+'</'+tag+'>');exec=false;}}
break;case'fontname':var selEl=this._getSelectedElement();this.currentFont=value;if(selEl&&selEl.tagName&&!this._hasSelection()){YAHOO.util.Dom.setStyle(selEl,'font-family',value);exec=false;}
break;case'fontsize':if((this.currentElement.length>0)&&(!this._hasSelection())){YAHOO.util.Dom.setStyle(this.currentElement,'fontSize',value);}else{this._createCurrentElement('span',{'fontSize':value});}
exec=false;break;}
if(exec){try{this._getDoc().execCommand(action,false,value);}catch(e){}}else{}
this.on('afterExecCommand',function(){this.unsubscribeAll('afterExecCommand');this.nodeChange();});this.fireEvent('afterExecCommand',{type:'afterExecCommand',target:this});},_createCurrentElement:function(tagName,tagStyle){var tagName=((tagName)?tagName:'a'),sel=this._getSelection(),tar=null,el=[],_doc=this._getDoc();if(this.currentFont){if(!tagStyle){tagStyle={};}
tagStyle.fontFamily=this.currentFont;this.currentFont=null;}
this.currentElement=[];var _elCreate=function(){switch(tagName){case'h1':case'h2':case'h3':case'h4':case'h5':case'h6':var el=_doc.createElement(tagName);break;default:var el=_doc.createElement('span');YAHOO.util.Dom.addClass(el,'yui-tag-'+tagName);YAHOO.util.Dom.addClass(el,'yui-tag');el.setAttribute('tag',tagName);el.tabIndex=1;for(var i in tagStyle){if(YAHOO.util.Lang.hasOwnProperty(tagStyle,i)){el.style[i]=tagStyle[i];}}
break;}
return el;};if(!this._hasSelection()){if(this._getDoc().queryCommandEnabled('insertimage')){this._getDoc().execCommand('insertimage',false,'yui-tmp-img');var imgs=this._getDoc().getElementsByTagName('img');for(var i=0;i<imgs.length;i++){if(imgs[i].getAttribute('src',2)=='yui-tmp-img'){el=_elCreate();imgs[i].parentNode.replaceChild(el,imgs[i]);this.currentElement[this.currentElement.length]=el;}}}else{if(this.currentEvent){tar=YAHOO.util.Event.getTarget(this.currentEvent);}else{tar=this._getDoc().body;}}
if(tar){el=_elCreate();if(tar.tagName.toLowerCase()=='body'){tar.appendChild(el);}else if(tar.nextSibling){tar.parentNode.insertBefore(el,tar.nextSibling);}else{tar.parentNode.appendChild(el);}
this.currentElement[this.currentElement.length]=el;this.currentEvent=null;if(this.browser.webkit){this._getSelection().setBaseAndExtent(el,0,el,0);this._getSelection().collapse(true);}}}else{this._setEditorStyle(true);this._getDoc().execCommand('fontname',false,'yui-tmp');var _tmp=[];var _tmp1=this._getDoc().getElementsByTagName('font');var _tmp2=this._getDoc().getElementsByTagName(this._getSelectedElement().tagName);var _tmp3=this._getDoc().getElementsByTagName('span');var _tmp4=this._getDoc().getElementsByTagName('i');var _tmp5=this._getDoc().getElementsByTagName('b');for(var e=0;e<_tmp1.length;e++){_tmp[_tmp.length]=_tmp1[e];}
for(var e=0;e<_tmp2.length;e++){_tmp[_tmp.length]=_tmp2[e];}
for(var e=0;e<_tmp3.length;e++){_tmp[_tmp.length]=_tmp3[e];}
for(var e=0;e<_tmp4.length;e++){_tmp[_tmp.length]=_tmp4[e];}
for(var e=0;e<_tmp5.length;e++){_tmp[_tmp.length]=_tmp5[e];}
for(var i=0;i<_tmp.length;i++){if((YAHOO.util.Dom.getStyle(_tmp[i],'font-family')=='yui-tmp')||(_tmp[i].face&&(_tmp[i].face=='yui-tmp'))){var el=_elCreate();el.innerHTML=_tmp[i].innerHTML;if(_tmp[i].parentNode){_tmp[i].parentNode.replaceChild(el,_tmp[i]);this.currentElement[this.currentElement.length]=el;this.currentEvent=null;if(this.browser.webkit){this._getSelection().setBaseAndExtent(el,0,el,0);this._getSelection().collapse(true);}
if(this.browser.ie&&tagStyle&&tagStyle.fontSize){this._getSelection().empty();}
if(this.browser.gecko){this._getSelection().collapseToStart();}}}}
var len=this.currentElement.length;for(var i=0;i<len;i++){if((i+1)!=len){if(this.currentElement[i]&&this.currentElement[i].nextSibling){if(this.currentElement[i].tagName&&(this.currentElement[i].tagName.toLowerCase()!='br')){this.currentElement[this.currentElement.length]=this.currentElement[i].nextSibling;}}}}}},saveHTML:function(){var html=this.cleanHTML();this.get('textarea').value=html;return html;},setEditorHTML:function(html){this._getDoc().body.innerHTML=html;this.nodeChange();},getEditorHTML:function(){return this._getDoc().body.innerHTML;},cleanHTML:function(html){if(!html){var html=this.getEditorHTML();}
html=html.replace(/<div><br><\/div>/gi,'<YUI_BR>');html=html.replace(/<p>(&nbsp;|&#160;)<\/p>/g,'<YUI_BR>');html=html.replace(/<p><br>&nbsp;<\/p>/gi,'<YUI_BR>');html=html.replace(/<p>&nbsp;<\/p>/gi,'<YUI_BR>');html=html.replace(/<br class="khtml-block-placeholder">/gi,'<YUI_BR>');html=html.replace(/<br>/gi,'<YUI_BR>');html=html.replace(/<br\/>/gi,'<YUI_BR>');html=html.replace(/<img([^>]*)>/gi,'<YUI_IMG$1>');html=html.replace(/<ul([^>]*)>/gi,'<YUI_UL$1>');html=html.replace(/<\/ul>/gi,'<\/YUI_UL>');html=html.replace(/<i([^>]*)>/gi,'<em$1>');html=html.replace(/<\/i>/gi,'</em>');html=html.replace(/<b([^>]*)>/gi,'<strong$1>');html=html.replace(/<\/b>/gi,'</strong>');html=html.replace(/<font/gi,'<font');html=html.replace(/<\/font>/gi,'</font>');html=html.replace(/<span/gi,'<span');html=html.replace(/<\/span>/gi,'</span>');html=html.replace(/<u/gi,'<u');html=html.replace(/\/u>/gi,'/u>');html=html.replace(/<ol([^>]*)>/gi,'<ol$1>');html=html.replace(/\/ol>/gi,'/ol>');html=html.replace(/<li/gi,'<li');html=html.replace(/\/li>/gi,'/li>');html=html.replace(new RegExp('<span ([^>]*) tag="a" ([^>]*)>([^>]*)<\/span>','gi'),'<a $1 $2>$3</a>');if(this.browser.webkit){html=html.replace(/Apple-style-span/gi,'');html=html.replace(/style="line-height: normal;"/gi,'');}
html=html.replace(/yui-tag-a/gi,'');html=html.replace(/yui-tag-span/gi,'');html=html.replace(/yui-tag/gi,'');html=html.replace(/yui-non/gi,'');html=html.replace(/yui-img/gi,'');html=html.replace(/ tag="span"/gi,'');html=html.replace(/ class=""/gi,'');html=html.replace(/ class=" "/gi,'');html=html.replace(/ class="  "/gi,'');html=html.replace(/ target=""/gi,'');html=html.replace(/ title=""/gi,'');html=html.replace(/<br><li/gi,'<li');html=html.replace(/<YUI_BR>/g,'<br>');html=html.replace(/<YUI_IMG([^>]*)>/g,'<img$1>');html=html.replace(/<YUI_UL([^>]*)>/g,'<ul$1>');html=html.replace(/<\/YUI_UL>/g,'<\/ul>');return html;},clearEditorDoc:function(){this._getDoc().body.innerHTML='&nbsp;';},_renderPanel:function(){if(!YAHOO.widget.EditorInfo.panel){var panel=new YAHOO.widget.Panel(this.EDITOR_PANEL_ID,{width:'300px',iframe:true,visible:false,underlay:'none',draggable:false,close:false});YAHOO.widget.EditorInfo.panel=panel;}else{var panel=YAHOO.widget.EditorInfo.panel;}
this.set('panel',panel);this.get('panel').setBody('---');this.get('panel').setHeader(' ');this.get('panel').setFooter(' ');if(this.DOMReady){this.get('panel').render(document.body);Dom.addClass(this.get('panel').element,'yui-editor-panel');}else{Event.onDOMReady(function(){this.get('panel').render(document.body);Dom.addClass(this.get('panel').element,'yui-editor-panel');},this,true);}
this.get('panel').showEvent.subscribe(function(){YAHOO.util.Dom.setStyle(this.element,'display','block');});return this.get('panel');},openWindow:function(win){this.toolbar.set('disabled',true);Event.addListener(document,'keypress',this._closeWindow,this,true);if(YAHOO.widget.EditorInfo.window.win&&YAHOO.widget.EditorInfo.window.scope){YAHOO.widget.EditorInfo.window.scope.closeWindow.call(YAHOO.widget.EditorInfo.window.scope);}
YAHOO.widget.EditorInfo.window.win=win;YAHOO.widget.EditorInfo.window.scope=this;var self=this,xy=Dom.getXY(this.currentElement[0]),elXY=Dom.getXY(this.get('iframe').get('element')),panel=this.get('panel'),newXY=[(xy[0]+elXY[0]-20),(xy[1]+elXY[1]+10)],wWidth=(parseInt(win.attrs.width)/2),align='center';this.fireEvent('beforeOpenWindow',{type:'beforeOpenWindow',win:win,panel:panel});body=document.createElement('div');body.className=this.CLASS_PREFIX+'-body-cont';var _note=document.createElement('h3');_note.className='yui-editor-skipheader';_note.innerHTML=this.STR_CLOSE_WINDOW_NOTE;body.appendChild(_note);form=document.createElement('form');form.setAttribute('method','GET');var windowName=win.name;Event.addListener(form,'submit',function(ev){var evName='window'+windowName+'Submit';self.fireEvent(evName,{type:evName,target:this});Event.stopEvent(ev);},this,true);body.appendChild(form);Dom.setStyle(panel.element.firstChild,'width',win.attrs.width);if(Lang.isObject(win.body)){form.appendChild(win.body);}else{var _tmp=document.createElement('div');_tmp.innerHTML=win.body;form.appendChild(_tmp);}
var _close=document.createElement('span');_close.innerHTML='X';_close.title=this.STR_CLOSE_WINDOW;_close.className='close';Event.addListener(_close,'click',function(){this.closeWindow();},this,true);var _knob=document.createElement('span');_knob.innerHTML='^';_knob.className='knob';win._knob=_knob;var _header=document.createElement('h3');_header.innerHTML=win.header;panel.cfg.setProperty('width',win.attrs.width);panel.setHeader(' ');panel.appendToHeader(_header);_header.appendChild(_close);_header.appendChild(_knob);panel.setBody(' ');panel.setFooter(' ');if(win.footer!=null){panel.setFooter(win.footer);}
panel.appendToBody(body);panel.showEvent.subscribe(function(){Event.addListener(panel.element,'click',function(ev){Event.stopPropagation(ev);});},this,true);panel.hideEvent.subscribe(function(){this.currentWindow=null;var evName='window'+windowName+'Close';this.fireEvent(evName,{type:evName,target:this});},this,true);this.currentWindow=win;this.moveWindow(true);panel.show();this.fireEvent('afterOpenWindow',{type:'afterOpenWindow',win:win,panel:panel});},moveWindow:function(force){if(!this.currentWindow){return false;}
var win=this.currentWindow,xy=Dom.getXY(this.currentElement[0]),elXY=Dom.getXY(this.get('iframe').get('element')),panel=this.get('panel'),newXY=[(xy[0]+elXY[0]),(xy[1]+elXY[1])],wWidth=(parseInt(win.attrs.width)/2),align='center',orgXY=panel.cfg.getProperty('xy'),_knob=win._knob;newXY[0]=((newXY[0]-wWidth)+20);newXY[0]=newXY[0]-Dom.getDocumentScrollLeft(this._getDoc());newXY[1]=newXY[1]-Dom.getDocumentScrollTop(this._getDoc());if(this.currentElement[0].tagName&&(this.currentElement[0].tagName.toLowerCase()=='img')){if(this.currentElement[0].src.indexOf(this.get('blankimage'))!=-1){newXY[0]=(newXY[0]+(75/2));newXY[1]=(newXY[1]+75);}else{var w=parseInt(this.currentElement[0].width);var h=parseInt(this.currentElement[0].height);newXY[0]=(newXY[0]+(w/2));newXY[1]=(newXY[1]+h);}
newXY[1]=newXY[1]+15;}else{if(Dom.getStyle(this.currentElement[0],'fontSize').indexOf('px')!=-1){newXY[1]=newXY[1]+parseInt(Dom.getStyle(this.currentElement[0],'fontSize'))+5;}else{newXY[1]=newXY[1]+20;}}
if(newXY[0]<elXY[0]){newXY[0]=elXY[0]+5;align='left';}
if((newXY[0]+(wWidth*2))>(elXY[0]+parseInt(this.get('iframe').get('element').clientWidth))){newXY[0]=((elXY[0]+parseInt(this.get('iframe').get('element').clientWidth))-(wWidth*2)-5);align='right';}
try{var xDiff=(newXY[0]-orgXY[0]);var yDiff=(newXY[1]-orgXY[1]);}catch(e){var xDiff=0;var yDiff=0;}
xDiff=((xDiff<0)?(xDiff*-1):xDiff);yDiff=((yDiff<0)?(yDiff*-1):yDiff);if(((xDiff>10)||(yDiff>10))||force){var _knobLeft=0,elW=0;if(this.currentElement[0].width){elW=(parseInt(this.currentElement[0].width)/2);}
var leftOffset=xy[0]+elXY[0]+elW;_knobLeft=leftOffset-newXY[0];if(_knobLeft>(parseInt(win.attrs.width)-40)){_knobLeft=parseInt(win.attrs.width)-40;}else if(_knobLeft<40){_knobLeft=40;}
if(isNaN(_knobLeft)){_knobLeft=40;}
if(force){if(_knob){_knob.style.left=_knobLeft+'px';}
if(this.get('animate')){Dom.setStyle(panel.element,'opacity','0');var anim=new YAHOO.util.Anim(panel.element,{opacity:{from:0,to:1}},.1,YAHOO.util.Easing.easeOut);panel.cfg.setProperty('xy',newXY);anim.onComplete.subscribe(function(){if(this.browser.ie){panel.element.style.filter='none';}},this,true);anim.animate();}else{panel.cfg.setProperty('xy',newXY);}}else{if(this.get('animate')){var anim=new YAHOO.util.Anim(panel.element,{},.5,YAHOO.util.Easing.easeOut);anim.attributes={top:{to:newXY[1]},left:{to:newXY[0]}}
anim.onComplete.subscribe(function(){panel.cfg.setProperty('xy',newXY);});var iframeAnim=new YAHOO.util.Anim(panel.iframe,anim.attributes,.5,YAHOO.util.Easing.easeOut)
var _knobAnim=new YAHOO.util.Anim(_knob,{left:{to:_knobLeft}},.75,YAHOO.util.Easing.easeOut);anim.animate();iframeAnim.animate();_knobAnim.animate();}else{_knob.style.left=_knobLeft+'px';panel.cfg.setProperty('xy',newXY);}}}},_closeWindow:function(ev){if(ev.keyCode==27){if(this.currentWindow){this.closeWindow();}}},closeWindow:function(){YAHOO.widget.EditorInfo.window={};this.fireEvent('closeWindow',{type:'closeWindow',win:this.currentWindow});this.currentWindow=null;this.get('panel').hide();this.get('panel').cfg.setProperty('xy',[-900,-900]);this.get('panel').syncIframe();this.unsubscribeAll('afterExecCommand');this.toolbar.set('disabled',false);this._focusWindow();Event.removeListener(document,'keypress',this._closeWindow);},destroy:function(){this.saveHTML();this.toolbar.destroy();Dom.setStyle(this.get('textarea'),'display','block');var textArea=this.get('textarea');this.get('element_cont').get('parentNode').replaceChild(textArea,this.get('element_cont').get('element'));this.get('element_cont').get('element').innerHTML='';for(var i in this){if(Lang.hasOwnProperty(this,i)){this[i]=null;}}
return true;},toString:function(){var str='Editor';if(this.get&&this.get('element_cont')){str='Editor (#'+this.get('element_cont').get('id')+')'+((this.get('disabled')?' Disabled':''));}
return str;}});YAHOO.widget.EditorInfo={window:{},panel:null}
YAHOO.widget.EditorWindow=function(name,attrs){this.name=name.replace(' ','_');this.attrs=attrs;}
YAHOO.widget.EditorWindow.prototype={_cache:null,header:null,body:null,footer:null,setHeader:function(str){this.header=str;},setBody:function(str){this.body=str;},setFooter:function(str){this.footer=str;},toString:function(){return'Editor Window ('+this.name+')';}};})();YAHOO.register("editor",YAHOO.widget.Editor,{version:"2.3.0",build:"442"});