﻿$(document).ready(function(){



 	var gallery=$("#ep_gallery").html();
 	$("#clipnav a").click(function(){
 		var me=$(this);
 		if (me.hasClass("here")) return false;
  		$("#tabs").slideUp(300, function(){
			$("#tabs div").removeClass("showing"); 			
 			if (me.text()=="gallery") $("#ep_gallery").html(gallery);
 			$("#tabs #ep_" + me.text()).addClass("showing");
	 		$("#clipnav a").removeClass("here");
	 		me.addClass("here");
	 		me.blur();
	 		$("#tabs").slideDown(300, function(){
			 	//$.scrollTo($("#clipnav"),700);		
	 		});
	 		
 		});
 		return false;
  	});
  	
  	$("#closer a").click(function(){
  		$("#tabs").slideUp(300,function(){
	  		$("#clipnav a").removeClass("here");
	  		//$.scrollTo({top:'0px', left:'0px'},700);
  		});
  		return false;
  	});
 
 	rotatetop();
 	rotatebot();
 	//setInterval("rotatetop()",3000);
  	//setInterval("rotatebot()",3300);
  	
  	$("ul#episodelist li").hover(function(){
  			clearTimeout(t);
  			current=$(this);
  			t=setTimeout("showblurb()",1000);
   			
   			
  		},function(){
  			clearTimeout(t);
  			hideblurb();
  		}
  	);
  	
 	
 	

	


 
 });
 
 	var current=null;
 	var t=null;

	function showblurb(){
		if (current !=null && current.find("span.blurb").text() !=""){

			$("body").append('<div id="blurb"><div></div></div>');
			$("#blurb div").text(current.find("span.blurb").text());
	   		$("#blurb").css({position:"absolute",top:current.offset().top+22,left:"0px",zIndex:"120000"});
	   	}
	}
	
	function hideblurb(){
		current=null;
		$("#blurb").remove();
	}
 
 
  	function rotatetop(){
  		var r=Math.floor(Math.random()*5)+1;
 		if(r<10) r="0"+r;
 		$("#episode").css("background","#000 url('/img/bgs/bk"+r+".gif')");
  	}
  	
  	function rotatebot(){
  		var r=Math.floor(Math.random()*5)+1;
 		if(r<10) r="0"+r;
 		$("#episodes").css("background","#fff url('/img/bgs/wh"+r+".gif')");
  	}
  	
  	

 	

