$(document).ready(function() {
	$(".img").fancybox({
		'titlePosition'	: 'over',
		'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over"><span class="page">Bild '+(currentIndex + 1)+' / '+currentArray.length+'</span>'+title+'&nbsp;</span>';
		},
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'onComplete'	: function() {
			$("#fancybox-wrap").hover(function() {
				$("#fancybox-title").show();
			}, function() {
				$("#fancybox-title").hide();
			});
		}
	});
	$(".vid").each(function() {
		this.href = this.href.replace(new RegExp("watch\\?v=", "i"), 'v/');
	});
	$(".vid").fancybox({
		'padding'	: 0,
		'autoScale'	: false,
		'title'		: this.title,
		'titleShow'	: false,
		'width'		: 680,
		'height'	: 495,
		'type'		: 'swf',
		'swf'		: {
			'wmode'				: 'transparent',
			'allowfullscreen'	: 'true'
		}
	});
	if (window.location.hash!='') {
		var hash = window.location.hash.replace(/#vid_/, "");
		if ($("#v_"+hash).length!=0) {
			$("#v_"+hash).trigger('click');
			return false;
		}
	}
});
