// Add an event to the window.onload property of the page.
function addLoadEvent(func) {
	var oldonload = window.onload;

	if (typeof window.onload != 'function')
		window.onload = func;
	else
		window.onload = function() { oldonload(); func(); };
}

// Shorthand for document.getElementById
function $(e) { return document.getElementById(e); }

function printPage() { window.print(); }

// Standard Compose Calls

function pop_image(image, width, height) 
{
	window.open(escape(image),"","width="+width+",height="+height+",menubar=0,scrollbars=1,toolbar=0");
	return false;
}

function pop_image2(image, width, height) 
{
	window.open(image,"","width="+width+",height="+height+",menubar=0,scrollbars=1,toolbar=0");
	return false;
}

function pop(url) 
{	
	var loc = window.location;
	window.open(url,'pop_resource','toolbar=0,menubar=0,location=0,scrollbars=1,height=500,width=600,resizable=1');
	return false;
}

function pop_window(url,width,height) 
{
	window.open(url,"info",'toolbar=no,menubar=no,resizable=yes,location=no,scrollbars=yes,height='+height+',width='+width);
	return false;
}

// Clear search keyword upon focus

function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
} 



// Show or hide a column if there is content in it.

addLoadEvent(function() {
	try {
		var hasRight = /\w/.test($('resources').innerHTML);

		if (!hasRight)  document.body.className = 'fullPage';
	} catch (e) {}
}); 



/**
 * Open links in new windows using XHTML standards compliant markup.
 * This version of the function considers elements on the local domain to not
 * be external no matter what rel is set to and they will not open in a new 
 * window.
 */
function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	var hostRegEx = new RegExp(window.location.hostname);
	
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			if (!hostRegEx.test(anchor.href)) anchor.target = "_blank";
		}
	}
}

addLoadEvent(externalLinks); 

