$(function() {
  $('a[href=#print]').click(function(evt) { evt.preventDefault(); javascript:print();    pageTracker._trackPageview(location.pathname+"/print"); });
  if($(".specials-container:first").size() > 0) {
    $(".specials-container:first").carousel({dispItems: 4, animSpeed:750});
  }
  $('a[rel=external]').each(function(i) {
    $(this).attr('target', '_blank');
  });
  $('#orderby').change(sortSpecial);
  $('.nieuwsbrief > .form').css({'width' : '0px'});

  $('.nieuwsbrief').mouseenter(nbOver);
  $('.nieuwsbrief').bind('mouseleave', nbOut);

  $('input[type=text]').focus(function(evt) {$(this).select();})

  var t;

  $('.nieuwsbrief input[type=text]').focus(function(e) {
    clearTimeout(t);
    $('.nieuwsbrief').unbind('mouseleave', nbOut);
  });
  $('.nieuwsbrief input[type=text]').blur(function(e) {
    t = setTimeout(function(evt) {
      $('.nieuwsbrief').bind('mouseleave', nbOut);
      clearTimeout(t);
    }, 2500);
  });
  
});

function nbOver(evt) {
  if(jQuery.browser.safari == true && jQuery.browser.mozilla == false) {
    $('.form', this).show().css({width:'auto', paddingRight : '10px'});
  } else {
    $('.form', this).animate({width:'235px'}, {duration:'fast', queue:false});
  }
}

function nbOut(evt) {
  if(jQuery.browser.safari == true && jQuery.browser.mozilla == false) {
    $('.form', this).hide().css({width:'0px'});
  } else {
    $('.form', this).animate({width:'0px'}, {duration:'fast', queue:false});
  }
}

function sortSpecial(evt) {
  var sort = $('option:selected', this).attr('class');
  $('#sort').val(sort);
  $(this).parents('form').submit();
}