// JavaScript Document

/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

var minHeight = 350;

function GetDocHeight(doc) 
{
  var docHt = 0, sh, oh;
  if (doc.height) 
    docHt = doc.height;
  else 
    if (doc.body)
    {
      if (doc.body.scrollHeight) 
        docHt = sh = doc.body.scrollHeight;
      if (doc.body.offsetHeight) 
        docHt = oh = doc.body.offsetHeight;
      if (sh && oh) 
        docHt = Math.max(sh, oh);
    }
  return docHt;
}

function SetIframeHeight(iframeName) 
{
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById ? document.getElementById(iframeName): document.all ? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) 
  {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    var docHt = GetDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt)
    {
      var newHeight = docHt + 30;
      if (minHeight == 0)
        minHeight = newHeight;
      else
        if (newHeight < minHeight)
          newHeight = minHeight;
      iframeEl.style.height = newHeight + "px";
      document.getElementById('info').style.height = newHeight + "px";
    }
  }
}

/*************************************************************************
  End of code from Dynamic Web Coding at http://www.dyn-web.com/
*************************************************************************/

var viewport = 
{
  getWinWidth: function () 
  {
    this.width = 0;
    if (window.innerWidth) this.width = window.innerWidth - 18;
    else if (document.documentElement && document.documentElement.clientWidth) 
  		this.width = document.documentElement.clientWidth;
    else if (document.body && document.body.clientWidth) 
  		this.width = document.body.clientWidth;
  },
  
  getWinHeight: function () 
  {
    this.height = 0;
    if (window.innerHeight) this.height = window.innerHeight - 18;
  	else if (document.documentElement && document.documentElement.clientHeight) 
  		this.height = document.documentElement.clientHeight;
  	else if (document.body && document.body.clientHeight) 
  		this.height = document.body.clientHeight;
  },
  
  getScrollX: function () 
  {
    this.scrollX = 0;
  	if (typeof window.pageXOffset == "number") this.scrollX = window.pageXOffset;
  	else if (document.documentElement && document.documentElement.scrollLeft)
  		this.scrollX = document.documentElement.scrollLeft;
  	else if (document.body && document.body.scrollLeft) 
  		this.scrollX = document.body.scrollLeft; 
  	else if (window.scrollX) this.scrollX = window.scrollX;
  },
  
  getScrollY: function () 
  {
    this.scrollY = 0;    
    if (typeof window.pageYOffset == "number") this.scrollY = window.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop)
  		this.scrollY = document.documentElement.scrollTop;
  	else if (document.body && document.body.scrollTop) 
  		this.scrollY = document.body.scrollTop; 
  	else if (window.scrollY) this.scrollY = window.scrollY;
  },
  
  getAll: function () 
  {
    this.getWinWidth(); 
    this.getWinHeight();
    this.getScrollX();  
    this.getScrollY();
  }
}


function SetSiteWidth(width) 
{
  var siteDiv = document.getElementById? document.getElementById('site'): document.all? document.all['site']: null;
  if (siteDiv) 
  {
    viewport.getWinWidth();
    var newWidth = Math.floor( ( viewport.width - width ) / 2 );
    siteDiv.style.left = (newWidth > 0 ? newWidth : 0) + "px";
    siteDiv.style.visibility = "visible";
  }
}

var menu_option_selected = null;

function SelectMenuOption(option, newPage)
{
/*
  if (menu_option_selected)
  {
    menu_option_selected.className = "menu";
  }
  if (option != null)
  {
    document.getElementById(option).className = "menu_selected";
    menu_option_selected = document.getElementById(option);
  }
  else
    menu_option_selected = null;
*/
  document.getElementById("content_frame").src = newPage;
}

function Init()
{
  SetSiteWidth(900);
}

