// toolbars
var __count = 100;
var __aAllComponents = new Array();
// all popup iframes
var __aAllPopups = new Array();
var __hasEvalation = false;
var __hasCancel    = false;
var __isEvaluation = false;
var __isMode       = "";

function Toolbars(containerid)
{
  this.aToolbars = new Array();
  this.container = containerid;
  this.backcolor = "ButtonFace";

  this.add           = __toolbars_add;
  this.create        = __toolbars_create;
  this.getComponents = __toolbars_getcomponents;
  this.reset         = __toolbars_reset;
  this.hide          = __toolbars_hide;
  this.show          = __toolbars_show;
}

function __toolbars_getcomponents()
{
  return __aAllComponents;
}

function __toolbars_add(toolbar)
{
  var id = this.aToolbars.length;
  this.aToolbars[id] = toolbar;
  toolbar.id = __count;
  __count++;
}

function __toolbars_create()
{
  var temp = "";
  var temp1 = "<div id='" + this.container + "_div" + "' style='width: 100%;height:";
  var temp2 = "px;background-color: " + this.backcolor + "'>";
  var height = 0;

  // get code for all toolbars
  for (var i=0;i<this.aToolbars.length;i++) {
    var toolbar = this.aToolbars[i];
    // calculate the height
    height = height + toolbar.height;
    temp+="<table class='ToolbarOut" + toolbar.design + "' width='100%' cellpadding=0 cellspacing=0 border=0><tr><td>";
    if(toolbar.fullsize)
      temp+="<table style='width:100%;"
    else
      temp+="<table style='width:1%;"
    if(!toolbar.border) {
      temp+= "border: 0";
    }
    temp+= "' class='ToolbarIn" + toolbar.design + "'  cellpadding=0 cellspacing=0 border=0><tr>";
    for (var j=0;j<toolbar.aComponents.length;j++) {
      var component = toolbar.aComponents[j];
      var html = component.create();
      temp+=html;
    }
    var eva = "";

    if(!__hasCancel) {
      if( (i == 0 && __isMode == "I")  ) {
        eva = "<a href='javascript: editCancel()'><img src='design/image/close.gif' border=0></a>";
        __hasCancel = true;
      }
    }

    if(!__hasEvalation) {
      if(i == this.aToolbars.length-1 && __isEvaluation) {
        eva = "&copy; 2004 NeoFuture";
        __hasEvalation = true;
      }
    }
    temp+="</tr></table>";
    if(toolbar.fullsize)
      temp+="</td><td></td></tr></table>";
    else
      temp+="</td><td style='border:0' align='right' width=100%>" + eva + "</td></tr></table>";
  }
  temp+="</div>";
  // write html code in div
  var objContainer = document.getElementById(this.container);
  objContainer.innerHTML = temp1 + height + temp2 + temp;

 //   alert(objContainer.innerHTML)
}

function __toolbars_reset()
{

  try {
    for (var i=0;i<__aAllPopups.length;i++) {
      eval(__aAllPopups[i]);
    }
  } catch(Error) {}
}

function __toolbars_hide()
{
  document.getElementById(this.container + "_div").style.display = 'none';
}

function __toolbars_show()
{
  document.getElementById(this.container + "_div").style.display = 'inline';
}

// Toolbar
function Toolbar()
{
  this.id     = "";
  this.height = 27;
  this.border = true;
  this.action = "";
  this.design = "";
  this.fullsize = false;

  this.aComponents = new Array();
  this.add       = __toolbar_add;
}

function __toolbar_add(component)
{
  var id = this.aComponents.length;
  this.aComponents[id] = component;
  component.id = __count;
  component.toolbar = this;
  __count++;

  // we ned this for access within events
  var id = __aAllComponents.length;
  __aAllComponents[id] = component;
}

