// JavaScript Document
function WScreen(){ return (Nav.esIE)? document.documentElement.clientWidth : window.innerWidth; }
function HScreen(){ return (Nav.esIE)? document.documentElement.clientHeight : window.innerHeight; }
function YPos(){ return (Nav.esIE)? document.documentElement.scrollTop : window.pageYOffset; }
function XPos(){ return (Nav.esIE)? document.documentElement.scrollLeft : window.pageXOffset; }
function HBody(){ return document.documentElement.scrollHeight; }
function WBody(){ return document.documentElement.scrollWidth; }
	
function setOpacity(opa, ele){
	if(!window.innerWidth){ ele.style.filter = 'alpha(opacity='+opa+')'; }
	else{ ele.style.opacity = (opa / 100); }
}
	
function getElementPos(ele){
	var p = ele.style.position;
	ele.style.position = 'relative';
	var x = ele.offsetLeft;
	var y = ele.offsetTop;
	ele.style.position = p;
	while(ele.tagName.toLowerCase() != 'body'){
		ele = ele.parentNode;
		if(ele.style.position == 'absolute'){
			x += ele.offsetLeft;
			y += ele.offsetTop;
		}
	}
	return {'x':x, 'y':y};
}

function strongEaseInOut(t,b,c,d){
	if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
	return c/2*((t-=2)*t*t*t*t + 2) + b;
}

//
var aSolActs = new Object;
function cambiarSolapa(id, pos, on, off, event){
	if(!!aSolActs[id]){
		aSolActs[id]['tit'].className = off;
		aSolActs[id]['con'].style.display = 'none';
	}
	aSolActs[id] = new Object;
	aSolActs[id]['tit'] = $('titSolDeCont'+id+'Pos'+pos);
	aSolActs[id]['tit'].className = on;
	aSolActs[id]['con'] = $('conSolDeCont'+id+'Pos'+pos);
	aSolActs[id]['con'].style.display = 'block';
	
	if(event) StopEvent(event);
}
var centrarContenido = function(contenido){
	if(contenido && typeof(contenido) == "string")contenido = $(contenido);
	if(!contenido){
		alert("Error en funcion centrarContenido: Contenido inexistente");
		return false;
	}
	var scrll = YPos();
	contenido.style.top = (Math.round((HScreen() - contenido.offsetHeight)/2)+YPos())+"px";
	contenido.style.left = (Math.round((WScreen() - contenido.offsetWidth)/2)+XPos())+"px";
}
var MostrarContenido = function(contenido,e){
	if(contenido && typeof(contenido) == "string")contenido = $(contenido);	
	if(!contenido){
		alert("Error en funcion MostrarPopUp: Contenido inexistente");
		return false;
	}
	centrarContenido(contenido);
	contenido.style.visibility = "visible";
	if(e)StopEvent(e);
	
}
var OcultarContenido = function(contenido,e){
	if(contenido && typeof(contenido) == "string")contenido = $(contenido);	
	contenido.style.visibility = "hidden";
	contenido.style.top = '-'+(contenido.offsetHeight+100)+"px";
	if(e)StopEvent(e);
}
var blockeadorGeneral = null;
var mostrarBlockeador = function(mostrar){
	if(!blockeadorGeneral){
		blockeadorGeneral = $("blockeadorGeneral");
		if(Nav.esIE || Nav.esIE7) blockeadorGeneral.style.filter = 'alpha(opacity=45)';
		else blockeadorGeneral.style.MozOpacity = ".45";
		
	}
	if(mostrar){
	//	alert(getBodyWHAvaible().h+' '+getWindowDims().h)
		blockeadorGeneral.style.display = "block";
		blockeadorGeneral.style.height = HBody()+"px";
		/*blockeadorGeneral.style.width = (WScreen())+"px";*/
	}
	else blockeadorGeneral.style.display = "none";
}

function getWindowDims(){
	if(Nav.esOp) return {w:window.innerWidth, h:window.innerHeight};
	else return {w:document.documentElement.clientWidth, h:document.documentElement.clientHeight};
}
function getBodyWHAvaible(){
	if(Nav.esOp) return {w:window.innerWidth, h:window.innerHeight};
	else return {w:document.documentElement.clientWidth, h:document.documentElement.clientHeight};
}
function getBodyDims(){
	if(Nav.esOp) return {w:document.body.clientWidth, h:document.body.clientHeight};
	else return {w:document.body.offsetWidth, h:document.body.offsetHeight};
}

//
function alingCols(){
	var a = $('divPos4'), b = $('divPos5'), h = 0;
	if(!a || !b){ a = $('divPos11'); b = $('divPos12'); }
	
	if(!!a && !!b){
		if(a.offsetHeight > b.offsetHeight){ h = a.offsetHeight; }
		else{ h = b.offsetHeight; }
		a.style.height = b.style.height = h + 'px';
	}
}
function alingCols2(){
	var a = $('divPos7'), b = $('divPos8'), c = $('divPos9'), h = 0;
	
	if(!!a && !!b && !!c){
		h = a.offsetHeight;
		if(b.offsetHeight > h)h = b.offsetHeight;
		if(c.offsetHeight > h)h = c.offsetHeight;
		a.style.height = b.style.height = c.style.height = h + 'px';
	}
}
AddEvent(window, 'load', alingCols);
AddEvent(window, 'load', alingCols2);

var subMenuOn = curSubMenuOn = inCurSubMenu = false;
function showSubMenu(e, m, b, t){
	if(!!subMenuOn){
		subMenuOn.e.className = '';
		if(!!subMenuOn.m){ subMenuOn.m.style.display = 'none'; }
		if(Nav.esIE7){ $('main').style.marginTop = '0'; }
	}
	subMenuOn = {e:e, m:$(m)}
	subMenuOn.e.className = 'btnOn';
	if(!!subMenuOn.m){ 
		subMenuOn.m.style.display = 'block';
		if(Nav.esIE7){ $('main').style.marginTop = '27px'; }
	}
	if(!!b){ curSubMenuOn = {e:e, m:$(m)}; }
}
function showCurSubMenu(b){
	if(inCurSubMenu){ window.clearTimeout(inCurSubMenu); }
	if(!!b){ inCurSubMenu = window.setTimeout(hideCurSubMenu, 1000); }
}
function hideCurSubMenu(){
	if(!!curSubMenuOn){
		var m = false;
		if(!!curSubMenuOn.m){ m = curSubMenuOn.m.id; }
		showSubMenu(curSubMenuOn.e, m);
	}
}
