﻿	var lastTooltip =null;
    
    showTooltip = function (strTitle,strText,strHelpText,strhelpImage,strmainImage) {   
    if (lastTooltip==null){                                                               
           var newDiv = document.createElement("div");           
           newDiv.className='newDivClass';
           
           var title = document.createElement("span"); 
		   title.className='TitleClass';
		   
           var titleText = document.createTextNode(strTitle);
           title.appendChild(titleText);    

           var mainParagraph = document.createElement("p");           
		   mainParagraph.className='mainParagraphClass';
            
           if (strmainImage) {
               var mainImg = document.createElement("img");    
               mainImg.setAttribute("src",strmainImage);
               mainImg.className='MainImageClass';          
               mainParagraph.appendChild(mainImg);  
           }
           
           var mainText = document.createTextNode(strText);            
           mainParagraph.appendChild(mainText);             
           newDiv.appendChild(title);
           newDiv.appendChild(mainParagraph);
           
           if (strHelpText) {
               var horLine = document.createElement("hr"); 
               horLine.style.width='96%';
		       horLine.style.clear='both';    
                        
               var helpDiv = document.createElement("div");   
               helpDiv.style.styleFloat='left';
		       helpDiv.style.cssFloat='left';   
		       helpDiv.style.clear='both';
		       helpDiv.style.paddingLeft='6px';     
		       helpDiv.style.height='24px';     
               
               if (strhelpImage) {
                   var helpImg = document.createElement("img");    
                   helpImg.setAttribute("src",strhelpImage);
                   helpImg.style.marginRight='8px';
                   helpImg.style.verticalAlign='middle';
                   helpDiv.appendChild(helpImg);
               }

               var helpText = document.createTextNode(strHelpText);                           
               helpDiv.appendChild(helpText);  
               newDiv.appendChild(horLine);
               newDiv.appendChild(helpDiv);                         
           }                    
                                                                        
            lastTooltip=newDiv;    
            if (document.addEventListener) document.addEventListener("mousemove",moveTooltip, true);
            if (document.attachEvent) document.attachEvent("onmousemove",moveTooltip);  
            
            var bodyRef = document.getElementsByTagName("body").item(0);
            bodyRef.appendChild(newDiv);                    
            }                                       
        };
        
       moveTooltip = function (e) {
       if (lastTooltip){
               if (document.all)
                    e = event;
               if (e.target)
                    sourceEl = e.target;
               else if (e.srcElement)
                    sourceEl = e.srcElement;
                      
               var coors=findPos(sourceEl);
               var positionLeft = e.clientX;
               var positionTop  =coors[1] + sourceEl.clientHeight + 1;
               
               lastTooltip.style.top=positionTop+'px';
               lastTooltip.style.left=positionLeft+'px';
               lastTooltip.style.visibility='visible';
           }
       }
    
       hideTooltip = function () {              
            var bodyRef = document.getElementsByTagName("body").item(0);
            if (lastTooltip) bodyRef.removeChild(lastTooltip);
            lastTooltip=null;
       };
       
       function findPos(obj) {
	        var curleft = curtop = 0;
	        if (obj.offsetParent) {
		        curleft = obj.offsetLeft
		        curtop = obj.offsetTop
		        while (obj = obj.offsetParent) {
			        curleft += obj.offsetLeft
			        curtop += obj.offsetTop
		        }
	        }
	        return [curleft,curtop];
        }
