var sectionID = null;
var shownID = null;
var timerID = null;
var browser = null;
      
function initPage()
{
  setPositions();
}

function setPositions()
{
  var headerHeight = 120;
  var footerHeight = 40;
  var mainHeight = 0;
  var docHeight = document.body.scrollHeight;
  var availHeight = document.body.clientHeight;
    
  var navWidth = 150;
  var availWidth = document.body.clientWidth;

  var main    = document.getElementById('main');
  var nav     = document.getElementById('nav');
  var content = document.getElementById('content');
  var footer  = document.getElementById('footer');

  if ( docHeight > availHeight )
  {
    mainHeight = docHeight - headerHeight;
    footer.style.top = docHeight - footerHeight;
  }
  else
  {
    mainHeight = availHeight - headerHeight;
    footer.style.top = availHeight - footerHeight;
  }
  
  main.style.height = mainHeight;
  nav.style.height = mainHeight;
  
  footer.style.width = availWidth - navWidth;
}

function showSubmenu(id)
{
  hideShown();
  clearTimeout(timerID);
  
  var subID = id + '_sub';
  document.getElementById(id).style.backgroundColor = '#b0bb88';
  document.getElementById(subID).style.display = 'block';
  
  sectionID = id;
  shownID = subID;
}

function startHideTimer()
{
  timerID = setTimeout("hideShown()", 500);
}

function hideShown()
{
  if ( shownID != null )
  {
    document.getElementById(sectionID).style.backgroundColor = '#A1AC72';	    
    document.getElementById(shownID).style.display = 'none';
  }
}

function activateSubmenu()
{
  clearTimeout(timerID);
}

function submitLoginForm()
{
  document.forms("loginForm").submit();
}

function getRandomPhoto()
{
  var rand = Math.round(Math.random() * 34);
  rand = "" + rand;
  if ( rand.length == 1 ) {
	rand = "0" + rand;
  }
  if ( location.href.substring(location.href.length-16, location.href.length) == "members_only.asp" )
  {
    document.body.style.backgroundImage = "url('images/members/group.jpg')";
  }
  else 
  {
	if (rand == "07" || rand == "08" || rand == "13" || rand == "14" ||
	    rand == "16" || rand == "17" || rand == "18" || rand == "19" ||
	    rand == "23" || rand == "24" || rand == "29" || rand == "33")
	{
	  getRandomPhoto();
    }
    else
    {
      document.body.style.backgroundImage = "url('images/members/00" + rand.toString() + ".gif')";
    }
  }
}