
$(document).ready(function()
{
	$("#portfolio .li_folio").click(function()
	{
		var url = $(this).children(".redirArticle").attr("href");
		//ajoutLien(url)
	})
	
	function ajoutLien(_url)
	{
		$("#sb-redir-article").remove()
		$("#sb-info-inner #sb-nav").append('<a href="'+_url+'" id="sb-redir-article">voir l\'article</a>')
		$("#sb-redir-article").css("width", 'auto')
	}
	
	
	/******************************************************************
	*		:: MASONRY ::
	*
	******************************************************************/
	var 
	  speed = 1000,   // animation speed
	  wall = $('#portfolio'),

	  masonryOptions = {         // initial masonry options
	    columnWidth: 5, 
	    itemSelector: '.li_folio:not(.invis)',
	    animate: true,
	    animationOptions: {
	      duration: speed,
	      queue: false
	    }
	  }
	;
	$("#portfolio .li_folio").each(function()
	{
		var clas = $(this).children("a").children("img").attr("class")
		$(this).addClass(clas)
	})
	// run on window.load so we can capture any incoming hashes
	  
	  // 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('#', '');
		$('#choixProjet a').removeAttr('id')
		$('#choixProjet a.'+possibleFilterClass).attr("id", "actif")
	    switch (possibleFilterClass) {
	    // if the hash matches the following words
	    case 'web-development' : case 'motion-design' : case 'web-design' : 
	      // 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;
	    }
	  }

	$('#choixProjet a').click(function(){
	  var 
	    color = $(this).attr('class'),
	    filterClass = '.' + color;
	  ;
		$('#choixProjet a').removeAttr('id')
		$(this).attr("id", "actif")
	  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;
	})
	/******************************************************************
	*		:: SLIDER PAGE ARTICLE ::
	******************************************************************/
	//$("#article #slider").Slider()
	if( $("#slider img").length > 1 )
	{
		$('#slider').nivoSlider({
		        effect:'random', //Specify sets like: 'fold,fade,sliceDown'
		        slices:15,
		        animSpeed:500, //Slide transition speed
		        pauseTime:6000,
		        startSlide:0, //Set starting Slide (0 index)
		        directionNav:false, //Next & Prev
		        directionNavHide:true, //Only show on hover
		        controlNav:true, //1,2,3...
		        controlNavThumbs:true, //Use thumbnails for Control Nav
		        controlNavThumbsFromRel:false, //Use image rel for thumbs
		        controlNavThumbsSearch: '.jpg', //Replace this with...
		        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		        keyboardNav:true, //Use left & right arrows
		        pauseOnHover:true, //Stop animation while hovering
		        manualAdvance:false, //Force manual transitions
		        captionOpacity:0.8, //Universal caption opacity
		        beforeChange: function(){},
		        afterChange: function(){},
		        slideshowEnd: function(){}, //Triggers after all slides have been shown
		        lastSlide: function(){}, //Triggers when last slide is shown
		        afterLoad: function(){} //Triggers when slider has loaded
		    });
	}
	
	triBlogInit()
})
/************************************************
*		:: triBlogInit ::
*
*	_description :
************************************************/
triBlogInit = function() 
{
	$('.blog #tri a').click(function()
	{
		$('.blog #tri a').removeClass('actif');
		var id = $(this).attr('id');
		$(this).addClass('actif');
		if( id == 'all' )
			{ $('.new').fadeIn(); }
		else
			{ $('.new').hide().filter('.'+id).fadeIn(); }
		return false;
	})
}


