// JavaScript Document

// Live Page Height and Width functions modified from Lanoie.com site
function findLivePageHeight() 
{
  // test for page height in Netscape
  if (window.innerHeight != null) {
    return window.innerHeight;
  }
  // test for page height in IE6
  if (document.documentElement.clientHeight != null) {
    return document.documentElement.clientHeight;
  }
  // test for page height in IE<6
  if (document.body.clientHeight != null) {
    return document.body.clientHeight;
  }
  return (600); // if neither condition is met, assume a default page height
}

function findLivePageWidth() 
{
  // test for page width in Netscape
  if (window.innerWidth != null) {
    return window.innerWidth;
  }
  // test for page width in IE6
  if (document.documentElement.clientWidth != null) {
    return document.documentElement.clientWidth;
  }
  // test for page width in IE<6
  if (document.body.clientWidth != null) {
    return document.body.clientWidth;
  }
  return (800); // if neither condition is met, assume a default page width
}

//global variables for header padding
var right_header_padding;
var center_header_padding;

function setScreen()
{
  // get the usuable screen dimensions
  var screenHeight = findLivePageHeight();
  var screenWidth = findLivePageWidth();
  if(screenWidth < 538 + 224 && screenHeight < 438)
  {
    screenWidth = 538 + 224 -20;
    screenHeight = 438 - 20;
  }
  else if (screenWidth < 538 + 224 )
  {
    screenWidth = 538 + 224 ;  // make width wide enough for logo and contact
    screenHeight -= 20; // make room for a scroll bar
  } 
  else if (screenHeight < 438 )
  {
    screenHeight = 438; // make divs evenly tall to match nav bar
    screenWidth -= 20; // make room for a scroll bar
  }
  // set the divs with flexible sizes
  var main = document.getElementById('mainDiv');
  var menu = document.getElementById('navBar');
  var supp = document.getElementById('SuppCol');
  var cont = document.getElementById('contactBox');
  
  var head = document.getElementById('headerWrapper');
  var rule1 = document.getElementById('topRule');
  var rule2 = document.getElementById('topSubRule');
  
  // set the main div height and width
  main.style.height = (screenHeight - 174)+'px';
  main.style.width = (screenWidth - 224 - 140 - 10)+'px';
  // set the menu height
  menu.style.height = (screenHeight - 174 - 15)+'px';
  // set the contact box and supp div left position
  supp.style.left = (screenWidth - 224)+'px';
  supp.style.height = (screenHeight - 174)+'px';
  cont.style.left = (screenWidth - 224)+'px';
  // set the widths
  head.style.width = (screenWidth)+'px';
  rule1.style.width = (screenWidth)+'px';
  rule2.style.width = (screenWidth)+'px';

}

function setMainScreen()
{
  // get the usuable screen dimensions
  var screenHeight = findLivePageHeight();
  var screenWidth = findLivePageWidth();
  
  var mainmain = document.getElementById('mainmainDiv');
  var menu = document.getElementById('navBar');
  var head = document.getElementById('headerWrapper');
  var rule1 = document.getElementById('topRule');
  var rule2 = document.getElementById('topSubRule');

  // set the main div height and width
  mainmain.style.width = (screenWidth - 140 - 10)+'px';
  mainmain.style.height = (screenHeight - 174)+'px';

  // set the menu height
  menu.style.height = (screenHeight - 174 - 15)+'px';
  
  // set the widths
  head.style.width = (screenWidth)+'px';
  rule1.style.width = (screenWidth)+'px';
  rule2.style.width = (screenWidth)+'px';
  
}

function toggle(id)
{
  obj = document.getElementById(id)
  if (obj.style.display == 'block')
  {
    obj.style.display = 'none';
  }
  else
  {
    obj.style.display = 'block';
  }
}
