/*THIS FUNCTION KEEPS THE TOP NAV STATE IN A HOVER STYLE WHILST SUB NAVS ARE BEING ROLLED OVER*/

$(document).ready(function(){
   
    $('ul#nav a').hover(
		function() {  
 			$(this).addClass('liNavHover'); 
 		},  
 		function() {  
 			$(this).removeClass('liNavHover');  
 			}  
		); 
	
	$('ul#nav ul').hover(
		function() {  
 			$(this).parent().children(":first").addClass('liNavHover'); 
 		},  
 		function() {  
 			$(this).parent().children(":first").removeClass('liNavHover'); 
			
 			}  
		);
	$('a#theMusician').click(function(){
		$('div.aHunter').removeClass('aHunter');
		$('div.rockerBio').addClass('aRocker');
		$(this).addClass('navOn');
		$('a#theOutdoorsman').removeClass('navOn');				  
									  
	  });
	 $('a#theOutdoorsman').click(function(){
	  	$('div.aRocker').removeClass('aRocker');
		$('div.hunterBio').addClass('aHunter');
		$(this).addClass('navOn');
		$('a#theMusician').removeClass('navOn');
		});
		
$(document).ready(function(){	
	function playTrack(track_url) {

	window.document.playsound.playerPlay(track_url);		

}

function stopTrack() {

	window.playsound.playerStop();	

}

						   });
/*SHOW ALL SECTIONS SLIDER CODE #########################################*/	
	$("a#showSections").click(function(){
		$("a#hideSections").addClass('sectionsOn');
			$('#allSections').slideDown(600);
			$("a#showSections").css({'display':'none'});
			$("a#hideSections").css({'display':'block'});	
	});
	$("a#hideSections").click(function(){
		$('a#showSections').removeClass('sectionsOn');
			$('#allSections').slideUp(600);
			$("a#showSections").css({'display':'block'});
			$("a#hideSections").css({'display':'none'});		
	});
	

	
/*THIS SCRIPT SHOWS THE TOP ADVERT*/

	$(document).ready(function(){
		var myLength=$(this).find("ul#topAdverts li").length;
		var randNumber=Math.floor(Math.random()*myLength);

		$('ul#topAdverts li').eq(randNumber).addClass('showMe');
	});
	
/*THIS SCRIPT IS FOR THE TED EPISODES EXPANDER*/	
	$(document).ready(function(){
		$('ul#seasonsMenu ul').hide();
		$.each($('ul#seasonsMenu'), function(){
			$('#' + this.id + '.expandfirst ul:first').show();
		});
		$('ul#seasonsMenu li a').click(
			function() {
				var checkElement = $(this).next();
				var parent = this.parentNode.parentNode.id;
	
				if($('#' + parent).hasClass('noaccordion')) {
					$(this).next().slideToggle('normal');
					return false;
				}
				if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
					if($('#' + parent).hasClass('collapsible')) {
						$('#' + parent + ' ul:visible').slideUp('normal');
					}
					return false;
				}
				if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
					$('#' + parent + ' ul:visible').slideUp('normal');
					checkElement.slideDown('normal');
					return false;
				}
			}
		);

	});
}); 

/*functions for the flash bio movie.. these function are being called from flash*/
function rockerOnDiv() {
	$(document).ready(function(){
		$('div.aHunter').removeClass('aHunter');
		$('div.rockerBio').addClass('aRocker');
		$('div.bioIntro').addClass('bioIntroOff');
	});
}
function hunterOnDiv() {
	$(document).ready(function(){
		$('div.aRocker').removeClass('aRocker');
		$('div.hunterBio').addClass('aHunter');
		$('div.bioIntro').addClass('bioIntroOff');
	});
}
/*pop up window code*/
var Win=0;
	function popUps(URLStr, width, height)
				{
  				var top=100;
  				var left=100;
  				
  				if(Win){
    			if(!Win.closed) Win.close();
  				}
  				Win = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
		}
		
		function popUpsScrolls(URLStr, width, height)
				{
  				var top=100;
  				var left=100;
  				
  				if(Win){
    			if(!Win.closed) Win.close();
  				}
  				Win = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
		}
		
		
window.onload = function() {
  if (!document.getElementsByTagName) return false;
  var lnks = document.getElementsByTagName("a");
  for (var i=0; i<lnks.length; i++) {
    if (lnks[i].className == "storePopup") {
      lnks[i].onclick = function() {
        storePopUp(this.getAttribute("href"));
        return false;
      }
    }
  }
}
function storePopUp(winURL) {
  window.open(winURL,"storePopup","width=338,height=450");
}
	
