var newsNewHeight = 1;

$(document).ready(function(){

	$("#footerMailJs").append($("<a/>").text("ft@filmtecknarna.se").attr("href", "mailto:ft@filmtecknarna.se"));
	
	//animateThumbnails();
	
	$("#footerMailJs").text("ft@filmtecknarna.se");					
	//loadShowReel();
	
	$(".startVideoImageLarge").click(function(event){

		var thumbnailTarget = event.currentTarget;
		var children = $(thumbnailTarget).children();
		var videoSource = children[0].href;
		var videoId = children[0].id;
		
		window.location = "http://www.filmtecknarna.se/work/#/" + videoId;
		//console.debug(videoId);
	});

	$(".startVideoImageSmall").click(function(event){

		var thumbnailTarget = event.currentTarget;
		var children = $(thumbnailTarget).children();
		var videoSource = children[0].href;
		var videoId = children[0].id;
		
		window.location = "http://www.filmtecknarna.se/work/#/" + videoId;
		//console.debug(videoId);
	});
	
	var news = $(".news");
	
	for(var i = 0;i < news.length;i++){
		var newsOldHeight = $(news[i]).innerHeight();
		//console.debug(newsOldHeight);
		//console.debug(newsHeight);
		//console.debug($(news[i]).innerHeight());
		if(newsNewHeight < newsOldHeight){
			newsNewHeight = newsOldHeight;
		}
	}
	
	//console.debug($("#latestNewsRight"));
	//console.debug(newsHeight);
	
	$(".news").css("height",newsNewHeight);
	$("#latestNewsWrapper").css("height",newsNewHeight);
});

function loadShowReel(){
	var theFlashVars = {	theSourcePath : "rtmp://fl1.c13959.cdn.qbrick.com/13959/F_REEL_2008.flv",
							theImagePath : "http://www.filmtecknarna.se/graphics/showreelStill/F_REEL_2008.jpg"};
	var theParameters = { 	allowfullscreen:"true",
							wmode : "opaque" };
	
	swfobject.embedSWF("flash/videoPlayerFT.swf", "theFlashVideoPlayer", "677", "381", "9.0.0", "scr/expressInstall.swf", theFlashVars, theParameters);
	
	
}

function animateThumbnails(){
	var i = 1;
	var thumbnailWrapper = new Array();
	
	while(thumbnails = document.getElementById("thumbnails"+i)){
		thumbnailWrapper.push(thumbnails);
		i++;
	}
	
	
	for(var i = 0;i < thumbnailWrapper.length; i++){
		thumbnailsAnimation(thumbnailWrapper[i]);
	}
}
