$('html').addClass('js');

$(function(){
  //************************ Product image gallery ***/
  $('#img-gallery ul li:first-child').addClass('active');
  $('#img-gallery ul li:nth-child(6n)').addClass('sans-margin');
  $('#img-gallery a').click(function(){
    var imgLink = $(this).attr('href');
    var imgAlt = $(this).attr('title');
    var imgBig = $('#img-gallery div img');
    $(this).parent().addClass('active').siblings().removeClass('active');
    $('#img-gallery div').addClass('loading');
    if ( imgBig.attr('src') !== imgLink ) {   
      imgBig.animate({ opacity: 0 }, function(){
        var img = new Image();
        $(img).load(function(){   
          $(this).css({opacity: 0});
          $('#img-gallery div').removeClass('loading').html(this).append(' ');
          $(this).animate({opacity: 1}).attr('alt',imgAlt);
        }).error(function(){}).attr('src', imgLink);
      });
    }
    return false;
  });
  
  //************************ Search form focus/blur ***/
  defVal = phrasebook.searchInput;
  $('#search-input input').attr('value',defVal).focus(function() {
      if( $(this).val() == defVal ) {
          $(this).val('');
      }
  }).blur(function() {
      if( !$(this).val().length ) {
          $(this).val(defVal);
      }
  });
  
});