//alert ("script changed 7");
var newWindow = null;

function closeWin() {
	if (newWindow != null) {
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin (url, type) {
	
	closeWin();
	
	var tools="";
	if (type == "glossary") tools = "resizable, toolbar=no, location=yes, scrollbars=no, menubar=no, width=420, height=200, top=0, left=0";
	if (type == "pdf") tools = "resizable, toolbar=yes, location=yes, scrollbars=yes, menubar=yes, left=0, top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}

function popUpEvent (ank) {
	//call the popup script
	popUpWin(this.href,this.className);
	//cancel the default link action if pop-up activated
	if (window.event) {
		window.event.returnValue = false;
		window.event.cancelBubble = true;
	} else if (ank) {
		ank.stopPropagation();
		ank.preventDefault();
	}
}

function resourceLinks() {
	// Get all links in content div
	var container = document.getElementById('content');
	var anchors = container.getElementsByTagName('a');
	// popups = document.getElementsByTagName("a");
	for (i=0;i<anchors.length;i++) {
		if (anchors[i].className == "glossary" || anchors[i].className == "pdf")		{
			// attach popup behaviour
			anchors[i].onclick = popUpEvent;
			// add info to title attribute to alert fact that it's a pop-up window
			anchors[i].title = (anchors[i].className == "pdf") ? anchors[i].title + " [PDF file opens in a new window]" : anchors[i].title + " [Opens in a new window]";
		}
	}
}

//addEvent(window, 'load', findPopUps, false);


/*function resourceLinks () {
	// Get all links in content div
	var container = document.getElementById('content');
	var links = container.getElementsByTagName('a');
	for (var i = 0; i < links.length; i++) {
		// Check to see if class is "glossary"
		if (links[i].className == "glossary" || links[i].className == "pdf") {
			// Make the link open up the term in the new windowis
			links[i].onclick = newWindowEvent;
			// Add info to title attribute
			links[i].title = links[i].title + "[Opens in a pop-up window]";
		}
	}
}*/
