Shadowbox.init({
	skipSetup: true
});

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

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

function cmsFunctions()
{	
	/* 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', '');
	});	
	
	/* links en buttons */
	$('input[type=submit]').addClass('button');	
	$('[rel=external],.external').attr('target', '_blank');
		
	/*if ( typeof $('#header').attr('class') != 'undefined' )
		$('#container > div.wrapper').css('background-image', "url('" + $('#header').attr('class') + "')");*/
}

function init()
{
	$('#blocks .item:first').addClass('first');
	
	$('#slider').cycle({
		fx: 'scrollRight',
		speed: 10000,
		timeout: 3000/*,
		//pause: 1 */
	});
	
	Shadowbox.setup("a[rel*='shadowbox']", {
		language: 'nl',
		enableKeys: false,
		players:  ['img', 'html', 'iframe', 'swf', 'flv'],
		autoplayMovies: false,
		continuous: true,
		counterLimit: 0,
		counterType: 'skip',
		handleOversize: 'drag'
	});
	
	if ( $('#stretched-background-image').length > 0 )
	{
		var imgPath = $('#stretched-background-image').attr('src');
		$('#stretched-background-image').hide().remove();
		$(document).bgStretcher({
			images: [imgPath], imageWidth: 1255, imageHeight: 1000
		});
	}

};
