$(document).ready(function(){
	// Add icons to link types
	$("a[href$='.pdf']").addClass("pdf");
	$("a[href$='.doc'], a[href$='.txt'], a[href$='.rft']").addClass("txt");
	$("a[href$='.zip'], a[href$='.rar']").addClass("zip");
	
	$("a[href$='.jpg'], a[href$='.gif'], a[href$='.png']").addClass("fancybox");
	$("a.fancybox").fancybox({
			'titlePosition'  : 'inside',
			'overlayColor'   :	'#fff'
		});
		
	$("div.video a").each(function(){
			$(this).after('<span class="play"></span>');
			url = $(this).attr('href');
			$(this).next("span").attr("data-url",url);
			$(this).next("span").addClass("not-loaded").click(function(){
				$(this).fancybox({
							'padding'		: 0,
							'autoScale'		: false,
							'transitionIn'	: 'none',
							'transitionOut'	: 'none',
							'title'			: this.title,
							'width'			: 680,
							'height'		: 495,
							'href'			: $(this).attr("data-url").replace(new RegExp("watch\\?v=", "i"), 'v/'),
							'overlayColor'  : '#fff',
							'type'			: 'swf',
							'swf'			: {
							'wmode'			: 'transparent',
							'allowfullscreen'	: 'true'
							}
						});
						if($(this).hasClass("not-loaded")){
							$(this).removeClass("not-loaded").trigger("click");
						}
		});
	});
	$("#carousel").codaSlider({
		autoSlide: true,
		autoSlideInterval: 8000,
		autoSlideStopWhenClicked: true,		
		dynamicArrows: false,
		dynamicTabsPosition: "bottom"
	});		
});
