$(document).ready(function()
{
		$("#datanav li ul").hide(); // Hide all sub menus
		$("#datanav li a.current").parent().find("ul").show();

		$("#datanav .bumphover").click( // When a top menu item is clicked...
			function () {
				$(this).parent().siblings().find("ul").slideUp("normal"); // Slide up all sub menus except the one clicked
				$(this).next().slideToggle("normal"); // Slide down the clicked sub menu
				return false;
			}
		);
		
    // Sidebar Accordion Menu Hover Effect:
		
		$("#datanav .bumphover").hover(
			function () {
				$(this).stop().animate({ paddingRight: "25px" }, 200);
			}, 
			function () {
				$(this).stop().animate({ paddingRight: "15px" });
			}
		);


    	// Content box tabs:	
		$('.content-box .content-box-content div.tab-content').hide(); // Hide the content divs
		$('ul.content-box-tabs li a.default-tab').addClass('current'); // Add the class "current" to the default tab
		$('.content-box-content div.default-tab').show(); // Show the div with class "default-tab"		
		/*
		$('.content-box ul.content-box-tabs li a').click( // When a tab is clicked...
			function() { 
				$(this).parent().siblings().find("a").removeClass('current'); // Remove "current" class from all tabs
				$(this).addClass('current'); // Add class "current" to clicked tab
				var currentTab = $(this).attr('href'); // Set variable "currentTab" to the value of href of clicked tab
				$(currentTab).siblings().hide(); // Hide all content divs
				$(currentTab).show(); // Show the content div with the id equal to the id of clicked tab
				return false; 
			}
		);
		*/

	    //Close button:	
		$(".close").click(
			function () {
				$(this).parent().fadeTo(400, 0, function () { // Links with the class "close" will close parent
					$(this).slideUp(400);
				});
				return false;
			}
		);

	    // Alternating table rows:		
		// $('tbody tr:even').addClass("alt-row"); // Add class "alt-row" to even table rows

    // Check all checkboxes when the one in a table head is checked:
		
		$('.check-all').click(
			function(){
				$(this).parent().parent().parent().parent().find("input[type='checkbox']").attr('checked', $(this).is(':checked'));   
			}
		)

    // Initialise Facebox Modal window:
		
		//$('a[rel*=modal]').facebox(); // Applies modal window to any link with attribute rel="modal"
		$('a[rel*=modal]').live("click",function(){
			$.facebox({ajax : $(this).attr("href")});
			return false;
		}); // Applies modal window to any link with attribute rel="modal"

    // Initialise jQuery WYSIWYG:
		
		$(".wysiwyg").wysiwyg(); // Applies WYSIWYG editor to any textarea with the class "wysiwyg"

		$('input[title]').each(function() {
			if($(this).val() === '') {
				$(this).val($(this).attr('title')).addClass('inputHint');
			}
			$(this).focus(function() {
				if($(this).val() == $(this).attr('title')) {
					$(this).val('').removeClass('inputHint');
				}
			});
			$(this).blur(function() {
				if($(this).val() === '') {
					$(this).val($(this).attr('title')).addClass('inputHint');	
				}
			});
		});
		
		$("form").submit(function() {
					$('input[title]').each(function() {
						if($(this).val() == $(this).attr('title')) {
							$(this).val('').removeClass('inputHint');
							}
					});
				});
	});


