window.addEvent('domready',winload);
function winload(){
	setTimeout(resize,500);
}
function resize(){
	var columns = $$('.column');
	var maxHeight = 0;
	columns.each(function(obj){
		var height = parseInt(obj.getStyle('height'));
		if(height > maxHeight)
		{
			maxHeight = height;
		}
	});
	columns.each(function(obj){
		obj.setStyle('height',maxHeight+'px');
	});
	
	$('pie').setStyles({'top':(350+maxHeight)+'px','visibility':'visible'});
}

function getPageSize(){	
	        
	     var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight + yScroll;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}

		return [pageWidth,pageHeight];
	
}

var myLightBox;
var myLoginBox

function loginbox(){
	lightbox();
	var lbWidth = 300;
	var lbHeight = 300;
	var lbMLeft = (-lbWidth/2);
	var lbMTop = (-lbHeight/2);
	myLoginBox = new Element('div',{'id':'pageLoginBox','styles':{'position':'absolute','z-index':1001,'width':lbWidth+'px','height':lbHeight+'px','top':'50%','left':'50%','margin-left':lbMLeft+'px','margin-top':lbMTop+'px','background-color':'#666'}});
	var miAjax = new Ajax('../templates/html/login_form.html',
	{
		update: $('pageLoginBox')
	});
	miAjax.request();
	myLoginBox.inject(document.body);
}

function lightbox(){
	var pageSize = getPageSize();
	if (!self.innerHeight && document.documentElement && document.documentElement.clientHeight){
		var pHeight = $('contenedor').getStyle('height');
		pHeight = (parseInt(pHeight) + 15) + 'px';
		myLightBox = new Element('div',{'styles':{'position':'absolute','z-index':1000,'background-color':'#000','width':pageSize[0]+'px','height':pHeight,'filter':'alpha(opacity=80)','opacity':'0.8'}});
	}else{
		myLightBox = new Element('div',{'styles':{'position':'fixed','z-index':1000,'background-color':'#000','width':pageSize[0]+'px','height':pageSize[1]+'px','filter':'alpha(opacity=80)','opacity':'0.8'}});
	}
	myLightBox.inject(document.body,'top');
}

function closeLightbox(){
	myLightBox.destroy();
}