function Button(text,id,image,action,tooltip,design,tag,width)
{
  this.id      = "";
  if(width >0)
    this.width   = width;
  this.toolbar = null;
  this.tag     = tag;
  this.text    = text;
  this.action  = action;
  this.image   = image;
  this.tooltip = tooltip;
  this.design  = design;
  this.pressed = false;
  this.enabled = true;
  this.visible = true;

  this.setVisible   = __button_visible;
  this.setEnabled   = __button_enable;
  this.setStatus    = __button_status;

  this.onmouseup    = __button_mouseup;
  this.onmousedown  = __button_mousedown;
  this.onmouseover  = __button_mouseover;
  this.onmouseout   = __button_mouseout;

  this.create       = __button_create;
}

function __button_direct(id,action)
{
  for (var j=0;j<__aAllComponents.length;j++) {
    if(__aAllComponents[j].id == id){
      var component = __aAllComponents[j];
      if(action == "OVER")
        component.onmouseover();
      if(action == "OUT")
        component.onmouseout();
      if(action == "DOWN")
        component.onmousedown();
      if(action == "UP") {
        component.onmouseup();
        if(component.toolbar.action != "") {
          if(component.tag != "" && component.tag != null)
            eval( component.toolbar.action + "('" + component.tag + "')");
        }
      }
    }
  }
}

function __button_create()
{
  var temp = "<td";
      if(this.width != "")
        temp+= " width='" + this.width + "'";
      temp+= "><table width='100%' cellspacing=1 cellpadding=0 border=0><tr>";
      temp+= "<td align='center'";
      if(this.width != "")
        temp+= " width='" + this.width + "'";
      temp+= " nowrap id='" + this.id + "' ";
      temp+= "class='ButtonStandard" + this.design + "' ";
      temp+= "onmouseover='__button_direct(" + this.id + ",\"OVER\")'";
      temp+= "onmouseout='__button_direct(" + this.id + ",\"OUT\")'";
      temp+= "onmousedown='__button_direct(" + this.id + ",\"DOWN\")'";
      temp+= "onmouseup='__button_direct(" + this.id + ",\"UP\")'";
      temp+= ">";
  if(this.image)
    temp+= "<img title='" + this.tooltip + "' align='absmiddle' border='0' src='" +  this.image + "'>";
  if(this.text)
    temp+= " " + this.text;
  temp+= "</td></tr></table></td>";
  return temp;
}

function __button_visible(value)
{
  this.visible = value;
}

function __button_enable(value)
{
  this.enabled = value;
  var button = document.getElementById(this.id);
  if(value) {
    button.className = 'ButtonDisabled';
    button.innerHTML = "<span class='ButtonDisabledContainer'><span class='ButtonDisabledContainer'>" + button.innerHTML + "</span></span>";
  } else {
    button.className = 'ButtonStandardOffice';
    button.innerHTML = button.firstChild.firstChild.innerHTML;
  }
}

function __button_status(value)
{
  this.pressed = value;
  if(value) {
    document.getElementById(this.id).className='ButtonActive' + this.design;
  } else {
    document.getElementById(this.id).className='ButtonStandard' + this.design;
  }
}

function __button_mouseup()
{
  if(!this.enabled)
    return;
  document.getElementById(this.id).className='ButtonHover' + this.design;
  if(this.action != "") {
    eval(this.action);
  }
}

function __button_mousedown()
{
  __toolbars_reset();
  if(!this.enabled)
    return;
  document.getElementById(this.id).className='ButtonActive' + this.design;
}

function __button_mouseover()
{
  if(!this.enabled)
    return;
  document.getElementById(this.id).className='ButtonHover' + this.design;
}

function __button_mouseout()
{
  if(!this.enabled)
    return;
  if(this.pressed == false)
    document.getElementById(this.id).className='ButtonStandard' + this.design;
  else
    document.getElementById(this.id).className='ButtonActive' + this.design;
}

