//-------------------------------------------------------
// the implementation of the menu
//-------------------------------------------------------

HWbName = navigator.appName;
vishide="hidden";
visshow="visible";
var hst=' height=100%';
var cselb=' style="background-color:';
var csele=';" ';

var clsleep=500; // timeout for closing a menu

var firsttime = true;
var prebMenus = new Array();
prebMenus[0]=1;
var iep='icons/empty.gif';
var ies='src="'+iep+'"';
var ie11='<IMG WIDTH=1 HEIGHT=1 '+ies+'">';
var mwh11=" WIDTH=1 HEIGHT=1 ";

var isMacIE = (navigator.platform.toLowerCase().indexOf('mac')!=-1 && navigator.appName.toLowerCase().indexOf('microsoft')!=-1);


function getAction(actionname,parameter)
{
  var param="";
  if (typeof parameter != "undefined")
    param=parameter;
  var ret=";internal&action="+actionname+".action";
  var parstr="&Parameter=";
  if (actionname=="_setlanguage") parstr="?"
  if (param!="")
    ret+=parstr+param;
  return ret;
}

//-------------------------------------------------------
//Menu Implementations
//-------------------------------------------------------

var HWMenuUnloaded=false;

function Menu_setTimeout(func,tim,win)
{
  var thewin=win||window;
  var timeouts;
  if (typeof top!="undefined")
  {
    if (typeof top.MenuTimeOuts =="undefined")
    {
      top.MenuTimeOuts = {};
    }
    timeouts=top.MenuTimeOuts;
  }
  else
  {
    MenuTimeOuts = {};
    timeouts=MenuTimeOuts;
  }

  var timerid=thewin.setTimeout(func,tim);
  timeouts[timerid]=thewin;
  return timerid;
}

function Menu_clearTimeout(id)
{
  var timeouts;
  if (typeof top!="undefined")
  {
    timeouts=top.MenuTimeOuts;
  }
  else
  {
    timeouts=MenuTimeOuts;
  }
  var thewin=timeouts[id];
  if (typeof thewin !="undefined")
    thewin.clearTimeout(id);
  delete timeouts[id];
}

function Menu_clearallTimeouts()
{
  HWMenuUnloaded=true;
  var timeouts;
  if (typeof top!="undefined")
  {
    timeouts=top.MenuTimeOuts;
    top.menu_registeredMenus = [];
  }
  else
  {
    timeouts=MenuTimeOuts;
    menu_registeredMenus = [];
  }
  for (var tid in timeouts)
  {
    var thewin=timeouts[tid];
    if (typeof thewin !="undefined" )
      thewin.clearTimeout(tid);
    delete timeouts[tid];
  }

  //test if menu exist and if yes delete it (frame case)
  if (typeof hwbar!= "undefined")
    hwbar.deleteVisual();

  if (typeof hwiconbar!= "undefined")
    hwiconbar.deleteVisual();

  if (typeof ms != "undefined" && typeof ms.sonunload == "function")
    ms.sonunload();
}


function Menu_onLoad () 
{
  Menu_onLoadDOM();

  if (typeof menu_ol!="undefined" && typeof menu_ol.sonload=="function") {
    menu_ol.sonload();
  }
}


Menu.prototype.deleteVisual=function()
{
  if (this.container_)
  {
    if (this.menuCont_ &&
      typeof top.frames[this.container_]!="undefined" && top.frames[this.container_].HW_pageLoaded)
    {
      WriteToPageRepl('',this.menuCont_);
    }
  }

}

Menu.prototype.getObject=function(it)
{
  var cur = this;
  while(!cur.obj_ && cur.parentItem_ && cur.parentItem_.menu_)
    cur=cur.parentItem_.menu_;
  return cur.obj_?cur.obj_:"";
}

Menu.prototype.getAttrObject=function(it)
{
  var cur = this;
  while(!cur.attrobj_ && cur.parentItem_ && cur.parentItem_.menu_)
    cur=cur.parentItem_.menu_;
  return cur.attrobj_?cur.attrobj_:null;
}

Menu.prototype.action=function(it)
{
  var ret="";
  if (!it.opobj_ || typeof move !="function")
    ret=this.getObject();
  var action = getAction(it.act_,it.actp_);
  if (ret.indexOf(";internal") != -1 && action.indexOf(";internal") != -1) {
    action = action.replace(/\;internal/, "");
  }
  ret+=action;
  return ret;
}

