function getBrowserType() {
  var browserType = "Unknown";

  if (typeof(window.innerWidth) == "number") {
    // not IE, so set width/height from window.inner*
    browserType    = "NotInternetExplorer";
  } else if (document.documentElement && ((document.documentElement.clientWidth > 0) || (document.documentElement.clientHeight > 0))) {
    // IE 6+ in standard mode
    browserType = "InternetExplorer6+";
  } else {
    // IE 4
    browserType = "InternetExplorer4";
  }

  return browserType;
}

function getPageWidth() {
  var pageWidth   = window.innerWidth;  // will need to set based on browser
  var browserType = getBrowserType();   // get browser type

  if (browserType == "InternetExplorer6+") {
    pageWidth = document.documentElement.clientWidth;
  } else if (browserType == "InternetExplorer4") {
    pageWidth = document.body.clientWidth;
  }

  return pageWidth;
}

function setPagePosition (pageId) {
  var windowWidth = parseInt(getPageWidth() - 30);
  var e           = document.getElementById(pageId);
  var pageWidth   = parseInt(e.style.width);
  var xPosition   = parseInt((windowWidth - pageWidth) / 2);
  
  if ((e == null) || (pageWidth >= windowWidth) || (xPosition < 0)) {
    xPosition = 0;
  }

  // alert("pageId = " + pageId + ", e.style.width = " + e.style.width);

  if (e != null) {
    e.style.left = xPosition;
  }

  // setIFrameHeightMRWD();
}

function setIFrameHeightMRWD() {
  var i  = document.getElementById('iFrame');
  var l  = document.getElementById('iFrameLeft');
  var r  = document.getElementById('iFrameRight');
  var lw = document.getElementById('iFrameLeftWrap');
  var rw = document.getElementById('iFrameRightWrap');
  var pw = document.getElementById('iFramePictureWrap');
  var h  = getFrameElementHeight(i);
  var lh = getFrameElementHeight(l);
  var rh = getFrameElementHeight(r);

  if (lh > rh + 205) {
    rh = lh - 205;
  }
  // alert('iframeLeft = ' + lh + "\niFrameRight = " + rh + "\n");

  setElementHeight(lw, lh);
  setElementHeight(rw, rh);
  setElementHeight(pw, 205);

  if (window.frames[0]) {
    var pg = window.frames[0].document.getElementById('page');
    var sb = window.frames[0].document.getElementById('sidebar');

    setElementHeight(pg, lh - 115);
    setElementHeight(sb, lh - 115);
  }
}

function setElementHeight(e, height) {
  if (e && (height >= 0)) {
    e.style.height = height + "px";
    // alert(e.id + ":height = " + e.style.height);
  }
}

function getFrameElementHeight(e) {
  var height = -1;

  if (e) {
    if (e.contentDocument) { //ns6 syntax
      // alert("1:id = " + e.id);
      if (e.contentDocument.documentElement.scrollHeight) {
        // alert("2:id = " + e.id);
        e.height = 1;
        e.parentNode.style.height="auto";
        e.height = parseInt(e.contentDocument.documentElement.scrollHeight) + 10;
      } else if (e.contentDocument.body.scrollHeight) {
        e.height = parseInt(e.contentDocument.body.scrollHeight) + 10;
      }
    } else if (e.Document && e.Document.body.scrollHeight) { //ie5+ syntax
      e.height = e.Document.body.scrollHeight + 10;
    }

//    alert(e.id + "::e.h:" + e.height);
    height = parseInt(e.height) + 35;

    e.style.height = height + "px";
//    alert("height = " + e.style.height + " h:" + height + " e.h:" + e.height);

    return(height);
  }

  return(-1);
}

function dockSlider(index, dockedCtrl, undockedCtrl) {
  var e = document.getElementById("slider" + index);
  var c = document.getElementById("control" + index);

  if (!dockedCtrl) {
    dockedCtrl = " + ";
  }
  if (!undockedCtrl) {
    undockedCtrl = " - ";
  }

  if (e) {
    var state  = "undocked";

    if (e.state) {
      state = e.state;
    }

    if (state == "undocked") {
      e.state     = "docked";
      e.style.visibility = "collapse";
      c.innerHTML = "[" + dockedCtrl + "]";
    } else {
      e.state     = "undocked";
      e.style.visibility = "visible";
      c.innerHTML = "[" + undockedCtrl + "]";
    }
  }
}