$(document).ready(function() {
	
		$.activeCycle = 1;
		
		$('.lightbox').fancybox();
		
		$('#photoWrapper').cycle();
		
		$('#newsPhotoWrapper').cycle();
		
		$('#portfolioPics a').easyTooltip();
		
		

		$(window).load(function() {
			$('.jcarousel-skin-evenepoel li a img').each(function() {
				$(this).parent().parent().width($(this).width());
				$(this).parent().parent().height($(this).height());
			});
			
			
			$('#portfolioPics').jcarousel();
			
			$('#newsThumbs').jcarousel({
				vertical: true
			});
		});
		
		
		/**
		 * Stop the cycle when clicked on an image
		 * 
		 * Fade the clicked image in
		 * 
		 */
		$('#newsThumbs a').click(function(e) {
			
			if($.activeCycle == 1) {
				$('#newsPhotoWrapper').cycle('stop');
				$('#newsPhotoWrapper .photocycle').each(function(){
					$(this).removeAttr('style');
					$(this).addClass('endCycle');
				})
				$.activeCycle = 0;
			}
			
			$.mediahref = $(this).attr('href');

			$('#newsPhotoWrapper .photocycle').each(function() {
				
				id = '#' + $(this).attr('id');
				if(id == $.mediahref) {
					$(this).fadeIn();
				} else {
					$(this).fadeOut();
				}
			});
			
			e.preventDefault();
		});

});
