function val_num (cadea) {
	var aux ;
	return isNaN (aux = parseInt (cadea)) ? 0 : aux ;
}
function abs_pos (nodo) {
	var aux = nodo ;
	var aux2, aux3, aux4, aux5 ;
	var volta = { left:0, top:0 } ;
	while (aux != document.body && aux != null) {
		volta.left += aux.offsetLeft ;
		volta.top += aux.offsetTop ;
		//if (aux != nodo) {
			if (dojo.isIE) {
				volta.top += val_num (aux.currentStyle.borderTopWidth) ;//- val_num (aux.currentStyle.marginTop) ;
				volta.left += val_num (aux.currentStyle.borderLeftWidth) ;//- val_num (aux.currentStyle.marginTop) ;
			} else if (dojo.isWebKit)
				volta.top += val_num ((aux2 = document.defaultView.getComputedStyle (aux, null)).getPropertyValue ('border-top-width')) ;//- val_num (aux2.getPropertyValue ('margin-top')) ;*/
		//}
		aux = aux.offsetParent ;
	}
	return volta ;
}



var ie_hover = (function() {
	var aux ;
	var insts=[] ;	
	function over (e) {
		var aux = e.target ;
		var ul ;
		do {
			if (aux.nodeType == 1) {
				if (aux.nodeName == 'LI' || aux == this.menu) {
					if (aux.className.search ('ie_hover') >= 0 || (ul && this.ultimo == ul))
						break ;
					aux.className = aux.className.replace (/ ?ie_hover/, '')+' ie_hover' ;
				}
				if (! ul && aux.nodeName == 'UL') {
					ul = aux ;
				}
			}
			aux = aux.parentNode ;
		} while (aux != null && aux != document.body && aux != this.menu.parentNode) ;
		if (ul && ul != this.ultimo)
			this.ultimo = ul ;
	}
	function out (e) {
		var ultimo ;
		if (this.ultimo) {
			var aux = e.relatedTarget ;
			while (aux != null && aux != document.body && aux != this.menu.parentNode) {
				if (aux.nodeType == 1) {
					if (aux.className.search ('ie_hover') >= 0 || aux == this.ultimo) {
						ultimo = aux ;
						break ;
					}
				}
				aux = aux.parentNode ;
			}
			var aux = e.target ;
			do {
				if (aux.nodeType == 1) {
					if (aux == ultimo && this.ultimo)
						return ;
					if (aux.nodeName == 'LI' || aux == this.menu) {
						aux.className = aux.className.replace (/ ?ie_hover/, '') ;
						if (e.relatedTarget == null)							return ;
					} else if (aux == this.ultimo)
						delete this.ultimo ;
				}
				aux = aux.parentNode ;
			} while (aux != null && aux != document.body && aux != this.menu.parentNode) ;
		}
	}
	function __ie_hover (id, menu) {
		var inst = this ;
		this.id = id ;
		this.menu = menu ;
		this.over = over ;
		this.out = out ;
		dojo.connect (menu, 'mouseover', inst, 'over') ;
		dojo.connect (menu, 'mouseout', inst, 'out') ;
	}
	return function (menu) {
		if (typeof insts ['menu'] == "undefined") {
			if (typeof (aux = document.getElementById (menu)) == 'undefined')
				return false ;
			else
				insts ['menu'] = new __ie_hover (menu, aux) ;
		}
		return insts ['menu'] ;
	}
})() ;
var ie_hover_inst ;
dojo.addOnLoad (function() {
	ie_hover_inst = new ie_hover ('menu_base') ;
}) ;


		
			var desprazamento = (function() {
		function desprazando (e) {
			this.desprazar (e.currentTarget) ;
		}
		function desprazar (actual) {
			if (actual.getAttribute ('bloqueo') == 1) {
				actual.removeAttribute ('bloqueo') ;
				return ;
			}
			var porc = actual.scrollTop / (actual.scrollHeight - actual.offsetHeight) ;
			for (i in this.barras) {
				if (this.barras [i] != actual) {
					this.barras [i].setAttribute ('bloqueo', 1) ;
					this.barras [i].scrollTop = porc * (this.barras [i].scrollHeight - this.barras [i].offsetHeight  + parseInt (this.barras [i].getAttribute ('pad_corr')));
				}
			}
		}
		function actualizar() {
			var max=0 ;
			for (i=1 ; i< this.barras.length ; i++) {
			var aux  ;
aux=0 ;
				if (this.barras [i].scrollHeight + aux > max) {
					max = this.barras [i].scrollHeight + aux ;
				}
			}

			this.corrector.style.height = max - parseInt (document.defaultView.getComputedStyle (this.corrector.parentNode.parentNode, null).getPropertyValue ('padding-top')) ;	
			this.desprazar (this.barras [0]) ;
		}
		function redim (e) {
			if (document.body.clientHeight == this.doc_alto && document.body.clientWidth == this.doc_ancho) return ;
			this.doc_alto = document.body.clientHeight ;
			this.doc_ancho = document.body.clientWidth ;
			//alert (e.target) ;
			this.actualizar() ;
		}
		function desprazamento (idents, corrector) {
			var inst = this ;
			this.desprazando = desprazando ;
			this.desprazar = desprazar ;
			this.actualizar = actualizar ;
			this.redim = redim ;
			this.barras  = [] ;
			this.corrector = document.getElementById (corrector) ;
			for (i in idents) {
				this.barras.push (document.getElementById (idents [i])) ;
				dojo.connect (this.barras [i], 'scroll', inst, 'desprazando') ;
				dojo.connect (window, 'resize', inst, 'redim') ;
				this.barras [i].setAttribute ('pad_corr', 0) ;
			}
			this.doc_alto = document.body.clientHeight ;
			this.doc_ancho = document.body.clientWidth ;

			var div = document.body.appendChild (document.createElement ('div')) ;
			div.style.width = '100px' ;
			div.style.overflowY = 'scroll' ;
			var ancho_scroll = div.offsetWidth - div.clientWidth;
			
			this.corrector.parentNode.parentNode.style.width = ancho_scroll + 1 ;
			this.corrector.parentNode.parentNode.style.paddingTop = ancho_scroll ;
			this.corrector.parentNode.parentNode.style.bottom = ancho_scroll ;
			//this.corrector.parentNode.parentNode.style.width=div.offsetWidth - div.clientWidth ;
			
		
			document.body.removeChild (div) ;
			
			this.actualizar() ;
		}
		return desprazamento ;
	})() ;
	//lenzo_scroll barra_scroll contedor_scroll
	/*var desprazamento_inst ;
	dojo.addOnLoad (function() {
		desprazamento_inst = new desprazamento (['lenzo_scroll', 'barra_scroll', 'contedor_scroll'], 'empuxe_scroll') ;
	});*/
