var glossaryWords = new Array();
var softPopupId = "softPopup";
var softPopupClassName = "glossaryPopup";


function addGlossaryWord(linkID, glossaryId, glossaryTitle, glossaryDescription) {
	glossaryWords[glossaryId] = new Array();
	glossaryWords[glossaryId]["title"] = glossaryTitle;
	glossaryWords[glossaryId]["description"] = glossaryDescription;
}


function openGlossary(event) {
	$ = jQuery;
	var glossaryId = $(event.target).attr("rel");
	openSoftPopup(event,glossaryWords[glossaryId]["title"], glossaryWords[glossaryId]["description"],$);
	return false;
}

function openSoftPopup(event, glossaryTitle, glossaryDescription) {

	var mySoftPopup = $("#"+softPopupId);
	
	if (mySoftPopup.length==0) {
		$("body").append("<div id=\""+softPopupId+"\" style=\"display:none;\"></div>");
		mySoftPopup = $("#"+softPopupId);
	}
	
	closeSoftPopup($);
	
	mySoftPopup.html("<div class=\"borderTop\"></div><div class=\"head\"><h2>" + glossaryTitle + "</h2><a href=\"javascript:closeSoftPopup();\" class=\"close\"></a></div><div class=\"content\">"+glossaryDescription+"</div></div><div class=\"borderBottom\"></div>");
	mySoftPopup.addClass(softPopupClassName);
	mySoftPopup.css("position","absolute");

	if(mySoftPopup.find(".head").css("padding-left")!="10px"){
		mySoftPopup.css("left",(event.pageX)+"px");
		mySoftPopup.css("top",(event.pageY-mySoftPopup.outerHeight()-5)+"px");
	}
	else{
		mySoftPopup.css("left",(event.pageX)+"px");
		mySoftPopup.css("top",(event.pageY-mySoftPopup.outerHeight()-10)+"px");
	}

	mySoftPopup.css("display","block");
	mySoftPopup.click(closeSoftPopup);
	$(document).click(closeSoftPopup);
}

function closeSoftPopup() {
	$ = jQuery;
	if ($("#"+softPopupId).length>0) {
		$("#"+softPopupId).css("display","none");
		$("#"+softPopupId).html("");
		$("#"+softPopupId).removeClass(softPopupClassName);
	}
}