// Create our own, custom JavaScript object
$.mainObject = {
	// Initialize the main object
	init: function() {
		// Enable drop down menus for the main navigation on mouseover
		$('#navigation > ul > li').hover(
			function() {
				$(this).addClass('showSubNavigation');
			},
			function() {
				$(this).removeClass('showSubNavigation');
			}
		);
		
		// Enable tabbed navigation
		// Tabs for news and agenda
		$('#newsAgenda').tabs();
		
		// Tabs for projects
		$('#projects').tabs({
			// Select the second tab
			selected: 0,
			// Animate tab switching
			fx: {
				opacity: 'toggle'
			}
		})
		// Rotate the tabs
		.tabs('rotate', 5000);
		
		// Clear input fields in form for dmail subscription
		$("#dmsubscription-name").focus(function() {
			$(this).attr("value","");
		});
		$("#dmsubscription-email").focus(function() {
			$(this).attr("value","");
		});
		
		// Enable the print button
		$('a#printPage').bind('click', function() {
			window.print();
			
			// Disable the link from jumping anywhere
			return false;
		});
	}
};

// Replace headers with Cufon
// This has to be done before document.ready, to prevent headers from flashing (IE bug)
Cufon.replace('h1',{hover: true})('h2',{hover: true})('h3',{hover: true})('#navigation ul.level1>li>a')('#navigation strong');

// Initialize the main object, which handles all website initialization
$(document).ready(function() {
	// Initialize the main object
	$.mainObject.init();
});