$(function(){
	
	// Modal windows for ToS, if you don't plan to use it, you can safely remove that zone
	/* remove this line
	$.fancybox({		
	  'width'		: 630,
	  'height'		: 720,
	  'autoSize'	: false,
	  'title'		: 'Terms of service',
	  'href'		: 'terms-of-service - alternative.html',
	  'type'		: 'ajax',
	  'closeBtn'	: false,
	  'modal' 		: true
	});
	// */
	
	// Fortress tabs
	$($('.fortress-status .tabs li[class="active"] a').attr('href')).fadeIn('slow');
	
	$('.fortress-status .tabs li a').click(function(){
		$('.fortress-status .tabs li[class="active"]').removeClass('active');
		$(this).parent('li').addClass("active");
		
		$('.fortress-status .content ul:visible').hide();
		$($(this).attr('href')).show();
	
		return false;
	});
	
	// Stuff for the medias videos to be rendered in fancybox popup ( still need to improve it)
	$(".medias a").click(function() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 640,
			'height'		: 390,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

		return false;
	});

	// to allow li hover on low ie version
	$('header nav li').hover(
		function(){$(this).addClass('active');},
		function(){$(this).removeClass('active');}
	)
	
	// Cycle on the focus
	$('#slideshow').cycle({ 
		fx:     'fade', 
		speed:  'slow', 
		timeout: 7500, 
		pager:  '#focus-pager', 
		pagerAnchorBuilder: function(idx, slide) {
			return '<li><a href="#"></a></li>'; 
		} 
	});
	$('#focus-pager li').css('width', ((100/$('#focus-pager li').length).toFixed(3)).toString() + '%');
})

