var iSlide	= 0;
var zIndex	= 0;

$(document).ready(function() 
{
	init();
});

function createEmailBySplit(splitString)
{
	var eParts 		= base64_decode(splitString).split('|');
	return eParts[0] + '@' + eParts[1] + '.' + eParts[2];
}

function homeSlide()
{
	iPrevSlide	= iSlide;
	iSlide--;
	if ( iSlide < 0 )
		iSlide = $('#homeslide li').length - 1;

	tempIndex	= ++zIndex;
	$('#homeslide li:eq(' + iPrevSlide + ')').css('z-index', ++zIndex);
	$('#homeslide li:eq(' + iSlide + ')').css('z-index', tempIndex);
	$('#homeslide li:eq(' + iPrevSlide + ')').animate({opacity: 0}, 750, null, function () 
	{		
		$('#homeslide li:eq(' + iSlide + ')').css('z-index', ++zIndex);
	}).animate( { opacity:1}, 1 );	

	setTimeout('homeSlide()', 5000);
}

function init()
{
	$('#navigation li:first,#home li:first,#footer li:first').addClass('first');
	$('#navigation li:first a').wrapInner('<span style="visibility: hidden;"></span>');
	
	/* emailadressen beschermen */
	$('span.eprotecttext').each( function(i)
	{
		$(this).text( createEmailBySplit( $(this).attr('alt') ) );
		$(this).attr('alt', '');
	});	
	$('span.eprotectlink').each( function(i)
	{
		var mailtoLink	= '<a href="mailto:' + createEmailBySplit( $(this).attr('alt') ) + '">' + $(this).text() + '</a>';
		$(this).html(mailtoLink);
		$(this).attr('alt', '');
		$(this).attr('title', '');
	});	
	
	$('a[@rel=external]').each( function(i)
	{
		$(this).attr('target', '_blank');
		$(this).addClass('external');
	});
	
	$('#header ul a').each( function()
	{
		$(this).css('background-image', 'url(\'/beheer/file/img/ico/flag/' + $(this).attr('class') + '.gif\')');
		$(this).find('span').css( { visibility: 'hidden', fontSize: '1px'} );
	});
	
	if ( $('#content').length > 0 )
		$('a[rel=lightbox]').lightBox();

	iSlide	= zIndex = $('#homeslide li').length-1;
	setTimeout('homeSlide()', 5000);
};