Menu.prototype.actionmult=function(it)
{
  var ret="";
  ret=this.getObject();
  ret+=getAction(it.actmult_,it.actpmult_);
  return ret;
}

Menu.prototype.addHideLayer=function(obj)
{
  this.hLays_[this.hLays_.length]=obj;
}


Menu.prototype.clWasDown=function ()
{
  this.wasDown_=false;
  if (!this.parentItem_)
  {
    hsLayers(this.hLays_,visshow)
  }
  for (var itemcont=0; itemcont< this.items_.length; itemcont++)
  {
    var it=this.items_[itemcont];
    if (it.child_)
      it.child_.clWasDown();
  }
}

Menu.prototype.MenuToString = function ()
{
  var rel="absolute";
  var ms=' menuid="'+this.id_+'"';
  var str = [];
  var layerstr='';
  var prelayerstr='';

  prelayerstr+='<div id="menu'+this.id_+'"'+ms+' class="'+this.cssClass_+'" onmouseover=\'menuEnter("'+this.id_+'",self.event || arguments[0])\' onmouseout=\'menuLeave("'+this.id_+'", 0, self.event || arguments[0])\' style="position:'+rel+';width:100%;top:0pt;left:0pt">';

  var mco=this.MenuConf_;

  // add Menu Table frames
  str[str.length]='<table id="menutable'+this.id_+'" class="Background" border="0" cellspacing="0" cellpadding="0">';

  // menuitems
  if (this.orientation_=="top") {
    str[str.length]='<tr'+ms+'>';
  }

  if ((this.parentItem_ || this.openerElement_) && this.items_.length>0) { // do not circle through top-menu
    var start_anchor = new MenuItem("",{});
    start_anchor.isStartAnchor_ = true;
    start_anchor.menu_ = this.items_[0].menu_
    str[str.length]= start_anchor.toString();
  }
  for (var itemcont=0; itemcont< this.items_.length; itemcont++)
  {
//     if ((it.isdisabled_ && this.showdisabledicons_) || !it.isdisabled_)
//     {
    var it=this.items_[itemcont];
    str[str.length]=it.toString();
    it.isdisplayed_=true;
//     }
//     else
//     {
//       it.isdisplayed_=false;
//     }
  }
  if ((this.parentItem_ || this.openerElement_) && this.items_.length>0) { // do not circle through top-menu
    var end_anchor = new MenuItem("",{});
    end_anchor.isEndAnchor_ = true;
    end_anchor.menu_ = this.items_[0].menu_
    str[str.length]= end_anchor.toString();
  }
  if (this.orientation_=="top") {
    str[str.length]='</tr>\n';
  }
  str[str.length]='</table>';
  layerstr+='</div>';
//    // top.debugWindow(str.join(''));
  return {str:str.join(''),prelayerstr:prelayerstr,postlayerstr:layerstr};
}

Menu.prototype.createNewMenuRep= function(obj)
{
  this.createNewMenuRepDOM(obj);
}

Menu.prototype.showAt= function(x,y,p2,visi)
{
  if(this.close_)
  {
    hsLayers(this.hLays_,vishide);
    menuLeave(this.id_,3000);
  }

  var p=p2||{};
  p.ma=p.ma||"l";
  vis=visshow;
  if (typeof visi!="undefined")
    vis=visi;

  if(vis==visshow)
    this.isvis_=true;
  else
    this.isvis_=false;

  if (!this.created_)
  {
    var obj=this.MenuToString();
    this.createNewMenuRep(obj);
  }

  var ox=x
  if (p.ma=="r") {

    x=x-this.width_;
  }
  if (p.may=="b") {

    y=y-this.height_;
  }

  var compy=this.clientHeight()+this.getScrollTop();

  if (compy<y+this.height_ && this.orientation_=="left")
    y=compy-this.height_;

  var compx=this.clientWidth();
  if (x+this.width_>compx)
  { // menu is displayed out of range of the frame
    if (p.positionConstraints && p.positionConstraints.left) 
    {
      x=Math.max(compx-this.width_,p.positionConstraints.left);
    }
    else
    {
      x=compx-this.width_;
    }
  }

  if (x<0) x=0;
  if (y<0) y=0;

  if (p.positionConstraints)
  {
    if (p.positionConstraints.left)
    {
      if (x<p.positionConstraints.left)
        x=p.positionConstraints.left
    }
    if (p.positionConstraints.right)
    {
      if (x+this.width_>p.positionConstraints.right)
        x=p.positionConstraints.left-this.width_;
    }
  }

  this.showAtDOM(x,y,vis,p.relright);

  this.x_=x;
  this.y_=y;
  if (!this.created_)
    this.created_=true;
}

