var Display = {
	run: function ()
	{


	/* ------------------------------------------------------------------------------------------------------------
		Print Page
	--------------------------------------------------------------------------------------------------------------*/




	/* ------------------------------------------------------------------------------------------------------------
		Context Menu Animation
	--------------------------------------------------------------------------------------------------------------*/
		
		$("	.context_expand, .context_collapse, .goto_top, #print").mouseover(function() {
			$(this).css("cursor","pointer");
		})


		$(".context_expand").click( function () {
			$(this) .parent()
					.prev()
					.find(".hideable")
					.show();
			$(this) .next().show();
			$(this) .hide();
		})
		
		$(".context_collapse").click( function () {
			$(this) .parent()
					.prev()
					.find(".hideable")
					.hide();
			$(this) .hide();
			$(this) .prev().show();
		})


	/* ------------------------------------------------------------------------------------------------------------
		Scroll Internal links; thanks http://www.learningjquery.com/2007/09/animated-scrolling-with-jquery-12
	--------------------------------------------------------------------------------------------------------------*/

	  $('a[href*=#]').click(function() {
		 if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
		   var $target = $(this.hash);
		   $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
		   if ($target.length) {
			  var targetOffset = $target.offset().top;
			  $('html,body').animate({scrollTop: targetOffset}, 1000);
		    return false;
		   }
		 }
	  });

	/* ------------------------------------------------------------------------------------------------------------
		Fix for incomplete LI Hover effect in CSS: add border-bottom on previous element
	--------------------------------------------------------------------------------------------------------------*/
		$('div.navigation li:not(.heading)').mouseover( function() {
			$(this).css("border-bottom", "1px #ccc solid");
			$(this).prev().css("border-bottom", "1px #ccc solid");			
		});

		$('div.navigation li:not(.heading)').mouseout( function() {
			$(this).css("border-bottom", "1px #eee solid");
			$(this).prev().css("border-bottom", "1px #eee solid");
		});

	/* ------------------------------------------------------------------------------------------------------------
		Highlight every other table row
		Spacer column in column 1 and 4 requires slice(); won't work w/o 'each'
	--------------------------------------------------------------------------------------------------------------*/

		$("tr:even").each(function (i) {
			$(this).children().slice(0,2).addClass("highlight");
		});


		$(".goto_top").click( function () {
			window.scrollTo(0,0);
		});

	/* ------------------------------------------------------------------------------------------------------------
		Content Expand and Collapse Effects
	--------------------------------------------------------------------------------------------------------------*/

		$(".collapse_main, .collapse_sub, .expand, #show_all, #hide_all").mouseover( function() {
			$(this).css("cursor","pointer");
		})
		
		$(".collapse_main").click( function() {
			$(this)	.hide().next().show();
			$(this)	.parent()
					.parent()
					.children()
					.not('.plus_minus, h2')
					.hide();
		})

		$(".expand").click( function() {
			$(this)	.hide();
			$(this)	.prev().show();
			$(this)	.parent()
					.parent()
					.children()
					.show();
		})

		$("#show_all").click( function () {
			$(".collapsable")	.children()
								.show();
			$(".collapse_main") .show();
			$(".collapse_sub") 	.show();			
			$(".expand").hide();			
		})				

		$("#hide_all").click( function () {
			$(".collapsable")	.children()
								.not('.plus_minus, h2')
								.hide();
			$(".collapse_main") .hide();
			$(".expand").show();								
		})				
		
	}

};

/* ------------------------------------------------------------------------------------------------------------
	Start JScript 
--------------------------------------------------------------------------------------------------------------*/

$(document).ready( function () {
	Display.run();
});

