function tooltip(options) {
	/*
		Propriedades
			target			o objeto que vai ser controlado pelo tooltip
			text			define o texto que aparecerá quando o mouse passar por cima do objeto
			width			tamanho do objeto, usar css
			height			tamanho do objeto, usar css
			font			font do objeto, usar css, ex.: Red 8pt Arial
			background		cor de fundo do objeto
		Métodos
			refresh			atualiza os dados obtidos de uma página através da propriedade request
	*/
	var _this = this;
	this.text = null;
	
	var ce = new String();  // c[reation ]e[rros]
	var popup;
	
	if (options != null) {
		this.target = options["target"];
			if (this.target == null)
				ce += "Propriedade requerida 'target' faltando.\n";
			else if (document.getElementById(this.target) == null)
				ce += "'target' não é id de um objeto\n";
			else {
				this.target = document.getElementById(this.target);  // converte em objeto real
				try {  // para IE
					this.target.attachEvent("onmousemove", target_onmousemove);
					this.target.attachEvent("onmouseout", target_onmouseout);
				} catch (e) { }
				try {  // para mozilla
					this.target.addEventListener("mousemove", target_onmousemove, false);
					this.target.addEventListener("mouseout", target_onmouseout, false);
				} catch (e) { }
			}
		this.width = options["width"];
			if (this.width == null)
				ce += "Propriedade requerida 'width' faltando.\n";
			else if (/^\d+(px|pt|pc|mm|cm|in|em|ex|%)$/.exec(this.width) == null)
				ce += "Formato inválido da propriedade 'width'.\n";
		this.height = options["height"];
			if (this.height == null)
				ce += "Propriedade requerida 'height' faltando.\n";
			else if (/^\d+(px|pt|pc|mm|cm|in|em|ex|%)$/.exec(this.height) == null)
				ce += "Formato inválido da propriedade 'height'.\n";
		this.text = options["text"];
		this.font = options["font"];
			if (this.font == null)
				this.font = "8pt Arial";
			else if (/^\d+(px|pt|pc|mm|cm|in|em|ex) +\w+$/.exec(this.font) == null)
				ce += "Formato inválido da propriedade 'font'.\n";
		this.background = options["background"];
			if (this.background == null)
				this.background = "LemonChiffon";
		this.className = options["className"];
		this.refresh = function() {
			request2text(this.request);
		}
		
		if (ce.length != 0) {
			ce = "tooltip: Erros de criação:\n" + ce;
			alert(ce);
		} else
			createpopup();
	}
	
	/*Eventos*/
		function target_onmousemove() {
			if (_this.text == "")  return;
			
			popup.innerHTML = _this.text;
			positioning();
			popup.style.visibility = "visible";
		}
		
		function target_onmouseout() {
			popup.style.visibility = "hidden";
		}
	/*/Eventos*/
	
	function createpopup() { 
		popup = document.createElement("DIV");
		
		popup.style.padding = "2px 4px";
		popup.style.font = _this.font;
		popup.style.background = _this.background;
		popup.className = _this.className;
		popup.style.position = "absolute";
		popup.style.display = "block";
		popup.style.visibility = "hidden";
		popup.style.border = "2px solid Silver";
		popup.style.width = _this.width;
		popup.style.height = _this.height;
		_this.target.parentNode.insertBefore(popup, null);
		positioning();
	}
	
	function positioning() {
		var SCROLL_BAR = 18;  // tamanho da barra de scroll
		var SPC = 5;  // spacing
		
		if (middlePosH(_this.target) <= 0)
			popup.style.left = _this.target.offsetLeft + _this.target.offsetWidth + SPC;
		else
			popup.style.left = _this.target.offsetLeft - popup.offsetWidth - SPC;

		if (middlePosV(_this.target) <= 0)
			popup.style.top = _this.target.offsetTop + _this.target.offsetHeight + SPC;
		else
			popup.style.top = _this.target.offsetTop - popup.offsetHeight - SPC;
		
		if (popup.offsetLeft - document.body.scrollLeft < 0)  popup.style.left = document.body.scrollLeft + SPC;
		if (popup.offsetTop - document.body.scrollTop < 0)  popup.style.top = document.body.scrollTop + SPC;
		if (popup.offsetLeft + popup.offsetWidth + SCROLL_BAR > document.body.offsetWidth)  popup.style.left = document.body.clientWidth - popup.offsetWidth + document.body.scrollLeft - SCROLL_BAR + SPC;
		if (popup.offsetTop + popup.offsetHeight + SCROLL_BAR > document.body.offsetHeight)  popup.style.top = document.body.clientHeight - popup.offsetHeight + document.body.scrollTop - SCROLL_BAR + SPC;
	}
	
	function middlePosH(obj) {
		/* 
			Verifica se um objeto está antes, no meio ou após a metade do documento (Horizontal)
			Retorno:
				-1: Antes do meio;
				 0: Meio;
				 1: Após o meio;
		*/
		var centerOfObject = obj.offsetLeft + obj.offsetWidth / 2;
		var centerOfDocument = (document.body.clientWidth - document.body.scrollLeft) / 2;
		if (centerOfObject == centerOfDocument)
			return  0;
		else if (centerOfObject < centerOfDocument)
			return -1;
		else if (centerOfObject > centerOfDocument)
			return  1;
	}

	function middlePosV(obj) {
		/* 
			Verifica se um objeto está antes, no meio ou após a metade do documento (Vertical)
			Retorno:
				-1: Antes do meio;
				 0: Meio;
				 1: Após o meio;
		*/
		var centerOfObject = obj.offsetTop + obj.offsetHeight / 2;
		var centerOfDocument = (document.body.clientHeight - document.body.scrollTop) / 2;
		if (centerOfObject == centerOfDocument)
			return  0;
		else if (centerOfObject < centerOfDocument)
			return -1;
		else if (centerOfObject > centerOfDocument)
			return  1;
	}
}


function createTarget(id) {
	document.write('\
		<DIV id="' + id + '" style="height: 16px; width: 16px; overflow: hidden; display: inline; cursor: help; position: absolute">\
			<DIV style="width: 16px; height: 16px" align="center"><FONT style="font: 60px Arial; position: relative; left: -3px; top: -25px">&bull;</FONT></DIV>\
			<DIV style="width: 16px; height: 16px" align="center"><FONT style="color: White; font: 13px Arial Black; position: relative; top: -16px; _top: -68px">?</FONT></DIV>\
		</DIV>\
		&nbsp;&nbsp;&nbsp;\
	');
}

