var sw;
var sh;

window.onload = function() {
	$(window).resize(function() {
 		windowResizeHandler();
	});
	windowResizeHandler();
	showBg();
}

function windowResizeHandler() {
if( typeof( window.innerWidth ) == 'number' ) {
  sw = window.innerWidth;
  sh = window.innerHeight;
} else { 
	sw = document.documentElement.clientWidth;
	sh = document.documentElement.clientHeight;
}
  $('#content').css({
  	'top':(sh-600)/2+'px',
  	'left':(sw-960)/2+'px'
  });
  var mw = $('#menu').width();
  $('#menu').css({
  	'left':(sw-mw)/2+'px'
  });
  $('#logo').css({
  		'left':(sw-259)/2+'px',
		'bottom':0+'px',
		'opacity':0.7
  });
  $('#loading').css({
	 	'left':(sw-50)/2+'px' 
  });
  $('#content').css('z-index',10);
  $('#menu').css('z-index',0);
  $('#menu-main').css('z-index',11);
}

function setupMenu() {
	$('.menu-item a').each(function() {
		$(this).click(function() {
			if (window.location == this.href) {
				return false;
			}
			//start the bg transition
			var a = this;
			$('#loading').fadeTo(300, 1);
			$('#bg').fadeTo(300, 0, function() {
				window.location = a.href;
			});
			return false;
		});
	});
		
	$('#logo').css({
			'left': (($('#menu').width()/2)-130)
	});
}

function showBg() {
	$('#loading').fadeTo(300, 0, function() { $(this).hide();});
	$('#bg').fadeTo(300, 1);
}
function loadwaiter() {
	$(window).load(function() {
		$('#menu, #logo, #content').fadeIn(1000);
	});
}
