// FSU Default template misc functions


(function() {
	
	// When page is loaded
	$(document).ready(function() {
							   
		var initshow = $('#left').hasClass('initshow');
		var initclass = (initshow) ? 'expandedmenu' : '';
							   
		// Set up for toggling menu expansion
		$('#left ul li ul').each(function(index) {
			if (! $(this).hasClass('initshow') && !initshow)
				$(this).addClass('hidden');
			$(this).parent().prepend(
									
				$('<div class="expander ' + initclass + '"></div>').click(function() {
					oUl = $(this).parent().find('ul:first');
					if (oUl != null) {
						$(this).toggleClass('expandedmenu');
						oUl.toggleClass('hidden');
					}
				})
				
			);
		});
		
		// Set up for toggling featured boxes
		$('div.featurebox.expanding').each(function(index, itm) {
			var $$ = $(this);
			
			// Collapse items that are set to be collapsed on startup
			$$.addClass('jsenabled');
			if ($$.hasClass('collapsed')) {
				$$.addClass('jscollapsed');
			}
			
			// Trap events
			$$.find('div.title').click(function() {
				$$.toggleClass('jscollapsed');
				return false;
			});
			
		});


		/* Set up for toggling menu expansion
		$('#topnav ul li ul').each(function(index) {
			$(this).parent().hover(function() {
				oUl = $(this).parent().find('ul');
				if (oUl != null) {
					oUl.addClass('expandedmenu');
				}
			});
		});
		*/

	});
	
})();

