function updateSlideText(){
	var index = $(this).parent().children().index(this);
	var numSlides =  $(this).parent().children().size();
	$("#ss-nav p.counter").html(index+1 + "/" + numSlides);
	$("#ss-foot p.description").html($(this).attr("alt"));
}


$(function(){
	
	//SLIDESHOW
	$("#ss-foot p").after('<div id="ss-nav"><a href="#" id="ss-prev"><img src="./images/pager-left.gif" alt="previous image" /></a><p class="counter"></p><a href="#" id="ss-next"><img src="./images/pager-right.gif" alt="next image" /></a></div>');
	$("#slideshow img").removeClass();
	$("#slideshow").cycle({ 
	    fx: 'scrollHorz',
		timeout: 0,
		sync: 1,
		easing: "easeInOutCubic",
		next: '#ss-next',
		prev: '#ss-prev',
		pause: 1,
		after: updateSlideText
	});
	
	
	//TEAMPIC MOUSEOVERS
	$("#roadtrippers-main div.hoverer").hover(function(){
		//hover on
		if(!$.browser.msie)	$(this).css("opacity", ".3").css("background-color", "#093");
		var currentClass = $(this).attr("class").slice(0,-8);
		$(this).parent().find("p." + currentClass + "_desc").addClass("active");
	}, function(){
		//hover off
		$(this).css("background-color", "transparent");
		var currentClass = $(this).attr("class").slice(0,-8);
		$(this).parent().find("p." + currentClass + "_desc").removeClass("active");
	});
	
	
	//TRANSCRIPTS
	$("a.showdsc").livequery("click", function(){
		$("a.showdsc").fadeOut("fast").remove();
		$("div#tscpt").fadeOut("fast").remove();
		$("div.dsctxt, div.ex-dsctxt").show();
		$("a.showtscpt").show();
	})
	
	$("a.showtscpt").livequery("click", function(){showTscpt();});
	$("div.dsctxt, div.ex-dsctxt h2").after("<a href='#' class='showtscpt'>See Episode Transcript</a>");
	
	
});

//transcript function
function showTscpt(){
	var tsfile;
	if($("div.dsctxt").attr("id") == "dsc1") tsfile = "./transcripts/tscpt01.txt";
	if($("div.dsctxt").attr("id") == "dsc2") tsfile = "./transcripts/tscpt02.txt";
	if($("div.dsctxt").attr("id") == "dsc3") tsfile = "./transcripts/tscpt03.txt";
	if($("div.dsctxt").attr("id") == "dsc4") tsfile = "./transcripts/tscpt04.txt";
	if($("div.dsctxt").attr("id") == "dsc5") tsfile = "./transcripts/tscpt05.txt";
	if($("div.dsctxt").attr("id") == "dsc6") tsfile = "./transcripts/tscpt06.txt";
	if($("div.dsctxt").attr("id") == "dsc7") tsfile = "./transcripts/tscpt07.txt";
	if($("div.dsctxt").attr("id") == "dsc8") tsfile = "./transcripts/tscpt08.txt";
	if($("div.ex-dsctxt").attr("id") == "dsc10k") tsfile = "./transcripts/10k.txt";
	if($("div.ex-dsctxt").attr("id") == "dscbeware") tsfile = "./transcripts/beware_dolls.txt";
	if($("div.ex-dsctxt").attr("id") == "dscemerald") tsfile = "./transcripts/emeraldcity.txt";
	if($("div.ex-dsctxt").attr("id") == "dscfinding") tsfile = "./transcripts/findingavoice.txt";
	if($("div.ex-dsctxt").attr("id") == "dscredefining") tsfile = "./transcripts/amy_pinard.txt";
	if($("div.ex-dsctxt").attr("id") == "dscrestoration") tsfile = "./transcripts/restorationromp.txt";
	if($("div.ex-dsctxt").attr("id") == "dscsean") tsfile = "./transcripts/sean_murphy_uganda.txt";
	if($("div.ex-dsctxt").attr("id") == "dscstick") tsfile = "./transcripts/stick_happens.txt";
	$("a.showtscpt").fadeOut("fast");
	$("div.dsctxt").before("<div id='tscpt'><p>Loading...</p></div>").fadeOut("fast", function(){
		$("div#tscpt").load(tsfile ,{} , function(){ $("div#tscpt").prepend("<p>").append("</p>") });
		$("div#tscpt").before("<a href='#' class='showdsc'>See Episode Description</a>")
	});
	$("div.ex-dsctxt").before("<div id='tscpt'><p>Loading...</p></div>").fadeOut("fast", function(){
		$("div#tscpt").load(tsfile ,{} , function(){ $("div#tscpt").prepend("<p>").append("</p>") });
		$("div#tscpt").before("<a href='#' class='showdsc'>See Episode Description</a>")
	});
}
