var headerDiv;
var menuDiv;
var contentDiv;
var footerDiv;
var lastWidth=-1;
var lastHeight=-1;
	
function initializeLayout() {
 	window.onresize = function() {resize();};
 	headerDiv = document.getElementById('mainHeaderDiv');
	menuDiv = document.getElementById('mainMenuDiv');
	contentDiv = document.getElementById('mainContentDiv');
	footerDiv = document.getElementById('mainFooterDiv');
	
 	resize();
}
 
function getWidth(obj) {
 	if ( ! obj ) {
 		return 0;
 	}
 	return parseInt(obj.style.width);
}
 
function getHeight(obj) {
 	if ( ! obj ) {
 		return 0;
 	}
 	return parseInt(obj.style.height);
}
 
function resize() {
	var w =   document.documentElement.clientWidth;
	var h =   document.documentElement.clientHeight;

	if ( lastWidth == w && lastHeight == h ) { //To prevent multiple calls ( seen on IE6 ) 
		return;
	}
	
	var upperTileHeight = getHeight(headerDiv);
	var lowerTileHeight = getHeight(footerDiv);
	var centerTileHeight = h - ( upperTileHeight + lowerTileHeight );
	
	var menuWidth = getWidth(menuDiv);
	var contentWidth = w - menuWidth;
	
	if ( headerDiv ) {
		headerDiv.style.width = '100%';
		headerDiv.style.top = '0px';
		headerDiv.style.left = '0px';
	}
	
	if ( menuDiv ) {
		menuDiv.style.height = centerTileHeight + 'px';
		menuDiv.style.top    = upperTileHeight + 'px';
		menuDiv.style.left   = '0px';
	}
	
	if ( footerDiv ) {
		footerDiv.style.top = (upperTileHeight + centerTileHeight) + 'px';
		footerDiv.style.left = '0px';
	}
	
	contentDiv.style.top = upperTileHeight + 'px';
	contentDiv.style.left= menuWidth + 'px';
	contentDiv.style.width= contentWidth + 'px';
	contentDiv.style.height = centerTileHeight + 'px';
	
	//For debugging
	//contentDiv.innerHTML += "resized to " + contentDiv.style.width + "x" + contentDiv.style.height + "<br>";
	
	lastWidth = w;
	lastHeight= h; 
}

//Funcion para alternar colores en una tabla
function alternate(id){
 if(document.getElementsByTagName){  
   var table = document.getElementById(id);  
   var rows = table.getElementsByTagName("tr");  
   for(i = 0; i < rows.length; i++){          
 //manipulate rows
     if(i % 2 == 0){
       rows[i].className = "impar";
     }else{
       rows[i].className = "par";
     }      
   }
 }
}


