
// This function is called on page load after the main menu builds on. It checks to see what section the current page 
// falls under ("home", "About Us", etc) and updates the main menu configuration to reflect this, switching the section's 
// respective button to it's "on" state. The Main Menu is generated from the file "menu_config.js" and is called from 
// the bottom of each .html page.

function idSection (currentSection) {
	if (currentSection != '') {
		var currentSection_img = '/images/shared/nav_' + currentSection + '_on.gif'
		document.getElementById('nav_' + currentSection).src = currentSection_img;	
	}
}


// Used for the AQI Definitions window

function openDetailWin(url) { 
	detailWin = window.open(url, '', 'width=620,height=500,status=0,scrollbars=yes,toolbar=no,resizable=yes');
	detailWin.focus();

}


// Used for the AQI Definitions window

function openWebcam() { 
	webcamWin = window.open('http://www.nwcleanair.org/baker_webcam/baker/default_new.htm', '', 'width=370,height=450,status=0,scrollbars=yes,toolbar=no,resizable=yes');
	webcamWin.focus();

}


// Used for the "Wood Heating" detail window

function openDetailWin_2(url) { 
	detailWin = window.open(url, '', 'width=492,height=530,status=0,scrollbars=no,toolbar=no,resizable=yes');
	detailWin.focus();

}


// Used for the "Wood Heating" detail window

function openDetailWin_3(url) { 
	detailWin = window.open(url, '', 'width=495,height=535,status=0,scrollbars=no,toolbar=no,resizable=yes');
	detailWin.focus();

}

// Used for the "Wood Heating" detail window

function openFlashPresentation(url) { 
	detailWin = window.open(url, '', 'width=800,height=640,status=0,scrollbars=no,toolbar=no,resizable=yes');
	detailWin.focus();

}



// Used for "Regulations" section

function openRegulationWin(regTitle) { 
	var url = '/formsRegs/regulations/' + regTitle + ".htm";
	//alert (url);
	regulationWin = window.open(url, '', 'width=640,height=480,status=0,scrollbars=yes,toolbar=no,resizable=yes');
	regulationWin.focus();

}


// Default Pop-Open window sizes for Laura to work with:

function openPopWin_size1(url) { 
	detailWin = window.open(url, '', 'width=320,height=240,status=0,scrollbars=yes,toolbar=no,resizable=yes');
	detailWin.focus();
}

function openPopWin_size2(url) { 
	detailWin = window.open(url, '', 'width=640,height=480,status=0,scrollbars=yes,toolbar=no,resizable=yes');
	detailWin.focus();
}

function openPopWin_size3(url) { 
	detailWin = window.open(url, '', 'width=800,height=600,status=0,scrollbars=yes,toolbar=no,resizable=yes');
	detailWin.focus();
}






/*************************************************************************
  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 "Regulations" section to dynamically set the iFrame displaying the specific "Regulation Text".
// This function is called from the "Regulation Text" document in an "onLoad" event each time a new "Regulation Text" 
// document is loaded into the iFrame on the regulations page.

function goSetHeight(iframeName) {
  if (parent == window) return;
  else parent.setIframeHeight(iframeName);
}