$(document).ready(function(){
	
	// Cufon
	Cufon.replace('h1');
	Cufon.replace('h3');
	

$(".videoGalleryYoutube").click(function() {
	$.fancybox({
			'padding'			: 10,
			'autoDimensions'	: true,
			'autoScale'			: true,
			'overlayOpacity'	: '0.85',
			'overlayColor'		: '#000000',
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

	return false;
});

$(".videoGalleryVimeo").click(function() {
	$.fancybox({
			'padding'			: 10,
			'autoDimensions'	: true,
			'autoScale'			: true,
			'overlayOpacity'	: '0.85',
			'overlayColor'		: '#000000',
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'href'			: this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

	return false;
});
	
	//Open all images in fancybox
	if(!$('a[rel=imagePicture]').length)
	{
		if(!$('.videoGalleryYoutube, .videoGalleryVimeo').length)
		{
			$("img").each(function() {
				$(this).addClass('image');
				var a = $('<a/>').attr('href', $(this).attr('src')).attr('rel', 'imagegal');
				$(this).wrap(a);
			});
		}
	}
	
	$('a[rel=imagegal]').fancybox({
				'autoDimensions'	: true,
				'autoScale'			: true,
				'overlayOpacity'	: '0.85',
				'overlayColor'		: '#000000',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'cyclic'			: true,
				'type'				: 'image',
				'href'				: $(this).attr('src'),
			});
	
	$('a[rel=imagePicture]').fancybox({
				'autoDimensions'	: true,
				'autoScale'			: true,
				'overlayOpacity'	: '0.85',
				'overlayColor'		: '#000000',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">' +  (currentIndex + 1) + ' / ' + currentArray.length + ' - <strong>' + title + '</strong></span>';
				},
				'cyclic'			: true,
				'type'				: 'image',
				'href'				: $(this).attr('src'),
			});

});
