var originalWidth = 0;
var originalHeight = 0;

function loadBigImage()
{
	
}

function initResizeImageBig()
{
	$(window).resize(function() {
 		resizeImageBig();
	});
	resizeImageBig();
}

function resizeImageBig()
{
	var newHeight = $(window).height();
	var top = 0;
	var newWidth = (newHeight * originalWidth) / originalHeight;
	if($(window).height() < 600) 
			newHeight = 600;
			
	newWidth = (newHeight * originalWidth) / originalHeight;
	top = ($(window).height() - newHeight) * .5;
	
	var left = ($(window).width() - newWidth) * .5;
	
	$(".bg:eq(0)").css({"top" : top + "px", "height" : newHeight + "px", "width" :  newWidth + "px", "left" : left + "px"});
}


function showBigImage(ind)
{
	var linkImg= '<img src = "'+ind+'" class = "bg" />';
	$(linkImg).css("display","none");
	showPreload();	
	$(linkImg).load(function()
	{
		originalWidth = this.width;
		originalHeight = this.height;
		hidePreload();
		$("body").prepend($(this));
		$(this).css("display","none");
		resizeImageBig();
		$(".bg:eq(0)").fadeIn(500);
		
		$(".bg:eq(1)").fadeOut(500, function()
		{
			$(this).remove();
		}
		);
		
		if(isHome == 1)
		{
			timerHome = setTimeout("changeImageAuto()",5000);
		}
	}
	);
}

function changeImageAuto()
{
	var actualId = parseInt($("#actualNumber").html()) - 1;
	var totalImages = parseInt($("#totPreview").html());
	if(actualId < totalImages - 1)
		{
			showBigImage($("#hiddenList li:eq("+(++actualId)+")").find("img").attr("rel"));
			$("#actualNumber").html(actualId + 1);	
		}
	else
		{
			showBigImage($("#hiddenList li:eq("+(0)+")").find("img").attr("rel"));
			$("#actualNumber").html("1");
		}
}
