function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}

$(document).ready(function() {
    equalHeight($(".folio"));
	equalHeight($(".author-info"));
});



$(document).ready(function(){
	
	// related work thumbnail slider
	$('.relatedwork.slidedown').hover(function(){
		$('.relatedthumb', this).stop().animate({top:'85px'},{queue:false,duration:300});
				}, function() {
		$('.relatedthumb', this).stop().animate({top:'0px'},{queue:false,duration:300});
				});
				
	// recently archived posts slider
	$('.recentarchived.slideright').hover(function(){
		$('.archivedthumb', this).stop().animate({left:'160px'},{queue:false,duration:300});
				}, function() {
		$('.archivedthumb', this).stop().animate({left:'0px'},{queue:false,duration:300});
				});
				
	// search posts slider
	$('.results.slideright').hover(function(){
		$('.resultsthumb', this).stop().animate({left:'220px'},{queue:false,duration:300});
				}, function() {
		$('.resultsthumb', this).stop().animate({left:'0px'},{queue:false,duration:300});
				});
	
	// Tabs
	$('#tabs div').hide();
	$('#tabs div:first').show();
	$('#tabs ul.tab-links li:first').addClass('active');

	$('#tabs ul.tab-links li a').click(function(){
	$('#tabs ul.tab-links li').removeClass('active');
	$(this).parent().addClass('active');
		var currentTab = $(this).attr('href');
	$('#tabs div').hide();
	$(currentTab).show();
		return false;
	});
	
	// Fancybox
	$("a.grande").fancybox();

});

// portfolio details slider
$(window).bind("load", function() { 
	$("div#sliderimages").slideView({ 
		easeFunc: "easeOutBounce", 
		easeTime: 1200 
		}); 
	});
	
// we are talk balloon	
$(function () {
  $('.talkbubble').each(function () {
    // options
    var distance = 10;
    var time = 250;
    var hideDelay = 10;

    var hideDelayTimer = null;

    // tracker
    var beingShown = false;
    var shown = false;
    
    var trigger = $('.trigger', this);
    var popup = $('.popup', this).css('opacity', 0);

    // set the mouseover and mouseout on both element
    $([trigger.get(0), popup.get(0)]).mouseover(function () {
      // stops the hide event if we move from the trigger to the popup element
      if (hideDelayTimer) clearTimeout(hideDelayTimer);

      // don't trigger the animation again if we're being shown, or already visible
      if (beingShown || shown) {
        return;
      } else {
        beingShown = true;

        // reset position of popup box
        popup.css({
          top: -20,
          left: 135,
          display: 'block' // brings the popup back in to view
        })

        // (we're using chaining on the popup) now animate it's opacity and position
        .animate({
          top: '-=' + distance + 'px',
          opacity: 1
        }, time, 'swing', function() {
          // once the animation is complete, set the tracker variables
          beingShown = false;
          shown = true;
        });
      }
    }).mouseout(function () {
      // reset the timer if we get fired again - avoids double animations
      if (hideDelayTimer) clearTimeout(hideDelayTimer);
      
      // store the timer so that it can be cleared in the mouseover if required
      hideDelayTimer = setTimeout(function () {
        hideDelayTimer = null;
        popup.animate({
          top: '-=' + distance + 'px',
          opacity: 0
        }, time, 'swing', function () {
          // once the animate is complete, set the tracker variables
          shown = false;
          // hide the popup entirely after the effect (opacity alone doesn't do the job)
          popup.css('display', 'none');
        });
      }, hideDelay);
    });
  });
});

// scrolling
$(document).ready(function() {
	$("a.scroller").anchorAnimate()
});

jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 400
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}