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

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

function init()
{
	/* emailadressen beschermen */
	$('span.eprotecttext').each( function(i)
	{
		$(this).text( createEmailBySplit( $(this).attr('class') ) );
	});	
	$('span.eprotectlink').each( function(i)
	{
		var mailtoLink	= '<a href="mailto:' + createEmailBySplit( $(this).attr('class') ) + '">' + $(this).text() + '</a>';
		$(this).html(mailtoLink);
		$(this).removeAttr('title');
	});	
	
	$('#blocks div.text').each( function(i)
	{
		if ( $(this).find('a').length > 0 )
		{
			$(this).click( function () {
				window.location = $(this).find('a').attr('href');
			});
			$(this).hover( function () {
				$(this).addClass('hover');
			}, function () {
				$(this).removeClass('hover');
			} );
		}
	});
	
	/* links en buttons */
	$('input[type=submit]').addClass('button');
	$('a[rel=external]').each( function(i)
	{
		$(this).attr('target', '_blank');
		$(this).addClass('external');
	});
	if ( $('#content').length > 0 )
		$('a[rel=lightbox]').lightBox();
	
	$('#blocks li div.imgs').cycle({
		fx: 'fade',
		timeout: 3000 
	});
	
	Cufon.replace('#index', {hover: true});
};
