/*
 * General functions.
 */
String.prototype.trim = function() 
{
	a = this.replace(/^\s+/, '');
	return a.replace(/\s+$/, '');
};

$(document).ready(function()
{
	// Code to display glossary defs in popup window
	handleGlossaryPopup();
});

// Code to display glossary defs in popup window
function handleGlossaryPopup()
{
	var showDelayTimer = null;
	var hideDelayTimer = null;

	var positionGlossaryPopup = function(spanObj) {
		var posX = spanObj.offset().left - 20;
		var posY = spanObj.offset().top - 155;
		$("div.glossary-popup").css({top: posY, left: posX});
	};

	$("span.glossary-term").hover(
		function () {
			clearTimeout(hideDelayTimer);
			$("div.glossary-popup").html($(this).find("span.glossary-data").html());
			positionGlossaryPopup($(this));
			showDelayTimer = setTimeout(function() {$("div.glossary-popup").show()}, 800);
			//$("div.glossary-popup").show();
		},
		function () {
			clearTimeout(showDelayTimer);
			hideDelayTimer = setTimeout(function() {$("div.glossary-popup").hide()}, 800);
		}
	);
}

// Return the value of the specified querystring param.
function getParameterByName(name)
{
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null )
		return "";
	else
		return results[1];
}

