//**********************************************************************
// Tool Tips general functions
// Required:
// - onloadManager.js
// - getPosition.js
// Jeff Chew
//**********************************************************************

var tooltip = {
	text: '',
	
	init: function(){
		divLayer = document.createElement('div');
		divLayer.id = "TTlayer";
		document.body.appendChild(divLayer);
		
		var ttlayer = document.getElementById('TTlayer');
		ttlayer.style.display = 			'none';
		ttlayer.style.fontFamily = 			'Arial, Helvetica, Sans-serif';
		ttlayer.style.fontSize = 			'10px';
		ttlayer.style.color = 				'#203C70';
		ttlayer.style.position = 			'absolute';
		ttlayer.style.width = 				'150px';
		ttlayer.style.border = 				'2px solid #CEDEE7';
		ttlayer.style.padding = 			'6px';
		ttlayer.style.backgroundColor = 	'#EEEEEE';
		ttlayer.style.zIndex = 				'100';
		ttlayer.style.filter = 				'progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135)';
		if(navigator.userAgent.indexOf('MSIE') != -1){
			ttlayer.onmouseover = function(){tooltip.resetTimer()};
			ttlayer.onmouseout = function(){tooltip.startTimer()};
		}else{
			ttlayer.setAttribute('onmouseover','tooltip.resetTimer()');
			ttlayer.setAttribute('onmouseout','tooltip.startTimer()');
		}		
	},
	
	startTimer: function(){
		if(document.getElementById('TTlayer').style.display == 'block'){
			tooltip.hideTimeout = setTimeout('tooltip.hide()',1000);
		}
	},
	
	resetTimer: function(){
		if(tooltip.hideTimeout){
			clearTimeout(tooltip.hideTimeout);
		}
	},
	
	hide: function(){
		document.getElementById('TTlayer').innerHTML = "";
		document.getElementById('TTlayer').style.display = "none";
	},
	
	toggle: function(obj,text){
		try {
			var ttlayer = document.getElementById('TTlayer');
			if(ttlayer.style.display == 'block' && ttlayer.text == text){
				tooltip.hide();
			}else{
				tooltip.show(obj,text);
			}
		}catch(err){
		
		}
	},
	
	show: function(obj,text){
		try{
			var ttlayer = document.getElementById('TTlayer');
			ttlayer.style.visibility = 'hidden';
			ttlayer.style.display = 'block';
			ttlayer.text = text;
			ttlayer.innerHTML = ttlayer.text;
			/************************************************************************
			BEGIN BOOTSTRAP CHANGE - 04/03/2008
			***********************************************************************/

			if(getPosition.returnX(obj) > parseInt(ttlayer.style.width)){ 
				ttlayer.style.left = getPosition.returnX(obj) - ttlayer.offsetWidth + 15;
			} else { 
				ttlayer.style.left = getPosition.returnX(obj) - (ttlayer.offsetWidth / 2) - 15;
			}

			/************************************************************************
			END BOOTSTRAP CHANGE - 04/03/2008
			***********************************************************************/
			ttlayer.style.top = getPosition.returnY(obj) + 15; 
			
	
			ttlayer.style.visibility = '';
			ttlayer.style.display = "block";
		}catch(err){
		
		}
	},
/************************************************************************
BEGIN BOOTSTRAP CHANGE - 04/04/2008
***********************************************************************/
	alwaysShow: function(obj, tooltipName){
		try{

			var tooltip = document.getElementById(tooltipName);

			tooltip.style.display = 'none';
			tooltip.style.fontFamily = 'Arial, Helvetica, Sans-serif';
			tooltip.style.position = 'absolute';
			tooltip.style.zIndex = '100';
			tooltip.style.left = getPosition.returnX(obj);
			tooltip.style.top = getPosition.returnY(obj) - 30;
			tooltip.style.padding = '2px';

			tooltip.style.filter = 'progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135)';
			
			
			tooltip.style.border = '2px solid #CEDEE7';
			tooltip.style.backgroundColor = '#FFFFFF';
			tooltip.style.display = 'block'; 

		} catch(e) {}

	}

/************************************************************************
END BOOTSTRAP CHANGE - 04/04/2008
***********************************************************************/
}

onloadManager.addFunction('tooltip.init()');