//---------------------------------------------------------------------------------------------
// Combo Object
//---------------------------------------------------------------------------------------------
function Combo(action)
{
  this.id = "";
  this.width="";
  this.action = action;

  this.setSelected = __combo_setselected;
  this.getSelected = __combo_getselected;
  this.create = __combo_create;
  this.add    = __combo_add;
}

function __combo_create()
{
  var temp = "<td style='padding-left: 2px'><select id='" + this.id + "' class='Combo' style='width:" + this.width + "px' onchange=\"javascript: __combo_direct(" + this.id + ")\"></select></td>";
  return temp;
}
function __combo_add(value,key)
{
  var combo = document.getElementById(this.id);
  var item = document.createElement("option");
  item.text = value;
  item.value = key;
  if(browser.ie) {
    combo.add(item);
  } else {
    combo.add(item,null);
  }
}
function __combo_getselected()
{
  var temp = "";
  try {
    var combo = document.getElementById(this.id);
    temp = combo.options[combo.selectedIndex].value;
  } catch(Error){}
  return temp;
}
function __combo_setselected(value)
{
  var temp = "";
  try {
    var combo = document.getElementById(this.id);
    len = combo.length;
    for(var i=0;i<len;i++) {
      if(combo.options[i].value == value) {
        combo.selectedIndex = i;
        break;
      }
    }
  } catch(Error){}
}
function __combo_direct(id)
{
  for (var j=0;j<__aAllComponents.length;j++) {
    if(__aAllComponents[j].id == id){
      var component = __aAllComponents[j];
      if(component.action != "") {
        eval(component.action);
      }
    }
  }
}

//---------------------------------------------------------------------------------------------
// Separator Object
//---------------------------------------------------------------------------------------------
function Separator(image)
{
  this.image   = image;
  this.create  = __separator_create;
  this.design  = "";
}
function __separator_create()
{
  //var temp = "<td class='ButtonStandard'><img border='0' src='" +  this.image + "'></td>";
  var temp = "<td><img border='0' src='" +  this.image + "'></td>";
  return temp;
}

//---------------------------------------------------------------------------------------------
// Distance Object
//---------------------------------------------------------------------------------------------
function Distance(width)
{
  this.width   = width;
  this.create  = __distance_create;
}
function __distance_create()
{
  var temp = "<td style=\"background-color: #"+ globalToolbarColor +";\"><div style='width:" + this.width + "px'></div></td>";
  return temp;
}

//-----------------------------------------------------------------------------------------------------
// TABLE BUTTON
//-----------------------------------------------------------------------------------------------------
var __pbutton_clicked;

function TableButton(image,action,tooltip,design,tag)
{
  this.id      = "";
  this.toolbar = null;
  this.action  = action;
  this.tag     = tag;
  this.image   = image;
  this.tooltip = tooltip;
  this.design  = design;
  this.pressed = false;
  this.enabled = true;
  this.visible = true;

  this.setVisible   = __pbutton_visible;
  this.setEnabled   = __pbutton_enable;
  this.setStatus    = __pbutton_status;

  this.onmouseup    = __pbutton_mouseup;
  this.onmousedown  = __pbutton_mousedown;
  this.onmouseover  = __pbutton_mouseover;
  this.onmouseout   = __pbutton_mouseout;

  this.create       = __pbutton_create;
}

function __pbutton_direct(id,action)
{
  for (var j=0;j<__aAllComponents.length;j++) {
    if(__aAllComponents[j].id == id){
      var component = __aAllComponents[j];
      if(action == "OVER")
        component.onmouseover();
      if(action == "OUT")
        component.onmouseout();
      if(action == "DOWN") {
        component.onmousedown();
        // get the position
        var tablepopup = document.getElementById("__tablepopup");
        var obj = document.getElementById(id);
        var x = globalGetPositonX(obj);
        var y = globalGetPositonY(obj);
        tablepopup.style.left = x;
        tablepopup.style.top = y + obj.offsetHeight - 1;
        //tablepopup.style.top = obj.offsetHeight;
        tablepopup.style.visibility = "visible";
        // save the current button
        __pbutton_clicked = component;
      }
      if(action == "UP") {
        component.onmouseup();
      }
    }
  }
}

