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 = 350;
  if (!height) height = 350;
  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);
}

function openFullImg(id) {
  width = 600;
  height = 500;
 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("/includes/full_img.jsp?id="+id,"winFull",features);
}

function openNormImg(fname) {
  width = 800;
  height = 700;
 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("/includes/img.jsp?file_name="+fname,"winFull",features);
}

function openImg(fname) {
  width = 600;
  height = 600;
 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("/includes/img.jsp?file_name=/images/lodge-floor-plans/"+fname,"winFull",features);
}

