Cufon.replace('h1:not(".no-title"),.menu-header-container a, .read-more, .view-more .xoxo h3, h3#reply-title, .site a:not(".site-thumb"), h2, #search-2 label, .wpcf7-form label, .form-title, #respond label, .nav-previous, .nav-next', { fontFamily: 'avant-garde-demi' });

jQuery(function( $ ){
	$('#personal-intro').height($('#personal-intro').height());
	$('#personal-intro span').hide();
	
	if($('#main-image-slider').size()>0){
		var mainImageHeight = $('#main-image-slider img:first').height();
		var smallImageWidth = $('#top-left-slider img:first').width();
		var smallImageHeight = $('#bottom-left-slider img:first').height();
		var imageCount = $('#main-image-slider img').length;
		$('#main-image-slider').css({
			'top':-($('#main-image-slider').height() - mainImageHeight),
			'height':$('#main-image-slider').height()
		});
		$('#top-left-slider').css({
			'width':imageCount * smallImageWidth,
			'left':-((imageCount-1) * smallImageWidth)+smallImageWidth
		});
		var z =2;
		for (var i=0; i < imageCount-1; i++) {
			imageClone = $('#bottom-left-slider img:eq('+z+')').clone();
			$('#bottom-left-slider').append(imageClone);
			$('#bottom-left-slider img:eq('+z+')').remove();
			z--;
		};
		$('#bottom-left-slider').css({
			'width':imageCount * smallImageWidth,
			'left':-((imageCount-1) * smallImageWidth)+smallImageWidth
		});
		

		(function moveMainImage() {
			setTimeout(function(){
				$('#main-image-slider').animate({'top':'+='+mainImageHeight+'px'},1000, 
				function(){
					imageClone = $('#main-image-slider img:last').clone();
					$('#main-image-slider').prepend(imageClone).css('top',-($('#main-image-slider').height() - mainImageHeight));
					$('#main-image-slider img:last').remove();
				});
				$('#top-left-slider').animate({'left':'+='+smallImageWidth+'px'},1000,
				function(){
					imageClone = $('#top-left-slider img:last').clone();
					$('#top-left-slider').prepend(imageClone).css('left',-((imageCount-1) * smallImageWidth)+smallImageWidth);
					$('#top-left-slider img:last').remove();
				});
				$('#bottom-left-slider').animate({'left':'-='+smallImageWidth+'px'},1000,
				function(){
					imageClone = $('#bottom-left-slider img:first').clone();
					$('#bottom-left-slider').append(imageClone).css('left',-((imageCount-1) * smallImageWidth)+smallImageWidth);
					$('#bottom-left-slider img:first').remove();
				});
				moveMainImage();
			},4000);
		})();
	}
	
	function initAnimation() {
		$('.block-1 span').fadeIn(500, function(){
			$('.a-freelance span').fadeIn(300,function(){
				$('div.web-designer span').fadeIn(500,function(){
					$('div.specialising-in span').fadeIn(700,function(){
						$('#more-about-me span').fadeIn(500);
					})
				})
			})
		});
	}
	
	if ($('#image-rotation').size()>0) {
		$('#image-rotation img:not(":first")').hide();

		(function rotateImages() {
			setTimeout(function(){
				$('#image-rotation img:visible').fadeOut(500);
				if($('#image-rotation img:visible').next('img').size() > 0) {
					$('#image-rotation img:visible').next('img').fadeIn(500);
				} else {
					$('#image-rotation img:first').fadeIn(500);
				}
				
				rotateImages();
			},4000);
		})();
	};
	
	if($('.block-1 span').size()>0) {
		initAnimation();
	}
	
	if($('.portfolio-item').size()>0) {
		$('p',this).slideUp();
		$('.portfolio-item-slide').height(200);
		$('.portfolio-item-slide .slider').css('top','-100px');
		$('.portfolio-item-slide .slider').each(function(){
			$(this).width($('img',this).width()*$('img',this).size());
		})
		
		$('a.move-left').click(function(e){
			e.preventDefault();
			if($(this).parent().children().children('.slider:not(":animated")').size()>0) {
				$(this).parent().children().children('.slider').children('img:last').prependTo($(this).parent().children().children('.slider'));
				$(this).parent().children().children('.slider').css('left','-860px').animate({'left':'0'});
			}
		})

		$('a.move-right').click(function(e){
			e.preventDefault();
			if($(this).parent().children().children('.slider:not(":animated")').size()>0) {
				$(this).parent().children().children('.slider').animate({'left':'-860px'},function(){
					$(this).children('img:first').appendTo($(this));
					$(this).css('left','0');
				});
			}
		})
		
		$('.portfolio-item').mouseenter(function(){
			$('.portfolio-item-slide, .move-left, .move-right',this).animate({'height':'400px'});
			$('.slider',this).animate({'top':'0'})
			$('p',this).slideDown();
		}).mouseleave(function(){
			$('.portfolio-item-slide, .move-left, .move-right',this).animate({'height':'200px'});	
			$('.slider',this).animate({'top':'-100px'})
			$('p',this).slideUp();
		})
	}

	if($('#thumbs').size()>0){

		$(window).load(function(){
			$('#thumbs img').each(function(){
				$(this).height($(this).height())
			})
			$('#thumbs').masonry({ 
				columnWidth: 5
			});
			$('#thumbs').fadeIn();
		})		
	}
});

