window.addEvent('domready',function(){
	setContent();
});

window.addEvent('load',function(){
	$i=0;
	$$('.pagina img').each(function(ele){
		anchos[$i]=ele.getStyle('width').replace('px','');
		totalAnchos = $i;
		anchoTotal += parseInt(anchos[$i]);
		anchos[$i]=anchoTotal;
		$i++;
	})
	$('imgContainer').setStyle('width', anchoTotal);
});

window.onresize = function() {
	setContent();
}

anchos = new Array;
totalAnchos = 0;
anchoActual = 0;
anchoTotal = 0;


//MOVER
function moverPaginasDer(){
	if (anchoActual < totalAnchos) {
		$newLeft = -1*anchos[anchoActual];
		new Fx.Tween($('imgContainer')).start('left', $newLeft);
		anchoActual++;
	}
}

function moverPaginasIzq(){
	if (anchoActual > 0) {
		anchoActual--;
		anchoActual--;
		$newLeft = -1*anchos[anchoActual];
		new Fx.Tween($('imgContainer')).start('left', $newLeft);
		anchoActual++;
	}
}





//CENTER
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function setContent() {
	if (document.getElementById('contentcenter')) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentElement = document.getElementById('contentcenter');
			var contentHeight = contentElement.offsetHeight;
			if (windowHeight - contentHeight > 0) {
				contentElement.style.position = 'relative';
				contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
			}
			else {
				contentElement.style.position = 'static';
			}
		}
	}
}