function __pbutton_popup_click(row,col)
{
  __pbutton_popup_cancel();
  if(__pbutton_clicked.action != "") {
    eval(__pbutton_clicked.action + "(" + row + "," + col + ")");
  }
}
function __pbutton_popup_cancel()
{
  try {
    document.getElementById("__tablepopup").style.visibility = "hidden";
    __pbutton_clicked.pressed = false;
    __pbutton_clicked.onmouseup();
  } catch(Error) {}
}

function __pbutton_create()
{
  var temp = "<td><table cellspacing=1 cellpadding=0 border=0><tr><td nowrap id='" + this.id + "' ";
      temp+= "class='ButtonStandard" + this.design + "' ";
      temp+= "onmouseover='__pbutton_direct(" + this.id + ",\"OVER\")'";
      temp+= "onmouseout='__pbutton_direct(" + this.id + ",\"OUT\")'";
      temp+= "onmousedown='__pbutton_direct(" + this.id + ",\"DOWN\")'";
      temp+= "onmouseup='__pbutton_direct(" + this.id + ",\"UP\")'";
      temp+= ">";
  if(this.image)
    temp+= "<img id='__image' title='" + this.tooltip + "' align='absmiddle' border='0' src='" +  this.image + "'>";
  if(this.text)
    temp+= " " + this.text;
  temp+= "<iframe unselectable='on' id='__tablepopup' src='popup/table.html?language=" + language + "&style=" + design + "' style='overflow:hidden;visibility:hidden;position:absolute;left:10px;width:100px;height:120px' frameborder='0' scrolling='no'></iframe>";
  temp+= "</td></tr></table></td>";

  // add the id to the popup collection
  var count = __aAllPopups.length;
  __aAllPopups[count] = "__pbutton_popup_cancel()";

  return temp;
}

function __pbutton_visible(value)
{
  this.visible = value;
}

function __pbutton_enable(value)
{
  this.enabled = value;
  var button = document.getElementById(this.id);
  if(value) {
    button.className = 'ButtonDisabled';
    button.innerHTML = "<span class='ButtonDisabledContainer'><span class='ButtonDisabledContainer'>" + button.innerHTML + "</span></span>";
  } else {
    button.className = 'ButtonStandardOffice';
    button.innerHTML = button.firstChild.firstChild.innerHTML;
  }
}

function __pbutton_status(value)
{
  this.pressed = value;
  if(value) {
    document.getElementById(this.id).className='ButtonPopup' + this.design;
  } else {
    document.getElementById(this.id).className='ButtonStandard' + this.design;
  }
}

function __pbutton_mouseup()
{
  if(!this.enabled)
    return;
  if(!this.pressed) {
    document.getElementById(this.id).className='ButtonStandard' + this.design;
    document.getElementById("__tablepopup").style.visibility = "hidden";
  }
}

function __pbutton_mousedown()
{
  __toolbars_reset();
  if(!this.enabled)
    return;
  this.pressed = ! this.pressed;
  if(this.pressed)
    document.getElementById(this.id).className='ButtonPopup' + this.design;
}

function __pbutton_mouseover()
{
  if(!this.enabled)
    return;
  if(this.pressed)
    document.getElementById(this.id).className='ButtonPopup' + this.design;
  else
    document.getElementById(this.id).className='ButtonHover' + this.design;
}

function __pbutton_mouseout()
{
  if(!this.enabled)
    return;
  if(this.pressed == false)
    document.getElementById(this.id).className='ButtonStandard' + this.design;
  else
    document.getElementById(this.id).className='ButtonPopup' + this.design;
}


var __csbutton_clicked;

