/*--------------------------------------------------------------------
JAVASCRIPT "tooltips" - Portal da Juventude

Version: 	1.0 - 2006/2007
author: 	Burocratik (alexandre gomes)
email: 		alex@burocratik.com
website: 	http://www.burocratik.com
-----------------------------------------------------------------------*/

/* =ESTILOS PARA AS TOOLTIPS
-----------------------------------------------------------------------*/
var W3CDOM = (document.getElementsByTagName && document.createElement);
if (W3CDOM){
	var link = document.createElement('link');
	link.setAttribute("rel", "stylesheet");
	link.setAttribute("type", "text/css");
	link.setAttribute("href", "../Style/pousada-tooltips-js.css");
	link.setAttribute("media", "screen");
	document.getElementsByTagName("head")[0].appendChild(link);
}


/* =BLOCO TOOLTIPS TABELA
-----------------------------------------------------------------------*/
function iniciarTooltips() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	var linkT = getElementsByClassName(document, "div", "linkTool");
	for (var i=0; i<linkT.length; i++ ) {
		//Hack para ie6 e ie7 bug com zindex
		linkT[i].style.zIndex=500-i;
		//
  	var sectionId = linkT[i].getAttribute("id").split("L")[1];
    if (!document.getElementById(sectionId)) continue;
		linkT[i].destination = sectionId;
    linkT[i].onmouseover = linkT[i].onfocus = function() {
			var elem = document.getElementById(this.destination);
			var largura = parseInt(qualStyle(this,"width"));
			var altura = parseInt(qualStyle(this,"height"));
			elem.style.zIndex="1000";
			elem.style.position = "absolute";
			elem.style.left = largura-150 +"px";
			elem.style.top = altura+2 +"px";
    } 
		linkT[i].onmouseout = linkT[i].onblur = function() {
			var elem = document.getElementById(this.destination);
			elem.style.left = "-9999px";
			elem.style.top = "-9999px";
  	} 
	}
}

//Sacar Estilos
function qualStyle(element, styleProperty){
  var computedStyle = null;
  if (typeof element.currentStyle != "undefined"){
    computedStyle = element.currentStyle;
  }else{
    computedStyle = document.defaultView.getComputedStyle(element, null);
  }
  return computedStyle[styleProperty];
}

/* =BLOCO TOOLTIPS SERVICOS
-----------------------------------------------------------------------*/
function iniciarServicos() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	var linkS = getElementsByClassName(document, "li", "toolServ");
	for (var i=0; i<linkS.length; i++ ) {
		//Hack para ie6 e ie7 bug com zindex
		linkS[i].style.zIndex=500-i;
		//
  	var sectionId = linkS[i].getAttribute("id").split("L")[1];
    if (!document.getElementById(sectionId)) continue;
		linkS[i].destination = sectionId;
    linkS[i].onmouseover = linkS[i].onfocus = function() {
			var elem = document.getElementById(this.destination);
			elem.style.zIndex="1000";
			elem.style.position = "absolute";
			elem.style.left = "-128px";
			elem.style.top = "29px";
    } 
		linkS[i].onmouseout = linkS[i].onblur = function() {
			var elem = document.getElementById(this.destination);
			elem.style.left = "-9999px";
			elem.style.top = "-9999px";
  	} 
	}
}


/* =Preparar Eventos
-----------------------------------------------------------------------*/
addLoadEvent(iniciarTooltips);
addLoadEvent(iniciarServicos);