$(document).ready(
	function()
	{
		// TABNAV Operations		
		var activecontent;
		$('#tabnav li a').click(function () 
			{
				$('.contenttab').hide();
				$('#tabnav li a').removeClass('active');
				$(this).addClass('active');
				activecontent = '#' + $(this).parent('li').attr('class') + 'content';
				$(activecontent).slideDown();
				return false;
			}
		);

		// Zebra-stripe data tables
		$("table.data tbody").each(function(){
			 $("tr:odd", this).not(".even").addClass("odd");
			 $("tr:even", this).not(".odd").addClass("even");
		 });

		// Zebra-stripe data lists as well
		$("ul.data").each(function(){
			 $("li:odd", this).not(".even").addClass("odd");
			 $("li:even", this).not(".odd").addClass("even");
		 });

		// ServicesTree Toggle
		$('#servicestree a.toggle').click(function () 
			{
				$(this).parent('li').children('ul').slideToggle('fast');
				return false;
			}
		);

		// ServicesTree ToggleAll
		$('#servicescontent a.toggleall').click(function () 
			{
				if ($(this).hasClass('hideall')){
					$(this).text('Expand All Services');
					$(this).removeClass('hideall');
					$('#servicescontent ul ul').slideUp('fast');
				} else {
					$(this).text('Hide All Services');
					$(this).addClass('hideall');
					$('#servicescontent ul ul').slideDown('fast');
				}
				$('#servicescontent ul ul ul').slideDown();
				return false;
			}
		);
		
		// Services Summary
		$('#servicessubnav a.viewsummary').click(function() {$('#servicessummary').show();});
		$('#servicessummary h3').click(function(){$('#servicessummary').fadeOut('fast');})
		

		// Billing Sidebar Toggle
		$('#billingsidebar a.toggle').click(function () 
			{
				$(this).parent('h3').next('div.togglable').slideToggle('fast');
				return false;
			}
		);

		// Add a sky div to body with overlaywindows and a translucent clouds div to provide the gray backdrop.
		$("body").prepend("<div id='sky'><div id='clouds'>&nbsp;</div></div>");

		// Add class of overlaywindow which will be common to all ther overlays (so we can close them easier).
		$(".overlayhidden").addClass("overlaywindow").removeClass("overlayhidden");

		// Put all ther overlays inside the sky with the cloud div...
		$(".overlaywindow").prependTo("#sky");

		// Show Search Results Overlay
		$('.searchbox a.linkbuttonlg').click(function()
			{
				$("div#sky").show();
				$("#searchresults").fadeIn('fast');
				$("html").css({ overflow:"hidden", height:"100%" });
				return false;
			}
		);
		
		// Add search value to text input
		$('.overlaywindow .casestudysearch input.txb').attr({ 
		          value: "Search:"
		        });
		// Hide search input value on click
		$('.overlaywindow .casestudysearch input.txb').click(function()
			{
				$(this).attr({ 
				          value: ""
				        });
			}
		);


		// Hide Overlay Window (of any type...)
		$('a.hideoverlay').click(function()
			{
				$("div#sky").hide();
				$(".overlaywindow").hide();
				$("html").css({ overflow:"auto", height:"auto" });
				return false;
			}
		);
		
		
		// Makes the nav work in IE6
				$('#casestudies ul li').hover(
					function() {$(this).addClass("over");},
					function() {$(this).removeClass("over");}
				);
			
		
		// Dropdown Functions for internal pages
			// Hide all togglable elements.
					$('.dropdowns ul').hide();
					
			// Switch Arrow default to closed
					$(".dropdowns").addClass("toggleclosed");
					
			// Add Hover State to h3 
					$(".dropdowns h3").addClass("togglehover")
			
			// Toggle Function
					$(".dropdowns h3").click(function()
						{
							$(this).parent('div').toggleClass("toggleclosed");
							$(this).next('.dropdowns ul').slideToggle('fast');
							return false;
						}
					);
					
			
			


	}
);