$(document).ready(
	function()
	{

	
		$("table.data").each(function(){
			 $("tr:odd", this).not(".even").addClass("odd");
			 $("tr:even", this).not(".odd").addClass("even");
		 });

		// Hide case studies which we'll show as an overlay window.
		$("#casestudies").hide();

		// Add class of overlaywindow which will be common to all ther overlays (so we can close them easier).
		$("#casestudies").addClass("overlaywindow");
	
		// Move the empty sky div to top of body we'll be puting all our overlays in here too.
		$("#sky").prependTo("body");	

		// Add a translucent clouds div inside the sky.
		$("body").prepend("<div id='sky'><div id='clouds'>&nbsp;</div></div>");

		// Put all ther overlays inside the sky with the cloud div...
		$(".overlaywindow").prependTo("#sky");

		// This one is fun... Clone the CSGallery block, remove a class that makes it work in the page layout
		// add a class that makes it work in the overlay, put it in the sky and hide it.
		$("#csgallery").clone().removeClass('galleryembed').addClass("overlaywindow").addClass("galleryoverlay").append("<div id='gallerybigimg'><img src='' alt='' /><span></span></div><div class='clear'>&nbsp;</div>").prependTo("#sky").hide();
		

		// Quick jQuery for the suckerfish dropdowns
		$('#nav li').hover(
			function() {
				$(this).addClass('hover');
			}, 
			function() {
				$(this).removeClass('hover');
			}
		);


		// Show Case Studies Window
		$('a.showcs').click(function()
			{
				$("div#sky").show();
				$("#casestudies").fadeIn('fast');
				$("body").height('100%');
				return false;
			}
		);


		// Show Gallery Window
		$('.csgallerylist a').click(function()
			{

				$("#gallerybigimg img").attr('src', $(this).attr('href'));
				$("#gallerybigimg span").html($(this).attr('title'))
				$(".galleryoverlay ul li a").removeClass('active');
				

				if ($(this).parent('li').parent('ul').parent('div').hasClass('galleryembed')){
					$("div#sky").show();
					$("#csgallery").fadeIn('fast');
					$("body").height('100%');
					var clickedTitle = $(this).attr('title');
					$('.galleryoverlay ul li a[title='+clickedTitle+']').addClass('active');
					
				} else {
					$(this).addClass('active');
				}
	

				return false;
			}
		);


		// Hide Overlay Window (of any type...)
		$('a.hideoverlay').click(function()
			{
				$("div#sky").hide();
				$(".overlaywindow").hide();
				$("body").height('auto');
				return false;
			}
		);

	}
);