// MASONRY
$(function(){

  var 
    speed = 500,   // animation speed
    $wall = $('#content').find('.wrap'),

    masonryOptions = {         // initial masonry options
      columnWidth: 100, 
      itemSelector: '.box:not(.invis)',
      animate: true,
      animationOptions: {
        duration: speed,
        queue: false
      }
    }
  ;

  // run on window.load so we can capture any incoming hashes
  $(window).load(function(){
    // run masonry on start-up to capture all the boxes we'll need
    $wall.masonry(masonryOptions);
    if ( window.location.hash ) {
      // get rid of the '#' from the hash
      var possibleFilterClass = window.location.hash.replace('#', '');
      switch (possibleFilterClass) {
      // if the hash matches the following words
      case 'interactive' : case 'illustration' : case 'print' : case 'contact' : case 'etc' : 
        // set masonry options animate to false
        masonryOptions.animate = false;
        // hide boxes that don't match the filter class
        $wall.children().not('.'+possibleFilterClass)
          .toggleClass('invis').hide();
        // run masonry again, this time with the necessary stuff hidden
        $wall.masonry(masonryOptions);
        break;
      }
    }

  });

  $('#nav a').click(function(){
    var 
      color = $(this).attr('class'),
      filterClass = '.' + color;
    ;

    if(filterClass=='.all') {
      // show all hidden boxes
      $wall.children('.invis')
        .toggleClass('invis').fadeIn(speed);
    } else {
      // hide visible boxes 
      $wall.children().not(filterClass).not('.invis')
        .toggleClass('invis').fadeOut(speed);
      // show hidden boxes
      $wall.children(filterClass+'.invis')
        .toggleClass('invis').fadeIn(speed);

    }
    $wall.masonry({ animate: true });
    // set hash in URL
    window.location.hash = color;
    return false;
  });

});


// HOVER ON BOXES

$(document).ready(function(){

$("span.text").css({'opacity':'0'});

$('#content a.thumb').hover(
	function() {
		$(this).find('span.text').stop().fadeTo(150, 1);
	},
	function() {
		$(this).find('span.text').stop().fadeTo(150, 0);
	}
)

$('#content div.thumb').hover(
	function() {
		$(this).find('span.text').stop().fadeTo(150, 1);
	},
	function() {
		$(this).find('span.text').stop().fadeTo(150, 0);
	}
)
});


// COLORBOX

$(document).ready(function(){
               //Examples of how to assign the ColorBox event to elements
               $("a[rel='1'], a[rel='2'], a[rel='3'], a[rel='4'], a[rel='5'], a[rel='6'], a[rel='7'], a[rel='8'], a[rel='9'], a[rel='10'], a[rel='11'], a[rel='12'], a[rel='13'], a[rel='14'], a[rel='15'], a[rel='16'], a[rel='17'], a[rel='18'], a[rel='19']").colorbox({
                       transition:"fade",
                       current: "{current} / {total}",
                       previous: "&larr;",
                       next: "&rarr;",
                       close: "x",
                       loop: false,
                       initialHeight: "60",
                       initialWidth: "100",
                       opacity: 0.7,
                       preloading: true
               });

//HRDLUV
		
// FIXED NAV

		$(window).scroll(function(){
			var wo = (window.scrollY) ? window.scrollY : document.documentElement.scrollTop;
			if(wo >= 370 ){
				$("#nav").addClass('fixed');
				$("#content").addClass('bumper');
			}
			else if(wo < 370){
				$("#nav").removeClass('fixed');
				$("#content").removeClass('bumper');
			}
		});

});	

// SCROLL TO TOP

$(function () {  
    $(window).scroll(function () {  
        if ($(this).scrollTop() >= 500) {  
            $('.top').fadeIn();  
        } else {  
            $('.top').fadeOut();  	
        }  
    });  
    $('.top').click(function () {  
        $('body,html').animate({  
            scrollTop: 370  
        },  
        800);  
    });  
});

// CLOSE BUTTON

$(document).ready(function() {
   $('a.close').click(function() {
     $('div.ie').addClass('hide');
   });
 });





