function getDocHeight(doc) {
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
}

function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt) iframeEl.style.height = docHt + 50 + "px";
  }
}

function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;   
    return false;
  }
  else return true;
}

window.onresize = function() { 
	setIframeHeight('ifrm');
	setIframeHeight('menuIfrm');
}

var selectedLink

function refreshLinkSelection() {

}

function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

function ReadCookie(cookieName) {
  var theCookie=""+document.cookie;
  var ind=theCookie.indexOf(cookieName);
  if (ind==-1 || cookieName=="") return ""; 
  var ind1=theCookie.indexOf(';',ind);
  if (ind1==-1) ind1=theCookie.length; 
  return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

function processOnLoad() {
  var _titleImgURL = ReadCookie('titleImgURL');
  var _menuImgURL = ReadCookie('menuImgURL');
  var _ifrmURL = ReadCookie('ifrmURL');
  var _menuIfrmURL = ReadCookie('menuIfrmURL');

  if(_titleImgURL == "" || _menuImgURL == "" ||
     _ifrmURL == "" || _menuIfrmURL == "") {
    return false;
  }

  return processMainMenuClick(_titleImgURL, _menuImgURL, _ifrmURL, _menuIfrmURL);
}

function processOnUnload() {
  SetCookie('titleImgURL', document.getElementById("sunflowerTitle").src, 1); 
  SetCookie('menuImgURL', document.getElementById("indexMap").src, 1); 
  SetCookie('ifrmURL', window.frames['ifrm'].location, 1);
  SetCookie('menuIfrmURL', window.frames['menuIfrm'].location, 1);

  return false;
}





