// JavaScript Document
$(document).ready(function(){

	/* Add a a Class of Last to last Navigation Item */
	$('#navigation li:last').addClass('last');
	
	/* Alternate Shading for Tables */
	//Removing this because it will be handled by tablesorter
	//$('#directory_left tr:odd').addClass('odd');
	
	/* Alternate Shading for Profile */
	$('table.profile tr:even').addClass('odd');
	$('table.profile tr:odd').addClass('nobg');
	
	/* Make Input Values Clear on Focus */
	if ($('.focus-blur').length > 0){
		$.getScript('scripts/jquery.valueFx.js',function(){ 
			// Execute this function once the plugin is loaded
			$('.focus-blur').valueFx();
		});
	}
	
	/* Dynamically changes links with a class of 'email' into Spam-Proofed Mailto Links */
	$('.email').mailto();
	
	/* Toggle the Class of Sort in the Table Header to show Ascending or Descending Direction */
	$('a.sort').click(function(){
		$(this).toggleClass('active');
		return false;
	});
	
	/* Accordion Navigation for Directory */
	$('ul.expand').each(function(){
		$('li.trigger', this).filter(':first').addClass('top').end().filter(':not(.open)').next().hide();
		$('li.trigger', this).click(function(){
			if($(this).hasClass('open')) {
				return false;
			} else {
				$(this).parent().find('li.trigger').removeClass('open').next().filter(':visible').slideUp();
				$(this).addClass('open').next().slideDown();
			}
		});
	});


	/* Show/Hide Script. Any link with a class of Showhide will toggle the visibility of a div called Hidden */
	if ($('a.showhide').length > 0){
		// hide those divs
		$('div.hidden').hide();
		// slide effect
		$('a.showhide').click(function(){
			$(this).nextAll('div.hidden').slideToggle('fast');
			if($(this).hasClass('active')){
				$(this).removeClass('active');
			} else {
				$(this).addClass('active');
			}
			return false;
		});
		
	}
	
	/*
	function showHidden(divClicked,divToShow)
	{
		var clicked = $("#" + divClicked);
		var toShow = $("#" + divToShow);	
		toShow.slideToggle('fast');
		if(clicked.hasClass('active')){
			clicked.removeClass('active');
		} else {
			clicked.addClass('active');
		}
		return false;	
	};*/
});