Menu.prototype.hide= function()
{
  if (this.menuLayer_) {
    // workaround for NN7:
    // move layer out of the visible area instead of setting visibility;
    // otherwise 508-support does not work
    this.menuLayer_.style.top=getCoordValue(-10000);
    this.menuLayer_.style.left=getCoordValue(-10000);
//      this.menuLayer_.style.visibility=vishide;
  }
  this.isvis_=false;
  this.focusMenu_ = null;
  this.focusElement_ = null;
  this.focusId_ = null;
  if (!this.parentItem_)
    this.saveStat();
}

Menu.prototype.visibility = function ()
{
  if (!this.menuLayer_)
    return vishide;
  if (parseInt(this.menuLayer_.style.top) == -10000) {  // see hide-method
    return vishide;
  }
  return visshow;
}

Menu.prototype.x= function()
{
  return this.x_;
}

Menu.prototype.y= function()
{
  return this.y_;
}

Menu.prototype.saveStat=function()
{
  if (this.useCookies_) {
    state = this.isvis_+'^'+this.x_+'^'+this.y_;
    setCookie(this.caption_,state,null);
  }
}

Menu.prototype.restorStat=function()
{
  var isopen =1;
  var cookie=null;
  if (this.useCookies_) cookie=getCookie(this.caption_);
  if(cookie == null) {
    this.x_=0;
    this.y_=0;
    return -1;
  }
  else {
    var cstate = cookie.split(':');
    var vals=cstate[0].split('^');
    isopen = eval(vals[0]);
    if (isopen)
    {
      this.x_=parseInt(vals[1]);
      this.y_=parseInt(vals[2]);
    }
    else
      isopen=0;
  }
  return isopen;
}

Menu.prototype.focus = function()
{
  this.focusMenu_ = null;
  if (this.focusElement_) {
    // top.debugWindow('set existing focus: Id: '+this.focusId_);
    this.focusElement_.focus();
    return true;
  }
  else {
    var first_element = this.theDocument_.getElementById(this.firstAnchorId_);
    if (first_element) {
      var menu_id = first_element.getAttribute('menuid');
      this.focusId_      = menu_id;
      // top.debugWindow('set focus to first element: Id: '+this.focusId_);
      this.focusElement_ = first_element;
      this.focusElement_.focus();
      return true;
    }
  }
  return false;
}

Menu.prototype.blur = function (theFocusMenu)
{
  // top.debugWindow('>>> blur()');
  this.focusMenu_ = theFocusMenu;

  if (this.focusElement_) {
    this.focusElement_.blur();
    return true;
  }
  return false;
}

Menu.prototype.focusNext = function ()
{
  // top.debugWindow('>>> focusNext()');
  var current_id = this.focusId_;
  var next_anchor_id;
  var items = this.items_;
  var current_found = false;
  
  for (var i=0; i<items.length; i++) {

    if (items[i].id_==current_id) {
      current_found = true;
      continue;
    }
    if (current_found && items[i].anchorId_) {
      next_anchor_id = items[i].anchorId_;
      break;
    }
  }
  if (!next_anchor_id) {
    next_anchor_id = this.firstAnchorId_;
  }
  var next_element = this.theDocument_.getElementById(next_anchor_id);
  var menu_id = next_element.getAttribute('menuid');
  this.focusId_      = menu_id;
  // top.debugWindow('set focus to next element: Id: '+this.focusId_);
  this.focusElement_ = next_element;
  this.focusElement_.focus();
  // top.debugWindow('<<< focusNext()');
  return true;
}

