$(document).ready(function() {

   if ($('#home').length>0) { 
 	
	 jQuery('#slide-thumb').jcarousel({
	        auto: 10,
	        scroll: 1,
	        wrap: 'circular',
	        initCallback: mycarousel_initCallback,
	        itemFirstOutCallback: mycarousel_itemFirstOutCallback,
	        itemFirstInCallback:  mycarousel_itemFirstInCallback
	    });

	$(function(){
      $("#twitter-wrap").tweet({
        avatar_size: 56,
        count: 6,
		username: ["pantherracing"],
		query: 'pantherracing OR jrhildebrand OR jbindy4 OR crippsee OR mikekitchel',
        loading_text: "searching twitter...",
        refresh_interval: 10
      });
    });

  }// end if home(homepage)
  

function mycarousel_initCallback(carousel)
	{
		// Disable autoscrolling if the user clicks the prev or next button.
		carousel.buttonNext.bind('click', function() {
			carousel.startAuto(0);
		});
	 
		carousel.buttonPrev.bind('click', function() {
			carousel.startAuto(0);
		});
	 
		// Pause autoscrolling if the user moves with the cursor over the clip.
		carousel.clip.hover(function() {
			carousel.stopAuto();
		}, function() {
			carousel.startAuto();
		});
	};
function mycarousel_itemFirstOutCallback(carousel, item, idx, state) 
	{
		 var newsid;
		  newsid = $(item).contents('a').attr('href');
		 $(newsid).hide();
	};

function mycarousel_itemFirstInCallback(carousel, item, idx, state) 
	{
		 var newsid;
		  newsid = $(item).contents('a').attr('href');
		 $(newsid).show();
	};

  // lightbox for photos in gallery
   $("ul.list-photos a").fancybox({
		'titlePosition'  : 'over'
	});

// Flash for main page
	var flashvars = {};
	var params = {wmode:"transparent"};
	var attributes = {};

   if ($('#flash-garage').length>0) { 

		$('#flash-garage').flash(
      {
        swf:'/flash/garagedoor.swf',
        width:545,
        height:235,
        wmode:'transparent'
      }
    );

   }//end if flash home (homepage)


// Flash for panther logo (home page)
	var flashvars = {};
	var params = {wmode:"transparent"};
	var attributes = {};

   if ($('#panther-logo').length>0) { 

		$('#panther-logo').flash(
      {
        swf:'/flash/panther_logo.swf',
        width:234,
        height:132,
        wmode:'transparent'
      }
    );

   }//end if flash panther logo (home page)
   

// Flash for pit crew page
	var flashvars = {};
	var params = {wmode:"transparent"};
	var attributes = {};

   if ($('#flash-pitcrew').length>0) { 

		$('#flash-pitcrew').flash(
      {
        swf:'/flash/pitstop.swf',
        width:777,
        height:387,
        wmode:'transparent'
      }
    );

   }//end if flash pitcrew 

 
   // Submenu JS
    $('#submenu  li  a').click(function(){
	
	  $('#submenu li').removeClass('active');
	  
      if ($(this).parent().attr('class') != 'active'){
	    Cufon.refresh();
	    $('#submenu  li a').parent().removeClass('active');
		$('#submenu  li ul').slideUp();
	    $(this).parent().addClass('active');
        $(this).next().slideToggle();
        Cufon.refresh();
        
      }
	
    }); //end submenu click


	//if ($('#principals').length>0) { 
	//  $('#menu-principals').addClass('active');
	//  $('#menu-principals').addClass('show');
	//}
	//
	//if ($('#pitcrew').length>0) { 
	//  $('#menu-pitcrew').addClass('active');
	//  $('#menu-pitcrew').addClass('show');
	//}
	//
	//if ($('#thepack').length>0) { 
	//  $('#menu-thepack').addClass('active');
	//  $('#menu-thepack').addClass('show');
	//}
	//
	//if ($('#teamhistory').length>0) { 
	//  $('#menu-teamhistory').addClass('active');
	//  $('#menu-teamhistory').addClass('show');
	//}
  


  //FANCYVIDEO
  $(".fancyvideo").click(function() {
  	$.fancybox({
  		'padding'		: 0,
  		'autoScale'		: false,
  		'transitionIn'	: 'none',
  		'transitionOut'	: 'none',
  		'title'			: this.title,
  		'width'		: 760,
  		'height'		: 570,
  		'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
  		'type'			: 'swf',
      'swf'       : {wmode: 'transparent'}
  	});
  
  	return false;
  });


	// ----------------  CUFON  --------------------------//

    Cufon.replace('ul#main-nav  a',{hover: true});
	Cufon.replace('a.link');
	Cufon.replace('div.pages a');
	
	
	Cufon.replace('#sidebar h3');
	Cufon.replace('#sidebar .box a.view');
	
	Cufon.replace('#main-content h1');
	Cufon.replace('#main-content h2');
	Cufon.replace('#main-content h3');
	Cufon.replace('.page-title');
	
	Cufon.replace('#home #content h2');
	Cufon.replace('#home #content h3');
	Cufon.replace('#home #content h4');
	Cufon.replace('#submenu li a', {hover: true});
	Cufon.replace('.timer');
	Cufon.replace('ul.list-standing span');
	Cufon.replace('#main-image p');
	Cufon.replace('a.follow', {hover: true});
	
	Cufon.replace('span.date');
	Cufon.replace('.schedule span.day');
	Cufon.replace('.schedule span.month');
	Cufon.replace('.schedule span.time', {fontFamily: 'Swis721 Blk BT'});
	Cufon.replace('.schedule .track', {fontFamily: 'Swis721 Blk BT'});
	
	Cufon.replace('.list-standing li em', {fontFamily: 'Swis721 Blk BT'});
	Cufon.replace('.list-time li', {fontFamily: 'Swis721 Blk BT'});
	Cufon.replace('#footer h4', {fontFamily: 'Swis721 Cn BT'});
	Cufon.replace('#footer li a', {hover: true,fontFamily: 'Swis721 Cn BT'});
	




});



