////////////////////////////////////////////////////////////////////////////////////
//This JS file contains code for formatting the page correctly.
//Code to control dynamic relocation of ads when pages are resized.
//Created by Paul Barton
$(document).ready(function() {
	resize("#mpu_ad_outer");
	formatPage();
});
$(window).resize(function() {
	resize("#mpu_ad_outer");
});

function resize(ad) {
	var windowWidth = $(window).width();
	var mpuWidth = $(ad).width() + (parseInt($(ad).css("margin-left"))*2);
	var left = (windowWidth/2)-(mpuWidth/2);
	if(left <0) {
		left = 0;
	}
	$(ad).css("left",left);
	$(ad).css("display", "block");
}

function formatPage() {
    $("#main_content_js").css("height", 890);
    $("#main_content_js").css("position", "absolute");

    $("#chrome").css("position", "absolute");
    $("#chrome").css("top", 5);

    $("#footer").css("position", "absolute");
    $("#footer").css("top", 875);
}

function ExternaliseLink(obj, link) {
	obj.each(function() {
		var href = $(this).attr("href");
		if(href != "#") {
			$(this).attr("href", link + href);
		}
	});
}
