var Switcher = Class.create({
	div: null,
	
	initialize: function(id) {
		this.div = $(id).down("div");
		var span = new Element("span").update("<strong>Next Article</strong>").addClassName("switcher");
		span.observe("click", function() { new Ajax.Updater(this.div, "ajax/load_article.php") }.bind(this));
		span.observe("mouseout",  function() { this.removeClassName("on"); });
		span.observe("mouseover", function() { this.addClassName("on"); });

		this.div.insert({ before: span });
	}
});		

document.observe("dom:loaded", function() {
	new Ajax.Request("ajax/count_articles.php", {
		onComplete: function(xhr) { if(xhr.responseJSON.article_count > 1) var switcher = new Switcher("news"); }
	});
});