jQuery(document).ready(function($){

	// top navigation

	$('#header .navigation li:first').addClass('first');
	$('#header .navigation li:last').addClass('last');

	if($('body').hasClass('single-portfolio') || $('body').hasClass('tax-portfolio-tags')) {
		$('#header .navigation li a').each(function(){
			if($(this).text() == "Portfolio"){
				$(this).parent('li').addClass('current-menu-item');
			}
		})
	}

	// services-blocks

	$('.services-blocks .box .hover-box').hover(function(){
		var boxHeight = $(this).find('.slide').height();
		var newHeight = 12 + boxHeight;

		$(this).find('.box-content').stop().animate({
			height	: newHeight
		}, 200, function(){
			$(this).next('.show').removeClass('show').addClass('hide');
		})
	},function(){
		$(this).find('.box-content').stop().animate({
			height	: 108
		}, 200, function(){
			$(this).next('.hide').removeClass('hide').addClass('show');
		})
	})

	// input file

	$('.quote-holder .wpcf7-file').wrap('<span><em></em></span>');

	$('.quote-holder span input').focus(function(){
		$(this).parent('span').addClass('active-input');
	})

	$('.quote-holder span input').blur(function(){
		$(this).parent('span').removeClass('active-input');
	})

	$('.quote-holder span textarea').focus(function(){
		$(this).parent('span').addClass('active-textarea');
	})

	$('.quote-holder span textarea').blur(function(){
		$(this).parent('span').removeClass('active-textarea');
	})

	// slider

	$('#slides').slides({
		preload: true,
		preloadImage: 'wp-content/themes/codus/images/loading.gif',
		play: 5000,
		pause: 2500,
		hoverPause: true,
		animationStart: function(current){
			$('.caption').animate({
				bottom:-40
			},100);
			if (window.console && console.log) {
				console.log('animationStart on slide: ', current);
			};
		},
		animationComplete: function(current){
			$('.caption').animate({
				bottom:0
			},200);
			if (window.console && console.log) {
				console.log('animationComplete on slide: ', current);
			};
		},
		slidesLoaded: function() {
			$('.caption').animate({
				bottom:0
			},200);
		}
	});

	$('#slides .pagination').wrap('<div class="control-holder"></div>');

	// testimonials

	$('ul#quotes').quote_rotator({
		rotation_speed: 6000,
		pause_on_hover: true
	});

	// tag cloud

	var currentTag = $('#content .portfolio-control .tag em').text();

	$('#content .tags-box a').each(function(){
		if ($(this).text() == currentTag) {
			$(this).addClass('active-tag');
		}
	})

})
