/*//////////////////////////////////////////
Author: Jamie Dixon
Function: Grabs the title attribute text from all anchor elements inside a specified parent element
		  and creates a tooltip under the anchors.
Created: 27/07/2007
Notes: The container for the tooltip has an ID of "MenuFunction". This can be styled using an external stylesheet etc.
//////////////////////////////////////////*/

function MenuTooltip(strContainerId)
   {
	   	var objMenu = document.getElementById(strContainerId);
		var objAnchors = objMenu.getElementsByTagName("a");
		var strTitle;
		var strAlt;
		this.menu = objMenu
		for(i = 0; i < objAnchors.length; i++)
		{
			strTitle = objAnchors[i].getAttribute("title");
			if(strTitle == null){objAnchors[i].setAttribute("title","enter me");} // Set default link title if non present
			addEvent(objAnchors[i],"mouseover",showTitlePopout);
			addEvent(objAnchors[i],"mouseout",hideTitlePopout); // reset suppressed title attribute onmouseout
		}
	function showTitlePopout() // Private method showTitlePopout which displays the tooltip
   {
	var objPara = document.getElementById("MenuFunction")
	if(objPara == null){objPara = document.createElement("p");} // check if para exists and if not, create one.
	
	objPara.setAttribute("id","MenuFunction");
	objMenu.appendChild(objPara);
	
   	var objPara = document.getElementById("MenuFunction");
	objPara.style.display = "block";
	strTitle = this.getAttribute("title")
	strAlt = this.getElementsByTagName('img')[0].getAttribute("alt")
	var objTN = document.createTextNode(strTitle);
	this.setAttribute("title",""); // suppress title attribute
	
	if(document.all){this.getElementsByTagName('img')[0].setAttribute("alt","")} // If IE repress ALT attribure also.
	
	objPara.appendChild(objTN);
   }
   
   function hideTitlePopout() // Private method hideTitlePopout which hides the tooltip
   {
   var objPara = document.getElementById("MenuFunction");
   while(objPara.firstChild)
   {
   	objPara.removeChild(objPara.firstChild);
   }
   this.setAttribute("title",strTitle);
 
  	if(document.all){this.getElementsByTagName('img')[0].setAttribute("alt",strAlt)} // If IE de-repress ALT attribure also.

objPara.style.display = "none";
   } 
   
   } // end MenuTooltip class
   
addEvent(window,"load",function(){var objMenuTooltip = new MenuTooltip("EzSite-Link");});