var glossaryWords = new Object();
var softPopupID = "softPopup";


function addGlossaryWord(linkID, glossaryID, glossaryTitle, glossaryDescription) {
	glossaryWords[glossaryID] = new Object();
	glossaryWords[glossaryID]["title"] = glossaryTitle;
	glossaryWords[glossaryID]["description"] = glossaryDescription;
}

function addCloseLink(linkDescription) {
	glossaryWords["closeLink"] = linkDescription;
}


function openGlossary(e, glossaryID) {
	openSoftPopup(e, "glossaryPopup", glossaryWords[glossaryID]["title"], glossaryWords[glossaryID]["description"]);
	return false;
}

function openSoftPopup(e, className, glossTitle, content) {
	
	var mySoftPopup = document.getElementById(softPopupID);
	
	if (mySoftPopup == null) {
		document.getElementsByTagName('body')[0].innerHTML = 
			"<div id=\""+softPopupID+"\" style=\"display:none;\"></div>" +
			document.getElementsByTagName('body')[0].innerHTML;
			;
		mySoftPopup = document.getElementById(softPopupID);
	}
	closeSoftPopup();
	
	mySoftPopup.innerHTML = '<div class="wrapper"><div class="head"><h1>' + glossTitle + '</h1></div><div class="glosspoup"><p>' + content + '</p><p class="close_link"><a href="javascript: closeSoftPopup();">' + glossaryWords["closeLink"] + '</a></p></div></div><div class="bottom"></div>';
	mySoftPopup.className = className;
	mySoftPopup.style.position = "absolute";
	
	/*Prototype Solution:*/
	mySoftPopup.style.left = (Event.pointerX(e)+10)+"px";
	mySoftPopup.style.top = (Event.pointerY(e)+10)+"px";
	mySoftPopup.style.display = "block";

	mySoftPopup.style.visibility = "hidden";
	try { //move to correct Position.
		var abs_top=Event.pointerY(e)-$('softPopup').getHeight();
		var abs_left=Event.pointerX(e)-$('softPopup').getWidth()/6;
		if (abs_top<0) {
			abs_top=0;
		}
		mySoftPopup.style.top = abs_top+"px";
		mySoftPopup.style.left =abs_left+"px";
	} catch (E) {}
	mySoftPopup.style.visibility = "visible";

}

function closeSoftPopup() {
	if (document.getElementById(softPopupID) != null) {
		document.getElementById(softPopupID).style.display = 'none';
		document.getElementById(softPopupID).innerHTML = '';
		document.getElementById(softPopupID).className = '';
	}
}

