// JavaScript Document

//Fires "getElements" function when page loads
_spBodyOnLoadFunctionNames.push("getElements");

//Global vars
var keywordsArray = [];
var keywords = [];
var description = [];
var holder = [];

function getElements()
{
	//Test to see if the page has a hiddenContent container. If it doesn't then do nothing
	if(document.getElementById("hiddenContent") != null)
	{
		//get contents of hidden div. The div contains 
	   	var contentOfHiddenDiv = document.getElementById("hiddenContent").innerHTML;
	   	keywordsArray = contentOfHiddenDiv.split("}");
	   	for(i=0;i<keywordsArray.length-1; i++)
	   	{
		   	holder = keywordsArray[i].split("{");
		   	keywords[i] = holder[0];
		   	description[i] = holder[1];
	   	}
	   
	   	var allHTMLTags=document.getElementsByTagName("*");
		
		for (k=0; k<keywords.length; k++) {
			for (i=0; i<allHTMLTags.length; i++) {
				if (allHTMLTags[i].className=="courseBody") {
  				var originalContent = allHTMLTags[i].innerHTML;
  				var changedContent = originalContent.replace(keywords[k], "<span style='position:relative;'><div class='before' id='before_"+i+k+"'></div><div class='tipArrow tipGradFill' id='hiddenDiv_"+i+k+"' style='z-index:10; position:absolute;visibility:hidden; width:200px; top:20px; left:0px; background-color:#fef; padding:10px; border:solid 1px #faf';>"+description[k]+"</div><div class='after' id='after_"+i+k+"'></div><span style='border-bottom:dotted 1px #0079bc;position:relative; cursor:default;' onmouseout='hideTip("+i+k+")' onmouseover='showTip("+i+k+")'>"+keywords[k]+"</span></span>");
				allHTMLTags[i].innerHTML = changedContent;
				}
			}
		}

	}
}

function showTip(theIndex)
{
	document.getElementById('hiddenDiv_'+theIndex).style.visibility="visible";
	document.getElementById('before_'+theIndex).style.visibility="visible";
	document.getElementById('after_'+theIndex).style.visibility="visible";
}
function hideTip(theIndex)
{
	document.getElementById('hiddenDiv_'+theIndex).style.visibility="hidden";
	document.getElementById('before_'+theIndex).style.visibility="hidden";
	document.getElementById('after_'+theIndex).style.visibility="hidden";
}

