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

jQuery(document).ready(function($) {
    
    $('#search').labelify();

    /* Portfolio toggle */
    $('.portfolio-toggle').click(function(event) {
        
        var button = $(event.target),
            container = $('#project_grid'),
            active_class = 'show-details-active';
        
        if( $(button).hasClass(active_class) ) {
            $(button).removeClass(active_class);
            $(container).removeClass('showing-details');
        } else {
            $(button).addClass(active_class);
            $(container).addClass('showing-details');        
        }
        
    });

    /* Team toggle */
    $('.team-toggle').click(function(event) {
        
        var button = $(event.target),
            team = $('#team'),
            active_class = 'show-details-active';
        
        if( $(button).hasClass(active_class) ) {
            $(button).removeClass(active_class);
            $(team).removeClass('showing-details');
        } else {
            $(button).addClass(active_class);
            $(team).addClass('showing-details');        
        }
        
    });

    /* Project toggle */
    $('.project-toggle #subhead h2').click(function(event) {
        var toggable = $('#folio-item');
        
        if( $(toggable).is(':visible') ) {
            $(toggable).slideUp();
            $(event.target).parents('#subhead:first').find('a').removeClass('active-toggle-button');
        } else {
            $(toggable).slideDown();
            $(event.target).parents('#subhead:first').find('a').addClass('active-toggle-button');
        }
    });

    /* Main menu dropdown */
    $('ul#main-menu')
        .superfish({
            animation:   {opacity:'show',height:'show'},
            easing:      'easeOutBack'
        })
        .find('ul').bgIframe({opacity:false});
	
	/* Colorbox on flickr galleries */
    $("a[rel='gallery']").colorbox({
        innerWidth: '550px'
        });
    
    /*JS Back button */
    $('a.js_back').click(function(e) {
        history.go(-1);
        e.preventDefault();
    });
});
