if ($.cookie('index') == null) { 
         $.cookie('index', 'tous',{ expires: 99, path: '/' }); 
         }

  
          // DOMContentLoaded
          $(function() {
          
        	/* $("a[href^='http']").attr('target','_blank'); */
        	
            // bind links
          	var $filterType = $('#filter a');
          	var $filterGroup = $('#filter');
        	 
          	// get the first collection
          	var $applications = $('#applications');
        	
          	// clone applications to get a second collection
          	var $data = $applications.clone();
 
            // attempt to call Quicksand on click change
          	$filterType.click(function() {
          	
          		if ($(this).hasClass('active')) {
          		$(this).toggleClass('active');
          		var $filteredData = $data.find('li');
          			$.cookie('index', 'tous',{ expires: 99, path: '/' });
          			$('#all_bottom').hide();
          		$applications.quicksand($filteredData, {
          	    duration: 1,
          	    easing: 'swing'}   , function() { // callback function
    $('#applications li a').tooltip({ 
    track: true, 
    delay: 0, 
    showURL: false, 
    showBody: " _ ", 
    fade: 250 
});
  }
       	  );
          		}
          		
          		else {
          	    $(this).toggleClass('active');
  				$(this).siblings('a').removeClass('active');
          	
          		if ($(this).attr('id') == 'tous') {
          			var $filteredData = $data.find('li');
          			$.cookie('index', 'tous',{ expires: 99, path: '/' });
          			$('#all_bottom').hide();
          			
          		} else {
          			var $filter = $(this).attr('id');
          			var $filteredData = $data.find('li[data-type=' + $filter + ']');
          			$.cookie('index', $filter,{ expires: 99, path: '/' });
          			$('#all_bottom').show();
          		}
        		
          		// finally, call quicksand
          	  $applications.quicksand($filteredData, {
          	    duration: 1,
          	    easing: 'swing'}   , function() { // callback function
    $('#applications li a').tooltip({ 
    track: true, 
    delay: 0, 
    showURL: false, 
    showBody: " _ ", 
    fade: 250 
});
  }
       	  );
 
          }	});
                  	
          		if ($.cookie('index') == 'tous') {
          			var $filteredData = $data.find('li');
          			$.cookie('index', 'tous',{ expires: 99, path: '/' });
          			$('#all_bottom').hide();
  
          			
          		} else {
          			var $filter = $.cookie('index');
          			var $filteredData = $data.find('li[data-type=' + $filter + ']');
          			$.cookie('index', $filter,{ expires: 99, path: '/' });
          			$('#all_bottom').show();
          		}
        		
          		// finally, call quicksand
          	  	$applications.quicksand($filteredData, {
          	    duration: 1,
          	    easing: 'swing'} , function() { // callback function
    $('#applications li a').tooltip({ 
    track: true, 
    delay: 0, 
    showURL: false, 
    showBody: " _ ", 
    fade: 250 
});
  }
 );
 
 var $uu = $filterGroup.find('a[id=' + $.cookie('index') + ']');
          	    $uu.addClass('active');

 
 $("#view_News a").tooltip({ 
	
    bodyHandler: function() { 
    	var uuu = $(this).attr("href");
        return '<img src="' + uuu + '"/>'; 
    }, 
    showURL: false, 
    track: true, 
    delay: 0, 
    fade: 250 
});

	
$('#all_bottom a').click(function(ev) {
	ev.preventDefault();
    $('#filter a#tous').click();
    $("#filter a").each(function(){
        $(this).removeClass("active");
      });
    
});

$('#site-name span, h2.subtitle span').hover(

 function () {
   $('#site-name span').addClass("hover");
    $('#index h2.subtitle span').addClass("hover");
  },
  function () {
    $('#site-name span').removeClass("hover");
     $('h2.subtitle span').removeClass("hover");
  });


$("#view_News a").click(function (ev) { ev.preventDefault(); });	

$("#email").DefaultValue("Your email");

$('#mailchimp').ajaxForm(function() { 
                alert("We must confirm your email address.\r\rTo complete your registration please click the link to the email we just sent you."); 
            }); 
          	        	
});