function idiomas (e) {
	if (dojo.isIE) {
		var e = window.event ;
		var tar = e.srcElement ;
	} else
		var tar = e.target ;
	while (tar.nodeName != 'A' && tar.nodeName != 'BODY') {
		tar = tar.parentNode ;
	}
	if (tar.nodeName == 'BODY' || tar.href.search (/.*(version=|url\.modo).*/) >= 0) return ;
	if ((aux = tar.href.replace (/^.*lang=([^&]+).*$/, '$1')) != tar.href)
		deixar_boia ('lingua', aux) ;
	else
		afundir_boia ('lingua') ;
	location.reload() ;
	if (dojo.isIE) {
		e.cancelBubble = true ;
		e.returnValue = false ;
	} else {
		e.preventDefault() ;
		e.stopPropagation() ;
	}
}
	var desprazamento_inst ;
var anim_texto_inst ;
var anim_carga_inst ;
	function arrincando() {
		//dojo.require ('dojo.NodeList-fx') ; -> peta porque é requerido antes
		desprazamento_inst = new desprazamento (['lenzo_scroll', 'desprazamento'], 'empuxe_scroll') ;
		new menus ('menu_base') ;
		if (dojo.isIE)
			document.getElementById ('idioma').attachEvent ('onclick', idiomas) ;
		else
			document.getElementById ('idioma').addEventListener ('click', idiomas, false) ;
	}

