jQuery(function($){

  /* =Header slider
  --------------------------------------*/

  function init_slider(){
    
    $('#header-slider').cycle({
      timeout: 5000,
      speed: 600,
      fx: 'scrollHorz',
      pause: false,
      next: '#next',
      prev: '#prev',
      cleartypeNoBg: true,// set to true to disable extra cleartype fixing (leave false to force background color setting on slides)
      width : '100%'
    });
    
  }

  init_slider();
  
  //Make downloadable files downloadable ;)
  $('a.downloadable').live('click', function(){
    var downloadable_url = 'index.php?download_attachment=true&download_filename='+$(this).attr('href');
    document.location = downloadable_url;
    return false;
  });

  //Context hover
  $("a").hover(
    function(){$("a[href='"+$(this).attr("href")+"']").addClass("hover");},
    function(){$("a[href='"+$(this).attr("href")+"']").removeClass("hover");}
  )
  .focus(
    function(){$("a[href='"+$(this).attr("href")+"]'").addClass("hover");}
  )
  .blur(
    function(){$("a[href='"+$(this).attr("href")+"]'").removeClass("hover");}
  );

  //IE last-child 'hack'
  $("ul > li:last-child").addClass('last-child');
  $("#main_menu > li:last-child").css('border-right', 'none');
  
});
