// JavaScript Document

$(function(){

	$("#ajaxErrors").ajaxError(function(event, xhr, settings, textError){
		var toast = $("#ajaxErrors");
		$(toast).html("An error occurred getting data from " + settings.url + ", error code: " + xhr.status);		
		$(toast).slideDown("slow");
		setInterval(function() {
			$(toast).slideUp("slow");
		 }, 8000);
	});

	$(".blogsummary").live("click", function(event) {
		$(this).find("a").each(function (index, link) {
			var url = $(link).attr("href");
			if(url.substring(0,10) == "./blog.php")
				document.location.href = url;
		});
	});

	$(".expanderHeader").live("click", function(event) {
		var header = $(this);
		$(this).siblings(".expanderContents").each( function (index, sibling) {
			if($(sibling).css("display") == "none")
			{
				$(sibling).slideDown("slow");
				$(header).html("(click here to hide extra info)");
			}
			else
			{
				$(sibling).slideUp("slow");
				$(header).html("(click to show extra info)");
			}
		});
	});
	
	$("div.mainmenuitem").live("click", function (event){
		if(event.target.nodeName != "A")
		{
			var navigateTo = $(event.target).find("a").attr("href");
			document.location.href = navigateTo;
		}
    });	
});

function EnableAdultContent()
{
	$("#showAdultContent").load("./adultContentSelection.php5?showAdultContent=true");
	setTimeout(function() {
		$("#showAdultContent").slideUp("slow");
	}, 3000);
}

function DisableAdultContent()
{
	$("#showAdultContent").load("./adultContentSelection.php5?showAdultContent=false");
	setTimeout(function() {
		$("#showAdultContent").slideUp("slow");
	}, 3000);
}
