// JavaScript Document

function debug(o,acumula){
			var txtAcumula = "";
			if(typeof(acumula) == 'boolean' && acumula ) txtAcumula = $('#debug').html() + "<br>";
			$('#debug').css('display','block'); $('#debug').html("debug: <br>" + txtAcumula + o);
			}
	
function resizeWindow() {
	var cointainerHeight= $(".centro").height();
	var documentHeight= $(document).height();
	var heightElems = 320;

	var heigh = documentHeight - heightElems 
	//debug( "documentHeight: "  +documentHeight+ " <br> cointainerHeight: "  +cointainerHeight +  " <br> heightElems:"  + heightElems  +  " <br> heigh:"  + heigh + " <br> " + typeof(heigh))
	//$("#tablacentro").height(heigh);
		
}
function changeImg(elem,src){
		$(elem).attr('src',src).animate({opacity: 1},2000);
		img = null;
}
function calRandom(ti){
	return Math.round( Math.random() * ti );
}


var img = null;
var totalImg = 16
var n = calRandom(totalImg)

function preloadImgs(){
	var pli=new Array();
	var j= pli.length;
    for(i=0; i<totalImg; i++){
    	pli[j]=new Image; 
		pli[j++].src="images/banner/header_bg"+i+".jpg";
	}
	pli[--j].onload = function(){ showImgs()}
}

function showImgs(){
	var r; //= calRandom();
	n++;// = ( n == r ) ? calRandom() : r;
	src = "images/banner/header_bg"+n+".jpg";
	$('#imgBg').animate({opacity: 0},1500,"",function(){changeImg(this,src);});
	setTimeout("showImgs()",7000);
					
		
	if (n==totalImg) n=1;
}
