var img = null;
var imageWidth = 0;
var imageHeight = 0;
var zoomWidth = 0;
var zoomHeight = 0;

function centerEntekens()
{
	var x = parseInt($(window).width())/2;
	var y = parseInt($(window).height())/2;

	if ($('#entekens'))
	{
		$('#entekens').show();
		$('#entekens').css('left', parseInt(x - (1095/2)));
	}

	if (img && $(img))
	{
		widthBorder = (2*24);
		heightBorder = (2*24) + 40;

		if ($(img).css && $(img).css('width'))
		{
			//zoomWidth = parseInt($(img).css('width')) + widthBorder;
			//zoomHeight = parseInt($(img).css('height')) + heightBorder;
			zoomWidth = imageWidth + widthBorder;
			zoomHeight = imageHeight + heightBorder;
	
			$('#picture').css('width', zoomWidth - widthBorder);
			$('#picture').css('height', zoomHeight - heightBorder);
		}
	}

	if ($('#zoom'))
	{
		$('#zoom').css('left', parseInt(x - (zoomWidth/2)));

		var zy = parseInt(y - (zoomHeight/2));

		if (zy < 15)
		{
			zy = 15;
		}

		$('#zoom').css('top', zy);
	}
}

$(window).resize(
	function()
	{
		centerEntekens();
	}
);

$(document).ready(
	function()
	{
		//centerEntekens();

		setInterval('centerEntekens();', 500);
		
		$('#zoom_nav_close').click(
			function()
			{
				zoom_close();
			}
		);
	
		$('#zoom_nav_left').click(
			function()
			{
				document.getElementById('slider').get_prev();
				$('#zoom_nav_left').find('img').blur();
			}
		);
	
		$('#zoom_nav_left').mouseover(
			function()
			{
				$('#zoom_nav_left').find('img').attr('src', '/images/beeldenvorming/nav_left_h.png');
			}
		);
			
		$('#zoom_nav_left').mouseout(
			function()
			{
				$('#zoom_nav_left').find('img').attr('src', '/images/beeldenvorming/nav_left.png');
			}
		);
		
		$('#zoom_nav_right').click(
			function()
			{
				document.getElementById('slider').get_next();
				$('#zoom_nav_right').find('img').blur();
			}
		);
	
		$('#zoom_nav_right').mouseover(
			function()
			{
				$('#zoom_nav_right').find('img').attr('src', '/images/beeldenvorming/nav_right_h.png');
			}
		);
			
		$('#zoom_nav_right').mouseout(
			function()
			{
				$('#zoom_nav_right').find('img').attr('src', '/images/beeldenvorming/nav_right.png');
			}
		);

		zoom_close();
	
		$(document).mouseover(
			function()
			{
				if (document.getElementById('slider'))
				{
					document.getElementById('slider').start();
				}
			}
		);
	}
);

function page_disable()
{
	$('#disabler').show();
	$('#disabler').css('opacity', 0.8);
}

function page_enable()
{
	$('#disabler').hide();
}

function zoom_close()
{
	$('#zoom').hide();

	page_enable();
}

function zoom_load(imageurl, label, description, width, height)
{
	$('#zoom_title').html(label);
	$('#zoom_description').html(description);

	imageWidth = width;
	imageHeight = height;

	centerEntekens();

	page_disable();

//	zoomWidth = 400;
//	zoomHeight = 200;

//	img = null;

	$('#picture').empty();

	$('#zoom').show();
//	$('#picture').css('width', zoomWidth - widthBorder);
//	$('#picture').css('height', zoomHeight - heightBorder);
//	centerEntekens();

	{
		img = document.createElement('img');
	}

	centerEntekens();

/*
//	$(img).css('display', 'none');
//	$(img).show();
	$(img).load(
		function()
		{

			$('#zoom').show();

			centerEntekens();

		//	setTimeout('centerEntekens();', 50);
		//	setTimeout('centerEntekens();', 900);
		//	setTimeout('centerEntekens();', 1500);
		//	setTimeout('centerEntekens();', 2500);
		}
	);
*/
	img.width = width;
	img.height = height;
	img.src = imageurl;

	$(img).appendTo($('#picture'));
}




