// JavaScript Document

$(document).ready(function() {
			
	  $('p.theend').fadeTo("fast", 0);

	
$('#wrapper').masonry
({
	columnWidth: 10, 
	itemSelector: '.box'
});

$(function() {
$.fn.showdelay = (function() {
	var delay = 0;
	$(this).hide();
	return this.each(function() {
		$(this).delay(delay).fadeIn(200);
      				delay += 80;
    			});
			});
			});
			
$('.box').showdelay();

$(".box").hover(function(){
	if ($(this).hasClass('dimmed')) {
		$(this).stop().fadeTo("fast", 1);
	}
	else if ($(this).hasClass('holder')) {
		$stop();
	} else if ($(this).hasClass("twitter")) {
$(this).find("#back, .tweetdate").stop().fadeTo("fast", 0.2);
$(this).find("p, p a").stop().animate({color: "#333333"}, 200);
$(this).find(".homeHeading").stop().animate({
bottom:0
}, 400);
}
	else {
		$(this).stop().fadeTo("fast", 0.2);
	}
},function () {
if($(this).hasClass('dimmed')){
  $(this).stop().fadeTo("fast", 0.2);
} else if ($(this).hasClass("twitter")) {
$(this).find("#back, .tweetdate").stop().fadeTo("fast", 1);
$(this).find("p, p a").stop().animate({color: "#FFFFFF"}, 200);
$(this).find(".homeHeading").stop().animate({
bottom:-40 + "px"
}, 400);
} else {
  $(this).stop().fadeTo("fast", 1);
}
  });
  
  	$(".filterwork").click(function(){
		if ($(this).hasClass('active')) {
			return false;
		}
		else {
  		$('#filters a').removeClass('active');
  		$(this).addClass('active');
		$('.parent3').fadeTo("medium", 0.2).addClass('dimmed');
  		$(".parent2").fadeTo("medium", 1).removeClass('dimmed');
  		return false;
		}
  	});
  	
  	$(".filterblog").click(function(){
		if ($(this).hasClass('active')) {
			return false;
		}
		else {
			$('#filters a').removeClass('active');
			$(this).addClass('active');
			$('.parent2').fadeTo("medium", 0.2).addClass('dimmed');
			$(".parent3").fadeTo("medium", 1).removeClass('dimmed');
			return false;
		}
  	});
  	
  	$(".filterall").click(function(){
  		$('#filters a').removeClass('active');
  		$(this).addClass('active');
  		$(".box").fadeTo("fast", 1).removeClass('dimmed');
  		return false;
  	});
  
  $('#wrapper').infinitescroll({
  navSelector  : '#ditto_pages',  // selector for the paged navigation 
  nextSelector : 'a.ditto_next_link',  // selector for the NEXT link (to page 2)
  itemSelector : '.boxScroll',     // selector for all items you'll retrieve
  loadingImg : '/assets/js/x.gif',
  donetext  : '',
  debug: false,
  errorCallback: function() { 
    // fade out the error message after 2 seconds
    $('#infscr-loading').animate({opacity: .8},2000).fadeOut('normal');   
  }
  },
  // call masonry as a callback
  function( newElements ) { 
    $(this).masonry({ appendedContent: $( newElements ).showdelay() });
 $(".box").hover(function(){
	if ($(this).stop().hasClass('dimmed')) {
		$(this).stop().fadeTo("fast", 1);
	}else if ($(this).hasClass("twitter")) {
$(this).find("#back, .tweetdate").stop().fadeTo("fast", 0.2);
$(this).find("p, p a").stop().animate({color: "#333333"}, 200);
$(this).find(".homeHeading").stop().animate({
bottom:0
}, 400);
}else {
		$(this).fadeTo("fast", 0.2);
	}
},function () {
if($(this).stop().hasClass('dimmed')){
  $(this).stop().fadeTo("fast", 0.2);
} else if ($(this).hasClass("twitter")) {
$(this).find("#back, .tweetdate").stop().fadeTo("fast", 1);
$(this).find("p, p a").stop().animate({color: "#FFFFFF"}, 200);
$(this).find(".homeHeading").stop().animate({
bottom:-40 + "px"
}, 400);
}else {
  $(this).stop().fadeTo("fast", 1);
}
  });

	if ($(".filterblog").hasClass('active')) {
$('.parent2').fadeTo("fast", 0.5).addClass('dimmed');
	}
	if ($(".filterwork").hasClass('active')) {
$('.parent3').fadeTo("fast", 0.5).addClass('dimmed');
	}

  }
);

/*$(".twitter").live("click", function(event) {
console.debug("click");
event.preventDefault();
window.open("http://www.twitter.com/pixilliondigi");
});*/

window.onunload = function(){}; 

});
