$(document).ready(function () {
	$().piroBox({
		my_speed: 400, //animation speed
		bg_alpha: 0.1, //background opacity
		slideShow : true, // true == slideshow on, false == slideshow off
		slideSpeed : 4, //slideshow duration in seconds(3 to 6 Recommended)
		close_all : '.piro_close,.piro_overlay'// add class .piro_overlay(with comma)if you want overlay click close piroBox

	});
	$("a[rel^='prettyPhoto']").prettyPhoto();
	var speed = 1000,  // animation speed
	    $wall = $('#primary')
	;
	$('a[rel~=external]').attr('target', '_blank');
	$('a.internal').each(function () {
		var url = $(this).text();
		url = url.replace(/(ftp|http|https|file):\/\//i, '');
		if (url.length > 10) {
			$(this).text(url.substr(0, 5) + '...');
		}
	});

	$wall.masonry({
	    // only apply masonry layout to visible elements
	    itemSelector: '.box:not(.invis)',
	    animate: true,
	    singleMode: true,
	    animationOptions: {
	        duration: speed,
	        queue: false
	    }
	});
	
	$('#filtering-nav a').click(function(){
	    var colorClass = '.' + $(this).attr('class');
	    
	    if(colorClass=='.all') {
	        // show all hidden boxes
	        $wall.children('.invis')
	            .toggleClass('invis').fadeIn(speed);
	    } else {    
	        // hide visible boxes 
	        $wall.children().not(colorClass).not('.invis')
	            .toggleClass('invis').fadeOut(speed);
	        // show hidden boxes
	        $wall.children(colorClass+'.invis')
	            .toggleClass('invis').fadeIn(speed);
	    }
	    $wall.masonry();
	
	    return false;
	});
	
});

