$.fn.search = function() {
  return this.focus(function() {
    if( this.value == this.defaultValue ) {
      this.value = "";
    }
  }).blur(function() {
    if( !this.value.length ) {
      this.value = this.defaultValue;
    }
  });
};

$(document).ready(function() {
  
  // search input
  
  // jQuery version doesn't work
  // http://groups.google.com/group/jquery-en/browse_thread/thread/1762da00b5f3f54b
  // $('#search-input').attr(
  //   { type: 'search' }
  // );

  if (document.getElementById('search-input'))
  {
   if ((parseInt(navigator.productSub)>=20020000)&&(navigator.vendor.indexOf("Apple Computer")!=-1))
   {
     s = document.getElementById('search-input');
     s.setAttribute('type', 'search');
     s.setAttribute('autosave', 'tcg_site_search');
     s.setAttribute('results', '10');
     s.setAttribute('placeholder', 'Search');
   }
  }
  
  $("#labs").tablesorter({ sortList: [[0,1]] });

  $("#email-input").search();
  
  //Home Slideshow
  $('ul#slideshow_home').css("visibility","visible");
  $('ul#slideshow_home').animatedinnerfade({
    speed: 2000,
    timeout: 6000,
    type: 'sequence',
    containerwidth: '885px',
    containerheight: '300px',
    animationSpeed: 0,
    animationtype: 'fade',
    bgFrame: 'none',
    controlBox: 'none',
    displayTitle: 'none'
  });
  
  $("img.banner").attr('src', ('/galleries/slideshow/slideshow_' + (Math.floor(Math.random()*7)+1) + '.jpg'));
  
});

$(function(){$('a[href][rel*=email]').each(function(i){this.href = "mailto:" + $(this).attr('class') + "@pallabs.org";});});
$(function(){$('a[href][rel*=external]').each(function(i){this.target = "_blank";});});