// original script from: http://www.yoursurfice.com/Content/Home/Home.htm

// Global 'constants'
var IE = (document.all ? true : false);
var NS = (document.layers ? true : false);
var NS6 = (document.getElementById ? true : false);
var LEFT = (IE ? "pixelLeft" : "left");
var TOP = (IE ? "pixelTop" : "top");

// Global variables
var Page;
var Tab;

// Global script
function Initialize()
  {
  var HeightTab = (document.images["ShowMenu"] ? document.images["ShowMenu"].height : 16);
  Page = new Page();
  Tab = new LinkBar("Tab", HeightTab);
  SetPositions();
  bMenuEnabled = true;
  window.setTimeout("OnTimer()", 100);
  }

function OnTimer()
  {
  SetPositions();
  Tab.OnTimer();
  window.setTimeout("OnTimer()", 100);
  }

function SetPositions()
  {
  var HeightTab = (document.images["ShowMenu"] ? document.images["ShowMenu"].height : 16);
  var WidthHeader = (document.images["Header"] ? document.images["Header"].width : 650);
  var Left;
  Tab.Position(0, Page.Height() - HeightTab);
  Left = ((Page.Width() - WidthHeader) / 2);
  Left = ((Left < 0) ? 0 : Left);
  }



// Page class

function Page()
  {
  // Properties

  // Methods
  this.Height = function()
    {
    var Height = window.innerHeight;
    Height = (isNaN(Height) ? document.body.clientHeight : Height) - 0;
    return Height;
    }

  this.Width = function()
    {
    var Width = window.innerWidth;
    Width = (isNaN(Width) ? document.body.clientWidth : Width) - 0;
    return Width;    
    }    
    
  this.Top = function()
    {
    var Top = window.pageYOffset;
    Top = (isNaN(Top) ? document.body.scrollTop: Top);
    return Top;
    }
}

// LinkBar class
function LinkBar(sID, iHeight)
  {
  // Properties
  this.ID = sID;
  this.Height = iHeight;

  if(IE)
    this.Style = document.all[sID].style;
  else if(NS6)
    this.Style = document.getElementById(sID).style;
  else if(NS)
    this.Style = document.layers[sID];

  // Methods
  this.Position = function(iLeft, iTop)
    {
    this.Style[LEFT] = iLeft;
    this.Style[TOP] = iTop;
    }

  this.OnTimer = function()
    {
    this.Position(0, Page.Top() + (Page.Height() - this.Height));
    }

  this.Swap = function(Div)
    {
    this.Style.visibility = "hidden";
    Div.Style.visibility = "visible";
    }
  }

