function showSeason(num)
{
  $('div[id^="season_"]').hide();
  $('div[id^="season_'+num+'"]').toggle();
  
  $('a[id^="link_"]').removeClass('active');
  $('a[id^="link_'+num+'"]').addClass('active');    
}

jQuery(document).ready(function($){
	$("a[rel^='prettyIframe']").prettyPhoto({
		animationSpeed: 'fast', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		opacity: 0.85, /* Value betwee 0 and 1 */
		showTitle: true, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 'of' 2 */
		theme: 'dark_square', /* light_rounded / dark_rounded / light_square / dark_square */
		callback: function(){}
	});
	
	$('a[rel="extern"]').click(function() {
	 window.open($(this).attr('href'));
	 return false; 
	});
	
	$('a[rel*="facebox"]').click(function() {
    FB.login();
    return false;
	});

  // Bloc Je recherche
  $("#bloc-search a").click(function() {
    $("#content-bloc-search").toggle();
    $("#bloc-search").toggleClass("bloc-on");
  });
  $("#content-bloc-search").mouseup(function() {
    return false
  });    
  $(document).mouseup(function(e) {
    if($(e.target).parent("a.search-link").length==0) {
      $("#bloc-search").removeClass("bloc-on");
      $("#content-bloc-search").hide();
    }
  });
  
  // Bloc espace membre
  $("#bloc-membre a.connexion-link").click(function() {
    $("#content-membre").toggle();
    $("#bloc-membre").toggleClass("bloc-on");
  });
  $("#content-membre").mouseup(function() {
    return false
  });    
  $(document).mouseup(function(e) {
    if($(e.target).parent("a.connexion-link").length==0) {
      $("#bloc-membre").removeClass("bloc-on");
      $("#content-membre").hide();
    }
  });
  
  $("#searchForm").submit(function(){
    var action = $(this).attr('action');
    $.ajax({
      url: action,
      type: 'POST',
      data: $(this).serialize(),
      beforeSend: function() { 
        $('#generator_result').html('<img src=\"/images/loading.gif\"> veuillez patienter...') 
      },
      success:function(data, textStatus) { 
        $('#generator_result').html(data);
      }      
    });
    return false;
  });
  
  $('#nav-fiche li').hover(
    function() { 
      if (false == $(this).hasClass('ui-state-right')){ $(this).addClass('ui-state-hover'); } 
      else { $(this).removeClass('ui-state-hover') }
    }, 
    function() { 
      if (false == $(this).hasClass('ui-state-right')){ $(this).removeClass('ui-state-hover'); } 
      else { $(this).addClass('ui-state-hover') }
    }
  );
  
  $('form.highlight input[type="text"], form.highlight select, form.highlight textarea').focus(function(){
    $(this).closest('div').addClass('highlight');
  }).blur(function(){
     $(this).closest('div').removeClass('highlight');
  });
});