var tooltip=function(){
	var id = 'tt';
	var top = 0;
	var left = 0;
	var maxw = 400;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt, brtop, b1top,b2top,b3top,b4top,brbottom, b1bottom,b2bottom,b3bottom,b4bottom, c, h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				
				brtop = document.createElement('b')
				brtop.className = 'rtop';
				
				b1top = document.createElement('b')
				b1top.className = 't_r1';
				
				b2top = document.createElement('b')
				b2top.className = 't_r2';
				
				b3top = document.createElement('b')
				b3top.className = 't_r3';
				
				b4top = document.createElement('b')
				b4top.className = 't_r4';
				
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				
				brbottom = document.createElement('b')
				brbottom.className = 'rbottom';
				
				b4bottom = document.createElement('b')
				b4bottom.className = 'b_r4';
				
				b3bottom = document.createElement('b')
				b3bottom.className = 'b_r3';
			
				b2bottom = document.createElement('b')
				b2bottom.className = 'b_r2';
				
				b1bottom = document.createElement('b')
				b1bottom.className = 'b_r1';
				
				tt.appendChild(brtop);
				
				brtop.appendChild(b1top);
				brtop.appendChild(b2top);
				brtop.appendChild(b3top);
				brtop.appendChild(b4top);
				
				tt.appendChild(c);
				tt.appendChild(brbottom);
				
				brbottom.appendChild(b4bottom);
				brbottom.appendChild(b3bottom);
				brbottom.appendChild(b2bottom);
				brbottom.appendChild(b1bottom);
			
				document.body.appendChild(tt);
			
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				
				document.onmousemove = this.pos;
			}
			
			tt.style.display = 'block';
			c.innerHTML = "<span>" + v + "</span>";
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				tt.style.width = tt.offsetWidth;
			}
			
			
			if(tt.offsetWidth > maxw){
					tt.style.width = maxw + 'px'
			}
			
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			
			tt.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;
			tt.style.top = (u - h + top) + 'px';
			tt.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);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();