$(document).ready(function(){
  // on duplique la nav du haut vers le bas
  // var nav = $('#pagination_top').html().replace(/\bid="/g, 'id="b');
  // $('#pagination_bottom').html(nav);
  
  // Politique d'accessibilite
  
  //dev.opera.com/articles/view/introduction-to-wai-aria/
  $("#main h1").attr("role", "banner");
  $("#nav").attr("role", "navigation");
  $("#search").attr("role", "search");
  $("#content").attr("role", "main");
  $(".hentry").attr("role", "secondary");
  $("#footer").attr("role", "contentinfo");
  // http://openweb.eu.org/articles/accesskey_essai_non_transforme/

  var aks = $('*[accesskey]').each(function(){
    var token = $(this).attr('accesskey');
    var reg = new RegExp("("+token+")", "i");
    var txt = $(this).text().replace(reg, '<span class="ak">$1</span>');
    $(this).html(txt);
  })
  
  var kcodes = {'ak':17, 'sc':91}

  if ($.browser.msie ) {

  }
  if ($.browser.safari ) {
    kcodes['ak'] = 17;
    kcodes['sc'] = 91;
  }
  if ($.browser.mozilla ) {
    kcodes['ak'] = 17;
    aks.focus(function(){
      if( href = $(this).attr('href') )
        window.location = href;
    });
  }
  if ($.browser.opera) {
    
  }

  $(window).keydown(function(event){
    switch (event.keyCode) {
      case 17: // touche CTRL sur OS X
        aks.addClass('accesskey-hit');
        break;
      case 83: // s
        break;
      case 91: // 
        // 83
        break;
      default:
        break;
      // ...
      // different keys do different things
      // Different browsers provide different codes
      // see here for details: http://unixpapa.com/js/key.html    
      // ...
    }
  });
  $(window).keyup(function(event){
    switch (event.keyCode) {
      case 17:
        aks.removeClass('accesskey-hit');
        break;
      default:
        break;
      // ...
      // different keys do different things
      // Different browsers provide different codes
      // see here for details: http://unixpapa.com/js/key.html    
      // ...
    }
  });
});