//--------------------------------------------------------------------------------------------------
// COLOR SELECTOR
//--------------------------------------------------------------------------------------------------
function ColorSelector(image,image2,action,tooltip,tooltip2,design,tag)
{
  this.id      = "";
  this.toolbar = null;
  this.action  = action;
  this.tag     = tag;
  this.image   = image;
  this.image2   = image2;
  this.tooltip = tooltip;
  this.tooltip2 = tooltip2;
  this.design  = design;
  this.pressed = false;
  this.enabled = true;
  this.visible = true;

  this.setVisible   = __csbutton_visible;
  this.setEnabled   = __csbutton_enable;

  this.onmouseup    = __csbutton_mouseup;
  this.onmousedown  = __csbutton_mousedown;
  this.onmouseover  = __csbutton_mouseover;
  this.onmouseout   = __csbutton_mouseout;

  this.create       = __csbutton_create;
}

function __csbutton_direct(id,action,part)
{
  for (var j=0;j<__aAllComponents.length;j++) {
    if(__aAllComponents[j].id == id){
      var component = __aAllComponents[j];
      if(action == "OVER")
        component.onmouseover(part);
      if(action == "OUT")
        component.onmouseout(part);
      if(action == "DOWN") {
        if(part==1) {
          // get the position
          var popup = document.getElementById("__cspopup" + id);
          var obj = document.getElementById(id);
          var x = globalGetPositonX(obj);
          var y = globalGetPositonY(obj);
          popup.style.left = x;
          popup.style.top = y + obj.offsetHeight;
          // save the current button
          __csbutton_clicked = component;
        }
        component.onmousedown(part);
      }
      if(action == "UP") {
        component.onmouseup(part);
      }
    }
  }
}

function __csbutton_popup_click(color)
{
  __csbutton_popup_cancel();
  if(color != "") {
    if(__csbutton_clicked.action != "") {
      eval(__csbutton_clicked.action + "('" + color + "')");
    }
    document.getElementById("__color" + __csbutton_clicked.id).style.backgroundColor = color;
  }
}
function __csbutton_popup_cancel()
{
  try {
    document.getElementById("__cspopup" + __csbutton_clicked.id).style.visibility = "hidden";
    document.getElementById(__csbutton_clicked.id + "_1").className='ButtonStandard' + __csbutton_clicked.design;
    __csbutton_clicked.pressed = false;
    //__csbutton_clicked.onmouseup();
  } catch(Error) {}
}

function __csbutton_create()
{
  var temp = "<td><table cellspacing=1 cellpadding=0 border=0><tr><td nowrap id='" + this.id + "' ";
      temp+= "class='ButtonStandard" + this.design + "' ";
      temp+= "onmouseover='__csbutton_direct(" + this.id + ",\"OVER\",0)'";
      temp+= "onmouseout='__csbutton_direct(" + this.id + ",\"OUT\",0)'";
      temp+= "onmousedown='__csbutton_direct(" + this.id + ",\"DOWN\",0)'";
      temp+= "onmouseup='__csbutton_direct(" + this.id + ",\"UP\",0)'";
      temp+= ">";
  if(this.image)
    temp+= "<img id='__image" + this.id + "' title='" + this.tooltip + "' align='absmiddle' border='0' src='" +  this.image + "'>";
  if(this.text)
    temp+= " " + this.text;
  temp+= "<br><div id='__color" + this.id + "' style='font-family: Arial;font-size:3px;width:16px;height:4px;background-color:red;'></div>";
  temp+= "</td>";

  temp+= "<td nowrap id='" + this.id + "_1" + "' ";
  temp+= "class='ButtonStandard" + this.design + "' ";
  temp+= "onmouseover='__csbutton_direct(" + this.id + ",\"OVER\",1)'";
  temp+= "onmouseout='__csbutton_direct(" + this.id + ",\"OUT\",1)'";
  temp+= "onmousedown='__csbutton_direct(" + this.id + ",\"DOWN\",1)'";
  temp+= "onmouseup='__csbutton_direct(" + this.id + ",\"UP\",1)'";
  temp+= ">";
  if(this.image2)
    temp+= "<img id='__image2" + this.id + "' title='" + this.tooltip2 + "' align='absmiddle' border='0' src='" +  this.image2 + "'>";
  temp+= "</td></tr></table></td>";
  temp+= "<iframe unselectable='on' id='__cspopup" + this.id + "' src='popup/color.html?language=" + language + "&style=" + design + "&bgcolor=" + globalToolbarColor + "' style='overflow:hidden;visibility:hidden;position:absolute;width:140px;height:110px' frameborder='0' scrolling='no'></iframe>";
  // add the id to the popup collection
  var count = __aAllPopups.length;
  __aAllPopups[count] = "__csbutton_popup_cancel()";

  return temp;
}

