/* 
	With Regret, I've resorted to using this excellent javascript column equaliser method by Paul Bellows
	 - The negative margin positve padding method wasn't working for me in IE - and I didn't want to use
	 tables - but in retrospect - I think it would have been less messy just to throw in a simple table
	by Paul@YellowPencil.com and Scott@YellowPencil.com
*/
function scriptInit() {
if (!document.getElementById) {
	return;
	}
}

// Set up Event Listener - the script that allows us to use the addEvent call below

function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
	elm.addEventListener(evType, fn, useCapture);
	return true;
	} else if (elm.attachEvent) {
	var r = elm.attachEvent('on' + evType, fn);
	return r;
	} else {
	elm['on' + evType] = fn;
	}
}

// Start Column Script
function setTall() {
	if (document.getElementById) {
		// the divs array contains references to each column's div element.  
		var divs = new Array(document.getElementById('left'), document.getElementById('middle'), document.getElementById('right'));
		
		// Let's determine the maximum height out of all columns specified
		var maxHeight = 0;
		for (var i = 0; i < divs.length; i++) {
			if (divs[i].offsetHeight > maxHeight) maxHeight = divs[i].offsetHeight;
		}
		
		// Let's set all columns to that maximum height
		for (var i = 0; i < divs.length; i++) {
			divs[i].style.height = maxHeight + 'px';

			// Now, if the browser's in standards-compliant mode, the height property
			// sets the height excluding padding, so we figure the padding out by subtracting the
			// old maxHeight from the new offsetHeight, and compensate!  So it works in Safari AND in IE 5.x
			if (divs[i].offsetHeight > maxHeight) {
				divs[i].style.height = (maxHeight - (divs[i].offsetHeight - maxHeight)) + 'px';
			}
		}
	}
}

addEvent(window, 'load', setTall, false);
addEvent(window, 'resize', setTall, false);

//this makes striped table rows
 function stripe(id) {
    var table = document.getElementById(id);
    if (! table) { return; }
    var trs = table.getElementsByTagName("tr");
    for (var i = 0; i < trs.length; i += 2) {
      trs[i].className += " even";
    }
  }
 //these functions make things with class doc open up in a new window while maintaining a compliant document
  function init() {
		// Fetch all the a elements in the document.
		var links = document.getElementsByTagName('a');

		// Loop through the a elements in reverse order
		// for speed.
		for (var i = links.length; i != 0; i--) {
			
			// Pull out the element for this iteration.
			var a = links[i-1];
			
			// If the element doesn't have an href, skip it.
			if (!a.href) continue;

			// If the element has a className that contains
			// 'doc' attach the onclick handler.
			if (a.className && a.className.indexOf('doc') != -1) a.onclick = PopWin;
		}
	}
	
	function PopWin(e) {
		// Accommodate IE's non-standard event handling.
		if (!e) var e = window.event;
		var a = e.target ? e.target : e.srcElement;

		// Open a new window with the link's href.
		var newwin = window.open(a.href);

		// The thought is that if the new window didn't
		// (popups blocked or whatever) we want to return
		// true so the link is follow normally. Not sure
		// if this works, but it doesn't seem to hinder.
		return !newwin;                               
	}


