﻿function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
		windowHeight = windowHeight - 0;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
			windowHeight = windowHeight - 0;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
				windowHeight = windowHeight - 0;
			}
		}
	}
	return windowHeight;
}
function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentHeight = document.getElementById('content').offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			footerHeight = footerHeight + 4;
			if (windowHeight - (contentHeight + footerHeight) >= 0) {
				footerElement.style.position = 'absolute';
				footerElement.style.top = (windowHeight - footerHeight) + 'px';
			}
			else {
				footerElement.style.position = 'static';
			}
		}
	}
}

window.onload = function() {
	setFooter();
}
window.onresize = function() {
	setFooter();
}


function Fade(objID,CurrentAlpha,TargetAlpha,steps){

  var obj = document.getElementById(objID);
  
  CurrentAlpha = parseInt(CurrentAlpha);
  if (isNaN(CurrentAlpha)){
       CurrentAlpha = parseInt(obj.style.opacity*100);
       if (isNaN(CurrentAlpha))CurrentAlpha=100;
  }
  
  var DeltaAlpha=parseInt((CurrentAlpha-TargetAlpha)/steps);
  var NewAlpha = CurrentAlpha - DeltaAlpha;
  
  obj.style.opacity = (NewAlpha / 100);
  obj.style.MozOpacity = obj.style.opacity;
  obj.style.filter = 'alpha(opacity='+NewAlpha+')';
  
  if (steps>1){
       setTimeout('Fade("'+objID+'",'+NewAlpha+','+TargetAlpha+','+(steps-1)+')', 50);
  }
}  

var actual;  
function precargarPestanas(){
    var d = document;
    actual = 0;
    if (d.images){
        if(!d.pestanas){
            d.pestanas = new Array();
        }
        var i;
        for(i = 0; i != precargarPestanas.arguments.length; i++){
            d.pestanas[i] = new Image;
            d.pestanas[i].src = '/imagenes/' + precargarPestanas.arguments[i];
        }
    }
}

var actual;  
function precargarPestanasNoticias(){
    var d = document;
    actual = 0;
    if (d.images){
        if(!d.pestanas_n){
            d.pestanas_n = new Array();
        }
        var i;
        for(i = 0; i != precargarPestanasNoticias.arguments.length; i++){
            d.pestanas_n[i] = new Image;
            d.pestanas_n[i].src = '/Ibernexus/imagenes/documenta/' + precargarPestanasNoticias.arguments[i];
        }
    }
}