function __csbutton_visible(value)
{
  this.visible = value;
}

function __csbutton_enable(value)
{
  this.enabled = value;
  var button = document.getElementById(this.id);
  if(value) {
    button.className = 'ButtonDisabled';
    button.innerHTML = "<span class='ButtonDisabledContainer'><span class='ButtonDisabledContainer'>" + button.innerHTML + "</span></span>";
  } else {
    button.className = 'ButtonStandardOffice';
    button.innerHTML = button.firstChild.firstChild.innerHTML;
  }
}

function __csbutton_mouseup(part)
{
  if(part==0) {
    document.getElementById(this.id).className='ButtonHover' + this.design;
    if(this.action != "") {
      var color = document.getElementById("__color" + this.id).style.backgroundColor;
      eval(this.action + "('" + color + "')");
    }
  }
}

function __csbutton_mousedown(part)
{
  if(!this.enabled)
    return;

  if(part==0) {
    document.getElementById(this.id).className='ButtonActive' + this.design;
  } else {
    if(!this.pressed) {
      document.getElementById(this.id + "_1").className='ButtonPopup' + this.design;
      document.getElementById("__cspopup" + this.id).style.visibility = "visible";
      this.pressed = true;
    } else {
      __toolbars_reset();
    }
  }
}

function __csbutton_mouseover(part)
{
  if(!this.enabled)
    return;
  document.getElementById(this.id).className='ButtonHover' + this.design;
  if(this.pressed)
    document.getElementById(this.id + "_1").className='ButtonPopup' + this.design;
  else
    document.getElementById(this.id + "_1").className='ButtonHover' + this.design;
}

function __csbutton_mouseout(part)
{
  if(!this.enabled)
    return;

  document.getElementById(this.id).className='ButtonStandard' + this.design;
  if(this.pressed == false)
    document.getElementById(this.id + "_1").className='ButtonStandard' + this.design;
  else
    document.getElementById(this.id + "_1").className='ButtonPopup' + this.design;
}


//-------------------------------------------------------------------------------------------------
// COLOR BUTTON
//-------------------------------------------------------------------------------------------------
function ColorButton(color,tooltip,design,tag)
{
  this.id      = "";
  this.color   = color;
  this.toolbar = null;
  this.tag     = tag;
  this.tooltip = tooltip;
  this.design  = design;
  this.pressed = false;
  this.enabled = true;
  this.visible = true;

  this.onmouseup    = __cbutton_mouseup;
  this.onmousedown  = __cbutton_mousedown;
  this.onmouseover  = __cbutton_mouseover;
  this.onmouseout   = __cbutton_mouseout;

  this.create       = __cbutton_create;
}

function __cbutton_direct(id,action)
{
  for (var j=0;j<__aAllComponents.length;j++) {
    if(__aAllComponents[j].id == id){
      var component = __aAllComponents[j];
      if(action == "OVER")
        component.onmouseover();
      if(action == "OUT")
        component.onmouseout();
      if(action == "DOWN")
        component.onmousedown();
      if(action == "UP") {
        component.onmouseup();
        if(component.toolbar.action != "") {
          if(component.tag != "" && component.tag != null)
            eval( component.toolbar.action + "('" + component.tag + "')");
        }
      }
    }
  }
}

