
function algomenu(id, menunum, ieheight){
  sComponent.call(this);

  this._element = document.getElementById(id); 

  this.setPosition("relative"); 
  this.setDisplay("block"); 
  this._element.style.whiteSpace = "nowrap";
  
  this._menuInd = 0;
  this._menuNum = menunum;
  this._tPath = "";
  
  this.ieH = ieheight;
}

_p = sExtend(algomenu, sComponent, "algomenu");

_p.createNewMenu = function(pid, smid){
  

  var m = new sComponent();
  m.setPosition("static");
  m.setCssClassName("algo-w2-menu");

  var mC = new sComponent("static");
  mC.setPosition("relative");

  mC.setCssClassName("algo-w2-maintext");

  if (sBrowser.ie){
    mC.setOverflow("hidden");
    mC.setDisplay("inline");
  }
  mC.getElement().appendChild(document.getElementById(pid));
  
  this.add(m);
  
  m.add(mC); 
  
  var sm = new sComponent("absolute");
  sm.setAttribute("menuindex", this._menuInd);
  sm.setCssClassName("algo-w2-submenu");
  sm.setZIndex(99999);
  
  var topMargin = new sImage("selement/style/blank.gif");
  topMargin.setPosition("relative");
  topMargin.setCssClassName("algo-w2-submenu-top-margin");
  
  if (sBrowser.ie){
    sm.setMarginLeft( mC.getWidth()*(-1) );
    sm.setMarginTop( m.getHeight() );
  }
  sm.add(topMargin);
  
  var smc = new sComponent("relative");
  smc._element = document.getElementById(smid);
  smc.setCssClassName("algo-w2-submenu-content");
  sm.add(smc);
  
  m.add(sm);
  
  function display(){
    sm.setDisplay("block");
    var menuWidth = sm.getParent().getElement().offsetWidth;
    var menuind = parseInt(sm.getAttribute("menuindex"));
    var startpx = menuWidth * menuind ;
    var tpx = m.getParent().getElement().offsetWidth;
    
    if ( (startpx + sm.getWidth() ) > tpx)
      sm.setRight(0);
    
  }
  
  m.addEvent("mouseover", function(){
    display();
  } );
  
  sm.addEvent("mouseout", function(){
    sm.setDisplay("none");
  } );
  
  m.addEvent("mouseout", function(){
    sm.setDisplay("none");
  } );
  
  this._menuInd++;
  if (sBrowser.ie);
    this.setHeight(this.ieH);
}

_p.changeParentSize = function(){
  var parent = this._element.parentNode;
  
  this.setWidth(parent.clientWidth);
  this.setHeight(parent.clientHeight);
}

_p.setTemplatePath = function(v){
  this._tPath = v;
}
