//ToolStripChildShow umbenenen in Opened

/*================================================================================*/
/*                                                                                */
/*       BW2Technologies.Web.JScript.Framework.ToolStrips (Alpha V1.0.0.0)        */
/*                                                                                */
/*                                Web-ToolStrips                                  */
/*                                                                                */
/*              Copyright © 2006-2010 by BW2Technologies (HP. Lassnig)            */
/*                           mail to : hansi@lassnig.ch                           */
/*                                                                                */
/*================================================================================*/

var _oListItems = null;
var _oToolStrip = null;
var _oToolStrips = new Array();
var _oToolStripItem;
var _oToolItem = null;
var _oToolItemText = null;
var _oToolItems = new Array();
var _oToolItemGroupsSelected = new Array();
var _oToolItemSelected = null;
var _oCtrlItemSelected = null;
var _oColorListStandard = new Array('FFFF00', '00FF00', '00FFFF', 'FF00FF', '0000FF', 'FF0000', '000080', '008080', '008000', '800080', '800000', '808000', '808080', 'C0C0C0', '000000');
var _oColorListExtended = new Array('000000', '993300', '333300', '003300', '003366', '000080', '333399', '333333', '800000', 'FF6600', '808000', '008000', '008080', '0000FF', '666699', '808080', 'FF0000', 'FF9900', '99CC00', '339966', '33CCCC', '3366FF', '800080', '999999', 'FF00FF', 'FFCC00', 'FFFF00', '00FF00', '00FFFF', '00CCFF', '993366', 'C0C0C0', 'FF99CC', 'FFCC99', 'FFFF99', 'CCFFCC', 'CCFFFF', '99CCFF', 'CC99FF', 'FFFFFF');
var _fCancelEvents = false;
var _fOnMouseDown = false;
var _nShowDelay = -1;

/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/