function __cbutton_popup_click(row,col)
{
  __pbutton_popup_cancel();
  if(__pbutton_clicked.action != "") {
    eval(__pbutton_clicked.action + "(" + row + "," + col + ")");
  }
}
function __cbutton_popup_cancel()
{
  document.getElementById("__tablepopup").style.visibility = "hidden";
  __pbutton_clicked.pressed = false;
  __pbutton_clicked.onmouseup();
}

function __cbutton_create()
{
  var temp = "<td nowrap id='" + this.id + "' ";
      temp+= "class='ButtonStandard" + this.design + "' ";
      temp+= "onmouseover='__cbutton_direct(" + this.id + ",\"OVER\")'";
      temp+= "onmouseout='__cbutton_direct(" + this.id + ",\"OUT\")'";
      temp+= "onmousedown='__cbutton_direct(" + this.id + ",\"DOWN\")'";
      temp+= "onmouseup='__cbutton_direct(" + this.id + ",\"UP\")'";
      temp+= ">";
  temp+= "<div style='height:11px;width:11px;font-family: Arial;font-size:3px;background-color:" + this.color + ";'></div>";
  temp+= "</td>";
  return temp;
}

function __cbutton_mouseup()
{
  if(!this.enabled)
    return;
  document.getElementById(this.id).className='ButtonHover' + this.design;
  if(this.action != "") {
    eval(this.action);
  }
}

function __cbutton_mousedown()
{
  __toolbars_reset();
  if(!this.enabled)
    return;
  document.getElementById(this.id).className='ButtonActive' + this.design;
}

function __cbutton_mouseover()
{
  if(!this.enabled)
    return;
  document.getElementById(this.id).className='ButtonHover' + this.design;
}

function __cbutton_mouseout()
{
  if(!this.enabled)
    return;
  if(this.pressed == false)
    document.getElementById(this.id).className='ButtonStandard' + this.design;
  else
    document.getElementById(this.id).className='ButtonActive' + this.design;
}



//-----------------------------------------------------------------------------------------------------
// MENU BUTTON
//-----------------------------------------------------------------------------------------------------
var __mbutton_clicked;

function MenuButton(menu,image,action,tooltip,design,tag)
{
  this.id      = "";
  this.width   = "150px";
  this.height  = "90px";
  this.toolbar = null;
  this.action  = action;
  this.menu    = menu;
  this.tag     = tag;
  this.image   = image;
  this.tooltip = tooltip;
  this.design  = design;
  this.pressed = false;
  this.enabled = true;
  this.visible = true;

  this.setVisible   = __mbutton_visible;
  this.setEnabled   = __mbutton_enable;
  this.setStatus    = __mbutton_status;

  this.onmouseup    = __mbutton_mouseup;
  this.onmousedown  = __mbutton_mousedown;
  this.onmouseover  = __mbutton_mouseover;
  this.onmouseout   = __mbutton_mouseout;

  this.create       = __mbutton_create;
}

function __mbutton_direct(id,action)
{
  for (var j=0;j<__aAllComponents.length;j++) {
    if(__aAllComponents[j].id == id){
      var component = __aAllComponents[j];
      if(action == "OVER")
        component.onmouseover();
      if(action == "OUT")
        component.onmouseout();
      if(action == "DOWN") {
        // get the position
        var tablepopup = document.getElementById("__menupopup" + component.id);
        var obj = document.getElementById(id);
        var x = globalGetPositonX(obj);
        var y = globalGetPositonY(obj);
        tablepopup.style.left = x;
        tablepopup.style.top = y + obj.offsetHeight - 1;
        //tablepopup.style.visibility = "visible";
        // save the current button
        __mbutton_clicked = component;
        component.onmousedown();
      }
      if(action == "UP") {
        component.onmouseup();
      }
    }
  }
}

