﻿ //<!--
//	ISN Tooltips
//	Created By: Denis Tsai
//	Created On: 06/19/2006
//	
//	Usage:
//	
//	Put any one of the following inside an event handler (e.g. onMouseOver, onMouseOut)
//	
//	showTooltip(sMsg)
//		- shows a tooltip with sMsg next to mouse pointer
//	showTooltipTR(sMsg)
//		- shows a tooltip with sMsg on top right of the screen
//	hideTooltip()
//		- hides the tooltip
//-->
	
		
	function getContentLength(sHTML)
	{
	    var subtractCount = 0 ;
	    var inHTML = false ;
	    var i
	    for (i = 0; i < sHTML.length; i++)
	    {
	        if (sHTML.charAt(i)=="<"){
	            inHTML=true ;
	        }
	        
	        if (inHTML){
               subtractCount++ ;
            }

	        if (sHTML.charAt(i)==">") {
	            inHTML=false ;
	        }
	      //  alert(sHTML.charAt(i));
	       
	        
	    }   
	    // alert(sHTML.length - subtractCount);
	    return sHTML.length-subtractCount ;
	}
		
	function showTooltip(sMsg)
	{

        var isnTooltipFrame = document.getElementById('isnTooltip');
        var isnTooltipTable = document.getElementById('isnTooltipTable');
        var isnTooltipText = document.getElementById('isnTooltipText');
        
	    var msgLength=getContentLength(sMsg);
		if (msgLength >= 40) 
		{
			isnTooltipTable.width=isnTooltipMaxWidth;
		}
		else
		{
			isnTooltipTable.width="";
		}
		isnTooltipText.innerHTML = sMsg;		
		topPos = yMousePos - (20 * (Math.floor(msgLength / 40) + 1)) - 5
        
        topPos = topPos + document.documentElement.scrollTop; 
        
		if (topPos < document.documentElement.scrollTop)
		{
			topPos = document.documentElement.scrollTop ;
		}
		isnTooltipFrame.style.top = topPos ;
		isnTooltipFrame.style.left = xMousePos + 5 ;
		isnTooltipFrame.style.filter = "alpha(opacity=0)"
		isnTooltipFrame.style.visibility = 'visible';
		isnTooltipFrame.style.display = 'inline' ;
			
		setOpacity('isnTooltip', 0, 100, 300);
	}
		
	function showTooltipTR(sMsg)
	{
        var isnTooltipFrame = document.getElementById('isnTooltip');
        var isnTooltipTable = document.getElementById('isnTooltipTable');
        var isnTooltipText = document.getElementById('isnTooltipText');
	    var msgLength=getContentLength(sMsg);
		if (msgLength >= 40) 
		{
			isnTooltipTable.width=isnTooltipMaxWidth;
			xAdjust = 40 * 6 + 20
		}
		else
		{
			isnTooltipTable.width="";
			xAdjust = ((msgLength % 40) * 6) + 20
		}
		isnTooltipText.innerHTML = sMsg;
		isnTooltipFrame.style.top = 5 + document.documentElement.scrollTop
		isnTooltipFrame.style.left = xMousePosMax - xAdjust
		
		isnTooltipFrame.style.filter = "alpha(opacity=0)"
		isnTooltipFrame.style.visibility = 'visible';
		isnTooltipFrame.style.display = 'inline' ;
			
		setOpacity('isnTooltip', 0, 100, 300);
	}
	
	// following added by Saks on 3/21/07
	// BRC = Bottom Right of Cursor
	function showTooltipBRC(sMsg)
	{

        var isnTooltipFrame = document.getElementById('isnTooltip');
        var isnTooltipTable = document.getElementById('isnTooltipTable');
        var isnTooltipText = document.getElementById('isnTooltipText');
        
	    var msgLength=getContentLength(sMsg);
		if (msgLength >= 40) 
		{
			isnTooltipTable.width=isnTooltipMaxWidth;
		}
		else
		{
			isnTooltipTable.width="";
		}
		isnTooltipText.innerHTML = sMsg;		
		//topPos = yMousePos + document.documentElement.scrollTop + 5
		topPos = yMousePos + 5

		/*if (topPos < document.documentElement.scrollTop)
		{
			topPos = document.documentElement.scrollTop ;
		}*/
		isnTooltipFrame.style.top = topPos ;
		isnTooltipFrame.style.left = xMousePos + 5;
		isnTooltipFrame.style.opacity = 0;
		isnTooltipFrame.style.filter = "alpha(opacity=0)"
		isnTooltipFrame.style.visibility = 'visible';
		isnTooltipFrame.style.display = 'inline' ;
			
		setOpacity('isnTooltip', 0, 100, 300);
				
	}
	
	function hideTooltip() {
        var isnTooltipFrame = document.getElementById('isnTooltip');
		isnTooltipFrame.style.visibility = 'hidden'
		isnTooltipFrame.style.display = 'none'		
	}	
	 
    function setOpacity(divID, opacStart, opacEnd, millisec) { 
        var speed = Math.round(millisec / 100); 
        var timer = 0; 

        if(opacStart > opacEnd) { 
            for(i = opacStart; i >= opacEnd; i--) { 
                setTimeout("changeOpac(" + i + ",'" + divID + "')",(timer * speed)); 
                timer++; 
            } 
        } else if(opacStart < opacEnd) { 
            for(i = opacStart; i <= opacEnd; i++) 
                { 
                setTimeout("changeOpac(" + i + ",'" + divID + "')",(timer * speed)); 
                timer++; 
            } 
        } 
    } 

    function changeOpac(opacity, id) { 
        var object = document.getElementById(id);;
        object.style.opacity = (opacity / 100); 
        object.style.filter = "alpha(opacity=" + opacity + ")"; 
    }
    
	function captureMousePosition(e) {
		if (document.layers) {
			// When the page scrolls in Netscape, the event's mouse position
			// reflects the absolute position on the screen. innerHight/Width
			// is the position from the top/left of the screen that the user is
			// looking at. pageX/YOffset is the amount that the user has
			// scrolled into the page. So the values will be in relation to
			// each other as the total offsets into the page, no matter if
			// the user has scrolled or not.
			xMousePos = e.pageX;
			yMousePos = e.pageY;
			xMousePosMax = window.innerWidth+window.pageXOffset;
			yMousePosMax = window.innerHeight+window.pageYOffset;
		} else if (document.all) {
			// When the page scrolls in IE, the event's mouse position
			// reflects the position from the top/left of the screen the
			// user is looking at. scrollLeft/Top is the amount the user
			// has scrolled into the page. clientWidth/Height is the height/
			// width of the current page the user is looking at. So, to be
			// consistent with Netscape (above), add the scroll offsets to
			// both so we end up with an absolute value on the page, no
			// matter if the user has scrolled or not.
			xMousePos = window.event.x+document.body.scrollLeft;
			yMousePos = window.event.y+document.body.scrollTop;
			xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
			yMousePosMax = document.body.clientHeight+document.body.scrollTop;
		} else if (document.getElementById) {
			// Netscape 6 behaves the same as Netscape 4 in this regard
			xMousePos = e.pageX;
			yMousePos = e.pageY;
			xMousePosMax = window.innerWidth+window.pageXOffset;
			yMousePosMax = window.innerHeight+window.pageYOffset;
		}
	}