var bodyHeight; 

function setBodyHeight() {
  bodyHeight = document.body.scrollHeight;
  //alert("scroll = " + document.body.scrollHeight + "\nclient = " + document.body.clientHeight + "\noffset = " + document.body.offsetHeight);
}

// function setFooter() {
//  if(bodyHeight > document.body.clientHeight-30) {
//    document.getElementById("FOOTER").style.top = bodyHeight;
//  } else {
//    document.getElementById("FOOTER").style.top = document.body.clientHeight-30;
//  }
//}

function init() {
  if(document.getElementById) {
    setBodyHeight();
//    setFooter();
  }
  initPage();
}

function initPage() {
  // to be overwriten by the page
}

function changeNav(el, on) {
  if(on) {
    el.style.backgroundColor = '#091E61';
    el.children[0].style.color = "#FFFFFF";
    el.style.cursor = 'hand';
  } else {
    el.style.backgroundColor = '#FFFFFF';
    el.children[0].style.color = "#333333";
  }
}


function toggleImg(img) {
  src = img.src;
  if(src.indexOf('_off') != -1)
    img.src = src.replace('_off', '_on');
  else if(src.indexOf('_on') != -1)
    img.src = src.replace('_on', '_off');
}

function preloadImg(img) {
  src = img.src;
  document.onImg = new Image();
  document.onImg.src = src.replace('_off', '_on');
}

function openPopupWindow(url, width, height, scrolling) {
  if (!width) width = 820;
  if (!height) height = 610;
  if (!scrolling) scrolling = "no"; 
  features = "width="+width+","
           + "height="+height+","
           + "toolbar=no,"
           + "location=no,"
           + "status=no,"
           + "menubar=no,"
           + "scrollbars="+scrolling+","
           + "top="+(window.screen.height-height)/2+","
           + "left="+(window.screen.width-width)/2;
  window.open(url,"win"+Math.round(Math.random()*1000),features);
}
