

/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

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 + 30 + "px";
  }
}

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



// Used in the "Support" section to dynamically set the iFrame displaying the specific Content Blocks.
// This function is called from the "Support Topic Text" document in an "onLoad" event each time a new "Support Topic Text" 
// document is loaded into the iFrame on the regulations page.

function goSetHeight(iframeName) {
  if (parent == window) return;
  else parent.setIframeHeight(iframeName);
}


// Pop-open Windows used throughout the site

function viewAddInfo(url) { 
	popupWin = window.open(url, '', 'width=460,height=285,status=0,scrollbars=yes,toolbar=no,resizable=yes');
	popupWin.focus();
}

function viewDirMsg(url) { 
	popupWin = window.open(url, '', 'width=460,height=535,status=0,scrollbars=yes,toolbar=no,resizable=yes');
	popupWin.focus();
}

function viewCallOutDetail(url) { 
	popupWin = window.open(url, '', 'width=380,height=300,status=0,scrollbars=no,toolbar=no,resizable=yes');
	popupWin.focus();
	window.self.name = 'MAIN';
}

function openSuccessRates(url) { 
	popupWin = window.open(url, 'successRates', 'width=375,height=410,status=0,scrollbars=yes,toolbar=no,resizable=yes');
	popupWin.focus();
}

function openWhoWeHelp(url) { 
	popupWin = window.open(url, 'whoWeHelp', 'width=375,height=275,status=0,scrollbars=yes,toolbar=no,resizable=yes');
	popupWin.focus();
}


// This script handles the "expanding" and "collapsing" of nested ULs
function updateMenu (categoryName) {
	// build the reference to the specific Category Title element 
	var categoryTitle= (categoryName + "_title");
	// Determine current status of menu being updated (expanded [display:block] or collapsed [display:none]) 
	var status = (document.getElementById(categoryName).style.display);
	// If it's colla[sed...
	if (status == "none") {
		// "Expand" the category listing by making the contained UL visible
		document.getElementById(categoryName).style.display="block";
		// Update the icon of the related categoryTitle element
		document.getElementById(categoryTitle).style.backgroundImage="url(../images/shared/iconExpanded.gif)";
	}
	// Else if it's currently "expanded"...
	else {
		// "Collapse" the category listing by making the contained UL visible
		document.getElementById(categoryName).style.display="none";
		// Update the icon of the related categoryTitle element
		document.getElementById(categoryTitle).style.backgroundImage="url(../images/shared/iconCollapsed.gif)";
	}
}



// Legacy Macromedia rollover scripts
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}