$(document).ready(function()
{
	$('#content-left, #content-right').css('display', 'block');

	$('div.outer').hover(function()
	{
		$(this).addClass('outer-a');
		return false;
	}, function()
	{
		$(this).removeClass('outer-a');
	});
	
    var items = $('.slideshow div.show').size();
	
	$('#delitem').click(function()
	{	
		if(!confirm('Weet u dit zeker?'))
		{	
			return false;
		}
	});
	$('#delpage').click(function()
	{	
		if(!confirm('Weet u zeker dat u deze pagina wilt verwijderen? Hiermee gaat de thumbnail en de tekst verloren.'))
		{	
			return false;
		}
	});
	
	for(var i = 1; i <= items; i++)
	{
		if(i != 1) $('#p' + i).hide();
		if(i != 1) $('#t' + i).hide();
		
		var cPos = 1;
		
		$('<div class="nav-outer" id="s' + i + '"><a href="#" id="' + i + '">' + i + '</a></div>').appendTo('.nav');
		if(i == 8)
		{
			$('<br class="clear">').appendTo('.nav');
		}
	}
	
	$('#s1').attr('style', 'background:#ff5c11;');
	$('.nav a#1').addClass('active');
	
	$('.nav a').click(function()
	{
		var clickedId = ($(this).attr('id'));
		if(cPos != clickedId)
		{
			$('#p' + cPos).hide();
			$('.nav a#' + cPos).removeClass('active');
			$('#s' + cPos).removeAttr('style');
			$('#p' + clickedId).show();
			
			$('#t' + cPos).hide();
			$('#t' + clickedId).show();
			$('.nav a#' + clickedId).addClass('active');
			$('#s' + clickedId).attr('style', 'background:#ff5c11;');
			cPos = clickedId;
		}
	});
	
	$('#prev a img, #next a img').attr('src', 'images/layout/nav-out.png');
	
	$('#prev a img').hover(function()
	{
		$(this).attr('src', 'images/layout/nav-left.png');
	},
	function()
	{
		$(this).attr('src', 'images/layout/nav-out.png');
	});
	
	$('#next a img').hover(function()
	{
		$(this).attr('src', 'images/layout/nav-right.png');
	},
	function()
	{
		$(this).attr('src', 'images/layout/nav-out.png');
	});
	
	
	
	$('#next a img').click(function()
	{
		clicked = parseInt($(this).attr('id'));
		
		if(clicked < items)
		{
			cPos = clicked+1;
			$('#p' + clicked).hide();
			$('.nav-outer').removeClass('active');
			$('.nav a#' + clicked).removeClass('active');
			$('#s' + clicked).removeAttr('style');
			$('#p' + (clicked +1)).show();
			$('.nav a#' + (clicked +1)).addClass('active');
			$('#s' + (clicked +1)).attr('style', 'background:#ff5c11;');
			$('#t' + clicked).hide();
			$('#t' + (clicked +1)).show();
		}
	});
	
	$('#prev a img').click(function()
	{
		clicked = parseInt($(this).attr('id'));
		if((clicked - 1) > 0)
		{
			cPos = clicked-1;
			$('#p' + clicked).hide();
			$('.nav a#' + clicked).removeClass('active');
			$('#s' + clicked).removeAttr('style');
			$('#p' + (clicked -1)).show();
			$('.nav a#' + (clicked -1)).addClass('active');
			$('#s' + (clicked-1)).attr('style', 'background:#ff5c11;');
			$('#t' + clicked).hide();
			$('#t' + (clicked -1)).show();
		}		
	});
});