$(document).ready(function(){
		
	$('#nav li').children('a').children('span:not(.current)').css({opacity: '0', display: 'block'});
	$('#nav li').hover(
			function(){$(this).children('a').children('span:not(.current)').stop().animate({opacity:"1"}, 350, "easeInOutQuad");},
			function(){$(this).children('a').children('span:not(.current)').stop().animate({opacity:"0"}, 350, "easeInOutQuad");}
	);

	var mHREF = "_include/img/trailers/game-trailer-1.flv";
	var myHREF = "_include/img/screenshots/game-screenshot-1.jpg";
	
	
	$('#thumbsholder li').css({opacity: 0});
	$('#thumbsholder span').css({opacity: 0});
	$('#screenshot img').css({opacity: 0});
	
	$('.screen-but').click(function (e) {
		e.preventDefault();	
		
		if($('#screen-but').children('span').hasClass("current")) {
		} else {
			
			if($('#flash-cont')) {
			
				$('#screenshot').removeClass("flash-cont");
				$('#screenshot').empty();
				$('#screenshot').append("\<img src='"+myHREF+"'\/>");
				$('#screenshot img').css({opacity: 0}).stop().animate({opacity: 0},1000).animate({opacity: 1},300, "easeInOutQuad");
				$('.activethumbnail').removeClass("activethumbnail");
				$('.screen-thumbs li').children('a:first').addClass("activethumbnail");
			}
			
			$(".current").stop().animate({opacity:"0"}, 350, "easeInOutQuad").removeClass("current");
			$('#screen-but').children('span').addClass("current");
			$('#screen-but').children('span').css({opacity: 1})
			
			$('#content').stop().animate({paddingTop:"0"}, 350, "easeInOutQuad");
			$('#thumbsholder li').stop().animate({opacity: 0},350);
			$('#thumbsholder span').stop().animate({opacity: 0},350);
			$('#media').fadeOut('medium', function() {
					$('#media').addClass("open");	
					$('#thumbset-0').css({display: 'none'});
					$('#thumbset-1').css({display: 'block'});
					$('#media').fadeIn('slow');
					$('#content').stop().animate({paddingTop:"65px"}, 350, "easeInOutQuad");
					$('#thumbsholder li').animate({opacity: 1},350);
					$('#thumbsholder span').stop().animate({opacity: 1},350);
			});
		}
		
	});
	
	$('.trailer-but').click(function (e) {
		e.preventDefault();	
	
		if($('#trailer-but').children('span').hasClass("current")) {
		} else {
			$(".current").stop().animate({opacity:"0"}, 350, "easeInOutQuad").removeClass("current");
			$('#content').stop().animate({paddingTop:"0"}, 350, "easeInOutQuad");
			$('#thumbsholder li').stop().animate({opacity: 0},350);
			$('#thumbsholder span').stop().animate({opacity: 0},350);
			$('#media').fadeOut('medium', function() {
					$('#media').addClass("open");	
					$('#thumbset-0').css({display: 'block'});
					$('#thumbset-1').css({display: 'none'});
					$('#media').fadeIn('slow');
					$('#content').stop().animate({paddingTop:"65px"}, 350, "easeInOutQuad");
					$('#thumbsholder li').animate({opacity: 1},350);
					$('#thumbsholder span').stop().animate({opacity: 1},350);
			});
			$('#trailer-but').children('span').addClass("current");
			$('#trailer-but').children('span').css({opacity: 1})
			
			$('#screenshot img').fadeOut('fast', function() {
				$('#screenshot').empty();
				$('#screenshot').append("<img id='playtrailer' src='_include/img/trailers/game-trailer-1.jpg'/>");
				$('#screenshot img').css({opacity: 0}).stop().animate({opacity: 0},1000).animate({opacity: 1},300, "easeInOutQuad");
				
				$('#playtrailer').click(function (e) {
					showTrailer();								  
			 	 });
				
			});

		}	
	});
	
	
	//view image
	$('.screen-thumbs li').children('a:first').addClass("activethumbnail");
	$('.screen-thumbs li').children('a').click(function (e) {
		e.preventDefault();
		$(".activethumbnail").removeClass("activethumbnail");
		$(this).addClass("activethumbnail");
		tHREF = $(this).attr("href");
		if ($('#screenshot').hasClass("flash-cont")){
			$('#screenshot').removeClass("flash-cont");
			$('#screenshot').empty();
			$('#screenshot').append("\<img src='"+tHREF+"'\/>");
			$('#screenshot img').css({opacity: 0}).stop().animate({opacity: 0},1000).animate({opacity: 1},300, "easeInOutQuad");
		} else {
			$('#screenshot img').fadeOut('fast', function() {
				$('#screenshot').empty();
				$('#screenshot').append("\<img src='"+tHREF+"'\/>");
				$('#screenshot img').css({opacity: 0}).stop().animate({opacity: 0},1000).animate({opacity: 1},300, "easeInOutQuad");
			});
		}
	}); 
	

	// launch trailer
	
		$('.screen-trailers li').children('a').click(function (e) {
			e.preventDefault();
			$(".athumbnail").removeClass("athumbnail");
			$(this).addClass("athumbnail");
			mHREF = $(this).attr("href");
			showTrailer();
		}); 
		
		function showTrailer() {
			$('#screenshot').removeClass("flash-cont");
			$('#screenshot').empty();
			var so = new SWFObject("flvplayer_em1.swf?videoDefault="+mHREF+"&autoHide=true&hideType=fade&autoStart=true&startVol=80&hideDelay=20&bgAlpha=100", "so", "603", "339", "8", "#000000");
			so.addParam("allowFullScreen", "true");
			so.write("screenshot");
			$('#screenshot').addClass("flash-cont");
			$('#screenshot img').css({opacity: 0}).stop().animate({opacity: 0},1000).animate({opacity: 1},300, "easeInOutQuad");
		};
})