$(function() {

	/*$("#nav li").mouseenter(function(){  
		jQuery("ul", this).fadeIn();  
	});
	$("#nav li").mouseleave(function(){  
	jQuery("ul", this).fadeOut();  
	});*/

	jQuery.fn.getTitle = function() {
		var arr = jQuery("a.fancybox");
		jQuery.each(arr, function() {
			var title = jQuery(this).children("img").attr("title");
			jQuery(this).attr('title',title);
		})
	}

	// Supported file extensions
	var thumbnails = 'a:has(img)[href$=".bmp"],a:has(img)[href$=".gif"],a:has(img)[href$=".jpg"],a:has(img)[href$=".jpeg"],a:has(img)[href$=".png"],a:has(img)[href$=".BMP"],a:has(img)[href$=".GIF"],a:has(img)[href$=".JPG"],a:has(img)[href$=".JPEG"],a:has(img)[href$=".PNG"]';

	jQuery(thumbnails).addClass("fancybox").attr("rel","fancybox").getTitle();

	$("a.fancybox").fancybox({
		'autoScale': true,
		'transitionIn': 'elastic',
		'transitionOut': 'elastic',
		'titleShow': true,
		'titlePosition': 'over',
		'margin': 70,
		'padding': 10,
		'opacity': true,
		'speedIn': 500,
		'speedOut': 500,
		'changeSpeed': 300,
		'overlayShow': true,
		'overlayColor': "#000000",
		'overlayOpacity': 0.7,
		'enableEscapeButton': true,
		'showCloseButton': true,
		'hideOnOverlayClick': true,
		'hideOnContentClick': false,
		'width':  560,
		'height':  340,
		'centerOnScroll': true
	});

	$("a[rel=youtube]").click(function() {
		$.fancybox({
			'padding'		: 1,
			'autoScale'		: false,
			'overlayColor'	: '#000000',
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade',
			'title'			: this.title,
			'width'			: 854,
			'height'		: 508,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});
		return false;
	});

});
