$(function(){
  //run masonry when page first loads
  $(window).load(function() {
  	$('#container').masonry(); 
  });
  //run masonry when window is resized
  $(window).resize(function() {
  	$('#container').masonry();
  });

//	
	
	$(".box").each(function(){
		$(this).css("opacity", .9);
	});
	
	$(".box").mouseover(function(){
			$(this).css("opacity", 1);
	});
	$(".box").mouseout(function(){
			$(this).css("opacity", .9);
	});
	
	//
  //url
	var arr = $('.box');
	 $("a[rel='history']").click(function(){  
		$(this).children("li").addClass("active");
		var toLoad = $(this).attr('href')+' #m'; 
		loadContent();
		window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length);  
		function loadContent() {
			$('#loading').show();
		    // $(".box").each(function(value){
		    // 			  	$(this).animate({
		    // 				    opacity: 0,
		    // 				  }, 100*value*2, function() {
		    // 				}).delay(value*100);	
		    // 		    });
			$('#container').load(toLoad, function(){
				
			});
		}
		 return false;  
	 });
});
function clearNav(){
	$("#navi1 li").each(function(){
		$(this).removeClass("active");
	});
}




