/**
 * @author Nikolay Borisov (nikolay@borisov.me | http://nikolay.borisov.me/)
 * @copyright Notamedia (http://notamedia.ru/)
 * @version 0.3
 * @required jQuery
 * @date 2009-11-17
 */

$(function(){

	var self = this;

	var config = {};

	var $arribaBtn = $('.arriba');
	var $derechaBtn = $('.derecha');
	var $abajoBtn = $('.abajo');
	var $izquierdaBtn = $('.izquierda');
	var $centroBtn = $('.centro');

	$centroBtn.click(function(e){
		window.location = '/#centro';
		return false;
	});

	$derechaBtn.click(function(e){
		window.location = '/#derecha';
		return false;
	});

	$arribaBtn.click(function(e){
		window.location = '/#arriba';
		return false;
	});

	$izquierdaBtn.click(function(e){
		window.location = '/#izquierda';
		return false;
	});

	$abajoBtn.click(function(e){
		window.location = '/#abajo';
		return false;
	});



	var $container = $('#container2');
	var $footer = $('#footer2');
	var $window = $(window);

	var containerWidth = $container.width();

	$container.css({ marginLeft:0, marginRight:0, position:'relative' });	
	$footer.css({ marginLeft:0, marginRight:0, position:'relative' });	

	var resizeMe = function(e){

		var stageWidth, leftOffset;

		if(typeof(window.innerWidth) == 'number'){
			stageWidth = window.innerWidth;
		}else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)){
			stageWidth = document.documentElement.clientWidth;
		}

		if(containerWidth < stageWidth){
			leftOffset = (stageWidth - containerWidth)/2;
		}else{
			leftOffset = 0;
		}

		$container.css({ left:leftOffset }, 300);
		$footer.css({ left:leftOffset }, 300);
	}

	$window.resize(resizeMe);

	resizeMe();

});
