jQuery(function ($) {

	// Thumbnail hover

	$("#carousel li a.image img").before('<span class="imghover"></span>');
	$("#carousel li a.youtube img, #carousel li a.vimeo img").before('<span class="vidhover"></span>');

	$('#carousel li a span').css('opacity', '0').css('display', 'block');
	
	$("#carousel li a").hover(
		function () {
			$(this).find('.imghover, .vidhover').stop().fadeTo('slow', .5); }, 
		function () {
			$('.imghover, .vidhover').stop().fadeOut('slow', 0);
	});
	
	// Fancybox gallery
	
	$("#carousel a").fancybox({		
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
	
	$("#carousel a.youtube").click(function() {
        $.fancybox({
            'padding' : 0,
            'autoScale' : false,
            'title' : this.title,
            'overlayOpacity' : '.6',
            'overlayColor' : '#333',
            'transitionIn' : 'none',
            'transitionOut' : 'none',
            'centerOnScroll' : false,
            'showCloseButton' : true,
            'hideOnOverlayClick': false,
            'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '&autoplay=1&hd=1',
            'type' : 'swf',
            'swf' : {'wmode': 'transparent', 'allowfullscreen': 'true'}
        });
        return false;
    });
    
    $("#carousel a.vimeo").click(function() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 560,
			'height'		: 312,
			'href'			: this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
			'type'			: 'swf'
		});
 
		return false;
	});
    
    // jCarousel slider
	
	$('#carousel').jcarousel();
	
	// Menu tooltip
	
	$('#menu a').poshytip({
		className: 'tooltip',
		showTimeout: 5,
		hideAniDuration: 0,		
		alignTo: 'target',
		alignX: 'center',
		offsetY: 7,
		allowTipHover: false,
		fade: true,
		slide: true		
	});
	
	// Menu scroll
	
	$('#menu a').click(function(e) {
		e.preventDefault();
		$.scrollTo($(this).attr('href'), 750);		
	});
	
});
