
// Only run if jQuery exists
if ( typeof jQuery == 'function' ) {
jQuery(document).ready(function($){
	
	$('.sideCalendar td.active a').hover(function(){
			$(this).siblings('.side-events').show();
		},function(){
			$(this).siblings('.side-events').hide();
		});
		
	
	/* Advanced show/hide */
		/**
		 * Set Default
		 * 
		 * Either 'show', 'hide', or 'show-first', default is show (all)
		 * Add show or hide to rel attribute to override default settings for specific links
		 */
		var showhide_default = 'show';
		var showhide_count = 0;
	jQuery('.showhide')
		.each(function(){
			var settings = ( typeof jQuery(this).attr('rel') != 'undefined' ) ? jQuery(this).attr('rel') : '';
			var target   = ( typeof jQuery(this).attr('href') != 'undefined' ) ? jQuery(this).attr('href') : '';
			jQuery(this)
				.data( 'rel', settings )
				.data( 'href', target )
				.data( 'show', (jQuery('span.show', this).text().length ? jQuery('span.show', this).text() : "Show") )
				.data( 'hide', (jQuery('span.hide', this).text().length ? jQuery('span.hide', this).text() : "Hide") )
				//.data( 'selected', (showhide_default == 'hide' ? 'show' : 'hide') )
				.data( 'selected', 'hide' )
				.text( jQuery(this).data(jQuery(this).data('selected')) );
		})
		.click(function(e){
			e.preventDefault();
			jQuery(this)
				.data( 'selected', showhidetext(jQuery(this).data('selected')) )
				.text( jQuery(this).data(jQuery(this).data('selected')) );
			showhideaction(jQuery(this));
		}).each(function(){
			if ( (showhide_default == 'hide' || (showhide_default == 'show-first' && showhide_count) || jQuery(this).data('rel').indexOf('hide') !== -1) && jQuery(this).data('rel').indexOf('show') === -1 ) jQuery(this).click();
			showhide_count++;
		});
	function showhidetext( $string ) {
		if ( 'hide' == $string ) return 'show';
		else return 'hide';
	};
	// You can use this to add more customized actions if need, for example if home is in rel attribute, do something special... or if on home page, etc.
	function showhideaction( $object ) {
		// Default is to use href of id to show/id
		jQuery( $object.data('href') ).toggle('fast');
	};
	
	/* Home page support: Table sorter */
	if ( jQuery('body').is('.home') ) {
		jQuery('#myTable').tablesorter({sortList: [[1,0]]});
		jQuery('#myTable1').tablesorter({sortList: [[1,1]]});
		jQuery('#myTableTask').tablesorter({sortList: [[2,0]]});
		
		/* Old show hide on home * /
		jQuery('.homehide').click(function(){
			jQuery(this).parent().parent().children('table').hide('fast');
		});
		jQuery(".homeshow").click(function(){
			jQuery(this).parent().parent().children('table').show('fast');
		});
		/**/
	}
	
});
}
