
jQuery(document).ready(function($){
	$(".toggler").click(function() {
		
		// get the top scroll point for the current view
		var ScrollTop = document.body.scrollTop;
		if (ScrollTop == 0)
		{
			if (window.pageYOffset)
				ScrollTop = window.pageYOffset;
			else
				ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
		}
		// get the height of the current view
		//IE
		if(!window.innerWidth)
		{
			//strict mode
			if(!(document.documentElement.clientWidth == 0))
			{
				cWidth = document.documentElement.clientWidth;
				cHeight = document.documentElement.clientHeight;
			}
			//quirks mode
			else
			{
				cWidth = document.body.clientWidth;
				cHeight = document.body.clientHeight;
			}
			cHeight = cHeight - 45; // adjusted for status bar
		}
		//w3c
		else
		{
			cWidth = window.innerWidth;
			cHeight = window.innerHeight - 45; // adjusted for status bar
		}
		// hide any open boxes
		$(".relLinks").hide();
		// offset of the div where pop up should appear
		var pos = $("#termRegion").offset();
		// position of the bottom of the box
		var bottomPos = pos.top + $(this).next("div").height();
		// position of the bottom of the viewable window
		var bottomRow = cHeight + ScrollTop;
		// if the position of the term region (plus the height of the box) is more than the visible
		// window - then adjust the location of the pop up
		if( bottomPos > bottomRow )
			pos.top = pos.top - (bottomPos - bottomRow);
		// position the div next to the current element
		$(this).next("div").css( {"top": + pos.top + "px", "left": + pos.left + "px"});
		//$(this).next("div").css( {"top": + posTop + "px", "left": + posLeft + "px"});
		$(this).next("div").toggle();
	});
	//$(".relLinks").bind("mouseleave", function() {
		//$(this).hide();
	//});
});