var castHeight;

$(document).ready(function(){
	castheight = $("#castimages").height()+15;
	$("#innercontent").animate({height: "1250px"},1700);
	
	$("#largeimage").fadeIn(1700);
	
	$(".castmember").click(function(){
		var newHeight = $("#"+$(this).attr("name")).height();
		var newBio = $(this).attr("name");
		var oldTiming = $("#innercontent").height()*1.7;
		$("#innercontent").animate({height: ($("#castimages").height()+15)+"px"},oldTiming);
		$("#largeimage").fadeOut(oldTiming);
		$("#headertext").fadeOut(oldTiming);
		$("#follow").fadeOut(oldTiming);
		$(".social").each(function(){
			$(this).fadeOut(oldTiming);
		});
		setTimeout('$(".bio").css("display","none")',oldTiming+100);
		setTimeout('$("#largeimage").attr("src","/images/'+$(this).attr("name")+'big.jpg")',oldTiming+100);
		setTimeout('$("#'+$(this).attr("name")+'").css("display","block")',oldTiming+100);
		setTimeout('$("#headertext").attr("src","http://www.situationinteractive.com/aleff/fonts/gdfont.php?msg='+$(this).attr("alt").replace(" ","+")+'&font=HelveticaNeueCondensedBold.ttf&size=18&bg_red=243&bg_grn=185&bg_blu=30")',oldTiming+100);
		if(($(this).attr("alt").indexOf("g") > 0) || ($(this).attr("alt").indexOf("j") > 0) || ($(this).attr("alt").indexOf("p") > 0) || ($(this).attr("alt").indexOf("q") > 0) || ($(this).attr("alt").indexOf("y") > 0)){
			setTimeout('$("#headertext").css({marginTop: "-3px", position: "relative", top: "3px"})',oldTiming+100);
		} else {
			setTimeout('$("#headertext").css({marginTop: "0px", top: "0px"})',oldTiming+100);
		}
		setTimeout('$("#follow").text("follow '+$(this).attr("alt")+'")',oldTiming+100);
		setTimeout('$("#headertext").attr("alt","'+$(this).attr("alt")+'")',oldTiming+100);
		setTimeout('$("#'+$(this).attr("name")+'qa").css("display","block")',oldTiming+100);
		setTimeout('$("#title").attr("align","left")',oldTiming+100);
		setTimeout('$(".castmember").removeClass("active");',oldTiming+100);
		setTimeout("showNewBio('"+newBio+"')",oldTiming+200);
	});
	
	$(".castmember:first").trigger('click');

	
});

function showNewBio(th){
	var showFollow = false;
	$(".castmember").each(function(){
		if($(this).attr("name") == th){
			$(this).addClass("active");
		}
	});
	if(th=="melb"){
		$("#header").css({backgroundImage: "url(/images/melheader.jpg)"});
	} else if(th=="kellymonaco"){
		$("#header").css({backgroundImage: "url(/images/kellyheader.jpg)"});
	} else if(th=="shoshanabean"){
		$("#header").css({backgroundImage: "url(/images/shoshanaheader.jpg)"});
	} else if(th=="hollymadison"){
		$("#header").css({backgroundImage: "url(/images/hollyheader.jpg)"});
	} else if(th=="joshstrickland"){
		$("#header").css({backgroundImage: "url(/images/joshheader.jpg)"});
	} else {
		$("#header").css({backgroundImage: "url(/images/creativeheader.jpg)"});
	}
	if($("#castimages").height()+15<$("#"+th).height()+10)
		$("#innercontent").animate({height: $("#"+th).height()+10 + "px"},$("#"+th).height()*1.7);
	$("#largeimage").fadeIn($("#"+th).height()*1.7);
	$("#headertext").fadeIn($("#"+th).height()*1.7);
	if($("#"+th).attr("youtube_link")!=""){
		$("#youtube a").attr({href: $("#"+th).attr("youtube_link")});
		$("#youtube").fadeIn($("#"+th).height()*1.7);
		showFollow = true;
	}
	if($("#"+th).attr("myspace_link")!=""){
		$("#myspace a").attr({href: $("#"+th).attr("myspace_link")});
		$("#myspace").fadeIn($("#"+th).height()*1.7);
		showFollow = true;
	}
	if($("#"+th).attr("twitter_link")!=""){
		$("#twitter a").attr({href: $("#"+th).attr("twitter_link")});
		$("#twitter").fadeIn($("#"+th).height()*1.7);
		showFollow = true;
	}
	if($("#"+th).attr("facebook_link")!=""){
		$("#facebook a").attr({href: $("#"+th).attr("facebook_link")});
		$("#facebook").fadeIn($("#"+th).height()*1.7);
		showFollow = true;
	}
	//if(showFollow){
		//$("#follow").fadeIn($("#"+th).height()*1.7);
	//}
}