// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
jQuery(document).ready(function(){
  
  
  // -----------------------------
  // accordion
  // -----------------------------
  if($('#accordion')) {;   
    $("#accordion").accordion({ activeitem: 'none' });
  }
	
  // -----------------------------
  // Image flow
  // -----------------------------
  if($('#product_images')) {
    $('#product_images a').lightBox();
  }
  
  // ----------------------------
  // home page slideshow
  // ----------------------------
  $(function() {
    setInterval("slideSwitch()", 5000);
  });

  $(document).ready(function(){
  	$("a[href^='http']").not("[href*='clubthompsons.com']").attr('target','_blank');
  });
});


function slideSwitch() {
  var $active = $('#slideshow img.active');
  if ($active.length == 0) $active = $('#slideshow img:last');
  var $next =  $active.next().length ? $active.next() : $('#slideshow IMG:first');
  $active.addClass('last-active');
  $next.css({ opacity: 0.0 })
  .addClass('active')
  .animate({opacity: 1.0}, 1000, function() {
      $active.removeClass('active last-active');
  });
}

function new_win(url,windowname,w,h,x,y){
window.open(url,windowname,"location=no,resizable=no,toolbar=no,scrollbars=no,menubar=no,status=no,directories=no,width="+w+",height="+h+",left="+x+",top="+y+"");
}