function __mbutton_popup_click(tag)
{
  __mbutton_popup_cancel();
  if(__mbutton_clicked.action != "") {
    eval(__mbutton_clicked.action + "('" + tag + "')");
  }
}
function __mbutton_popup_cancel()
{
  try {
    document.getElementById("__menupopup" + __mbutton_clicked.id).style.visibility = "hidden";
    document.getElementById(__mbutton_clicked.id).className='ButtonStandard' + __mbutton_clicked.design;
    __mbutton_clicked.pressed = false;
  } catch(Error) {}
}

function __mbutton_create()
{
  //var temp = "<td><table cellspacing=1 cellpadding=0 border=0><tr><td align='center'";
  //temp+= "</td></tr></table></td>";

  var temp = "<td><table cellspacing=1 cellpadding=0 border=0><tr><td nowrap id='" + this.id + "' ";
      temp+= "class='ButtonStandard" + this.design + "' ";
      temp+= "onmouseover='__mbutton_direct(" + this.id + ",\"OVER\")'";
      temp+= "onmouseout='__mbutton_direct(" + this.id + ",\"OUT\")'";
      temp+= "onmousedown='__mbutton_direct(" + this.id + ",\"DOWN\")'";
      temp+= "onmouseup='__mbutton_direct(" + this.id + ",\"UP\")'";
      temp+= ">";
  if(this.image)
    temp+= "<img id='__image' title='" + this.tooltip + "' align='absmiddle' border='0' src='" +  this.image + "'>";
  if(this.text)
    temp+= " " + this.text;
  temp+= "</td></tr></table></td>";
  temp+= "<iframe unselectable='on' id='__menupopup" + this.id + "' src='popup/" + this.menu + "?language=" + language + "&style=" + design + "&bgcolor=" + globalToolbarColor + "' style='overflow:hidden;visibility:hidden;position:absolute;left:10px;width:" + this.width + ";height:" + this.height + "' frameborder='0' scrolling='no'></iframe>";

  // add the id to the popup collection
  var count = __aAllPopups.length;
  __aAllPopups[count] = "__mbutton_popup_cancel()";
  return temp;
}

function __mbutton_visible(value)
{
  this.visible = value;
}

function __mbutton_enable(value)
{
  this.enabled = value;
  var button = document.getElementById(this.id);
  if(value) {
    button.className = 'ButtonDisabled';
    button.innerHTML = "<span class='ButtonDisabledContainer'><span class='ButtonDisabledContainer'>" + button.innerHTML + "</span></span>";
  } else {
    button.className = 'ButtonStandardOffice';
    button.innerHTML = button.firstChild.firstChild.innerHTML;
  }
}

function __mbutton_status(value)
{
  this.pressed = value;
  if(value) {
    document.getElementById(this.id).className='ButtonPopup' + this.design;
  } else {
    document.getElementById(this.id).className='ButtonStandard' + this.design;
  }
}

function __mbutton_mouseup()
{
  if(!this.enabled)
    return;
}

function __mbutton_mousedown()
{
  if(!this.enabled)
    return;

  if(!this.pressed) {
    document.getElementById(this.id).className='ButtonPopup' + this.design;
    document.getElementById("__menupopup" + this.id).style.visibility = "visible";
    this.pressed = true;
  } else {
    __toolbars_reset();
  }
}

function __mbutton_mouseover()
{
  if(!this.enabled)
    return;

  if(this.pressed)
    document.getElementById(this.id).className='ButtonPopup' + this.design;
  else
    document.getElementById(this.id).className='ButtonHover' + this.design;
}

function __mbutton_mouseout()
{
  if(!this.enabled)
    return;

  if(this.pressed == false)
    document.getElementById(this.id).className='ButtonStandard' + this.design;
  else
    document.getElementById(this.id).className='ButtonPopup' + this.design;
}

function __toolbar_setkey(value)
{
  __isEvaluation = value;
}
function __toolbar_setmode(value)
{
  __isMode = value;
}
