﻿GoodNites.Articles = function(serverVars) {
	this.ServerVars = serverVars;
	this.Initialize();
};
GoodNites.Articles.prototype = {
	Initialize: function() {
		
		function toggleArchivedContent(element) {
		
		    // Toggle the display of the ul for this header
		    $("ul." + element.id, serverVars.archiveSelector).slideToggle();
		    
		    // Toggle the Expanded class on the header
		    $(element.parentNode).toggleClass("Expanded");
		}
		
		$("h3 a", serverVars.archiveSelector).click(function(event) {
		    toggleArchivedContent(this);		    
		    
		    // Prevent the default action so that we don't jump around the page
		    event.preventDefault();
		    event.returnValue = false;
		});
		
		// If the document has a hash we should auto-expand it
		if (document.location.hash.length > 0) {
		    toggleArchivedContent($(document.location.hash, serverVars.archiveSelector).get(0));
		}
	}
};
GoodNites.Extend(GoodNites.Articles, GoodNites.Core);