﻿// JavasScript for LifeWords Website.
// includes a resize function to keep columns the right height (can't be done in pure CSS)
// and the script to toggle the nav sidebar text and graphics.

window.onload=resize;
window.onresize=resize;

// resize the mainWrap div whenever the browser is resized.
function resize(){  
	var frame = document.getElementById("mainWrap");  
	var footer = document.getElementById("footer").offsetHeight;  
	
	// Not all browsers use the same functions to get the size of the content 
	// area (the Canvas).
  var canvaswidth = 0, canvasheight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    canvaswidth = window.innerWidth;
    canvasheight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6, IE7 etc in 'standards compliant mode'
    canvaswidth = document.documentElement.clientWidth;
    canvasheight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    canvaswidth = document.body.clientWidth;
    canvasheight = document.body.clientHeight;
  }	
  // change the height of the mainWrap.
  frame.style.height = canvasheight - 187 - footer -10 + "px";

  // change the height of the iFrame (if it exists)
  var theIframe = document.getElementById? document.getElementById('ifrm'): document.all? document.all['ifrm']: null;
    if (theIframe) {
    theIframe.style.height = canvasheight - 187 - footer -30 + "px";
    }
} 


// toggle a particular element visible or invisible - select by it's ID.
// also switches the graphic at the left between "open" and "closed"
function toggle(id, title) 
{
		var d = document.getElementById(id);
		var t =  document.getElementById(title);

		//if(d != null)
			d.className = (d.className == "h") ? "s" : "h"; 		
		//if(t != null)
			t.className = (t.className == "closed") ? "open" : "closed"; 
} 
	

