$(document).ready(function() {
	// slideshow
	$('.flexslider').flexslider({
		animation: "slide",
		pauseOnHover: true,
		pauseOnAction: true
	});
	
	$('.work-detail-slides').flexslider({
		slideshow: false,
		controlNav: true,
		animation: "slide"
	});
	
	// tweets
	$(".tweet").tweet({
		username: "pencilstudio",
		count: 4,
		template: "{time} {text}",
		loading_text: "Loading tweets..."
	});
	
	// portfolio hover
	$(".item").hover(function () {
		$(this).children(".panel").slideToggle(300);
	});
	
	// portfolio clickable div
	$(".panel").click(function(){
	     window.location=$(this).find("a").attr("href");
	     return false;
	});
	
	// footer social hover - http://www.sohtanaka.com/web-design/greyscale-hover-effect-w-css-jquery/
	$("ul.social li, .description-nav li, .more-info li").hover(function() {

		var socialOver = $(this).find("img").attr("src");

		$(this).find("a.thumb").css({'background' : 'url(' + socialOver + ') no-repeat center bottom'});

		$(this).find("span").stop().fadeTo(200, 0 , function() {
			$(this).hide();
		});
	} , function() {
		$(this).find("span").stop().fadeTo(200, 1).show();
	});
	
	// portfolio sort - http://net.tutsplus.com/tutorials/javascript-ajax/creating-a-filterable-portfolio-with-jquery/
	$('ul#filter a').click(function() {
		$(this).css('outline','none');
		$('ul#filter .current').removeClass('current');
		$(this).parent().addClass('current');
		
		var filterVal = $(this).text().toLowerCase().replace(' ','-');
				
		if(filterVal == 'all') {
			$('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
		} else {
			
			$('ul#portfolio li').each(function() {
				if(!$(this).hasClass(filterVal)) {
					$(this).fadeOut('normal').addClass('hidden');
				} else {
					$(this).fadeIn('slow').removeClass('hidden');
				}
			});
		}
		
		return false;
	});
	
	// our team toggle
	$(".profile-toggle-a, .profile-toggle-b, .profile-toggle-c").css("display","none");
	
	$(".luke a").click(function () {
		$("p.profile-toggle-a").slideToggle("300");
		return false;
    });
    
    $(".sullivan a").click(function () {
		$("p.profile-toggle-b").slideToggle("300");
		return false;
    });
    
    $(".harry a").click(function () {
		$("p.profile-toggle-c").slideToggle("300");
		return false;
    });
    
    // map tabs
    $(".tab-content").hide();
	$("ul.tabs li:first").addClass("active").show();
	$(".tab-content:first").show();
	$("ul.tabs li").click(function() {
	    $("ul.tabs li").removeClass("active");
	    $(this).addClass("active");
	    $(".tab-content").hide();
	    var activeTab = $(this).find("a").attr("href");
	    $(activeTab).show();
	    
	    return false;
	});

});




