jQuery(document).ready(function($) {

	// make the background shadow more transparent
	$('#shade').css({ 'opacity': 0.6 });
	
	// move the absolutely positioned main container to the half of its width to the left against the css 50% to center
	var left = ($('#container').width()/2) * -1;
	$('#container').css({ 'margin-left': left });


	// MENU
	// make it pop up over the footer on hover, if covered
	$('#menu').hover(function(){
		$(this).css({ 'position': 'relative' });
	}, function(){
		$(this).css({ 'position': '' });	
	});

	// gallery
	if( $('.gallery').length )
	{
		// random position
		var gid = '#'+$('.gallery').attr('id');
		var gid = $(gid);
		var w = 0;
		var tallest = 0;
		var max1 = 100;
		var max2 = 50;
		
		gid.find('.gallery-item').each(function(){
			var t = $(this);
			var rand1 = Math.floor(Math.random() * max1);
			var rand2 = Math.floor(Math.random() * max2);
			t.css({ 'top': rand1, 'left': rand2/2 });
		});
		
		// measure	
		$(window).load(function(){
			var padding = parseInt(gid.find('.gallery-item:first').css('padding-left').substr(0,2));
			
			gid.find('.gallery-item').each(function(){
				var t = $(this);
				var tw = t.width();
				if(tw > tallest) tallest = tw;
				w += (tw + padding);
			});
			w += max2;
			gid.width(w);
		});
	}
	
});
