// getElementsByClass was taken from example code at
// www.dustindiaz.com/getelementsbbyclass/
// and modified slightly to improve readability and style
function getElementsByClass(searchClass,node,tag) {
	if ( node == null ) {
		node = document;
	}

	if ( tag == null ) {
		tag = '*';
	}

	var classElements = new Array();
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");

	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}

	return classElements;
}

function showPopup(id) {
	hideAllPopups();
	document.getElementById(id).style.display = 'block';
	return false;
}

function hidePopup(id) {
	document.getElementById(id).style.display = 'none';
}

function hideAllPopups() {
	// get all span.popups
	var popups = getElementsByClass('popup');
	// loop and style.display='none'
	for (i = 0; i < popups.length; i++) {
		popups[i].style.display='none';
	}
}

function showPrintWindow(URL) {
	var popup = window.open(URL, 'Print', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=1,width=750,height=400');
}
