// 'flood' is the global object for flood theme functions
var flood = {};
// Reduce potential conflicts with other scripts on the page
flood.jQuery = jQuery.noConflict(true);
var $flood = flood.jQuery;
// Create a unique object and namespace for theme functions
flood.themeFunctions = {};
// Define a closure
flood.themeFunctions = (function() {
    // When jQuery is used it will be available as $ and jQuery but only inside the closure
    var jQuery = flood.jQuery;
    var $ = jQuery;
	var $flood = jQuery.noConflict();

// ExtraContent functionality 
$flood(document).ready(function () {
	var extraContent =  (function() {
		var ecValue = 10;
		for (i=1;i<=ecValue;i++)
		{
			$flood('#myExtraContent'+i+' script').remove();
			$flood('#myExtraContent'+i).appendTo('#extraContainer'+i);
		}
	})();
});
	

// Function to fade-in parts of a page when the window has finished loading.
// Adjust the fadeIn speeds accordingly. Speeds are specified in milliseconds.		
$flood(window).load(function(){
	$flood('#header').delay(1000).fadeIn(2000);
	$flood('#bannerWrapper').delay(1000).fadeIn(2000);
	$flood('#contentContainer').delay(1000).fadeIn(2000);
	$flood('#footer').delay(1000).fadeIn(2000);
});
	
	
// Function to generate animated drop-down menus and to apply unique class ID's onto each list and list item
$flood(document).ready(function () {
	$flood("#nav>ul>li>ul").hide();
	$flood("#nav li").hover(function(){
	$flood(this).find('ul:first').css({visibility: "visible",display: "none"}).fadeIn(500);
	},function(){
	$flood(this).find('ul:first').fadeOut(500);
	});

	$flood("#nav li").each(function (i) {
		i = i+1;
		$flood(this).addClass("link"+i);
		});
		$flood("#nav ul").each(function (i) {
   		i = i+1;
   		$flood(this).addClass("list"+i);
	});
});

// Function to generate a mega menu with a given set of page links generated by RapidWeaver
$flood(document).ready(function () {
	$flood('#megamenu>ul>li').hover(  
	function () {  
	$flood('ul', this).fadeIn(500); 
	},   
	function () {
	$flood('ul', this).fadeOut(500);          
	}  
	);  
});

// Function to measure the height of the header and set the height accordingly
// This code was added in version 2.0 to stop an ugly jumping effect if the header was set to fade in.
$flood(document).ready(function () {
	var headerHeight = $flood('#header').height(); 
	$flood('#headerWrapper').css({'height':headerHeight});
});

	
})(flood.themeFunctions);
