//////////////////////////////////////////////////////////////////
// qTip - CSS Tool Tips - by Craig Erskine
// http://qrayg.com | http://solardreamstudios.com
//
// Inspired by code from Travis Beckham
// http://www.squidfingers.com | http://www.podlob.com
//////////////////////////////////////////////////////////////////


// version modificada por Rene Lopez Caballero
// 14 de abril de 2006
// para que use un div, creado previamente como tooltip

//There's No need to edit anything below this line//
tooltip = {
	name : "qTip",
	offsetX : -30,
	offsetY : 25,
	tip : null,
	qTips : {}
}

tooltip.add = function ( elementID,tipContainerID ) {
	this.qTips[elementID] = tipContainerID;
}

tooltip.init = function () {
	if (!document.getElementById) return;
	
	var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
	
	var tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
	tipContainer.setAttribute("id", this.name);
	document.getElementsByTagName("body").item(0).appendChild(tipContainer);
	
	// i dont like this, but ie, dont works fine if i don do this, weid?
	this.tip = tipContainer;
	
	document.onmousemove = function (evt) {tooltip.move (evt)};
	
	tooltip.setLinks();
}
// here i create a function so i can add tooltips after the init function has been looaded
tooltip.setLinks = function( property ) {
	for( var property in this.qTips) {
		var tipContainer = $( this.qTips[property] );
		tipContainer.style.position= 'absolute';
		tipContainer.style.zIndex= '1000';
		tipContainer.style.display= 'none';
		
		var a = $( property );
		a.title = '';
		a.qTipContainer = this.qTips[property];
		//a.onmouseover = function() {tooltip.show(this.qTipContainer)};
		a.observe('mouseover', function() {  
			tooltip.show(this.qTipContainer);
		});  
		a.onmouseout = function() {tooltip.hide(this.qTipContainer)};
	}
}

tooltip.move = function (evt) {
	if( !this.tip ) 
		return;
	var x=0, y=0;
	if (document.all) {//IE
		x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		x += window.event.clientX;
		y += window.event.clientY;
	} else {//Good Browsers
		x = evt.pageX;
		y = evt.pageY;
	}
	this.tip.style.left = (x + this.offsetX) + "px";
	this.tip.style.top = (y + this.offsetY) + "px";
}

tooltip.show = function (container) {
	this.tip = $( container );
	this.tip.style.display = "block";
}

tooltip.hide = function ( container ) {
	// if i set up to null i dont know why ie, make some weird stuff, so i always have some layer assigned
	//this.tip = null;
	$( container ).style.display = "none";
}

if( !qTipOnLoad ){
	var qTipOnLoad = window.onload;
	window.onload = function () {
		if( qTipOnLoad )
			qTipOnLoad();
		tooltip.init();
	}
}

