$(document).ready (function () {				
	$(".menu li").hover(
		function() {
			$(this).addClass("sfhover");
		},
		function() {
			$(this).removeClass("sfhover");
		}
	);

	
	$('#menu-hide').hide().addClass('hidden');

	$('#menu-button a').click(function() {
		if ($('#menu-hide.hidden').length == 0) {
			$('#menu-hide').addClass('hidden');
			$('#menu-hide').hide('slide', { direction: "up" }, 200);
		}
		else if ($('#menu-hide.hidden').length == 1) {
			$('#menu-hide').removeClass ('hidden');
			$('#menu-hide').show('slide', { direction: "up" }, 600);			
		}
		return false;
	});
	
	$('#menu-button a').hover(
		function() {
			if ($('#menu-hide.hidden').length == 1) {
				$('#menu-hide').show('slide', { direction: "up" }, 600);
				$('#menu-hide').removeClass ('hidden');
			}
		}, function() {}
	);
	
	$('#title').hover(
		function() {}, function () {
			if ($('#menu-hide.hidden').length == 0) {	
				$('#menu-hide').addClass('hidden');
				$('#menu-hide').hide('slide', { direction: "up" }, 200);
			}
		}
	);
	
	$('#main-intro-right').cycle ({
		fx:     'scrollHorz',
		prev:   '#prev',
		speed:	'fast',
		next:   '#next',
		timeout: 5000,
		after:   onAfter
	});
});

function onAfter(curr, next, opts) {
    var index = $(this).parent().children().index(this);
    $('#prev')[index == 0 ? 'fadeOut' : 'fadeIn']();
    $('#next')[index == opts.slideCount - 1 ? 'fadeOut' : 'fadeIn']();
}