var tooltip = function(target){

target = document.getElementById(target);

var tooltipOver = function(){
this.onmouseover = null;
var copiedNode = document.getElementById(this.getAttribute("rel")).cloneNode(true);
var sticky = copiedNode.className;
copiedNode.className = "";
var tooltipNode = document.createElement("div");
tooltipNode.className = "toolTip";
this.style.zIndex = 2;

if(sticky == "true"){
var closeButton = document.createElement("div");
closeButton.className = "closeButton";
closeButton.onclick = closeToolTip;
tooltipNode.appendChild(closeButton);
}else{
this.onmouseout = tooltipOut;
}

var divs = document.getElementsByTagName("div");
for(var i = 0; i<divs.length; i++){
if(divs[i].className == "toolTip"){
divs[i].parentNode.style.zIndex = 1;
divs[i].onmouseout = null;
divs[i].parentNode.onmouseover = tooltipOver;
divs[i].parentNode.removeChild(divs[i]);
}
}

tooltipNode.appendChild(copiedNode);
this.appendChild(tooltipNode);

}

var tooltipOut = function(){
this.onmouseout = null;
this.removeChild(this.getElementsByTagName("div")[0]);
this.style.zIndex = 1;
this.onmouseover = tooltipOver;
}

var closeToolTip = function(){
this.onclick = null;
this.parentNode.style.zIndex = 1;
this.parentNode.parentNode.onmouseover = tooltipOver;
this.parentNode.parentNode.removeChild(this.parentNode);

}

target.onmouseover = tooltipOver;

}




window.onload = function(){
var createTooltip = tooltip("stickyExample");
var createTooltip = tooltip("normalExample");
}


