
  
  
   
   var systems = "";
   var types = "";

   
   
   
   
   function goFilter () {
        
      
      $(".filter ul li").each(function() {
          if ($(this).hasClass("selected")) {
            if ($(this).attr("id").substr(0,4) == 'syst')
              addSystem($(this).attr("id").substr(5, $(this).attr("id").length));
            else
              addType($(this).attr("id").substr(5, $(this).attr("id").length));
          }
      });
      
      if (systems.length == 0 && types.length == 0) {
        systems = "0";
        types = "0";
      }
      temp = document.location.href;
      pos = temp.indexOf(".html");
      pos2 =  temp.indexOf("#ajax");
      temp2 = temp.substring(0, pos);
      //alert(temp2);
      //alert(temp2+".html");
      

      //GSY.Ajax.update('get','/news_filter_'+ systems +'_'+ types +'_fr.html', 'games-news', null);
      //GSY.Ajax.request('get','/news_filter_'+ systems +'_'+ types +'_fr.html', null);
      
      GSY.fade('games-news', 100, 30, 100);
      $.ajax({
        url: '/news_filter_'+ systems +'_'+ types +'_fr.html',
        success: function(data) {
           
           document.location.href="";
        }
      });
      
      
       
        //document.location.href="";//window.scrollTo(0, 260);
        
        
        
                            
          
        
        //GSY.Ajax.request('get','/news_filter_'+ systems +'_'+ types +'_fr.html', null);
        
        
      
      
   }
   
   function addSystem (system) {
   
    if (systems.length == 0)  {
       systems = system;
    
    }
    
    else {
      systems += "-" + system;
    }   
   }
   
   function addType (type) {
   
    if (types.length == 0)  {
       types = type;
    
    }
    
    else {
      types += "-" + type;
    }   
   }
   
   function selectSystems (systs) {
    
    if (systs == null) {
      
      $(".filter ul li[id^='syst_']").each(function() {
        if (!($(this).hasClass("tout-rien"))) {
          $(this).removeClass("selected");
        }
      });
      
    }
    else if (systs[0] == 0) {
      
      $(".filter ul li[id^='syst_']").each(function() {
        if (!($(this).hasClass("tout-rien"))) {
          $(this).addClass("selected");
        }
      });

    }
    else {
      for (i=0; i<systs.length; i++) {
        
        $("#syst_"+systs[i]).addClass("selected");
      
      }
    }
   }
   
   function selectTypes (typs) {
    
    if (typs == null) {
      
      $(".filter ul li[id^='type_']").each(function() {
        if (!($(this).hasClass("tout-rien"))) {
          $(this).removeClass("selected");
        }
      });
      
    }
    else if (typs[0] == 0) {
      
      $(".filter ul li[id^='type_']").each(function() {
        if (!($(this).hasClass("tout-rien"))) {
          $(this).addClass("selected");
        }
      });

    }
    else {
    
      for (i=0; i<typs.length; i++) {
        
        $("#type_"+typs[i]).addClass("selected");
      
      }
    }
      
   }
   
   function init () {
    $(".filter").hide();
    $(".filter ul li[id^='type_']").each(function() {
        if (!($(this).hasClass("tout-rien"))) {
          $(this).removeClass("selected");
        }
      });
    $(".filter ul li[id^='syst_']").each(function() {
        if (!($(this).hasClass("tout-rien"))) {
          $(this).removeClass("selected");
        }
      });
    goFilter();
   }            
  
   $(".filter").hide();
    
    /*$(".filter-icon").click(function () {
       
      
      if ($(this).attr("src").indexOf("__") > 0) {
        
        $(this).attr("src",$(this).attr("src").replace("__", "_"));
        
      }
      else {
        $(this).attr("src",$(this).attr("src").replace("_", "__"));
      }
      
    });*/
    
    $("#filter-show").click(function () {
      if ($(".filter").css("display") == 'none') {
        $(".filter").slideDown();
        $("#filter-show").attr("src",$(this).attr("src").replace("bas", "haut"));
      }
      else {
        $(".filter").slideUp();
        $("#filter-show").attr("src",$(this).attr("src").replace("haut", "bas"));
      }
    }); 
    $(".filter ul li").hover( 
      
        function () {
          if (!($(this).hasClass("tout-rien"))) {
            $(this).addClass("highlight");
          }
        },
      	function () {
      	  if (!($(this).hasClass("tout-rien"))) {
            $(this).removeClass("highlight");
          }
      	}
    	
    );
    
    $(".filter ul li").click( function () {
      if ($(this).hasClass("selected")) {
        if (!($(this).hasClass("tout-rien"))) {
          $(this).removeClass("selected");
        }
      }
      else {
        if (!($(this).hasClass("tout-rien"))) {
          $(this).addClass("selected");
        }
        
      }
    });
    
    $(".filter-button").click(function () {
      $(".filter").slideUp();
      $("#filter-show").attr("src",$("#filter-show").attr("src").replace("haut", "bas"));
      goFilter();
    });
    
    $(".filter-init").click(function () {
      init();
      
    });