Menu.prototype.focusPrevious = function ()
{
  // top.debugWindow('>>> focusPrevious()');
  var current_id = this.focusId_;
  var next_anchor_id;
  var items = this.items_;
  var current_found = false;
  
  for (var i=items.length-1; i>=0; i--) {
    if (items[i].id_==current_id) {
      current_found = true;
      continue;
    }
    if (current_found && items[i].anchorId_) {
      next_anchor_id = items[i].anchorId_;
      break;
    }
  }
  if (!next_anchor_id) {
    next_anchor_id = this.lastAnchorId_;
  }
  var next_element = this.theDocument_.getElementById(next_anchor_id);
  var menu_id = next_element.getAttribute('menuid');
  this.focusId_      = menu_id;
  // top.debugWindow('set focus to previous element: Id: '+this.focusId_);
  this.focusElement_ = next_element;
  this.focusElement_.focus();
  // top.debugWindow('<<< focusPrevious()');
  return true;
}

//------------------------------------------------------------
// MenuItem implementations
//------------------------------------------------------------

function hideItem(itemid)
{
  var menuitem=getRegisteredMenu(itemid);
  if (menuitem.clTimId_)
    Menu_clearTimeout(menuitem.clTimId_);
  if (menuitem.child_ && !menuitem.isdisabled_)
    menuitem.child_.hide();
  if (menuitem.lowlightItem)
    menuitem.lowlightItem();
}

function showItem(itemid)
{
  var menuitem=getRegisteredMenu(itemid);
  menuitem.showChild();
  if (menuitem.shtim_)
    Menu_clearTimeout(menuitem.shtim_);
  menuitem.shtim_=null;
}

closeId_=0;
theclmen=null;

function showPageLayers(tid)
{
  if (typeof tid=="undefined") return;
  var amen=getRegisteredMenu(tid);
  if (amen.clmenId_)
    Menu_clearTimeout(amen.clmenId_);
  amen.clWasDown();
}


MenuItem.prototype.setClose=function(timeout)
{
  var functionString="hideItem("+this.id_+")";
  var sleep=clsleep;
  if (this.menu_.orientation_=="top"){sleep=250};
  if (typeof timeout!="undefined"){sleep=timeout;}
  if (this.clTimId_!=null)
    Menu_clearTimeout(this.clTimId_);
  this.clTimId_=Menu_setTimeout(functionString,sleep,window);
  if (this.menu_.parentItem_)
  {
    this.menu_.parentItem_.setClose(sleep);
  }
  else
  {
    functionString="showPageLayers("+this.menu_.id_+")";
    if (this.menu_.clmenId_!=null)
      Menu_clearTimeout(this.menu_.clmenId_);
    this.menu_.clmenId_=Menu_setTimeout(functionString,clsleep,window);
    if (this.menu_.close_)
    {
      functionString="hideItem("+this.menu_.id_+")";
      if (this.menu_.clmenId2_!=null)
        Menu_clearTimeout(this.menu_.clmenId2_);
      this.menu_.clmenId2_=Menu_setTimeout(functionString,clsleep,window);
    }

  }
}

MenuItem.prototype.clearClose=function()
{
  if (this.menu_.clmenId_!=null)
  {
    Menu_clearTimeout(this.menu_.clmenId_);
    this.menu_.clmenId_=null;
  }
  if (this.clTimId_!=null)
    Menu_clearTimeout(this.clTimId_);
  this.clTimId_=null;

  if (this.menu_.clmenId2_!=null)
  {
    Menu_clearTimeout(this.menu_.clmenId2_);
    this.menu_.clmenId2_=null;
  }
  if (this.clTimId2_!=null)
    Menu_clearTimeout(this.clTimId2_);
  this.clTimId2_=null;

  if (this.menu_.parentItem_)
    this.menu_.parentItem_.clearClose();
}

function handleClicked(id)
{
  var men=getRegisteredMenu(id);
  var ret=true;
  if (men.hanid_ != -1 && men.items_[men.hanid_].exec_)
    ret=men.items_[men.hanid_].exec_(id);
  if (ret)
    men.hide();
}

function movestart(obj)
{
  if (HWbName!="Netscape")
  {
    window.event.cancelBubble=true;
    window.event.returnValue = false;
  }
  men=getRegisteredMenu(obj.menuid).menu_;
//  men.startMove(obj.menuid);
  return false;
}

