// jQuery Quicksand project categories filtering
// Thanks to Sacha Greif - http://www.sachagreif.com/

jQuery(document).ready(function($){

	//	Set the height of the quote to 75px, but store the original height
	var quote_height_original = $("#quote-container").css('height');
	$("#quote-container").css({"height" : "75px"});

 	// Clone applications to get a second collection
	var $data = $(".portfolio-content").clone();
	
	//NOTE: Only filter on the main portfolio page, not on the subcategory pages
	$('.portfolio-main li').click(function(e) {
		$(".filter li").removeClass("active");	
		// Use the last category class as the category to filter by. This means that multiple categories are not supported (yet)
		var filterClass=$(this).attr('class').split(' ').slice(-1)[0];
		
		if (filterClass == 'all-projects') {
			var $filteredData = $data.find('.project');
		} else {
			var $filteredData = $data.find('.project[data-type=' + filterClass + ']');
		}
		$(".portfolio-content").quicksand($filteredData, {
			duration: 800,
			easing: 'swing',
		},function(){
			 $('.piro_overlay,.pirobox_content').remove();
			 $().piroBox({
				my_speed: 400, //animation speed
				bg_alpha: 0.3, //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
	
			});

		});		
		$(this).addClass("active"); 			
		return false;
	});
	
	//Email
	$('.mask').html('@');

/*
	//	Navigation style (keep heading white)
	$('.rs-navigation li div').mouseover(function(){
		$(this).parent().find('.keep').css('color', 'white');
	}).mouseout(function(){
		$(this).parent().find('.keep').css('color', '');
	});
*/
	
	//	Hide sub nav
	$('.rs-side-navigation li div').hide();
	$('.rs-side-navigation li.current div').show();
	
	//	Expand sub navs on hover
	$('.rs-side-navigation li .keep').click(function(){
		$('.hide-em').hide(); //  Hide all other subnavs
		$(this).parent().find('div').show();
		$('.active').removeClass('active');
		$(this).parent().addClass('active');
	});
	
	
	
	$('.keep').click(function(){
		$(this).parent().next('div').show();
		
		$(this).next('div').pulse({
		    opacity: [0.3,1]
		}, {
		    duration: 80, // duration of EACH individual animation
		    times: 1, // Will go three times through the pulse array [0,1]
		    easing: 'linear' // easing function for each individual animation
		});		
		
		return false;
	});
	
	$('#quote-fade-out').mouseover(function(){
		//	Calculate the height of .fade-container
		//	$('#quote-container').animate({height:quote_height_original, duration:100});
 		$('#quote-container').animate({
	    	height:quote_height_original,
	    	duration:100
	    }, 100, function() {
	    	$('#quote-fade-out').fadeOut();
	    });			
		
		
		
	});
	
	//	Tipsy
	$('.tip').tipsy();
	$('.tip-w').tipsy({gravity:'w', html:true, opacity:0.1});
	
	//	Fancy
	$('.inline').fancybox();
	$("a.gallery_item").fancybox();
	
	//	Sidebar
	$('.what-is-non-duality-reveal').click(function(){
		if ( $('.what-is-non-duality-list').is(':visible') ) {
			$('.what-is-non-duality-list').pulse({
				opacity: [0.3,1]
			},{
			    duration: 80, // duration of EACH individual animation
			    times: 1, // Will go three times through the pulse array [0,1]
			    easing: 'linear' // easing function for each individual animation
			});
		}else{
			$('.what-is-non-duality-list').slideDown();
		}
	});
	
	$('.what-is-non-duality-reveal').mouseover(function() {
	    $('.what-is-non-duality-list').slideDown();
	    //var offset = $('#sidebar').offset();
	    //$('#sidebar').css('top'. offset.top );
	});
	
	$('#right720').mouseover(function() {
	    $('.what-is-non-duality-list').slideUp();
	    $('#quote-container').animate({height:75});
		$('#quote-fade-out').show();
	});
	
	//	Homepage Carousel
	$('#homepage-roundabout li').hover(
		function()
		{
			if ( $(this).hasClass( 'roundabout-in-focus' ) )
			{
				$(this).find('.placeholder').hide();
				$(this).find('.reveal').fadeIn();
			}
		},
		function()
		{
			if ( $(this).hasClass( 'roundabout-in-focus' ) )
			{
				$(this).find('.reveal').hide();
				$(this).find('.placeholder').fadeIn();
			}
		}
	);
	
	
	
});


