//
// Copyright (c) 2006 BroadVision, Inc. All rights reserved.
//
// This software is copyrighted.  Under the copyright laws, this software
// may not be copied, in whole or in part, without prior written consent
// of BroadVision, Inc. or its assignees. This software is provided under
// the terms of a license between BroadVision and the recipient, and its
// use is subject to the terms of that license.
//
// This software may be protected by one or more U.S. and International
// patents. Certain applications of BroadVision One-To-One software are
// covered by U.S. patent 5,710,887.
//
// TRADEMARKS: BroadVision and the BroadVision logo are registered
// trademarks, and BroadVision One-To-One is a trademark of BroadVision,
// Inc. IONA and Orbix are trademarks of IONA Technologies, Ltd. RSA,
// MD5, and RC2 are trademarks of RSA Data Security, Inc. All other
// trademarks, service marks, and trade names belong to their respective
// owners. BroadVision, Inc. disclaims any proprietary interest in the
// marks and names of others.
//


//
// Browser - Represents a browser object.
//
function BrowserEx() {

  //
  this.getClientWidth = _browser__getClientWidth;
  this.getClientHeight = _browser__getClientHeight;
}

//
//
//
function _browser__getClientWidth() {
  if (window.innerWidth) {
    return window.innerWidth;
  }
//  else if (browser.ie6) {
//    return document.body.parentElement.clientWidth;
//  }
  else if (document.documentElement && document.documentElement.clientWidth) {
    return document.documentElement.clientWidth;
  }
  else if (document.body && document.body.clientWidth) {
    return document.body.clientWidth;
  }
  return 0;
}

//
//
//
function _browser__getClientHeight() {
  if (window.innerHeight) {
    return window.innerHeight;
  }
//  else if (browser.ie6) {
//    return document.body.parentElement.clientHeight;
//  }
  else if (document.documentElement && document.documentElement.clientHeight) {
    return document.documentElement.clientHeight;
  }
  else if (document.body && document.body.clientHeight) {
    return document.body.clientHeight;
  }
  return 0;
}


//
//
//
function _div__refresh(contents) {
  if (browser.dom) {
    this.element.innerHTML = contents;
  }
  else if (browser.ie4) { 
    this.element.innerHTML = contents;
  }
  else if (browser.ns4) { 
    this.element.document.open();
    this.element.document.writeln(contents);
    this.element.document.close();
  }
}


//
//
//
function getAnchorPoint(anchor) {
  var x = 0;
  var y = 0;

  if (browser.ns4) {
    for (var index = 0; index < document.anchors.length; index++) {
      if (document.anchors[index].name == anchor) {
        x = document.anchors[index].x;
        y = document.anchors[index].y;
        break;
      }
    }
  }
  else {
    var element = getElementByName(anchor);
    if (element != null) {
      x = !browser.ns4 ? element.offsetLeft : element.pageX;
      y = !browser.ns4 ? element.offsetTop : element.pageY;
  
      if (!browser.ns4 && !browser.ns6) {
        while ((element = element.offsetParent) != null) {
          x += element.offsetLeft;
          y += element.offsetTop;
        }
      }
    }
  }

  var point = new Point(x, y);
  return point;
}


//
//
//
function on_mouseover(e) {
  if (c_disable) return;

  e = (e) ? e : ((event) ? event : null);
  if (e && document.getElementById) {
    var element = (e.target) ? e.target : e.srcElement;

    menu_mouseover_listener();
    popup_mouseover_listener();
  }
}

//
//
//
function on_scroll(e) {
  g_scrollLeft = document.body.scrollLeft;
  g_scrollTop = document.body.scrollTop;
}

//
// Globals
//

  var browser = new Browser;
  var browserEx = new BrowserEx;

  var g_scrollLeft = 0;
  var g_scrollTop = 0;

  var c_disable = false;

  document.onmouseover = on_mouseover;
  window.onscroll = on_scroll;

  g_menubars["menubar"] = new Menubar("menubar", true);
//  g_menubars["menubar"] = new Menubar("menubar", true);
//  g_menubars["menu"] = new Menubar("menu", false);
//  g_menubars["xmenu"] = new Menubar("xmenu", true);

