$(document).ready(function() {
    
	/************************************************
     function to manipulate the layered background
     which sits at the bottom of the '#page'
    ************************************************/
	//Run on page load
	positionBackground();

    //Run on page/browser resize
    $(window).resize(function(){
   		positionBackground();
    });

	//The function which also hides the div if the 
	//browser height is less than 600px
	function positionBackground() {
	    var windowWidth = $(window).width();
	    var windowHeight = $(window).height();
	    var divWidth = $('#layer_background').width();
	    var newPos = (windowWidth - divWidth)/2;	    
	    $('#layer_background').css({left:newPos});
	    
	    if (windowHeight < 600 ) {
	    	$('#layer_background').hide();
	    } else {
	    	$('#layer_background').show();
	    }
	}

	/************************************************
     Skyscraper adverts
    ************************************************/
	$(window).ready(function(){
		ad_skyscraper();
	});

	$(window).resize(function(){
		ad_skyscraper();
	});

	function ad_skyscraper() {
		var browserWidth = $(window).width();
		var adWidth = 120;

		if (browserWidth > 1230) {
			$('#ad_vert').fadeIn('slow');			
			//Calculate the distance required
			var posfromright = ((browserWidth - 992)/2) - (adWidth + 10);
			$('#ad_vert').css('right',posfromright + 'px');
		} 
		else 
		{
			$('#ad_vert').fadeOut('slow');
		}
	
	}
    
});
