/* Author: Jeremy Grancher
		http://dijitale.fr
*/

$(document).ready(function() {
  
  // Slider Clients in Homepage
		$("#list_logos").simplyScroll({
			autoMode:'loop',
			pauseOnHover:false
		});
	
  
  // Accordeon on Jobs page
  $('a.link_details_job').click(function() {
  	
  	var id_clicked			= $(this).attr('data-id');
  	var content_clicked = $('div.content_job[data-id="'+id_clicked+'"]');
  	var item_actif			= $('li.item_category_jobs.active');
  	var content_actif		= $('li.item_category_jobs.active div.content_job');
  	
  	if($(item_actif).attr('data-id')==id_clicked) {
  		
  		$(item_actif).removeClass('active');
  		$(content_actif).slideUp();
  	
  	} else {
  		
  		$(item_actif).removeClass('active');
  		if(content_actif != '') $(content_actif).slideToggle();
  	
  		$('li.item_category_jobs[data-id="'+id_clicked+'"]').addClass('active');
  		$(content_clicked).slideToggle();
  	}
  	
  	return false;
  });
  
  
  // Return to Top animation
	$('a[href=#page]').click(function(){
  	$('html, body').animate({scrollTop:0}, 'slow');
    return false;
  });
  
  
  // Get a Twitter feed in footer
  var twitter_username = 'bemobee';
	$.getJSON("http://twitter.com/statuses/user_timeline.json?screen_name="+twitter_username+"&count=1&callback=?",
		function(data){
	  	$.each(data, function(i,item){
	   		ct = item.text;
	   		ct = ct.replace(/http:\/\/\S+/g,  '<a href="$&" target="_blank">$&</a>');
	   		$("#content_tweet").html(ct);
	  	});
	});
  
  
});
