Cufon.replace('h1');
Cufon.replace('.sidebar h2');
Cufon.replace('h2.cufon');

var navTO;

$.aod = {
	init: function() {

		// Define Scroll Follow
		if ( $(".scroll").length > 0 ) {
			$(".scroll").css('position', 'relative');
			$('.scroll').scrollFollow( {
				speed: 500,
				offset: 10,
				onText: 'Disable Follow',
				offText: 'Enable Follow'
			});
		}
		
		// Change class of subnavigation background div
		$('#navigation ul > li').not("ul li ul li").bind('mouseover', function() {
			var navigationId = $(this).attr('id');
			$('html body').removeClass();
			$('html body').addClass(navigationId);
		});
		
		//alert($(".active .level2").height());

		// Show sub navigation on mouseover
		var navItems = $('#navigation ul li').not("ul li ul li");
		navItems.hover(
			
			function() {
				//$('.level2').not('.active').css('display', 'none');
				clearTimeout(navTO);
				navItems.removeClass('visible');
				$(this).addClass('visible');
				$("#navigation .level2").css('display', 'none');
				$(this).children('ul').css('display', 'block');
			},
			function () {
				var elementThis = $(this).children('ul');
				navTO = setTimeout(function() {
					elementThis.css('display', 'none');
					$("#navigation .level2").css('display', 'none');
					$("#navigation .active .level2").css('display', 'block');
					$('html body').removeClass();
					navItems.removeClass('visible');
				}, 3000);
			}
		);

		// Create a slideshow for the front page intro
		if ( $("#dossier-slides").length > 0 ) {
			$('#dossier-slides') 
				.before('<div id="dossier-slide-nav">')
				.cycle({ 
					fx:      'turnDown',
					speed:   '500',
					timeout: 10000,
					pager:   '#dossier-slide-nav'
				});
		}
		
		// Create nav-info on homepage
		if ( $("#nav-info").length > 0 ) {
			$('#nav-info') 
				.cycle({ 
					fx: 'fade',
					speed: '750',
					cleartype: true,
				    cleartypeNoBg: true,
					timeout: 10000
				});
		}
	}
}

$(document).ready(function() {

	// Initialize the main object
	$.aod.init();
});