$(document).ready(

	// back to top
	function()
	{
		// hide #back-top first
		$("#back-top").hide();
		
		// fade in #back-top
		$(function () {
			$(window).scroll(function () {
				if ($(this).scrollTop() > 100) {
					$('#back-top').fadeIn();
				} else {
					$('#back-top').fadeOut();
				}
			});
	 
			// scroll body to 0px on click
			$('#back-top a').click(function () {
				$('body,html').animate({
					scrollTop: 0
				}, 800);
				return false;
			});

		$("a.thumbnail").fancybox ({
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic',
			'overlayColor'	: '#000',
			'overlayOpacity': 0.9
		});
		
		$("a[rel=group]").fancybox ({
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic',
			'overlayColor'	: '#000',
			'overlayOpacity': 0.9,
			'titlePosition'	:	'over',
			'onComplete'	:	function() {
				$("#fancybox-wrap").hover(function() {
					$("#fancybox-title").show();
				}, function() {
					$("#fancybox-title").hide();
				});
			}
		});
		
		$("#fancyvideo").click(function() {
			$.fancybox({
					'padding'		: 0,
					'autoScale'		: true,
					'autoPlay'		: true,
					'overlayColor'	: '#000',
					'overlayOpacity': 0.9,
					'transitionIn'	: 'fade',
					'transitionOut'	: 'fade',
					'title'			: this.title,
					'width'			: 640,
					'height'		: 360,
					'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
					'type'			: 'swf',
					'swf'			: {'wmode'		: 'transparent', 'allowfullscreen'	: 'true'}
				});

			return false;
		});
		
		$("#swf").fancybox({
			'width'				: '75%',
			'height'			: '75%',
			'padding'           : 0,
			'autoScale'     	: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none'
		});
	});
});
