$(document).ready(function() {

	$(document).pngFix(); // Init PNG fix
	
	if($.browser.msie && $.browser.version=="6.0") {
		$('#homepageHero').css('margin-top', -2);
		$('#navigation ul li ul.subnav li a').css('width', 200);
	}
	
	initMenu();
	
	// Init Slideshow
	$("ul.tabs").tabs("#hero .panes > div", {
		current: 'ui-tabs-selected',
		event: 'mouseover',
		effect: 'fade',
		fadeInSpeed: 2000,
		fadeOutSpeed: 2000,
		rotate: true
	}).slideshow({
		autoplay: true,
		autopause: true,
		interval: 5000
	});
	
	
});

function initMenu() {
	//Only shows drop down trigger when js is enabled – Adds empty span tag after ul.subnav
	$('ul.subnav').parent().append('');

	$('ul.topnav li a').hover(function() {
	
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find('ul.subnav').slideDown(300).show(); //Drop down the subnav on hover
		
		$(this).parent().hover(function() {
			// do nothing
		}, function(){
			$(this).parent().find('ul.subnav').slideUp(200); //When the mouse hovers out of the subnav, move it back up
		});
	}, function () {
		// do nothing
	});
}
