﻿//*************** iframe resize script ************************
var resizeTimeout = undefined;
var resizeInProgress = false;

function resizeComplete() {
  clearTimeout(resizeTimeout);
  resizeInProgress = false;
}

function resetHandler() {
  if (isBrowser("IE") && resizeInProgress == false) {
    if (resizeTimeout != undefined) {
      clearTimeout(resizeTimeout);
    }
    resizeTimeout = setTimeout("resetSize();", 1000);
  }
  else if (isBrowser("FF")) {
    resetSize();
  }
}

function myResize(myDoc)
{
  var tblHeader = $("[@id$=tblHeaderPanel]")[0];
  var accNav = $("[@id$=accordNavigation]")[0];
  var iframe = $("[@id$=pagebody_frame]")[0];
  var iframeCell = iframe.parentNode;
  var maxWidth = myDoc.body.clientWidth;
  if (iframeCell.clientWidth > maxWidth) {
    maxWidth = iframeCell.clientWidth;
  }
  if (myDoc.body.scrollWidth > maxWidth) {
    maxWidth = myDoc.body.scrollWidth;
  }
  var maxHeight = document.body.clientHeight - tblHeader.clientHeight - 25;
  if (myDoc.body.clientHeight > maxHeight) {
    maxHeight = myDoc.body.clientHeight;
  }
  if (myDoc.body.scrollHeight > maxHeight) {
    maxHeight = myDoc.body.scrollHeight;
  }
  iframe.setAttribute("width", maxWidth);
  iframe.setAttribute("height", maxHeight);
  accNav.style.height = (maxHeight - 100).toString() + "px";
}

function resetSize()
{
  var myWidth = 0, myHeight = 0;
  if (typeof (window.innerWidth) == 'number')
  {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  }
  else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
  {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  }
  else if (document.body && (document.body.clientWidth || document.body.clientHeight))
  {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  var tdLogo = $("[@id$=tdLogo]")[0];
  var maxWidth = myWidth - tdLogo.clientWidth;
  var numImages = parseInt(maxWidth / 114);
  var img;
  for (var i = 1; i < 7; i++) {
    img = $("[@id$=img" + i.toString() + "]")[0];
    if (i <= numImages) {
      img.style.display = "block";
    }
    else {
      img.style.display = "none";
    }
  }
  clearTimeout(resizeTimeout);
  resizeTimeout = setTimeout("resizeComplete();", 1500);
}

// window.onresize = resetHandler;

function isBrowser(which) {
  var toCheck;
  switch (which) {
    case "IE": toCheck = "MSIE";
      break;
    case "FF": toCheck = "Firefox";
      break;
  }
  if (undefined != toCheck) {
    return (navigator.userAgent.indexOf(toCheck) != -1)
  }
  return false;
}

function MM_findObj(n, d) { //v4.01
  var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
    d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
  }
  if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
  for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
  if (!x && d.getElementById) x = d.getElementById(n); return x;
}