function itemClicked(obj, anEvent)
{
  var menuid = obj.getAttribute('menuid');
  var it=getRegisteredMenu(menuid);

  if (it.ishanl_)
  {
    handleClicked(it.menu_.id_);
    return false;
  }

  var oldwd=it.menu_.wasDown_;
  it.menu_.wasDown_=true;
  if (!oldwd)
  {
    itemEnter(obj);
    hsLayers(it.menu_.hLays_,vishide);
  }
  if (it.isdisabled_)
    return false;
  if (anEvent)
    anEvent.cancelBubble = true;

  if (it.maillink_)
  {
    it.mailLink()
    return false;
  }

  if (it.save_)
  {
    it.save();
    return false;
  }

  if (it.exec_) {
    it.exec_();
    it.setClose(0);
  }

  var theurl="";
  if (it.act_)
    theurl=it.menu_.action(it);
  else if (it.url_)
    theurl=it.url_;

  var theurlmult="";
  if (it.actmult_)
    theurlmult=it.menu_.actionmult(it);
      
  if ( !it.url_ && theurl.length && top.gChildContext )
  {
    if (theurl.indexOf(';internal')==-1)
      theurl += ';internal';  
    theurl += "&ctx=" + top.gChildContext;  
  }

  if (theurl.length)
  {
    // ERS - bug fix (#2492): allow submit selected objects from the iconbar items
    var itFrame = eval("top.frames."+it.menu_.frame_);
    if (it.menu_ && it.menu_.frame_ && itFrame && itFrame.move)
    {
      move=itFrame.move;
    }

    if((it.op_ || it.opobj_) && typeof move=="function")
    {
      var move_params = {
        target: it.target_,
        targetmult: it.targetmult_,
        url: theurl,
        urlmult: theurlmult,
        onsel: it.opobj_,
        submit: it.submit_,
        name: it.name_,
        namemult: it.namemult_,
        winstyle: it.winstyle_,
        attrobj: it.menu_.getAttrObject()
      }
      move((it.operation_!="") ? it.operation_ : it.actp_, move_params);
    }
    else
    {
      if (it.target_){
        if (typeof opDlg =="function")
        {
          if (it.winstyle_)
            opDlg(theurl,it.target_,it.winstyle_);
          else
            opDlg(theurl,it.target_);
        }
        else
        {
          var h=window.screen.height;
          h*=0.75;
          window.open(theurl,it.target_,"status=yes,toolbar=no,scrollbars=yes,resizable=yes,width=640,height="+h);
        }
      }
      else {
        if (it.menu_ && it.menu_.frame_)
        {
          var menu_frame = eval("top.frames."+it.menu_.frame_);
          menu_frame.location.href=theurl;
        }
        else
        {
          window.location.href=theurl;
        }
      }
    }
    it.setClose(0);
  }
  return false;
}

function itemEnter(obj, anEvent)
{
  var mitem=getRegisteredMenu(obj.getAttribute('menuid'));
  itemEnterDOM(obj, anEvent);

  if (mitem.status_)
    window.status=mitem.status_;
}

function itemLeave(obj, anEvent)
{
  var menuid = obj.getAttribute('menuid');
  var mitem=getRegisteredMenu(menuid);
  itemLeaveDOM(obj, anEvent);
}

function menuEnter(itemid, anEvent)
{
  var menu=getRegisteredMenu(itemid);
  if (anEvent)
    anEvent.cancelBubble = true;

  if (menu.clmenId_!=null)
  {
    Menu_clearTimeout(menu.clmenId_);
    menu.clmenId_=null;
  }
  if (menu.clmenId2_!=null)
  {
    Menu_clearTimeout(menu.clmenId2_);
    menu.clmenId2_=null;
  }

  if (menu.parentItem_)
    menu.parentItem_.clearClose();
}

function menuLeave(itemid, timeout2, anEvent)
{
  var timeout=timeout2||clsleep;
  if (anEvent) {
    anEvent.cancelBubble = true;
  }
  var menu=getRegisteredMenu(itemid);
  if (!menu.wasDown_ && !menu.close_)
    return;
  if (menu.parentItem_)
  {
    menu.parentItem_.setClose();
  }
  else
  {
    functionString="showPageLayers("+menu.id_+")";
    if (menu.clmenId_!=null)
      Menu_clearTimeout(menu.clmenId_);
    menu.clmenId_=Menu_setTimeout(functionString,timeout,window);
    if (menu.close_)
    {
      functionString="hideItem("+menu.id_+")";
      if (menu.clmenId2_!=null)
        Menu_clearTimeout(menu.clmenId2_);
      menu.clmenId2_=Menu_setTimeout(functionString,timeout,window);
    }
  }
}

