// loop through all links in the document looking for those which have a class of "popup"
// for those that have that class, replace the normal link behavior with the popUp window function
function prepareLinks() {
	if (!document.getElementsByTagName) return false;
	var links = document.getElementsByTagName("a");
	for (var i=0; i<links.length; i++) {
		if (links[i].getAttribute("class") == "popup") {
			// check and make sure that the user wasn't trying to force the link to open in a new window; if they are, allow their action to go forward and cancel the popUp function
			// borrowed this function from the JSTarget function by Roger Johansson, www.456bereastreet.com
			links[i].onclick = function(e) {
				var event = (!e) ? window.event : e;
				if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return true;
				else {
					popUp(this.getAttribute("href"));
					return false;
				}
			}
		}
	}
}

// define the width and height of the screen
var width = screen.width;
var height = screen.height;

// reset variables
var pWidth = 322;
var pHeight = 262;
var positionTop = 0;
var positionLeft = 0;

// center new window on screen
var positionLeft = ((width/2) - (pWidth/2));
var positionTop = ((height/2) - (pHeight/2));

// create the new window
function popUp(winURL) {
	window.open(winURL, "popup", "width=" + pWidth + ",height=" + pHeight + ",left=" + positionLeft + ",top=" + positionTop + ",resizable=1, scrollbars=1, menubar=0, toolbar=0");
}	

