  $(document).ready(function() {
	// Blank out any fields with defaults when they are focussed
	$(".blank_default").each(function() {
		$(this).attr("rel", $(this).attr("value"));
	})
	.focus(function() {
		if ($(this).val() == $(this).attr("rel"))
		{
			$(this).val("");
		}
	})
	.blur(function() {
		if ($(this).val() == "")
		{
			$(this).val($(this).attr("rel"));
		}
	});
  });


// Fix display of the subnavigation, line up elements which only have one line of text
$(document).ready(function() {
	$("#subnav ul li").each(function() {
		childA = $(this).find("a");
		if (childA.height() <= 35)
		{
			// This is probably one one line
			childA.css("display", "block");
			childA.css("paddingTop", 10);
		}
	});
});

$(document).ready(function() {
	$("a").each(function() { if ($(this).attr("target") == "_blank") { $(this).removeAttr("target"); } });
	$("a.external").each(function() { $(this).attr("target", "_blank");  });
});


$(document).ready(function() {
try {
	var contentbottom = $("#content").offset().top + $("#content").height();
	var sideboxesbottom = $("#sideboxes").offset().top + $("#sideboxes").height();
	if (sideboxesbottom > contentbottom)
	{
		$("#footer").css("marginTop", sideboxesbottom - contentbottom);
	}
	else 
	{
		$("#footer").css("marginTop", 30);
	}
}catch(e){}
});

$(document).ready(function() {
	$(".home_cta h2").css("cursor", "pointer");
	$(".home_cta h2").click(function() {
		document.location = $(this).siblings("a").attr("href");
	});

	$(".back_link").click(function() {
		history.go(-1);
		return false;
	});

	$("a").each(function() {
		attr = $(this).attr("href");
		if (typeof attr == 'undefined' || attr == false)
		{
			// Where <a> tags are used as anchors, reset their colour to that of their parent
			$(this).css("color", $(this).parent().css("color"));
		}
	});

});