MenuItem.prototype.toString = function()
{
  return this.toStringDOM();
}

MenuItem.prototype.showChild = function()
{
  if (this.child_ && !this.isdisabled_)
  {
    var _focus = false;
    if (this.menu_ && this.menu_.frame_ && this.menu_.container_)
    {
      this.child_.frame_=this.menu_.frame_;
      this.child_.frametop_=this.menu_.frametop_;
    }
    if (!this.child_.created_) {
      var _focus = true;
      this.child_.showAt(this.menuRight(),this.menuTop(),{},vishide);
    }
    if (this.menu_.orientation_=="left") {
      var _focus = true;
      this.child_.showAt(this.menuRight(),this.menuTop()-this.child_.itemOffsety_);
    }
    else
    {
      var _focus = true;
      var left;
      if (this.menu_.relright_)
        left=this.menuLeft()+this.child_.itemOffsetx_;
      else
        left=this.menuLeft()-this.child_.itemOffsetx_;
      this.child_.showAt(left,this.menuBottom(),{relright:this.menu_.relright_});
    }
    this.child_.wasDown_=true;

    if (_focus && (this.enterEvent=="focus" || this.enterEvent=="keypress")) {
      this.menu_.blur(this.child_);
      this.child_.focus();
    }
  }
}

MenuItem.prototype.highlighteItem = function()
{
  if (this.menu_ && this.menu_.isiconbar_ && this.icondefault_)
  {
    if (!this.isdisabled_)
    {
      if (this.icononmouseover_ && this.iconimg_)
      {
        this.iconimg_.src =this.icononmouseover_;
      }
      mco=this.menu_.MenuConf_
      if (!isMacIE || !mco.ItemSelBGColor)
        this.iLay_.className='Hover';
      else {
        this.iLay_.style.backgroundColor = mco.ItemSelBGColor;
      }
    }
  }
  else
  {
    mco=this.menu_.MenuConf_
    if (!isMacIE || !mco.ItemSelBGColor) {
      this.iLay_.className='Hover';
    }
    else {
      this.iLay_.style.backgroundColor = mco.ItemSelBGColor;
    }
    if (this.chiimg_)
    {
      if (this.menu_.orientation_!="top")
        this.chiimg_.src=mco.ChildLIconInv;
      else
        this.chiimg_.src=mco.ChildTIconInv;
    }
    if (this.checkimg_) {
      if (this.ischecked_)
        this.checkimg_.src=mco.CheckedIconInv;
      else if (this.iconInv_)
        this.checkimg_.src=this.iconInv_;
    }
  }
  if (typeof this.alignprevitem_!= "undefined")
  {
    var prevItem=this.getPrevMenuItem();
    if (prevItem)
    {
      prevItem.highlighteItem();
    }
  }
}

MenuItem.prototype.getPostMenuItem=function()
{
  for (var icount=0;icount<this.menu_.items_.length-1;icount++)
  {
    if (this.menu_.items_[icount].id_==this.id_)
    {
      if (this.menu_.items_[icount+1].alignprevitem_)
      {
        return getRegisteredMenu(this.menu_.items_[icount+1].id_);
      }
    }
  }
  return false;
}

MenuItem.prototype.lowlightItem = function()
{
  if (this.menu_ && this.menu_.isiconbar_ && this.icondefault_)
  {
    if (!this.isdisabled_ && this.iconimg_)
    {
      this.iconimg_.src =this.icondefault_;
    }
    mco=this.menu_.MenuConf_;
    if (!isMacIE || !mco.ItemBGColor)
      this.iLay_.className='Default';
    else {
      this.iLay_.style.backgroundColor=mco.ItemBGColor;
    }
  }
  else
  {
    mco=this.menu_.MenuConf_;
    if (!isMacIE || !mco.ItemBGColor) {
      this.iLay_.className='Default';
    }
    else {
      this.iLay_.style.backgroundColor=mco.ItemBGColor;
    }
    if (this.chiimg_)
    {
      if (this.menu_.orientation_!="top")
        this.chiimg_.src=mco.ChildLIcon;
      else
        this.chiimg_.src=mco.ChildTIcon;
    }
    if (this.ischecked_ && this.checkimg_)
      this.checkimg_.src=mco.CheckedIcon;
  }
  if (typeof this.alignprevitem_!= "undefined")
  {
    var prevItem=this.getPrevMenuItem();
    if (prevItem)
    {
      prevItem.lowlightItem();
    }
  }
}

