var tipOn = false;

function tip(obj, testo){
	if(!tipOn){
		//tipOn = true;
		//var testo = obj.offsetParent.firstChild.innerHTML;
		var x = document.getElementById("tip_" + obj.id);
		if(!x){
		
			var d = document.createElement("diV");
			
			
			
			d.id = "tip_" + obj.id;
			d.className = "divtip";
			d.innerHTML = testo;
			document.body.appendChild(d);
					
			var scanObj = obj;
			var lleft = 0;
			var ttop = 0;
			while (scanObj){
				//alert(scanObj);
				lleft += scanObj.offsetLeft;
				ttop += scanObj.offsetTop;
				scanObj = scanObj.offsetParent;
			}
			
			d.style.left = (lleft - 82) + 'px';
			d.style.top = (ttop - 30) + 'px';
			
			d.style.width = '185px';
			//d.style.height = '78px';
			
			//d.style.display = "block";
			addMethod(d);
			d.animationFade.show();
		}
		
	}
}

function tipOff(obj){
	d = document.getElementById("tip_" + obj.id);
	//document.body.removeChild(d);
	d.animationFade.hide();
}


function addMethod(o){
	var obj = o;//document.getElementById(str);
		
	obj.animationFade = new aoc();
	
	var abort = false;
	
	function aoc(){
		var fadeInSpeed = 8;
		var fadeOutSpeed = 8;
		var objVisible = false;
		var moving = false;
		var targetObj = obj;
		var fadeVal = 0;
	
		//this.setTargetObj = setTargetObj;
		this.show = show;
		this.hide = hide;
		
		this.getObjVisible = getObjVisible;
		this.getMoving = getMoving;
	
		function setTargetObj(val)
		{
			targetObj = val;
		}
		function getObjVisible(){
			return objVisible;
		}
		function getMoving(){
			return moving;
		}

		
		function show(){
			if(!moving){
				targetObj.style.display='block';
	
				targetObj.style.opacity = 0;
				targetObj.style.filter = 'alpha(opacity=0)';
				
				objVisible = true;
				moving = true;
				fadeInDiv();
			}
		}
		
		function fadeInDiv(){
			fadeVal += fadeInSpeed;
			if(fadeVal>100){
				fadeVal=100;
			}
			targetObj.style.opacity = fadeVal/100;
			targetObj.style.filter = 'alpha(opacity=' + fadeVal + ')';
			if(fadeVal<100 && !abort){
				setTimeout(fadeInDiv,20);
			}else{
				targetObj.style.opacity = 99;
				targetObj.style.filter = 'alpha(opacity=,99)';
				moving = false;
			}
		}
		
		
		function hide(){
			abort = true;
			//if(!moving){
				moving=true;
				fadeOutDiv();
			//}
		}
		
		function fadeOutDiv(){
			fadeVal -= fadeOutSpeed;
			if(fadeVal<0){
				fadeVal=0;
			}
			targetObj.style.opacity = fadeVal/100;
			targetObj.style.filter = 'alpha(opacity=' + fadeVal + ')';
			if(fadeVal>0){
				setTimeout(fadeOutDiv,20);
			}else{
				//targetObj.style.display="none";
				tipOn = false;
				abort = false;
				document.body.removeChild(targetObj);
				moving = false;
			}
		}
	
	}
	
	
}