// JavaScript Document

ToolTip = function(oConfig){
	//
	var z 	= 1;
	var css = '';
	var msg = '';
	//
	if(oConfig && oConfig.zIndex) z = oConfig.zIndex-1;
	if(oConfig && oConfig.css) css = oConfig.css;
	if(oConfig && oConfig.mensaje) msg = oConfig.mensaje;
	
	var oT = this;
	//
	this.cont = document.createElement('div');
	this.cont.style.position = 'absolute';
	this.cont.style.display = 'none';
	this.cont.style.zIndex = z;
	this.cont.unselectable = true;
	document.body.insertBefore(this.cont, document.body.firstChild);
	//
	this.iframe = document.createElement('iframe');
	this.iframe.style.position = 'absolute';
	this.iframe.style.zIndex = z;
	this.iframe.style.width = 0;
	this.iframe.border = 0;
	this.iframe.scrolling = 'no';
	this.iframe.frameBorder = 0;
	this.iframe.disabled = true;
	this.cont.appendChild(this.iframe);
	//
	this.tip = document.createElement('div');
	this.tip.style.position = 'relative';
	this.tip.style.zIndex = z + 1;
	this.tip.style.width = 0;
	if(css) this.tip.className = css;
	if(msg) this.tip.innerHTML = msg;
	this.tip.unselectable = true;
	this.cont.appendChild(this.tip);
	this.iframe.style.left = 0+"px";
	this.tip.style.left = 0+"px";
	
	//
	this.ocultar = function(){
		this.cont.style.display = 'none';
		if(this.ele)RemEvent(this.ele,"mousemove",this.controlarUbicacion.closure(this));
	}
	this.mostrar = function(event,msg, css){
		//
		this.mensaje(msg);
		if(css) this.tip.className = css;
		//
		this.cont.style.visibility = "hidden";
		this.cont.style.display = 'block';
		this.iframe.style.width = 0;
		this.iframe.style.height = 0;
		
		this.tip.style.width = 'auto';
		this.tip.style.height = 'auto';
		//
		//this.controlarTamanios();
		//this.controlarUbicacion();
		if(Nav.esIE){
			this.ele = window.event.srcElement;
		}
		else{
			this.ele = event.target;		
		}
		RemEvent(this.ele,"mousemove",this.controlarUbicacion.closure(this));
		AddEvent(this.ele,"mousemove",this.controlarUbicacion.closure(this));
		if(Nav.esIE){
			window.event.cancelBubble = true;
			window.event.returnValue = false;			
		}
		else event.preventDefault();
		this.cont.style.visibility = "visible";	
	}
	this.mensaje = function(msg){
		if(msg) this.tip.innerHTML = msg;
	}
	this.controlarUbicacion = function(event){
		
		if(Nav.esIE){
			if(event){
				this.cont.style.top  = (event.clientY + document.documentElement.scrollTop+ 19) + 'px';
				if(event.clientX + this.cont.offsetWidth - 2 + document.documentElement.scrollLeft  < document.body.offsetWidth){
					this.cont.style.left = (event.clientX - 2 + document.documentElement.scrollLeft) + 'px';
				}
				else{
					this.cont.style.left = (event.clientX + document.documentElement.scrollLeft + 10 - this.cont.offsetWidth) + 'px';

				}
				window.event.cancelBubble = true;
				window.event.returnValue = false;		
			}
		}
		else{
			if(event){
				this.cont.style.top  = (event.clientY + window.scrollY+ 19) + 'px';
				if(event.clientX + this.cont.offsetWidth - 2 + window.scrollX  < document.body.offsetWidth){
					this.cont.style.left = (event.clientX - 2 + window.scrollX) + 'px';
				}
				else{
					this.cont.style.left = (event.clientX + window.scrollX + 10 - this.cont.offsetWidth) + 'px';
				}
			
				event.preventDefault();
			}
		}
	}
	this.controlarTamanios = function(){
		//
		this.iframe.style.width = (this.tip.offsetWidth + 2) + 'px';
		this.iframe.style.height = (this.tip.offsetHeight + 2) + 'px';
		
		this.tip.style.width = (this.tip.offsetWidth - 4) + 'px';
		this.tip.style.height = (this.tip.offsetHeight - 4) + 'px';

	}
	
	//this.cont.attachEvent('onmouseover', this.ocultar.closure(this));
}

