// JavaScript Document
var lastImgUrl = '';
var navHeight = 86;
var contentHeight = 199;
var contentSpanHeight = 200;
	
function getPhoto(me, imgurl) {
	if (lastImgUrl != imgurl) {
		lastImgUrl = imgurl;
		$(".thumbnails a").removeClass("selected");
		//alert(me);
		me.addClass("selected");
		$("#photomask").animate({"width": 0} , 200, 0 , loadPhoto);
		$("#photoDesc").animate({"width": 0} , 200);
		//$("#photomask").load(imgurl, {});
	}
}

function loadPhoto() {
	$("#photomask").hide();
	$("#photoDesc").hide();
	$("#loading").show();
	$("#loading").html('<img src="tutorial/images/asteroids.gif" />');
	$("#photomask").load(lastImgUrl, {}, photoLoaded);
}

function photoLoaded() {
	var txt = $("#big_show .hidden").html();
	$("#photoDesc > div").html(txt);
	//alert(txt);
	$(".photo img").load(function(){
		//alert("loaded");
		$("#loading").hide();
		$("#photomask").show();
		$("#photoDesc").show();
		$("#photomask").animate({"width": "650px"} , 200);
		$("#photoDesc").animate({"width": "300px"} , 200);
		$(".photo img").click(hideSlideShow);
		
	});
}

function sizeUp() {
	$("#big_show").load("slideshow/slides/"+URLSegment, {}, showSlideShow);
	$("#prev-next").hide();
	$("#prev-next-slideshow").show();
	$("#navi").animate({"height": 0}, 300);
	$("#content").animate({"height": 480+10 + "px"} , 300);
}
		
function doafter() {
	//$("#big_show").load("slideshow/slides/"+URLSegment, {}, show);
}

function showSlideShow() {
	//$(".slideshow").height(0);
	//alert("showSlideShow");
	var txt = $("#big_show .hidden").html();
	$("#photoDesc > div").html(txt);
	$("#big_show").show();
	$("#thumbmask").animate({"width": "325px"}, 200);
	//$(".slideshow").animate({"height": "480px"}, 300,0);
	$(".photo img").load(function(){
		$(".photo img").click(hideSlideShow);
		$("#photomask").animate({"width": "650px"}, 200);
	});
}

function hideSlideShow() {
	//$("#big_show").fadeOut(300);
	$(".images img").show();
	$("#thumbmask").animate({"width": 0}, 200, sizeDown);
	$("#photomask").animate({"width": 0}, 200, 0, doafter2);
	//$(".slideshow").animate({"height": 0} , 300, 0, doafter2);
	//sizeDown();
}

function doafter2() {
	$("#big_show").hide();
	//alert(contentSpanHeight);
	$(".span-1, .span-2, .span-3, .span-4, .span-5, .span-6").each(function() {
		$(this).show();
		$(this).animate({"height": contentSpanHeight+"px"} , 300);
	});
}
function sizeDown() {
	$("#navi").animate({"height": navHeight+"px"}, 300);
	$("#content").animate({"height": contentHeight + "px"} , 300);
	$("#see_more").show();
	
}
function setHeights() {
	navHeight = $("#navi").height();
	contentHeight = $("#content").height();
	//alert(contentHeight);
}

$(document).ready(function() {
						   
	$(".roll_inner").hover(
		function() { $(this).children(".shortDescOverview").animate({"height": "155px"},{ queue:false, duration:200 });},
		function() { $(this).children(".shortDescOverview").animate({"height": 0},{ queue:false, duration:200 });}
	);
	$(".articleTitle").hover(
		function() { $(this).prev(".roll_inner").children(".shortDescOverview").animate({"height": "155px"},{ queue:false, duration:200 });},
		function() { $(this).prev(".roll_inner").children(".shortDescOverview").animate({"height": "0px"},{ queue:false, duration:200 });}

	);
	
	

	
	
	$("#big_show").hide();
	
	if(SlideOnOff == 1){
		$("#see_more, .images img").click(function()
			
				{		
					//$(".span-1, .span-2, .span-3, .span-4, .span-5, .span-6").fadeOut(250);
					$time = 300;
					setHeights();
					$(".span-1, .span-2, .span-3, .span-4, .span-5, .span-6").each(function() {
						if ($(this).height() > contentSpanHeight) contentSpanHeight = $(this).height();
						$(this).animate({"height": 0} , $time,0,function(){$(this).hide();});
						//$time += 200;
					});
					//alert(contentSpanHeight);
					sizeUp();
					$("#see_more").hide();
					
				}

		);
	};
	
	
	


});