$(document).ready(function(){ 
	
	$(".rel div").addClass("pop");
	$(".pop").hide();
	$(".pop").prepend("<a href='#non' class='close'><img src='/images/close.gif' alt='close'/></a>");
	
	
	$(".hints a").click(function () {
		$(this).parent().parent().parent("td").children(".rel").children(".pop").toggle();
	});
	$(".close").click(function () {
		$(this).parent(".pop").toggle();
	});

	/* ------------------------------------------------
	-- EXTERNAL LINK POPUP WINDOWS
	------------------------------------------------ */
	
	function prepareLinks() {
		if (!document.getElementsByTagName) return false;
		var links = document.getElementsByTagName("a");
		for (var i=0; i<links.length; i++) {
			// if an anchor in the array contains the attribute "rel" with the value "external"
			if (links[i].getAttribute("rel") == "external") {
				links[i].onclick = function() {
					// apply the popUp function to this anchor and get the href attribute
					popUp(this.getAttribute("href"));
					return false;
				}
			}
		}
	}
			
	// popUp function used by prepareLinks
	function popUp(winURL) {
		window.open(winURL,"popup","width=565, height=500, scrollbars=yes, resizable=yes");
	}

	prepareLinks()
});