/*================================================================================*/
/* <Function> Create ToolStrip </Function>
/*================================================================================*/
function __bw2ToolStrip(strToolStrip, nType, nWidth, nHeight, fEnabled, nResizeType, fStretched, nSpecialHandled, fIsContextMenu, fAjax) {

         /*--- Base-Object ---*/
         this.Ajax = fAjax;
         this.Enabled = fEnabled;
         this.ID = strToolStrip;
         this.IsContextMenu = fIsContextMenu;
         this.IsSubMenu = false;
         this.Items = new Array();
         this.ResizeType = null;
         this.SpecialHandled = null;
         this.Type = null;
         this.Width = nWidth;
         this.Height = nHeight;

         /*--- Special-Handled ---*/
         switch (nSpecialHandled) {
                case 1 : this.SpecialHandled = 'editor'; break;
         }
         
         /*--- ToolStrip-Type ---*/
         switch (nType) {
                case -1 : this.Type = 'userrendered'; break;
                case  0 : this.Type = 'toolbar'; break;
                case  1 : this.Type = 'menubar'; break;
                case  2 : this.Type = 'menu'; break;
                case  3 : this.Type = 'dropdown'; break;
                case  4 : this.Type = 'popup'; break;
                case  5 : this.Type = 'submenu'; 
                      this.IsSubMenu = true; break;
                case  6 : this.Type = 'statusbar'; 
                      if ((window.statusbar) && (window.statusbar.visible)) {
                         var oImg = __bw2GetElementById(this.ID + '_ImageSizer');
                         if (oImg) oImg.style.display = 'none';
                      }

                      break;
         }

         /*--- Resize-Type ---*/
         switch (nResizeType) {
                case 1 : this.ResizeType = 'both'; break;
                case 2 : this.ResizeType = 'horizontal'; break;
                case 3 : this.ResizeType = 'vertical'; break;
         }

         /*--- [Functions] ---*/  
         this.Hide = _bw2ToolStripHide;
         this.Initialize = _bw2ToolStripInitialize;

         /*--- ToolStrip-Element ---*/
         this.ToolStrip = __bw2GetElementById(strToolStrip);
         
         if (this.ToolStrip != null) {
            this.ToolStrip.ParentObject = this;
            this.ToolStrip.Enabled = fEnabled;
            this.ToolStrip.Stretched = fStretched;
            this.ToolStrip.IsDynamic = false;
            this.ToolStrip.IsLoaded = false;
            this.ToolStrip.ResizeType = this.ResizeType;
            this.ToolStrip.SpecialHandled = this.SpecialHandled;
            this.ToolStrip.Type = this.Type;

            this.ToolStrip.onmouseover = _bw2ToolStrip_OnMouseOver;
            this.ToolStrip.onmouseout = _bw2ToolStrip_OnMouseOut;
         }
         
         this.Initialize(null);

/*--------------------------------------------------------------------------------*/

         function _bw2ToolStripInitialize(strInnerHTML) {
                  if (this.ToolStrip == null) return;  
            
                  var oMN = null;
                  
                  try {
                      oMN = __bw2GetElementById(this.ID);
                  } catch (e) {
                      alert('1 _bw2ToolStripInitialize Error : ' + e + ', ' + this.ID);
                  }

                  try {
                      if (oMN != null) {
                         this.ToolStrip = oMN;
                         this.ToolStrip.IsLoaded = true;
                         this.ToolStrip.Type = this.Type; 
                      } else {
                         __bw2AppendChildElement(this.ToolStrip);
                         this.ToolStrip.IsLoaded = false;
                         this.ToolStrip.IsDynamic = true;
                         this.ToolStrip.style.position = 'absolute';
                         this.ToolStrip.style.display = 'none';
                         //__bw2ObjectShadow(this.ToolStrip);
                      }

                      if (strInnerHTML != null) this.ToolStrip.innerHTML = strInnerHTML;

                  } catch (e) {
                      alert('3 _bw2ToolStripInitialize Error : ' + e + ', ' + this.ID);
                  }
         }

         /*--------------------------------------------------------------------------------*/


         function _bw2ToolStripHide() {
                  for (strIID in this.Items) {
                      with (this.Items[strIID].Item) {
                           className = CssClass;
                            
                           if (Opened) {
                              _oToolStrips[ToolStripChildID].Hide();
                              Opened = false;
                            }
                      }
                  }

                  this.ToolStrip.style.display = 'none';
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolStrip_OnMouseOver(oEvent) {
                  if (!this.Enabled) return;
                  if (oEvent == null) oEvent = window.event;

                  __bw2RemoveEventListener(document.body, 'mousedown', __bw2ToolStripOutsideClick, false);
                  oEvent.cancelBubble = true;
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolStrip_OnMouseOut(oEvent) {
                  if (!this.Enabled) return;
                  if (oEvent == null) oEvent = window.event;

                  __bw2AddEventListener(document.body, 'mousedown', __bw2ToolStripOutsideClick, false);
                  oEvent.cancelBubble = true;
         }
}

/*================================================================================*/
/* <Function> Create a dynamic ToolStrip </Function>
/*================================================================================*/
function __bw2ToolStripCreate(strToolStrip, strInnerHTML) {
         var oTS = __bw2GetElementById(strToolStrip);

         if (oTS == null) {
            oTS = document.createElement('DIV');
            oTS.id = strToolStrip;
            oTS.style.position = 'absolute';
            __bw2AppendChildElement(oTS);
            //__bw2ObjectShadow(oTS);
         }
         
         oTS.innerHTML = strInnerHTML;
         oTS.style.display = 'none';
}

/*================================================================================*/
/* <Function> Get ToolStrip-Item by Key or SpecialHandled </Function>
/*================================================================================*/
function __bw2ToolStripGetItem(strToolStripKey, strItemKey) {
         try {
             return _oToolStrips[strToolStripKey].Items[strItemKey].Item;
         } catch (e) {
             return null;
         }
}

/*--------------------------------------------------------------------------------*/

function __bw2ToolStripGetItemByCommand(strToolStripKey, strItemCommand) {
         for (strMID in _oToolStrips) {
             var oToolStrip = _oToolStrips[strMID];

             try {
                 if (strMID.substring(0, strToolStripKey.length) == strToolStripKey) {
                    for (strIID in oToolStrip.Items) {
                        if (oToolStrip.Items[strIID].Item.Command == strItemCommand) {
                           return __bw2GetElementById(strIID);
                        }
                    }
                 }
             } catch (e) {
             }
         }

         return null;
}

/*================================================================================*/
/* <Function> Initialize ToolStrip </Function>
/*================================================================================*/
function __bw2ToolStripsInitialize() {
         this.CurrentItem = null;
         
         try {
             for (strMID in _oToolStrips) {
                 var oToolStripObj = _oToolStrips[strMID];
             
                 if (oToolStripObj.Initialized == null) {
                    try {
                        for (strIID in oToolStripObj.Items) {
                            oToolStripObj.Items[strIID].SetToolStripObj(oToolStripObj);
                        }
                        
                        oToolStripObj.Initialized = true;
                    } catch (e) {}
                 }
             }
         } catch (e) {}
}

/*================================================================================*/
/* <Function> ToolStrip-CtrlItem reset Selection </Function>
/*================================================================================*/
function __bw2ToolStripSpezialHandled(oItem) {
         try { 
             var strSH = null;

             if (oItem.ToolStripObj.SpecialHandled != null) {
                strSH = oItem.ToolStripObj.SpecialHandled;
             } else if (oItem.SpecialHandled != null) {
                strSH = oItem.SpecialHandled;
             } else {
                return;
             }

             switch (strSH) {
                    case 'editor' :
                         if (_oEditor) _oEditor.EventItem(oItem);
                         break;
             }
         } catch (e) {
         }
}

/*================================================================================*/
/* <Function> ToolStrip anzeigen (bei DropDown & PopUp) </Function>
/*================================================================================*/
function __bw2ToolStripShow(oEvent, oItem, fSubToolStrip) {
         if ((oItem == null) || (oItem.ToolStripChildID == null)) return;
              
         /*--- Get ToolStrip ---*/
         _oToolStrip = __bw2GetElementById(oItem.ToolStripChildID);

         if ((_oToolStrip == null) || (_oToolStrip.IsLoaded == false) || (_oToolStrip.innerHTML == '')) {
            /*--- Load ToolStrip by Ajax ---*/ 
            if (oItem.Ajax) __bw2AjaxObjOnEvent(oEvent, oItem, 'loadtoolstrip', 1);

            _oToolStrip = __bw2GetElementById(oItem.ToolStripChildID);
         }

         if (_oToolStrip) {
             _oToolStrip.ParentItem = oItem;
             _oToolStrip.ParentToolStrip = oItem.ToolStripObj.ToolStrip;

             if ((_fIE) && ((_oToolStrip.Type == 'dropdown') || (_oToolStrip.Type == 'popup') || (_oToolStrip.Type == 'submenu'))) {
                 _oToolStrip.style.width = 0;
            }
            
            __bw2RemoveEventListener(document.body, 'mousedown', __bw2ToolStripOutsideClick, false);
            __bw2ToolStripShowPos(_oToolStrip, oItem);
         }
}

/*--------------------------------------------------------------------------------*/

function __bw2ToolStripShowDynamic(strToolStrip, strOnItem, nLeft, nTop, nWidth, nHeight, strInnerHTML) {

         /*--- Get ToolStrip ---*/
         var oToolStripObj = _oToolStrips[strToolStrip]; if (oToolStripObj == null) return;
         var oItem = __bw2GetElementById(strOnItem);

         _oToolStrip = oToolStripObj.ToolStrip
         _oToolStrip.ParentItem = oItem;
         _oToolStrip.ParentToolStrip = oItem.ToolStripObj;
         
         if ((_fIE) && (nWidth == 0) && (_oToolStrip.Type) && ((_oToolStrip.Type == 'dropdown') || (_oToolStrip.Type == 'popup') || (_oToolStrip.Type == 'submenu'))) {
             _oToolStrip.style.width = 0;
         }

         /*--- Initialize ToolStrip ---*/
         if (strInnerHTML != null) { 
            oToolStripObj.Initialize(strInnerHTML);

            try {
                for (strIID in oToolStripObj.Items) {
                    oToolStripObj.Items[strIID].Initialize(oToolStripObj);
                }
            } catch (e) {
            }
         }
           
         __bw2RemoveEventListener(document.body, 'mousedown', __bw2ToolStripOutsideClick, false);
         __bw2ToolStripShowPos(_oToolStrip, __bw2GetElementById(strOnItem), nLeft, nTop, nWidth, nHeight);
         //__bw2AddEventListener(_oToolStrip, 'mouseover', __bw2ToolStripOnOver, false);
         //__bw2AddEventListener(_oToolStrip, 'mouseout', __bw2ToolStripOnOut, false);
}

/*================================================================================*/
/* <Function> Child-ToolStrip anzeigen </Function>
/*================================================================================*/
function __bw2ToolStripChildShow(oEvent, oItem) {
         switch (_nShowDelay) {
                case -1 : 
                     return; 
                     break;

                case 0 : _nShowDelay = 1;
                     window.TempEvent = oEvent;
                     window.TempObject = oItem;
                     setTimeout('__bw2ToolStripChildShow()', 300);
                     break;

                case 1 : _nShowDelay = 2;
                     if ((window.TempEvent) && (window.TempObject) && (_oToolItem == window.TempObject)) {
                        _oToolItemSelected = _oToolItem;
                        _oToolItemSelected.Opened = true;
                        __bw2ToolStripShow(window.TempEvent, _oToolItem, true)
                        window.TempEvent = null;
                        window.TempObject = null;
                     }
                     break;
         }
}

/*================================================================================*/
/* <Function> Child-ToolStrip anzeigen </Function>
/*================================================================================*/
function __bw2ToolStripShowPos(oToolStrip, oItem, nLeft, nTop, nWidth, nHeight) {

         var nW = 0, nOW = __bw2ObjectWidth(oItem);     /* [oItem.offsetWidth] bewirkt beim IE einen langen Wait */
         var nH = 0, nOH = __bw2ObjectHeight(oItem); 
         var nX = 0, nOX = __bw2ObjectOffsetLeft(oItem); 
         var nY = 0, nOY = __bw2ObjectOffsetTop(oItem); 
         var nWW = __bw2WindowWidth();
         var nWH = __bw2WindowHeight();

         if ((nLeft != null) && (nLeft > 0)) nX = nLeft; 
         if ((nTop != null) && (nTop > 0)) nY = nTop;
         if ((nWidth != null) && (nWidth > 0)) nW = nWidth;
         if ((nHeight != null) && (nHeight > 0)) nH = nHeight;
         
         oToolStrip.style.display = 'block';
         oToolStrip.style.zIndex = __bw2ZIndex();
            
         switch (oToolStrip.Type) {
                case 'menu' :
                     nX = nOX;
                     nY = nOY;

                     if (_fIE) {
                        if (nW < 1) nW = 1 
                     }

                     if (oToolStrip.ParentItem.IsMacOsX) {
                        nY += oItem.offsetHeight
                     }

                     break;

                case 'dropdown' :
                     nX = nOX;
                     nY = nOY;

                     if (_fIE) {
                        nX++;
                        nY++;
                     }
                     
                     if (nW < 1) nW = oToolStrip.offsetWidth;
                      
                     break;

                case 'popup' : 
                     if (nX == 0) nX = nOX;
                     if (nY == 0) nY = nOY + nOH;
                     
                     if (_fIE) nX += 1; else nY -= 1;
                 
                     if (nW < 1) nW = oToolStrip.offsetWidth;
                     __bw2AddEventListener(document.body, 'mousedown', __bw2ToolStripOutsideClick, false);
                      
                     break;
                      
                case 'submenu' :
                     var nMW = __bw2ObjectWidth(oToolStrip);

                     nY = nOY - 1;

                     if ((nOX + nOW + nMW) > nWW) {
                        nX = nOX - nMW - 4;
                     } else {
                        if ((_fIE) && ((oItem.ToolStripObj.IsContextMenu) || (oItem.ToolStripObj.IsSubMenu))) {
                           nOX--;
                           nY--;
                        }

                        nX = nOX + nOW;
                     }

                     if (nW < 1) nW = oToolStrip.offsetWidth;
                     
                     oToolStrip.style.zIndex = oItem.ToolStripObj.ToolStrip.style.zIndex + 1; 

                     break;

                default :       /*--- MenuBar, ToolBar User-Rendered ---*/
                     nW = 0;
                     break;

         }

         /*--- Set ToolStrip Pos & Size ---*/
         if (nW > 0) oToolStrip.style.width = nW;
         if (nX + oToolStrip.offsetWidth > nWW) nX = nWW - oToolStrip.offsetWidth - 1; 
         if (nY + oToolStrip.offsetHeight > nWH) nY = nWH - oToolStrip.offsetHeight - 1; 

         oToolStrip.style.left = nX;
         oToolStrip.style.top = nY;

         try {
             /*--- Set Resize-Bar Size ---*/   
             if (oToolStrip.ResizeType != null) {
                var oRS = __bw2GetElementById(oToolStrip.id + '_RESIZE');
                if (oRS) oRS.style.width = oToolStrip.offsetWidth;
             }
         } catch (e) {}
}

/*================================================================================*/
/* <Function> ToolStrip (On Mouse-Over) </Function>
/*================================================================================*/
//function __bw2ToolStripOnOver(oEvent) {
//         __bw2RemoveEventListener(document.body, 'mousedown', __bw2ToolStripOutsideClick, false);
//}

/*================================================================================*/
/* <Function> ToolStrip (On Mouse-Out) </Function>
/*================================================================================*/
//function __bw2ToolStripOnOut(oEvent) {
//         __bw2AddEventListener(document.body, 'mousedown', __bw2ToolStripOutsideClick, false);
//}

/*================================================================================*/
/* <Function> Click ToolStripItem </Function>
/*================================================================================*/
function __bw2ToolStripItemClick(oEvent) {
         if (_fCancelEvents) return;
         __bw2ToolStripsHide();
}

/*================================================================================*/
/* <Function> Click outside ToolStripItem </Function>
/*================================================================================*/
function __bw2ToolStripOutsideClick(oEvent) {
         if (_fCancelEvents) return;
         __bw2ToolStripsHide();
         //__bw2ToolStripCtrlItemSelectedReset();
         //__bw2ToolStripItemClick(oEvent);
}

/*================================================================================*/
/* <Function> Destroy ToolStrips (Context-Menus) </Function>
/*================================================================================*/
function __bw2ToolStripsDestroy() {
         for (strMID in _oToolStrips) {
             try {
                 with (_oToolStrips[strMID]) {
                      if ((IsContextMenu) && (ToolStrip.IsDynamic) && (ToolStrip.style.display == 'none')) {
                         ToolStrip.innerHTML = null;
                         __bw2RemoveChildElement(ToolStrip);
                         //if (Ajax) __bw2AjaxObjOnEvent(window.event, ToolStrip, 'destroytoolstrip', 1);
                         _oToolStrips[strMID] = null;
                      }
                 }
             } catch (e) {}
         }
}

/*================================================================================*/
/* <Function> ToolStrips ausblenden (bei DropDown & PopUp) </Function>
/*================================================================================*/
function __bw2ToolStripsHide(nMode) {
         __bw2RemoveEventListener(document.body, 'mousedown', __bw2ToolStripOutsideClick, false);
         __bw2ListItemsHide();

         switch (nMode) {
                case 1: break;
                case 2: break;
                default : 
                     __bw2ToolStripCtrlItemSelectedReset(); 
                     _oToolStrip = null; 
                     break;
         }

         for (strMID in _oToolStrips) {
             try {
                 var oToolStripObj = _oToolStrips[strMID];
                                  
                 switch (oToolStripObj.Type ) {
                        case null :
                        case 'menubar' :
                        case 'statusbar' : 
                        case 'toolbar' : 
                        case 'userrendered' : break;
                        default :  
                             if (oToolStripObj.ToolStrip.style.display != 'none') {
                                if (nMode == 2) {
                                   if ((oToolStripObj.Type == 'submenu') || (oToolStripObj.Type == 'popup')) {
                                      if ((_oToolStrip.ParentToolStrip) && (_oToolStrip.ParentToolStrip.id != strMID) && ((_oToolStrip.ParentToolStrip.Type == 'popup') || (_oToolStrip.ParentToolStrip.Type == 'submenu'))) {
                                         _oToolStrip.ParentToolStrip.style.display = 'block';
                                      } else {
                                         if ((_oToolStrip) && (_oToolStrip.id != strMID)) oToolStripObj.ToolStrip.style.display = 'none';
                                      }
                                   }
                                } else {
                                   oToolStripObj.ToolStrip.style.display = 'none';
                                }
                             }
                             
                             break;
                 }
             } catch (e) {
             }
         }

         if (_oToolItemSelected) {   
            _oToolItemSelected.Opened = false;
            _oToolItemSelected.Selected = false;
            _oToolItemSelected = null;
         }
}

/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/


/*================================================================================*/
/* <Function> Create ToolItem Object </Function>
/*================================================================================*/
function __bw2ToolItem(strItemID, strTag, strContainerID, strToolStripChildID, strValue, fEnabled, fSelected, strCommand, strOptions, strCssClass, strCssClassClick, strCssClassOnOver, strCssClassSelected, strCssClassDisabled, strCssClassLabel, strCssClassLabelSelected, strImage, strImageLeft, strImageMid, strImageRight, strImageCell, fCanNotDelete, fAjax) {
         this.Ajax = fAjax;
         this.ID = strItemID;

         /*--- Get Container-Element ---*/
         this.Container = __bw2GetElementById(strContainerID);

         /*--- Get Item-Element ---*/
         if ((strTag != null) && (this.Container != null)) {
            this.Item = __bw2GetElementById(strItemID);
         
            if (this.Item == null) {
               this.Item = document.createElement(strTag); this.Container.appendChild(this.Item);
               this.Item.id = strItemID;
               if (strTag == 'SPAN') this.Item.style.display = 'inline-block';
            }

            this.Item.ParentObject = this;
            this.Item.Ajax = fAjax;
            this.Item.Enabled = fEnabled;
            this.Item.CanNotDelete = fCanNotDelete;
            //this.Item.Checked = true;
            this.Item.Command = strCommand;
            this.Item.Opened = false;
            this.Item.Options = strOptions;
            this.Item.Selected = fSelected;
            this.Item.ToolStripChildID = strToolStripChildID;
            this.Item.Value = strValue;

            this.Item.CssClass = strCssClass;
            this.Item.CssClassOnClick = strCssClassClick;
            this.Item.CssClassOnOver = strCssClassOnOver;
            this.Item.CssClassSelected = strCssClassSelected;
            this.Item.CssClassDisabled = strCssClassDisabled;
            this.Item.CssClassLabel = strCssClassLabel;
            this.Item.CssClassLabelSelected = strCssClassLabelSelected;

            this.Item.Image = strImage;
            this.Item.ImageCell = strImageCell;
            this.Item.ImageLeft = strImageLeft;
            this.Item.ImageMid = strImageMid;
            this.Item.ImageRight = strImageRight;

            /*--- Register Functions & Events ---*/  
            //this.Item.onclick = _bw2ToolItem_OnClick;
            this.Item.onmousedown = _bw2ToolItem_OnMouseDown;
            this.Item.onmouseup = _bw2ToolItem_OnMouseUp;
            this.Item.onmouseover = _bw2ToolItem_OnMouseOver;
            this.Item.onmouseout = _bw2ToolItem_OnMouseOut;
            this.Item.Background = _bw2ToolItem_Background;
            this.Item.Check = _bw2ToolItem_Check;
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolItem_Background(strStyle) {
                  if (strStyle == null) strStyle = '';
                    
                  var oText = __bw2GetElementById(this.id + '_Text');
                    
                  switch (strStyle) {
                         case 'checked' : 
                              if (this.CssClassSelected) this.className = _oSkinCssClasses[this.CssClassSelected];
                              if ((oText) && (this.CssClassLabelSelected)) oText.className = _oSkinCssClasses[this.CssClassLabelSelected];

                              if (this.Image) {
                                 var oImg = __bw2GetElementById(this.id + '_Image');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.Image].ImageSelected + ')';
                              }

                              if (this.ImageLeft) {
                                 var oImg = __bw2GetElementById(this.id + '_ImageLeft');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.ImageLeft].ImageSelected + ')';
                              }

                              if (this.ImageMid) {
                                 var oImg = __bw2GetElementById(this.id + '_ImageMid');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.ImageMid].ImageSelected + ')';
                              }

                              if (this.ImageCell) {
                                 var oImg = __bw2GetElementById(this.id + '_ImageCell');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.ImageCell].ImageSelected + ')';
                              }

                              if (this.ImageRight) {
                                 var oImg = __bw2GetElementById(this.id + '_ImageRight');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.ImageRight].ImageSelected + ')';
                              }
                         
                              break; 

                         case 'click' : 
                              if (this.CssClassOnClick) this.className = _oSkinCssClasses[this.CssClassOnClick];
                              if ((oText) && (this.CssClassLabel)) oText.className = _oSkinCssClasses[this.CssClassLabelSelected];

                              if (this.Image) {
                                 var oImg = __bw2GetElementById(this.id + '_Image');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.Image].ImageOnClick + ')';
                              }

                              if (this.ImageLeft) {
                                 var oImg = __bw2GetElementById(this.id + '_ImageLeft');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.ImageLeft].ImageOnClick + ')';
                              }

                              if (this.ImageMid) {
                                 var oImg = __bw2GetElementById(this.id + '_ImageMid');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.ImageMid].ImageOnClick + ')';
                              }

                              if (this.ImageCell) {
                                 var oImg = __bw2GetElementById(this.id + '_ImageCell');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.ImageCell].ImageOnClick + ')';
                              }

                              if (this.ImageRight) {
                                 var oImg = __bw2GetElementById(this.id + '_ImageRight');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.ImageRight].ImageOnClick + ')';
                              }
                         
                              break; 
                              
                         case 'hilight' : 
                              if (this.CssClassOnOver) this.className = _oSkinCssClasses[this.CssClassOnOver];
                              if ((oText) && (this.CssClassLabel)) oText.className = _oSkinCssClasses[this.CssClassLabelSelected];

                              if (this.Image) {
                                 var oImg = __bw2GetElementById(this.id + '_Image');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.Image].ImageOnOver + ')';
                              }

                              if (this.ImageLeft) {
                                 var oImg = __bw2GetElementById(this.id + '_ImageLeft');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.ImageLeft].ImageOnOver + ')';
                              }

                              if (this.ImageMid) {
                                 var oImg = __bw2GetElementById(this.id + '_ImageMid');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.ImageMid].ImageOnOver + ')';
                              }

                              if (this.ImageCell) {
                                 var oImg = __bw2GetElementById(this.id + '_ImageCell');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.ImageCell].ImageOnOver + ')';
                              }

                              if (this.ImageRight) {
                                 var oImg = __bw2GetElementById(this.id + '_ImageRight');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.ImageRight].ImageOnOver + ')';
                              }
                              break; 

                         default : 
                              if (this.CssClass) this.className = _oSkinCssClasses[this.CssClass];
                              if ((oText) && (this.CssClassLabel)) oText.className = _oSkinCssClasses[this.CssClassLabel];

                              if (this.Image) {
                                 var oImg = __bw2GetElementById(this.id + '_Image');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.Image].Image + ')';
                              }

                              if (this.ImageLeft) {
                                 var oImg = __bw2GetElementById(this.id + '_ImageLeft');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.ImageLeft].Image + ')';
                              }

                              if (this.ImageMid) {
                                 var oImg = __bw2GetElementById(this.id + '_ImageMid');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.ImageMid].Image + ')';
                              }

                              if (this.ImageCell) {
                                 var oImg = __bw2GetElementById(this.id + '_ImageCell');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.ImageCell].Image + ')';
                              }

                              if (this.ImageRight) {
                                 var oImg = __bw2GetElementById(this.id + '_ImageRight');
                                 if (oImg) oImg.style.backgroundImage = 'url(' + _oSkinImages[this.ImageRight].Image + ')';
                              }

                              break; 
                  }  
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolItem_Check(fChecked) {
                  this.Checked = fChecked;
            
                  if (this.Checked == '1') {
                     this.Background('checked');
                  } else {
                     this.Background();
                  }
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolItem_OnClick(oEvent) {
                  if (!this.Enabled) return;
                  if (oEvent == null) oEvent = window.event;
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolItem_OnMouseDown(oEvent) {
                  if (!this.Enabled) return;
                  
                  if (this.Checked) {
                     if (this.Checked == '1') {
                        this.Check('0');
                        if (this.Ajax) __bw2AjaxObjOnEvent(window.event, strItemID, 'oncheck', false);
                     } else {  
                        this.Check('1');
                        if (this.Ajax) __bw2AjaxObjOnEvent(window.event, strItemID, 'oncheck', true);
                     }
                  } else {
                     this.Background('click');
                  }

                  __bw2Unselect();
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolItem_OnMouseUp(oEvent) {
                  if (!this.Enabled) return;

                  if (this.Checked) {
                     if (this.Checked == '1') {
                        this.Background('checked');
                     } else {  
                        this.Background();
                     }
                  } else {
                     this.Background('hilight');
                  }
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolItem_OnMouseOver(oEvent) {
                  if (!this.Enabled) return;

                  if (this.Checked) {
                     if (this.Checked == '1') {
                        this.Background('hilight');
                     } else {  
                        this.Background('hilight');
                     }
                  } else {
                     this.Background('hilight');
                  }
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolItem_OnMouseOut(oEvent) {
                  if (!this.Enabled) return;
                  if (this.Checked) {
                     if (this.Checked == '1') {
                        this.Background('checked');
                     } else {  
                        this.Background();
                     }
                  } else {
                     this.Background();
                  }
         }
}         

/*================================================================================*/
/* <Function> Delete ToolItem Object </Function>
/*================================================================================*/
function __bw2ToolItemDelete(strItemID, fAjax) {
         try {
             var oFilter = __bw2GetElementById(strItemID);
             if (oFilter == null) return;
         
             /*--- Ajax-Post ---*/   
             if (fAjax) {
                __bw2AjaxObjOnEvent(window.event, strItemID, 'ondelete');
             } else {
             }

             /*--- Hide [Element] ---*/   
             if (oFilter.CanNotDelete) {
                //oFilter.style.display ='none';

             /*--- Remove [Element] ---*/   
             } else {
                oFilter.ParentObject.Container.removeChild(oFilter);
  
                /*--- Clear Definition ---*/   
                _oToolItems[strItemID] = null;
             }
         } catch (e) {}
}

/*================================================================================*/
/* <Function> Create MacOsX-ToolItem Object </Function>
/*================================================================================*/
function __bw2ToolItemMacOsX(strItemID, nType, strToolStripContainerID, strToolStripChildID, strValue, fEnabled, fSelected, strCommand, strOptions, nMaxHeight, nMinHeight, fAjax) {
         this.Ajax = fAjax;
         this.ID = strItemID;
         this.Item = null;
         this.Command = strCommand;
         this.Enabled = fEnabled;
         this.Opened = false;
         this.Options = strOptions;
         this.Selected = fSelected;
         this.ToolStripChildID = strToolStripChildID;
         this.ToolStripContainerID = strToolStripContainerID;
         this.Type = null;
         this.MaxHeight = nMaxHeight;
         this.MinHeight = nMinHeight;
         this.Value = strValue;

         /*--- Item-Type ---*/
         switch (nType) {
                case -1 : this.Type = 'userrendered'; break;             
                case  0 : this.Type = 'standard'; break;             
                case  1 : this.Type = 'separator'; break;             
                case  2 : this.Type = 'dropdown'; break;             
                case  3 : this.Type = 'dropdowninput'; break;             
                case  4 : this.Type = 'dropdownmenu'; break;             
                case  5 : this.Type = 'dropdownmenuitem'; break;             
                case  6 : this.Type = 'label'; break;             
                case  7 : this.Type = 'input'; break;             
                case  8 : this.Type = 'checkbox'; break;             
                case  9 : this.Type = 'optionbox'; break;             
         }

         this.Initialize = _bw2ToolItemInitialize;
         this.SetToolStripObj = _bw2ToolItemSetToolStripObj;

         /*--- Initialize-Item ---*/
         this.Initialize();

/*--------------------------------------------------------------------------------*/

         function _bw2ToolItemInitialize(oToolStripObj) {
                  try {
                      /*--- Assign to Element ---*/  
                      var oIT = __bw2GetElementById(this.ID); if (oIT == null) return;

                      if (_fIE) {
                         oIT.style.cursor = 'hand';
                      } else {
                         oIT.style.cursor = 'pointer';
                      }

                      this.Item = oIT;
                      this.Item.ParentObject = this;
                      this.Item.IsHandled = false;
                      this.Item.IsMacOsX = true;
                      this.Item.Ajax = this.Ajax;
                      this.Item.Command = this.Command;
                      this.Item.Enabled = this.Enabled;
                      this.Item.Opened = false;
                      this.Item.Options = this.Options;
                      this.Item.Selected = this.Selected;
                      this.Item.ToolStripChildID = this.ToolStripChildID;
                      this.Item.ToolStripContainerID = this.ToolStripContainerID;
                      this.Item.Type = this.Type;
                      this.Item.Value = this.Value;

                      /*--- Item Event-Handlers ---*/
                      this.Item.Click = _bw2ToolItem_Click;

                      /*--- Set Image ---*/
                      this.Item.Image = __bw2GetElementById(this.ID + '_Image'); 
                      
                      if (this.Item.Image) {
                         var oCont = __bw2GetElementById(this.Item.ToolStripContainerID);

                         this.Item.Image.ParentObject = this.Item;
                         this.Item.Image.MaxHeight = this.MaxHeight;
                         this.Item.Image.MinHeight = this.MinHeight;
                         this.Item.Image.XFactor = this.Item.Image.offsetWidth / this.Item.Image.offsetHeight;
                         this.Item.Image.XDefault = Number(oCont.getAttribute('DefaultLeft'));
                         this.Item.Image.XOffset = this.Item.Image.XDefault + ((this.MinHeight * this.Item.Image.XFactor) / 2);

                         /*--- Image Event-Handlers ---*/
                         this.Item.Image.onmousedown = _bw2ToolItem_OnMouseDown;
                         this.Item.Image.onmouseup = _bw2ToolItem_OnMouseUp;
                         this.Item.Image.onmousemove = _bw2ToolItem_OnMouseMove;
                         this.Item.Image.onmouseover = _bw2ToolItem_OnMouseOver;
                         this.Item.Image.onmouseout = _bw2ToolItem_OnMouseOut;
                      }

                      /*--- Set Refrence to Container-ToolStrip ---*/
                      if (oToolStripObj) this.SetToolStripObj(oToolStripObj);
                  } catch (e) {}
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolItemSetToolStripObj(oToolStripObj) {
                  this.Item.ToolStripObj = oToolStripObj;
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolItem_Click(oEvent) {
                  __bw2ToolStripsHide();

                  if (oEvent == null) oEvent = window.event;

                  /*--- Ajax Post ---*/  
                  if (this.Ajax) {
                     if ((this.Options) && (this.Options == 'loading')) __bw2Loading(true);

                     __bw2AjaxObjOnEvent(oEvent, this, 'onclick', 1);

                     /*--- Additional Click-Actions ---*/  
                     try { 
                         var strCV = this.getAttribute('ClickValue');
                         
                         if (strCV != null) {
                            window.eval(strCV);
                         }
                     } catch (e) {}

                  /*--- Page Post ---*/  
                  } else {
                     __doPostBack(this.id, 'ITEMCLICK');
                  }
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolItem_OnMouseDown(oEvent) {
                  if (oEvent == null) oEvent = window.event;

                  try {
                      var nW = this.MaxHeight * this.XFactor;

                      /*--- Set Item Width & Height ---*/   
                      this.style.height = this.MaxHeight;
                      this.style.width = nW;

                      /*--- Set ToolStrip X-Offset ---*/   
                      __bw2GetElementById(this.ParentObject.ToolStripContainerID).style.left = this.XOffset - (nW / 2);
                      
                      if (_oToolItemText) _oToolItemText.style.display = 'none';

                      with (this.ParentObject) {
                           IsHandled = false;

                           /*--- Menu, Popup and SubMenu ---*/ 
                           if (ToolStripChildID != null) {
                              if ((ToolStripObj) && (ToolStripObj.Type != 'menu') && (ToolStripObj.Type != 'dropdownmenu') && (ToolStripObj.Type != 'dropdownmenuitem') && (ToolStripObj.Type != 'popup') && (ToolStripObj.Type != 'submenu')) __bw2ToolStripsHide();
                              Selected = true;  
                              _oToolItemSelected = this.ParentObject;
                              __bw2ToolStripShow(oEvent, this.ParentObject);
                              IsHandled = true;
                              return;
                           }
                      }
                  } catch (e) {}
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolItem_OnMouseUp(oEvent) {
                  try {
                      with (this.ParentObject) {
                           if ((Enabled == false) || (Opened == true) || (ToolStripChildID != null) || (HasListItems)) { _fCancelEvents = true; return; }
                           
                           if (!IsHandled) {
                              Click(oEvent);
                           } else {
                              IsHandled = false;
                           }
                      }
                  } catch (e) {}
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolItem_OnMouseMove(oEvent) {
                  if (oEvent == null) oEvent = window.event;
                  if (oEvent.button == 1) return; 

                  try {
                      var nOX = __bw2ObjectOffsetLeft(this);
                      var nOY = __bw2ObjectOffsetTop(this); 
                      var nX = oEvent.clientX - nOX;
                      var nH = this.MinHeight;
                      var nHS = this.MaxHeight - nH;
                      var nOW2 = this.offsetWidth / 2;
                      var sF = 0;

                      if (_fIE) nX--;

                      if (nX < nOW2 - 1) {
                         sF = nOW2 - (nOW2 - nX);
                         sF = sF * (nHS / nOW2);
                         nH += sF;
                      } else if (nX > nOW2 + 1) {
                         sF = nOW2 - (nX - nOW2);
                         sF = sF * (nHS / nOW2);
                         nH += sF;
                      } else {
                         nH = this.MaxHeight;
                      }
                      
                      if (nH < this.MinHeight) nH = this.MinHeight;
                      if (nH > this.MaxHeight) nH = this.MaxHeight;

                      var nW = nH * this.XFactor;

                      /*--- Set Item Width & Height ---*/   
                      this.style.height = nH;
                      this.style.width = nW;
                      
                      /*--- Set ToolStrip X-Offset ---*/   
                      __bw2GetElementById(this.ParentObject.ToolStripContainerID).style.left = this.XOffset - (nW / 2);
                      
                      /*--- Item-Text ---*/   
                      if ((_oToolItemText) && (!_oToolItemText.IsPos)) {
                         _oToolItemText.IsPos = true;
                         _oToolItemText.style.left = (nOX + ((this.MaxHeight * this.XFactor) / 2 )) - (_oToolItemText.offsetWidth / 2);
                      }
                  } catch (e) {}
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolItem_OnMouseOver(oEvent) {
                  if (oEvent == null) oEvent = window.event;

                  /*--- Hide all ToolStrips ---*/
                  if ((_oToolStrip) && (_oToolStrip.ParentItem != this.ParentObject)) __bw2ToolStripsHide();

                  try {
                      /*--- ToolItem Text ---*/  
                      var strT = this.getAttribute('Text');

                      if (_oToolItemText == null) {  
                         _oToolItemText = document.createElement('DIV');
                         _oToolItemText.id = 'oToolItemText';
                         _oToolItemText.className = 'MainMenuItemText';
                         _oToolItemText.style.position = 'absolute';
                         _oToolItemText.style.zIndex = 1000;
                         window.document.body.appendChild(_oToolItemText);  
                         //_oSkinImages['TOOLSTRIP_OPEN']
                      }

                      _oToolItemText.IsPos = false;

                      if ((strT == null) || (strT == '')) { 
                         _oToolItemText.style.display = 'none';
                      } else {  
                         _oToolItemText.style.top = this.ParentObject.ToolStripObj.ToolStrip.offsetTop + this.MaxHeight + 2;
                         _oToolItemText.innerHTML = strT;
                         _oToolItemText.style.display = 'block';
                         __bw2ObjectShadow(_oToolItemText);
                      }
                  } catch (e) {}
         }                  

/*--------------------------------------------------------------------------------*/

         function _bw2ToolItem_OnMouseOut(oEvent) {
                  if (oEvent == null) oEvent = window.event;

                  try {
                      if (_oToolItemText) _oToolItemText.style.display = 'none';
                      this.style.height = this.MinHeight;
                      this.style.width = this.MinHeight * this.XFactor;
                      __bw2GetElementById(this.ParentObject.ToolStripContainerID).style.left = this.XDefault;
                  } catch (e) {}
         }
}

/*================================================================================*/
/* <Function> Create ToolStrip-Item Object </Function>
/*================================================================================*/
function __bw2ToolStripItem(strItemID, nType, strToolStripContainerID, strToolStripChildID, strValue, fEnabled, fSelected, fIsCheckable, fChecked, fHasListItems, strOptionGroup, nSpecialHandled, strCommand, strOptions, fAjax) {
         this.Ajax = fAjax;
         this.ID = strItemID;
         this.Item = null;
         this.Command = strCommand;
         this.Enabled = fEnabled;
         this.IsCheckable = fIsCheckable;
         this.Checked = fChecked;
         this.HasListItems = fHasListItems;
         this.Opened = false;
         this.OptionGroup = strOptionGroup;
         this.Options = strOptions;
         this.Selected = fSelected;
         this.SpecialHandled = null;
         this.ToolStripChildID = strToolStripChildID;
         this.ToolStripContainerID = strToolStripContainerID;
         this.Type = null;
         this.Value = strValue;

         /*--- Special-Handled ---*/
         switch (nSpecialHandled) {
                case 1 : this.SpecialHandled = 'editor'; break;
         }

         /*--- Item-Type ---*/
         switch (nType) {
                case -1 : this.Type = 'userrendered'; break;             
                case  0 : this.Type = 'standard'; break;             
                case  1 : this.Type = 'separator'; break;             
                case  2 : this.Type = 'dropdown'; break;             
                case  3 : this.Type = 'dropdowninput'; break;             
                case  4 : this.Type = 'dropdownmenu'; break;             
                case  5 : this.Type = 'dropdownmenuitem'; break;             
                case  6 : this.Type = 'label'; break;             
                case  7 : this.Type = 'input'; break;             
                case  8 : this.Type = 'checkbox'; break;             
                case  9 : this.Type = 'optionbox'; break;             
         }

         this.Initialize = _bw2ToolStripItemInitialize;
         this.SetToolStripObj = _bw2ToolStripItemSetToolStripObj;

         /*--- Initialize-Item ---*/
         this.Initialize();

/*--------------------------------------------------------------------------------*/

         function _bw2ToolStripItemInitialize(oToolStripObj) {
                  try {
                      /*--- Assign to Element ---*/  
                      var oIT = __bw2GetElementById(this.ID); if (oIT == null) return;

                      this.Item = oIT;
                      this.Item.ParentObject = this;
                      this.Item.Ajax = this.Ajax;
                      this.Item.Command = this.Command;
                      this.Item.Enabled = this.Enabled;
                      this.Item.HasListItems = this.HasListItems;
                      this.Item.IsCheckable = this.IsCheckable;
                      this.Item.IsControl = false;
                      this.Item.IsDropDownMenuItem = false;
                      this.Item.Checked = this.Checked;
                      this.Item.Opened = this.Opened;
                      this.Item.OptionGroup = this.OptionGroup;
                      this.Item.Options = this.Options;
                      this.Item.Selected = this.Selected;
                      this.Item.SpecialHandled = this.SpecialHandled;
                      this.Item.ToolStripChildID = this.ToolStripChildID;
                      this.Item.ToolStripContainerID = this.ToolStripContainerID;
                      this.Item.Type = this.Type;
                      this.Item.Value = this.Value;

                      /*--- Register Functions & Events ---*/  
                      this.Item.Check = _bw2ToolStripItem_Check;
                      this.Item.Click = _bw2ToolStripItem_Click;
                      
                      //this.Item.onclick = _bw2ToolStripItem_OnClick;
                      this.Item.onmousedown = _bw2ToolStripItem_OnMouseDown;
                      this.Item.onmouseup = _bw2ToolStripItem_OnMouseUp;
                      this.Item.onmouseover = _bw2ToolStripItem_OnMouseOver;
                      this.Item.onmouseout = _bw2ToolStripItem_OnMouseOut;

                      /*--- Clip-Arrow for DropDown and SubMenu ---*/  
                      this.Item.Arrow = __bw2GetElementById(this.ID + '_Arrow');

                      if (this.Item.Arrow) {
                         this.Item.Arrow.Clicked = false;
                         this.Item.Arrow.style.position = 'relative'; 
                         this.Item.Arrow.Click = function (fClick) { this.Clicked = fClick;  if (fClick) { this.style.left = 1; this.style.top = 1; } else { this.style.left = 0; this.style.top = 0; } };
                      }  

                      /*--- Grouped Check-Items ---*/  
                      if ((this.Item.Checked) && (this.Item.OptionGroup != null)) _oToolItemGroupsSelected[this.Item.OptionGroup] = this.Item;

                      /*--- Set Refrence to Container-ToolStrip ---*/
                      if (oToolStripObj) this.SetToolStripObj(oToolStripObj);
                  } catch (e) {}
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolStripItemSetToolStripObj(oToolStripObj) {
                  try {
                      /*--- Remove ToolStrip-Object ---*/
                      if (oToolStripObj == null) {
                         this.Item.ToolStripObj = null;
                         return;

                      /*--- Css-Settings by ToolStrip-Type ---*/
                      } else {
                         if (oToolStripObj) {  
                            switch (oToolStripObj.Type) {
                                   case 'menu' :
                                   case 'dropdown' :
                                   case 'dropdownmenu' :
                                   case 'dropdownmenuitem' :
                                   case 'popup' :
                                   case 'submenu' : 
                                        if (this.Item.CssClass == null) this.Item.CssClass = _oSkinCssClasses['TOOLSTRIP_MENUITEM'];
                                        if (this.Item.CssClassCaption == null) this.Item.CssClassCaption = _oSkinCssClasses['TOOLSTRIP_MENUITEM_CAPTION'];
                                        if (this.Item.CssClassCaptionList == null) this.Item.CssClassCaptionList = _oSkinCssClasses['TOOLSTRIP_MENUITEM_CAPTION_LIST'];
                                        if (this.Item.CssClassDisabled == null) this.Item.CssClassDisabled = _oSkinCssClasses['TOOLSTRIP_MENUITEM_DISABLED'];
                                        if (this.Item.CssClassDropDown == null) this.Item.CssClassDropDown = _oSkinCssClasses['TOOLSTRIP_MENUITEM_DROPDOWN'];
                                        if (this.Item.CssClassLabel == null) this.Item.CssClassLabel = _oSkinCssClasses['TOOLSTRIP_MENUITEM_LABEL'];
                                        if (this.Item.CssClassLabelText == null) this.Item.CssClassLabelText = _oSkinCssClasses['TOOLSTRIP_MENUITEM_LABEL_TEXT'];
                                        if (this.Item.CssClassOnClick == null) this.Item.CssClassOnClick = _oSkinCssClasses['TOOLSTRIP_MENUITEM_CLICK'];
                                        if (this.Item.CssClassOnOver == null) this.Item.CssClassOnOver = _oSkinCssClasses['TOOLSTRIP_MENUITEM_ONOVER'];
                                        if (this.Item.CssClassSelected == null) this.Item.CssClassSelected = _oSkinCssClasses['TOOLSTRIP_MENUITEM_SELECTED'];
                                        if (this.Item.CssClassSub == null) this.Item.CssClassSub = _oSkinCssClasses['TOOLSTRIP_MENUITEM_SUB'];
                                        if (this.Item.CssClassText == null) this.Item.CssClassText = _oSkinCssClasses['TOOLSTRIP_MENUITEM_TEXT'];
                                        break;

                                   /*--- MenuBar, ToolBar, User-Rendered ---*/ 
                                   default :          
                                        /*--- Css-Settings by Item-Type ---*/
                                        switch (this.Item.Type) {
                                               case 'input' : 
                                               case 'dropdowninput' : 
                                                    this.Item.IsControl = true;
                                                    if (this.Item.CssClass == null) this.Item.CssClass = _oSkinCssClasses['TOOLSTRIP_CTRLITEM'];
                                                    if (this.Item.CssClassCaption == null) this.Item.CssClassCaption = _oSkinCssClasses['TOOLSTRIP_CTRLITEM_CAPTION'];
                                                    if (this.Item.CssClassDisabled == null) this.Item.CssClassDisabled = _oSkinCssClasses['TOOLSTRIP_CTRLITEM_DISABLED'];
                                                    if (this.Item.CssClassDropDown == null) this.Item.CssClassDropDown = _oSkinCssClasses['TOOLSTRIP_CTRLITEM_DROPDOWN'];
                                                    if (this.Item.CssClassInput == null) this.Item.CssClassInput = _oSkinCssClasses['TOOLSTRIP_CTRLITEM_INPUT'];
                                                    if (this.Item.CssClassInputIndication == null) this.Item.CssClassInput = _oSkinCssClasses['TOOLSTRIP_CTRLITEM_INPUT_INDICATION'];
                                                    if (this.Item.CssClassOnClick == null) this.Item.CssClassOnClick = _oSkinCssClasses['TOOLSTRIP_CTRLITEM_CLICK'];
                                                    if (this.Item.CssClassOnOver == null) this.Item.CssClassOnOver = _oSkinCssClasses['TOOLSTRIP_CTRLITEM_ONOVER'];
                                                    if (this.Item.CssClassSelected == null) this.Item.CssClassSelected = _oSkinCssClasses['TOOLSTRIP_CTRLITEM_SELECTED'];
                                                    if (this.Item.CssClassText == null) this.Item.CssClassText = _oSkinCssClasses['TOOLSTRIP_CTRLITEM_TEXT'];

                                                    /*--- Handle Input-Events ---*/
                                                    var oInp = __bw2GetElementById(this.ID + '_Input');

                                                    if (oInp) {
                                                       oInp.ParentObject = this.Item;
                                                       oInp.onfocus = _bw2ToolStripItemInput_OnFocus;
                                                       oInp.onblur = _bw2ToolStripItemInput_OnBlur;
                                                    
                                                       //var strIT = oInp.getAttribute("IndicationText");
                                                       //if (strIT) {
                                                       //   oInp.Indication = true; 
                                                       //}
                                                

                                                       //var fOnChange = oInp.getAttribute("HandleOnChange");
                                                       //if ((fOnChange) && (fOnChange == '1')) oInp.onkeyup = function() { __bw2AjaxObjOnEvent(event, this, 'onchange', this.value); }

                                                       //var fOnChanged = oInp.getAttribute("HandleOnChanged");
                                                       //if ((fOnChanged) && (fOnChanged == '1')) oInp.onkeyup = function() { __bw2AjaxObjOnEvent(event, this, 'onchange', this.value); }
                                                    
                                                    }
                                                    
                                                    //oInp.onfocusout = _bw2ToolStripItem_OnFocusOut;

                                                    break; 
                                                    
                                               case 'userrendered' : 
                                                    __bw2Debug(this.Item.id);
                                                    break; 

                                               /*--- Standard, Separator, Label, User-Rendered ---*/ 
                                               default :          
                                                    if (this.Item.CssClass == null) this.Item.CssClass = _oSkinCssClasses['TOOLSTRIP_ITEM'];
                                                    if (this.Item.CssClassCaption == null) this.Item.CssClassCaption = _oSkinCssClasses['TOOLSTRIP_ITEM_CAPTION'];
                                                    if (this.Item.CssClassDisabled == null) this.Item.CssClassDisabled = _oSkinCssClasses['TOOLSTRIP_ITEM_DISABLED'];
                                                    if (this.Item.CssClassDropDown == null) this.Item.CssClassDropDown = _oSkinCssClasses['TOOLSTRIP_ITEM_DROPDOWN'];
                                                    if (this.Item.CssClassLabel == null) this.Item.CssClassLabel = _oSkinCssClasses['TOOLSTRIP_ITEM_LABEL'];
                                                    if (this.Item.CssClassLabelText == null) this.Item.CssClassLabelText = _oSkinCssClasses['TOOLSTRIP_ITEM_LABEL_TEXT'];
                                                    if (this.Item.CssClassOnClick == null) this.Item.CssClassOnClick = _oSkinCssClasses['TOOLSTRIP_ITEM_CLICK'];
                                                    if (this.Item.CssClassOnOver == null) this.Item.CssClassOnOver = _oSkinCssClasses['TOOLSTRIP_ITEM_ONOVER'];
                                                    if (this.Item.CssClassSelected == null) this.Item.CssClassSelected = _oSkinCssClasses['TOOLSTRIP_ITEM_SELECTED'];
                                                    if (this.Item.CssClassText == null) this.Item.CssClassText = _oSkinCssClasses['TOOLSTRIP_ITEM_TEXT'];
                                                    break; 
                                        }

                                        break;
                            }
                         }

                         /*--- Init ListItems-Settings (Create DIV-Element for the DropDown-List) ---*/                         
                         if (this.Item.HasListItems) {
                            this.Item.ListItems = document.createElement('DIV'); 
                            this.Item.ListItems.id = this.ID + '_ListItems';
                            this.Item.ListItems.innerHTML = 'Loading ...';
                            this.Item.ListItems.className = this.Item.CssClassDropDown;
                            this.Item.ListItems.style.display = 'none';
                            this.Item.ListItems.style.overflow = 'auto';
                            this.Item.ListItems.style.position = 'absolute';
                            this.Item.ListItems.style.visibility = 'hidden';

                         /*--- Init DropDown-Menu with Selected-Item (Handle Image-Cell as Selected-Item) ---*/ 
                         //} else if ((this.Item.Type == 'dropdownmenu') || (this.Item.Type == 'dropdownmenuitem')) {
                         } else if (this.Item.Type == 'dropdownmenuitem') {
                            this.Item.Item = __bw2GetElementById(this.ID + '_CellImage');

                            if (this.Item.Item) {
                               this.Item.Item.ParentObject = this.Item; 
                               this.Item.Item.IsDropDownMenuItem = true; 
                               this.Item.Item.onmousedown = _bw2ToolStripItem_OnMouseDown;
                               this.Item.Item.onmouseup = _bw2ToolStripItem_OnMouseUp;
                               this.Item.Item.onmouseout = _bw2ToolStripItem_OnMouseOut;
                            }
                         }

                         /*--- Init Class Settings ---*/                         
                         if (this.Item.Enabled) {
                            if (this.Item.Type == 'label') {
                               this.Item.className = this.Item.CssClassLabel;
                            } else if ((this.Item.Type != 'checkbox') && (this.Item.Type != 'optionbox')) { 
                               if (((this.Item.IsCheckable) && (this.Item.Checked == true)) || (this.Item.Selected == true)) {
                                  this.Item.className = this.Item.CssClassSelected;
                               } else {
                                  this.Item.className = this.Item.CssClass;
                               }
                            } else {
                               this.Item.className = this.Item.CssClass;
                            }
                         } else {
                            this.Item.className = this.Item.CssClassDisabled;
                         }
                         
                         this.Item.ToolStripObj = oToolStripObj;
                      }
                  } catch (e) {}
         }

/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/

         function _bw2ToolStripItemOnMouseDown(oObj, oEvent) {
                  //if ((oObj.Enabled == false) || (oObj.Opened == true)) return;
                  if (oObj.Enabled == false) return;
                  if (oEvent == null) oEvent = window.event;

                  try {
                      with (oObj) {
                           /*--- Click Image on DropDown-Menu ---*/ 
                           if (IsDropDownMenuItem) {
                              style.backgroundColor = _oSkinColors['TOOLSTRIP_ITEM_CLICK'];                           
                              oEvent.cancelBubble = true;  
                              return;
                           }

                           className = CssClassOnClick; 

                           if ((_oCtrlItemSelected) && (_oCtrlItemSelected != oObj)) __bw2ToolStripsHide();

                           /*--- Control-Items (DropDown & Input) ---*/ 
                           if (IsControl) {
                              _oCtrlItemSelected = oObj;
                              Selected = true;  

                              /*--- DropDown with ListItems ---*/  
                              if (HasListItems) {
                                 var oS = __bw2EventSource(oEvent);

                                 //if ((oS) && (oS.tagName == 'INPUT')) {
                              
                                 if ((Opened) || ((oS) && (oS.tagName == 'INPUT'))) {
                                    Opened = false;
                                    __bw2ListItemsHide();
                                    if (Arrow) Arrow.Click(false);
                                    className = CssClassOnOver; 
                                    return;
                                 } else {
                                    Opened = true;  
                                    __bw2ListItemsShow(oEvent, oObj);
                                 }

                              /*--- DropDown with Child-ToolStrip ---*/  
                              } else if (ToolStripChildID != null) {
                                 if (Opened) {
                                    Opened = false
                                    __bw2ToolStripsHide();
                                    if (Arrow) Arrow.Click(false);
                                    className = CssClassOnOver; 
                                    return;
                                 } else {
                                    Opened = true;  
                                    _fCancelEvents = true; 
                                    __bw2ToolStripShow(oEvent, oObj);
                                 }

                              /*--- Input ---*/  
                              } else { 
                              }

                           /*--- Menu, Popup and SubMenu ---*/ 
                           } else if (ToolStripChildID != null) {
                              if ((ToolStripObj) && (ToolStripObj.Type != 'menu') && (ToolStripObj.Type != 'dropdownmenu') && (ToolStripObj.Type != 'dropdownmenuitem') && (ToolStripObj.Type != 'popup') && (ToolStripObj.Type != 'submenu')) __bw2ToolStripsHide();
                              Selected = true;  
                              _oToolItemSelected = oObj;
                              __bw2ToolStripShow(oEvent, oObj);
                              return;

                           /*--- Click-Even for all Items on Menus or DropDowns ---*/ 
                           } else if ((Type == 'standard') && (ToolStripObj) && (ToolStripObj.Type != 'menubar') && (ToolStripObj.Type != 'statusbar') && (ToolStripObj.Type != 'toolbar')) {
                              Click(oEvent);
                           }

                           if ((!IsControl) && (ToolStripObj) && (ToolStripObj.Type != 'popup') && (ToolStripObj.Type != 'submenu')) 
                              __bw2ToolStripCtrlItemSelectedReset();

                           if (Arrow) Arrow.Click(Opened);
                      }
                  } catch (e) {}
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolStripItemOnMouseUp(oObj, oEvent) {
                  if ((oObj.Enabled == false) || (oObj.Opened == true) || (oObj.ToolStripChildID != null) || (oObj.HasListItems)) { _fCancelEvents = true; return; }
                  if (oEvent == null) oEvent = window.event;

                  try {
                      with (oObj) {
                           if (IsDropDownMenuItem) {
                              style.backgroundColor = '';                           
                              oEvent.cancelBubble = true;  
                              ParentObject.Click(oEvent);
                              return;
                           }

                           if (IsControl) return;

                           className = CssClassOnOver;

                           if ((ToolStripObj) && (ToolStripObj.Type == 'popup')) __bw2ToolStripCtrlItemSelectedReset();
                           if (Arrow) Arrow.Click(false);
                           if (IsCheckable) Check();
                           
                           Click(oEvent);
                      }
                  } catch (e) {}
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolStripItemOnMouseOver(oObj, oEvent) {
                  if (!oObj.Enabled) return;
                  if (oEvent == null) oEvent = window.event;

                  try {
                      with (oObj) {
                           //if ((_oToolStrip) && (_oToolStrip.ParentToolStrip) && (ToolStripObj) && (_oToolStrip != ToolStripObj.ToolStrip)) {
                           //   return;
                           //}
                  
                           var oSplit = __bw2GetElementById(id + '_Split'); 
                  
                           _oToolItem = oObj; 
                           _fCancelEvents = false;
                           _nShowDelay = -1;

                           /*--- Checkable-Item ---*/ 
                           if ((oObj.Type == 'checkbox') || (oObj.Type == 'optionbox')) { 
                              className = CssClassOnOver;
                           } else if (IsCheckable) {
                              if (!Checked) className = CssClassOnOver;
                           } else {
                              className = CssClassOnOver;
                           }
                           
                           if (oSplit) {
                              oSplit.style.backgroundColor = _oSkinColors['TOOLSTRIP_ITEM_BORDER'];
                              oSplit = null;
                           }

                           /*--- Menus, Sub-Menus & DroDowns ---*/ 
                           if ((ToolStripObj) && (ToolStripObj.Type != 'menubar') && (ToolStripObj.Type != 'statusbar') && (ToolStripObj.Type != 'toolbar') && (ToolStripObj.Type != 'userrendered')) {
                              _oToolStrip = ToolStripObj.ToolStrip;
                              
                              /*--- Menu-Item has a Sub-Menu ---*/
                              if (ToolStripChildID != null) {
                                 /*--- Close all Sub-Menus ---*/
                                 try {
                                     for (strIID in ToolStripObj.Items) {
                                         with (ToolStripObj.Items[strIID].Item) {
                                              if ((ToolStripChildID != null) && (Opened)) {
                                                 if (oObj.id != strIID) {
                                                    className = CssClass;
                                                    Opened = false;
                                                    _oToolStrips[ToolStripChildID].Hide(); 
                                                 }
                                              }
                                         }
                                     }
                                 } catch (e) {} 

                                 /*--- [Exit] Sub-Menu is visible ---*/
                                 try {
                                     if (_oToolStrips[ToolStripChildID].ToolStrip.style.display != 'none') return;
                                 } catch (e) {} 

                                 /*--- Show Sub-Menu delayed ---*/
                                 //Opened = true;
                                 //_oToolItemSelected = oObj;
                                 _nShowDelay = 0; 
                                 __bw2ToolStripChildShow(oEvent, oObj);

                              /*--- Close all Sub-Menus ---*/
                              } else {
                                 try {
                                     for (strIID in ToolStripObj.Items) {
                                         with (ToolStripObj.Items[strIID].Item) {
                                              if (ToolStripChildID != null) {
                                                 if (!Opened) {
                                                    className = CssClass; 
                                                 } else if (oObj.id != strIID) {
                                                    className = CssClass; 
                                                    Opened = false;
                                                    _oToolStrips[ToolStripChildID].Hide(); 
                                                 }
                                              }
                                         }
                                     }
                                 } catch (e) {} 
                              }

                           /*--- Close all Menus ---*/
                           } else if ((_oToolItemSelected) && (_oToolItemSelected != oObj)) {
                              __bw2ToolStripsHide();
                           }
                      }
                  } catch (e) {}
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolStripItemOnMouseOut(oObj, oEvent) {
                  if ((oObj.Enabled == false) || (oObj.Opened == true) || ((oObj.IsControl) && (oObj.Selected))) return;
                  if (oEvent == null) oEvent = window.event;

                  try {
                      var oSplit = __bw2GetElementById(oObj.id + '_Split'); 

                      _oToolItem = null; 

                      with (oObj) {
                           if ((Selected) && ((IsControl) || (IsDropDownMenuItem))) {
                              style.backgroundColor = '';                           
                              return;
                           }

                           if ((oObj.Type == 'checkbox') || (oObj.Type == 'optionbox')) { 
                              className = CssClass;
                           } else if ((IsCheckable) && (Checked)) {
                              className = CssClassSelected;
                           } else {
                              className = CssClass;
                           }

                           if (oSplit) {
                              oSplit.style.backgroundColor = ''; 
                              oSplit = null;
                           }

                           if (Arrow) Arrow.Click(false);
                      }
                  } catch (e) {}
         }

/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/

         function _bw2ToolStripItem_Check(fChecked) {
                  if (this.IsCheckable) {
                     if (this.OptionGroup != null) {
                        if (fChecked != null) {
                           this.Checked = fChecked;
                        } else {
                           this.Checked = true;
                        }
                        
                        this.className = this.CssClassSelected; 

                        try {
                            if (_oToolItemGroupsSelected[this.OptionGroup] != null) {
                              _oToolItemGroupsSelected[this.OptionGroup].Checked = false;
                              _oToolItemGroupsSelected[this.OptionGroup].className = this.CssClass;
                              _oToolItemGroupsSelected[this.OptionGroup] = this;
                            } else {
                              _oToolItemGroupsSelected[this.OptionGroup] = this;
                            }
                        } catch (e) {
                            _oToolItemGroupsSelected[this.OptionGroup] = this;
                        }
  
                     } else {
                        if (fChecked != null) {
                           this.Checked = fChecked;
                        } else {
                           this.Checked = !this.Checked;
                        }

                        if (this.Type == 'checkbox') {
                           this.className = this.CssClass; 

                           var oImg = __bw2GetElementById(this.id + '_Image');

                           if (this.Checked) {
                              if (oImg) oImg.src = _oSkinImages['TOOLSTRIP_CHECKBOX'].ImageSelected;
                           } else {
                              if (oImg) oImg.src = _oSkinImages['TOOLSTRIP_CHECKBOX'].Image;
                           }
                        } else {
                           var oImg = __bw2GetElementById(this.id + '_Image');

                           if (this.Checked) {
                              this.className = this.CssClassSelected;
                              if ((oImg) && (this.Image)) oImg.src = _oSkinImages[this.Image].ImageSelected;
                           } else {
                              if ((oImg) && (this.Image)) oImg.src = _oSkinImages[this.Image].Image;
                           }
                        }
                        
                        _oToolItemSelected = this;
                    }
                  }
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolStripItem_Click(oEvent) {
                  __bw2ToolStripSpezialHandled(this);
                  __bw2ToolStripsHide();

                  if (oEvent == null) oEvent = window.event;

                  /*--- Ajax Post ---*/  
                  if (this.Ajax) {
                     if ((this.Options) && (this.Options == 'loading')) __bw2Loading(true);

                     if (this.IsCheckable) {
                        __bw2AjaxObjOnEvent(oEvent, this, 'oncheck', this.Checked);
                     } else {
                        __bw2AjaxObjOnEvent(oEvent, this, 'onclick', 1);
                     }

                     /*--- Additional Click-Actions ---*/  
                     try { 
                         var strCV = this.getAttribute('ClickValue');
                         
                         if (strCV != null) {
                            window.eval(strCV);
                         }
                     } catch (e) {}

                  /*--- Page Post ---*/  
                  } else {
                     __doPostBack(this.id, 'ITEMCLICK');
                  }

                  oEvent.cancelBubble = true;  
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolStripItem_OnClick(oEvent) {
                  if ((_fCancelEvents) || (this.Enabled == false) || (this.Opened == true)) return;

                  try {
                      if (_fCancelEvents) return;
                      __bw2ToolStripsHide();
                  } catch (e) {}
         }
         
/*--------------------------------------------------------------------------------*/

         function _bw2ToolStripItem_OnMouseDown(oEvent) {
                  _bw2ToolStripItemOnMouseDown(this, oEvent);
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolStripItem_OnMouseUp(oEvent) {
                  _bw2ToolStripItemOnMouseUp(this, oEvent);
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolStripItem_OnMouseOver(oEvent) {
                  _bw2ToolStripItemOnMouseOver(this, oEvent);
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolStripItem_OnMouseOut(oEvent) {
                  _bw2ToolStripItemOnMouseOut(this, oEvent);
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolStripItemInput_OnFocus(oEvent) {
                  try {
                      /*--- Reset selection ---*/
                      if ((this.ParentObject) && (_oCtrlItemSelected) && (_oCtrlItemSelected != this.ParentObject)) {
                         _bw2ToolStripItemOnMouseDown(this.ParentObject, oEvent);
                      }
                  
                      /*--- Indication-Handling ---*/
                      var strIT = this.getAttribute("IndicationText");

                      if (strIT) {
                         if (this.value == strIT) this.value = '';
                         this.className = _oSkinCssClasses['TOOLSTRIP_CTRLITEM_INPUT'];  
                      }

                      if (this.value) this.select();

                  } catch (e) {}
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ToolStripItemInput_OnBlur(oEvent) {
                  try {
                      /*--- Indication-Handling ---*/
                      var strIT = this.getAttribute("IndicationText");

                      if ((strIT) && ((this.value == null) || (this.value == ''))) {
                         this.className = _oSkinCssClasses['TOOLSTRIP_CTRLITEM_INPUT_INDICATION'];  
                         this.value = this.getAttribute("IndicationText");
                      }
                  } catch (e) {}
         }
}

/*================================================================================*/
/* <Function> ToolStrip-ColorItem Event (Event-Handeler) </Function>
/*================================================================================*/
function __bw2ToolStripColorItemEvent(oEvent, oItem, strToolStrip, strColor, strCommand, strSpecialHandled, fAjax) {
         _oToolItem = oItem; 
         _fCancelEvents = false;

         /*--- Set Symbol-Color ---*/
         var oM = _oToolStrips[strToolStrip];

         try {
             if (strColor == 'autocolor') {
                oItem.AutoColor = true;
                 
                if (_oEditor) {
                   strColor = _oEditor.DefForeColor;
                } else {
                   strColor = '#FFFFFF'; //'transparent';
                }
             } else if (strColor == 'transparent') {
                oItem.AutoColor = true;
             }

             __bw2GetElementById(strToolStrip + '_ColorMarker1').style.backgroundColor = strColor;
             __bw2GetElementById(strToolStrip + '_ColorMarker2').style.backgroundColor = strColor;
         } catch (e) {
         }

         /*--- Color-Unselection ---*/
         if ((oM) && (oM.ColorSel)) {
            oM.ColorSel.className = oM.CssClassItem;

            if (oM.ColorSel.AutoColor) {
               oM.ColorSel.onmouseover = function () { this.className = oM.CssClassItemOnOver; } 
               oM.ColorSel.onmouseout = function () { this.className = oM.CssClassItem; } 
            } else {
               oM.ColorSel.style.padding = '4 4 4 4';
               oM.ColorSel.onmouseover = function () { this.className = oM.CssClassItemOnOver; this.style.padding = '3 3 3 3'; } 
               oM.ColorSel.onmouseout = function () { this.className = oM.CssClassItem; this.style.padding = '4 4 4 4'; } 
            }
         } else { 

if (oM == null) return;

            var nP = oItem.id.search(/_#/); 
            var fE = false;
         
            if (nP > -1) {
               var strI = oItem.id.substring(0, nP + 2);

               for (nI = 0; nI < _oColorListStandard.length; nI++) {
                   var oE = __bw2GetElementById(strI + _oColorListStandard[nI]);

                   if ((oE) && (oE.className) && (oE.className == oM.CssClassItemSelected)) {
                      oE.className = oM.CssClassItem;
                      oE.style.padding = '4 4 4 4';
                      oE.onmouseover = function () { this.className = oM.CssClassItemOnOver; this.style.padding = '3 3 3 3'; } 
                      oE.onmouseout = function () { this.className = oM.CssClassItem; this.style.padding = '4 4 4 4'; } 
                      fE = true;
                      break;
                   }
               }

               if (!fE) {
                  for (nI = 0; nI < _oColorListExtended.length; nI++) {
                      var oE = __bw2GetElementById(strI + _oColorListExtended[nI]);

                      if ((oE) && (oE.className) && (oE.className == oM.CssClassItemSelected)) {
                         oE.className = oM.CssClassItem;
                         oE.style.padding = '4 4 4 4';
                         oE.onmouseover = function () { this.className = oM.CssClassItemOnOver; this.style.padding = '3 3 3 3'; } 
                         oE.onmouseout = function () { this.className = oM.CssClassItem; this.style.padding = '4 4 4 4'; } 
                         break;
                      }
                  }
               }
            }
         }
            
         /*--- Color-Selection ---*/
         oM.ColorSel = oItem;
         oItem.className = oM.CssClassItemSelected;
         if (!oItem.AutoColor) oItem.style.padding = '3 3 3 3';
         oItem.onmouseover = function () { this.className = oM.CssClassItemOnOver; } 
         oItem.onmouseout = function () { this.className = oM.CssClassItemSelected; } 

         /*--- Special Handled ---*/
         try {
             oItem.ToolStripObj = _oToolStrips[strToolStrip];
             oItem.Command = strCommand;
             oItem.SpecialHandled = strSpecialHandled;
             oItem.Value = strColor;
         
             __bw2ToolStripSpezialHandled(oItem);
         } catch (e) {
         }

         /*--- Ajax-Post ---*/
         if (fAjax) {
            __bw2AjaxObjOnEvent(oEvent, oItem, 'onclick', strColor);

         /*--- Page-Post ---*/
         } else {
            __doPostBack(oItem.id, 'ITEMCLICK');
         }

         __bw2ToolStripsHide(1);
}

/*================================================================================*/
/* <Function> ToolStrip-CtrlItem reset Selection </Function>
/*================================================================================*/
function __bw2ToolStripCtrlItemSelectedReset() {
         try {
             if (_oCtrlItemSelected != null) {
                _oCtrlItemSelected.className = _oCtrlItemSelected.CssClass; 
                _oCtrlItemSelected.Opened = false;
                _oCtrlItemSelected.Selected = false;
                if (_oCtrlItemSelected.Arrow) _oCtrlItemSelected.Arrow.Click(false);
             }
         } catch (e) {} finally {_oCtrlItemSelected = null;}
}

/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/


/*================================================================================*/
/* <Function> ListItems anzeigen (DropDown) </Function>
/*================================================================================*/
function __bw2ListItemsShow(oEvent, oItem) {
         if ((oItem == null) || (!oItem.HasListItems)) return;
         
         try {
             var strDDW = oItem.getAttribute('DropDownWidth');
             var nL = __bw2ObjectOffsetLeft(oItem);
             var nT = __bw2ObjectOffsetTop(oItem);

             _oListItems = oItem.ListItems;
             _oListItems.style.display = 'block';

             if (oItem.Ajax) __bw2AjaxRequest(oItem.id, 'DIV', null, 'onlistitems', null, null, true);
             
             if (_oListItems.innerHTML != '') {
                __bw2AppendChildElement(_oListItems);

                if (_fIE) nL++; else nT--;
                if (strDDW) _oListItems.style.width = strDDW;
                _oListItems.style.left = nL;
                _oListItems.style.top = nT + oItem.offsetHeight;
                _oListItems.style.visibility = 'visible';
                _oListItems.style.zIndex = __bw2ZIndex();

                if (_oListItems.children) {
                   for (var nI = 0; nI < _oListItems.children.length; nI++)	{
                       if (_oListItems.children[nI].tagName == 'TABLE') {
                          _oListItems.children[nI].style.width = '100%';
                          
                          if (_oListItems.children[nI].rows) {
                             for (var nR = 0; nR < _oListItems.children[nI].rows.length; nR++)	{
                                 var oRow = _oListItems.children[nI].rows[nR];
                                 if (oRow) oRow.onmousedown = _bw2ListItems_OnMouseDown;
                             }
                          }

                          break; 
                       }
                   }
                } else {
                   for (var nI = 0; nI < _oListItems.childNodes.length; nI++)	{
                       if (_oListItems.childNodes[nI].tagName == 'TABLE') {
                          _oListItems.childNodes[nI].style.width = '100%';

                          if (_oListItems.childNodes[nI].rows) {
                             for (var nR = 0; nR < _oListItems.childNodes[nI].rows.length; nR++)	{
                                 var oRow = _oListItems.childNodes[nI].rows[nR];
                                 if (oRow) oRow.onmousedown = _bw2ListItems_OnMouseDown;
                             }
                          }

                          break; 
                       }
                   }
                }

                /*--- Handle Events ---*/
                _oListItems.onmouseover = _bw2ListItems_OnMouseOver;
                _oListItems.onmouseout = _bw2ListItems_OnMouseOut;

                __bw2ObjectShadow(_oListItems);

             } else {
                _oListItems.style.visibility = 'hidden';
             }
         } catch (e) {}

/*--------------------------------------------------------------------------------*/

         function _bw2ListItems_OnMouseOver(oEvent) {
                  __bw2RemoveEventListener(document.body, 'mousedown', __bw2ToolStripOutsideClick, false);
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ListItems_OnMouseOut(oEvent) {
                  _fCancelEvents = false;  
                  __bw2AddEventListener(document.body, 'mousedown', __bw2ToolStripOutsideClick, false);
         }

/*--------------------------------------------------------------------------------*/

         function _bw2ListItems_OnMouseDown(oEvent) {
                  __bw2RemoveEventListener(document.body, 'mousedown', __bw2ToolStripOutsideClick, false);
                  __bw2AjaxRequest(this.id, 'TR', null, 'onlistitemselected', null, null, true);
                  __bw2ToolStripsHide();
         }
}

/*================================================================================*/
/* <Function> ListItems ausblenden (DropDown) </Function>
/*================================================================================*/
function __bw2ListItemsHide() {
         if (_oListItems == null) return;

         try {
             _oListItems.style.display == 'none';
             _oListItems.innerHTML = null;
             __bw2RemoveChildElement(_oListItems);
             _oListItems = null;
         } catch (e) {}
}

/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/