MenuItem.prototype.mailLink = function()
{
  var attrobj=this.menu_.getAttrObject();
  if (!attrobj)
  {
    alert("No Object provided");
    return;
  }
  var title=attrobj.title;
  if (!title)
  {
    alert("No Object Title provided");
    return;
  }
  var url=attrobj.url||"";
  if (!url)
  {
    alert("No Object URL provided");
    return;
  }
  if (top.frames.HW_DataRequestFrame) 
  {
    var object_url = url; // url may contain already an action (e.g. image.action)
                          // and internal part (e.g. for version controlled documents)

    if (object_url.indexOf(";internal&") != -1) {
      object_url = object_url.replace(/\&action\=/, "&redirect_action="); // rename possible action part from url
      object_url = object_url.replace(/\;internal\&/, ";internal&action=send_cs_email.action&");
    }
    else {
      object_url += ';internal&action=send_cs_email.action';
    }
    top.frames.HW_DataRequestFrame.location.href = object_url;
  }
  else 
  {
    url = window.location.protocol+"\/\/"+window.location.host + encodeURIPath(url);

    var decode_url = "mailto:recipient@domain.com?subject=Link to '";
    decode_url += decodeURIComponent(title).replace(/&/g,"+");
    decode_url += "'&body=";
    decode_url += url;
    window.location.href = decode_url;
  }
}

MenuItem.prototype.save = function()
{
  var attrobj=this.menu_.getAttrObject();
  if (!attrobj)
  {
    alert("No Object provided");
    return;
  }
  var url=attrobj.url||"";
  if (!url)
  {
    alert("No Object URL provided");
    return;
  }
  var idx=url.indexOf(";internal&action=");
  if (idx!=-1)
  {
    url=url.substring(0,idx);
  }
  fullurl=url+";internal&action=save.action";
  if (top.frames.HW_DataRequestFrame) {
    top.frames.HW_DataRequestFrame.location.href = fullurl;
  }
  else {
    window.location.href=fullurl;
  }
}

MenuItem.prototype.menuTop=function()
{
  if (typeof this.alignprevitem_!= "undefined")
  {
    var prevItem=this.getPrevMenuItem();
    if (prevItem)
      return prevItem.menuTop_;
  }
  return this.menuTop_;
}

MenuItem.prototype.menuBottom=function()
{
  if (typeof this.alignprevitem_!= "undefined")
  {
    var prevItem=this.getPrevMenuItem();
    if (prevItem)
      return prevItem.menuBottom_;
  }
  return this.menuBottom_;
}

MenuItem.prototype.menuLeft=function()
{
  if (typeof this.alignprevitem_!= "undefined")
  {
    var prevItem=this.getPrevMenuItem();
    if (prevItem)
      return prevItem.menuLeft_;
  }
  return this.menuLeft_;
}

MenuItem.prototype.menuRight=function()
{
  if (typeof this.alignprevitem_!= "undefined")
  {
    var prevItem=this.getPrevMenuItem();
    if (prevItem)
      return prevItem.menuRight_;
  }
  return this.menuRight_;
}

MenuItem.prototype.getPrevMenuItem=function()
{
  var found=0;
  var itemid=this.menu_.items_[0].id_;
  for (var icount=0;icount<this.menu_.items_.length;icount++)
  {
    if (this.menu_.items_[icount].id_==this.id_)
    {
      found=1;
      break;
    }
    itemid=this.menu_.items_[icount].id_;
  }
  return getRegisteredMenu(itemid);
}

function hsLayers(lays,vis)
{
  toHsLayers(lays,vis);
  if (typeof trhlayers != "undefined")
  {
    toHsLayers(trhlayers,vis);
  }
}

function toHsLayers(lays,vis)
{
  for (var x=0;x<lays.length;x++)
  {
    var a=lays[x];
    if (typeof a =="string")
    {
      a=eval(a);
      lays[x]=a;
    }
    if (a)
    {
      if (typeof a.style =="object")
        a.style.visibility=vis;
    }
  }
}

function debugnl(str)
{
  if (typeof HW_debugnl=="function")
    HW_debugnl(str);
}

function getCoordValue (aNumber)
{
  return aNumber + "px";
}

