
BDS.Web={};BDS.Web.StyleEditorManager=function(){var $C=YAHOO.util.Color;var $D=YAHOO.util.Dom;var $E=YAHOO.util.Event;var $=$D.get;var $cn=$D.getElementsByClassName;var styleEditorElCol=[],styleEditorHash=[];return{init:function(){styleEditorElCol=$cn("style-editor");var i,styleEditorElLength=styleEditorElCol.length;for(i=0;i<styleEditorElLength;i++){var styleEditorEl=styleEditorElCol[i];var styleEditor=BDS.Web.StyleEditor(styleEditorEl);styleEditor.init();styleEditorHash.push(styleEditor);}
var arVersion=navigator.appVersion.split("MSIE");var version=parseFloat(arVersion[1]);if((version>=5.5)&&(document.body.filters))
{for(var i=0;i<document.images.length;i++)
{var img=document.images[i];var imgName=img.src.toUpperCase();if(imgName.substring(imgName.length-3,imgName.length)=="PNG")
{var imgID=(img.id)?"id='"+img.id+"' ":"";var imgClass=(img.className)?"class='"+img.className+"' ":"";var imgTitle=(img.title)?"title='"+img.title+"' ":"title='"+img.alt+"' ";var imgStyle="display:inline-block;"+img.style.cssText;if(img.align=="left")imgStyle="float:left;"+imgStyle;if(img.align=="right")imgStyle="float:right;"+imgStyle;if(img.parentElement.href)imgStyle="cursor:hand;"+imgStyle;var strNewHTML="<span "+imgID+imgClass+imgTitle
+" style=\""+"width:"+img.width+"px; height:"+img.height+"px;"+imgStyle+";"
+"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+"(src=\'"+img.src+"\', sizingMethod='scale');\"></span>";img.outerHTML=strNewHTML;i=i-1;}}}}};}();BDS.Web.StyleEditor=function(el){var $C=YAHOO.util.Color;var $D=YAHOO.util.Dom;var $E=YAHOO.util.Event;var $=$D.get;var $cn=$D.getElementsByClassName;var fontFamilyEl;var fontSizerElCol=[],fontIncreaserEl,fontDecreaserEl;var fontDecorationInputElCol=[];var colorPickerElCol=[],colorPickerHash=[];var sampleTextEl;var pickerThumbSrc,hueThumbSrc;var parseStyles=function(){var fontFamily=$D.getStyle(sampleTextEl,"font-family");if(fontFamily){var o,optionsLength=fontFamilyEl.options.length;for(o=0;o<optionsLength;o++){if(fontFamilyEl.options[o].value===fontFamily){fontFamilyEl.options[o].selected=true;}}}
var fontSize=$D.getStyle(sampleTextEl,"font-size");if(fontSize){var fontSizerInputId=fontIncreaserEl.getAttribute("fontSizerInput");var fontSizerInputEl=$(fontSizerInputId);fontSizerInputEl.value=parseInt(fontSize);}
var fontWeight=$D.getStyle(sampleTextEl,"font-weight");if(fontWeight){fontDecorationInputElCol[0].checked=(fontWeight==="bold");}
var fontStyle=$D.getStyle(sampleTextEl,"font-style");if(fontStyle){fontDecorationInputElCol[1].checked=(fontStyle==="italic");}
var textDecoration=$D.getStyle(sampleTextEl,"font-style");if(textDecoration){fontDecorationInputElCol[2].checked=(textDecoration==="underline");}}
var onChangeFont=function(e){$D.setStyle(sampleTextEl,"font-family",fontFamilyEl.options[fontFamilyEl.selectedIndex].value);}
var onDecorateFont=function(e){var fontDecorationEl=$E.getTarget(e);var decoration=fontDecorationEl.parentNode.getAttribute("decoration");switch(decoration){case"bold":$D.setStyle(sampleTextEl,"font-weight",(fontDecorationEl.checked)?"bold":"normal");break;case"italicize":$D.setStyle(sampleTextEl,"font-style",(fontDecorationEl.checked)?"italic":"normal");break;case"underline":$D.setStyle(sampleTextEl,"text-decoration",(fontDecorationEl.checked)?"underline":"none");break;}}
var onSizeFont=function(e){var fontSizerEl=$E.getTarget(e);var step=fontSizerEl.getAttribute("step");var fontSizerInputId=fontSizerEl.getAttribute("fontSizerInput");var fontSizerInputEl=$(fontSizerInputId);fontSizerInputEl.value=parseInt(fontSizerInputEl.value)+parseInt(step);$D.setStyle(sampleTextEl,"font-size",fontSizerInputEl.value);}
var onRgbChange=function(o){var updatedHexValue="#"+$C.rgb2hex(o.newValue);this.associatedInputEl.value=updatedHexValue;$D.setStyle(sampleTextEl,this.targetStyle,updatedHexValue);}
return{init:function(){fontFamilyEl=$cn("style-editor-font-family","select",el)[0];$E.on(fontFamilyEl,"change",onChangeFont);fontSizerElCol=$cn("font-sizer","a",el);fontIncreaserEl=fontSizerElCol[0];fontDecreaserEl=fontSizerElCol[1];$E.on(fontSizerElCol,"click",onSizeFont);var isDecorationCheckBox=function(el){if(el.parentNode){var decoration=el.parentNode.getAttribute("decoration");return(decoration&&(decoration==="bold"||decoration==="italicize"||decoration==="underline"));}else{return false;}}
fontDecorationInputElCol=$D.getElementsBy(isDecorationCheckBox,"input",el);$E.on(fontDecorationInputElCol,"click",onDecorateFont);colorPickerElCol=$cn("style-editor-color-picker","div",el);var i,colorPickerElColLength=colorPickerElCol.length;for(i=0;i<colorPickerElColLength;i++){var colorPickerEl=colorPickerElCol[i],colorPickerElId=colorPickerEl.id,colorPickerInputElId=colorPickerEl.getAttribute("colorPickerInput"),colorPickerInputEl=$(colorPickerInputElId);if(!(pickerThumbSrc||hueThumbSrc)){pickerThumbSrc=colorPickerEl.getAttribute("pickerThumbSrc");hueThumbSrc=colorPickerEl.getAttribute("hueThumbSrc");}
var colorPicker=new YAHOO.widget.ColorPicker(colorPickerElId,{showcontrols:true,showhexcontrols:true,images:{PICKER_THUMB:pickerThumbSrc,HUE_THUMB:hueThumbSrc}});colorPicker.set("showwebsafe",false);colorPicker.set("showrgbcontrols",false);colorPicker.set("showhexsummary",false);colorPicker.targetStyle=colorPickerEl.getAttribute("targetStyle");colorPicker.associatedInputEl=colorPickerInputEl;colorPicker.setValue($C.hex2rgb(colorPickerInputEl.value.replace("#","")),false);colorPicker.on("rgbChange",onRgbChange);colorPickerHash[colorPickerElId]=colorPicker;}
sampleTextEl=$cn("style-editor-sample-text","div",el)[0];parseStyles();}};}
YAHOO.util.Event.on(window,"load",BDS.Web.StyleEditorManager.init);