var tooltip=function(){
	var id = 'wshTolltip';
	var top = 3;
	var left = 3;
	var maxw = 290;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var shTolltip,ttTitle,ttCont,ttHeight;
	var ie = document.all ? true : false;
	
	return{
		show:function(arrayEl,ttWidth){
			var arrayEl=arrayEl.split("::");
			var elTitle = arrayEl[1];
			var elBody = arrayEl[0];
		
			if(shTolltip == null){
				shTolltip = document.createElement('div');
				shTolltip.setAttribute('id',id);
				ttTitle = document.createElement('div');
				ttTitle.setAttribute('id',id + 'Title');
				ttCont = document.createElement('div');
				ttCont.setAttribute('id',id + 'Cont');

				shTolltip.appendChild(ttTitle);
				shTolltip.appendChild(ttCont);
				document.body.appendChild(shTolltip);
				shTolltip.style.opacity = 0;
				shTolltip.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			
			shTolltip.style.display = 'block';
			ttTitle.innerHTML = setTooltipTitles();
			ttCont.innerHTML = elBody;
			shTolltip.style.width = ttWidth ? ttWidth + 'px' : 'auto';
			
			function setTooltipTitles () {
				if (!elTitle) 
					return (" ");
				else 
					return (elTitle);
			}
			
			if(!ttWidth && ie){
				shTolltip.style.width = shTolltip.offsetWidth;
			}
			
			if(shTolltip.offsetWidth > maxw){shTolltip.style.width = maxw + 'px'}
			ttHeight = parseInt(shTolltip.offsetHeight) + top;
			clearInterval(shTolltip.timer);
			shTolltip.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			shTolltip.style.top = (u - ttHeight) + 'px';
			shTolltip.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				shTolltip.style.opacity = alpha * .01;
				shTolltip.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(shTolltip.timer);
				if(d == -1){shTolltip.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(shTolltip.timer);
			shTolltip.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();
