$(document).ready(function(){
	
	Cufon.replace('nav a, .cufon', {hover: true});
	
	// check for firefox
	if(jQuery.browser.mozilla){
		
		// get all video's
		$('video[loop="loop"]').bind('ended', function(){
			this.play();
		})
		
	}

	$('ul.webisodes a').click(function(e){
		e.preventDefault();
		// find video with id
		$('a.vimeo:not(.spec)').css('display', 'none');
		if($('a#' + this.href.split(/#/)[1]).length > 0){
			$('a#' + this.href.split(/#/)[1]).css('display', 'block');
			$('ul.webisodes a.active').removeClass('active');
			$(this).addClass('active');
		}
	})
	
	$("a.vimeo").click(function(e) {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 800,
			'height'		: 400,
			'href'			: this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
			'type'			: 'swf',
			'overlayShow'	: false
		});

		e.preventDefault();
	});
	
	$('body.home  nav > ul > li').click(function(e){
		var sub = $(this).find('.sub-menu');
		if (sub.length && !$(this).hasClass('menu-news')){
			if (!sub.hasClass('active')) {
				sub.addClass('active');
				e.preventDefault();
			}
		}
	})
	
})
