// by Paul@YellowPencil.com and Scott@YellowPencil.com

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('pagewrapper'));
		
		// 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;
		}
		
		// set all columns to maximum height
		for (var i = 0; i < divs.length; i++) {
			divs[i].style.height = maxHeight + 'px';

			// if the browser's working 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!
			if (divs[i].offsetHeight > maxHeight) {
				divs[i].style.height = (maxHeight - (divs[i].offsetHeight - maxHeight)) + 'px';
			}
		}
	}
}

window.onload = function() {
	if (document.getElementById('pagewrapper')) {
		//setTall();
	}
}

window.onresize = function() {
	if (document.getElementById('pagewrapper')) {
		//setTall();
	}
}

// Toggles element's visibility
function toggleDiv(obj) {
	var el = $(obj);
	if ( el.style.display != 'block' ) {
		el.style.display = 'block';
	}           else {
		el.style.display = 'none';
	}
}

// Attaches functions to the window's load event
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

// Navigate to new page
function SelectNav(el)
{
	destination = el.options[el.selectedIndex].value;
	if (destination) location.href = destination;
}

//generic popup window
function OpenPopupWindow(url, title, width, height) {
	var newWin;
	newWin = window.open(url,title,"width=" + width + ",height="  + height + ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
	newWin.focus();
}


// Email Replacement
function showEmail(username,hostname) {
	var linktext = username + "@" + hostname;
	document.write("<a href=" + "mail" + "to:" + username +
"@" + hostname + ">" + linktext + "</a>")
}

// replacement with text as link
function showEmail_text(username,hostname,linktext) {
	document.write("<a href=" + "mail" + "to:" + username +
"@" + hostname + ">" + linktext + "</a>")

}