
$(document).ready(function(){
	$("div.newsPost").click(function(){
		$(this).siblings(".newsPostForm").fadeIn(500);
	});
	
	$("input[name=WussPuss]").click(function(){
		var newsTitle = $(this).siblings("input[name=title]").val();
		var newsBody = $(this).siblings("textarea[name=body]").val();
		var newsType = $(this).siblings("input[name=gameType]").val();
		
		
		$.post("ajaxNews.html", {type: newsType, body: newsBody, title: newsTitle}, updateNews);
	});
	
	$("div.newsitem h1").click(function(){
		$(this).siblings("div.article").slideToggle(500);									
	});
});

function updateNews(output)
{
	//This function is responsible for AJAXing in the new news articles on the page.
	//It's basically only used right after a news article is posted, but could theoretically
	//be used to auto-refresh the news lists when a user lingered on the page.
	
	//window.alert("Success?");
	//Reload the page with the results.
	location.reload(true);
}

function deleteArticle(newsid)
{
	if (confirm("Really delete this article?"))
	{
		window.alert("Augh!! The pain!");
		//OK then, delete it.
		//This is dead simple.
		$.post("ajaxDeleteNews.html", {id: newsid}, updateNews);
	}
}