/* Author: Lee Boyce
*/

/*$('img.pro-img').hide();*/
//HOMEPAGE 
//masonry initiate	
$('#home-screen').masonry({	columnWidth: 160, itemSelector: '.home-box' });
$('#project-image-screen').masonry({ columnWidth: 160, itemSelector: '.box' });
//hover effect initiate  
 $(document).ready(function(){
    $("li.box").hover(function() {
    // $("li.box").stop().animate({opacity: "0.3"}, '400'); 
      	$("li.box-details", this).animate({top:'0px'},{queue:true,duration:0});
      //   $(this).stop().animate({opacity: "1"}, '200');    
    },
    function() {
     // $("li.box").stop().animate({opacity: "1"}, '400'); 
     $("li.box-details", this).animate({top:'-30px'},{queue:true,duration:0});
    });
  }); 
  
   $(document).ready(function(){
    $("div.home-box").hover(function() {
    //  $("div.home-box").stop().animate({opacity: "0.3"}, '400'); 
      	$("div.home-box-details", this).animate({top:'0px'},{queue:true,duration:0});
     //     $(this).stop().animate({opacity: "1"}, '200');    
    },
    function() {
    //  $("div.home-box").stop().animate({opacity: "1"}, '400'); 
     $(".home-box-details", this).animate({top:'-88px'},{queue:true,duration:0});
    });
  });
//END HOMEPAGE

//CENTENARY
$(document).ready(function(){
   // centenary menu
  	$('.centenary-nav').click(function(){	
  		$(this).addClass('active-cent');
  		$(this).siblings().removeClass('active-cent');
  		$(this).animate({ 'opacity': 1 });
  		$(this).siblings().animate({ 'opacity': 0.4 });
  		$("#centenary-content").animate({ 'opacity': 0 }, 20);
 		var get = $(this).attr('id');
 		$("#centenary-content").load("centenary-content.php #"+get , 
 		 	function(response, status, xhr) {
  				if (status == "error") {
    				var msg = "Sorry but there was an error: ";
    				$("#error").html(msg + xhr.status + " " + xhr.statusText);
  				}
  				else { 
  					$("#centenary-content").delay(800).animate({ 'opacity': 1 }, 800); 
  					
//Timeline masonry initiate. 

$('.cent-page').masonry({	columnWidth: 160, itemSelector: '.cent-item' });
  				}
  			}
  		);
	});
});




//PROJECTS PAGE
//hover effect initiate  
  $(document).ready(function(){
    $("div.project").hover(function() {
   //   $("div.project").stop().animate({opacity: "0.3"}, '400'); 
      	$("div.project-details", this).animate({top:'0px'},{queue:true,duration:0});
    //      $(this).stop().animate({opacity: "1"}, '200');    
    },
    function() {
   //   $("div.project").stop().animate({opacity: "1"}, '400'); 
     $(".project-details", this).animate({top:'-88px'},{queue:true,duration:0});
    });
  });
//masonry filter
var 
  speed = 1000,   // animation speed
  $wall = $('#main').find('#projects-screen'),
  masonryOptions = {         // initial masonry options
    columnWidth: 160, 
    itemSelector: '.project: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 'education' : case 'healthcare' : case 'sciences' : case 'residential' : case 'specialist' :
      // 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;
    }
  }
});
$('.filtering-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;
});
//END PROJECTS PAGE
//masonry initiate	
$('#projects-screen .project-images').masonry({columnWidth: 160, itemSelector: '.img' });

$('#home-screen .home-box').masonry({columnWidth: 160, itemSelector: '.img' });
$('#home-screen').css({marginLeft: '5px'});

//Timeline masonry initiate. 

$('.cent-page').masonry({	columnWidth: 160, itemSelector: '.cent-item' });


