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

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

function init()
{
	if ( ( window.location + '' ).indexOf('search=') !== -1 && $("form#autopost").length > 0 )
	{
		$("form#autopost").submit();
	}
	
	$("iframe").change(function () {
		alert( $('iframe').attr('src') );
	});

		
	$('input[type=text]').addClass('text');
	$('input[type=submit]').addClass('button');
	$('#breadcrumbs li a').before('<span>&raquo;</span> ');
	
	/* 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');
	});	
	
	$('iframe').css('overflow-x', 'hidden');
	
	/* 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();
	
	$('#nav > li').hover( function () {
		$(this).addClass('hover');
		$(this).find('> a').addClass('hover');
	}, function () {
		$(this).removeClass('hover');
		$(this).find('> a').removeClass('hover');
	} );

};
