Cufon.replace('.cufon-futura-bold', { fontFamily: 'Futura LT Bold' });

$(document).ready(function(){
	$('.case-study').hide();
	$('.case-study-item').hover(
		function() {
			if(!$(this).hasClass("activated")) { 
				$(this).find(".case-study-item-overlay").show();
				$(this).find(".case-study-item-overlay").animate({opacity: 0.9}, 300);
			} 
		}, 
		function() {
			if(!$(this).hasClass("activated")) { 
				$(this).find(".case-study-item-overlay").animate({opacity: 0}, 300);
				$(this).find(".case-study-item-overlay").hide();
			}
		}
	);

	$("#quicksand li, .client-list li").click(function (e) {
		e.preventDefault();												
		var selectedCasestudy = $(this).attr('data-id');
		if(selectedCasestudy) {
			$('.case-study').hide();
			$('.' + selectedCasestudy).show();
			//var offset = $('.' + selectedCasestudy).offset();
			//alert(offset.top);
			//$('html,body').animate({scrollTop: $("#"+selectedCasestudy).offset().top},'slow');
			//$.scrollTo( 'a[name=' + selectedCasestudy + ']', 1000 );
			//$.scrollTo( '.case-study', 1000 );
			$.scrollTo( '.' + selectedCasestudy, 1000 );
		}
		return false;
	});

	$(".ttt").click(function () {
		//$.scrollTo( 'a[name=top]', 1000 );
		
		$.scrollTo( 0, 1000 );
		$('.case-study').fadeOut(1500);
		return false;
	});
	
	var $applications = $('#quicksand');
	var $data = $applications.clone();
	
	$(".case-study-filters li a").click(function () {
		$(".case-study-filters li a").removeClass("active-filter");
		$(this).addClass("active-filter");
		var $filterType = $(this).attr("data-type");
		if ($filterType == 'all') {
			$('#quicksand li').css("display","none").fadeIn(1000);						
		} else {
			$('#quicksand li').css("display","none");
			$('.'+ $filterType).fadeIn(1000);
			//$('#quicksand li[data-type=' + $filterType + ']').fadeIn(2000);
		}
		
		return false;
	});		


/* Home Page Items */
	jQuery.fn.delay = function(time,func){
		return this.each(function(){
			setTimeout(func,time);
		});
	};
		
	$('.section_1').delay(4000, function(){
		$('.section_1').fadeOut("slow");
		$('.section_2').fadeIn("slow");
		//$('.browse').fadeIn("slow");
		$(".hero a.browse").hide()
		$('.section_2').scrollable({circular: true, mousewheel: true, speed: 1000}).autoscroll({
			interval: 4000		
		});
		var api = $(".section_2").data("scrollable");
		// do something upon scroll
		api.onSeek(function() {
			//console.info("current position is: " + this.getIndex())
		});
		$(".hero").hover(
		   function() {
			   $(".hero a.browse").fadeIn("slow");
		   },
		   function() {
			   $(".hero a.browse").fadeOut("slow");
		   }
		);
	})

	$(".item").hover(
	   function() {
		   $(this).find('.info_box').fadeIn("slow");
	   },
	   function() {
		   $(this).find('.info_box').fadeOut("slow");

	   }
	); 

	$(".item").click(function () {
		window.location=$(this).find("a.hero_link").attr("href");return false;
	});		

	
	$('a.timeline-browse, a.browse, a.opacity, div.div-more-link').hover(
		function() {
			$(this).find("img").animate({opacity: 1}, 300);
		}, 
		function() {
			$(this).find("img").animate({opacity: 0}, 300);
		}
	);
	
	var people_height = $('.people').height();
	$('.people-switch').click(function() {
		if($(this).hasClass("people-switch-active")) {
			$('.people .person .position').css("color", "#AAAAAA");
			$('.people').animate({
				//opacity: 0.25,
				//height: '+=50',
				height: 660
				}, 1000, function() {
					$('.people').css("overflow", "hidden");// Animation complete.
					
			});
			$(".people-switch img").attr("src", "/wp-content/themes/identica/images/arrow-up-full.png");
		} else {
			$('.people').animate({
				//opacity: 0.25,
				//height: '+=50',
				height: '40'
				}, 1000, function() {
					$('.people').css("overflow", "hidden");// Animation complete.
					$('.people .person .position').css("color", "#282828");
			});
			$(".people-switch img").attr("src", "/wp-content/themes/identica/images/arrow-down-full.png");
		}
		$(this).toggleClass("people-switch-active"); return false;
	});
	
	var partners_height = $('.partners').height();
	$('.partner-switch').click(function() {
		if($(this).hasClass("partner-switch-active")) {
			$('.partners').animate({
				//opacity: 0.25,
				//height: '+=50',
				height: partners_height
				}, 1000, function() {
					$('.partners').css("overflow", "hidden");// Animation complete.
					$('.partners .partner .partner-name').css("color", "#AAAAAA");
			});
			$(".partner-switch img").attr("src", "/wp-content/themes/identica/images/arrow-up-full.png");
		} else {
			$('.partners').animate({
				//opacity: 0.25,
				//height: '+=50',
				height: '40'
				}, 1000, function() {
					$('.partners').css("overflow", "hidden");// Animation complete.
					$('.partners .partner .partner-name').css("color", "#282828");
			});
			$(".partner-switch img").attr("src", "/wp-content/themes/identica/images/arrow-down-full.png");
		}
		$(this).toggleClass("partner-switch-active"); return false;
	});	
	
	
	$('.people').height(40);
	$('.people').animate({
				//opacity: 0.25,
				//height: '+=50',
				height: 660
				}, 1500, function() {
					$('.people').css("overflow", "hidden");// Animation complete.
					$('.people .person .position').css("color", "#AAAAAA");
	});
	$(".people-switch img").attr("src", "/wp-content/themes/identica/images/arrow-up-full.png");
	
	$(".highlight, .mini-highlight, .div-more-link").click(function () {
		window.location=$(this).find("a").attr("href");return false;									   
	});

	

});



