$(document).ready(function() 
{
	init();
});

function createEmailBySplit(splitString)
{
	var eParts 		= base64_decode(splitString).split('|');
	return eParts[0] + '@' + eParts[1] + '.' + eParts[2];
}

function doPopup(sTarget, iHeight, iWidth)
{
	iHeight	= iHeight ? iHeight: 350;
	iWidth	= iWidth ? iWidth: 300;
	window.open('', sTarget, 
		'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=' + iWidth + ', height=' + iHeight);
}

function protectEmailadresses()
{
	$('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', '');
	});	
}

function generateDropdownNavigation()
{
/*
	$.get
	(
		'/file/ajax/gettopnavigation.php', 
		{ id: $('#container').attr('class') },
		function (data)
		{
			$('#top').html(data);
			
			// hover kan pas toegekend worden als html in DOM is geladen
			$('#top li').hover( function() 
			{
				$(this).find('ul').fadeIn('fast');	
			}, function() {
				$(this).find('ul').fadeOut('fast');
			} );
		}
	);
*/
			$('#top li').hover( function() 
			{
				$(this).find('ul').fadeIn('fast');	
			}, function() {
				$(this).find('ul').fadeOut('fast');
			} );
}

function init()
{
	/* emailadressen beschermen */
	protectEmailadresses();
	generateDropdownNavigation();
	
	/* links en buttons */
	$('a[@href$=pdf]').addClass('pdf');
	$('a[@href$=doc]').addClass('doc');
	$('a[@href$=zip]').addClass('zip');
	$('a[@href$=rar]').addClass('rar');
	$('input[@type$=submit]').addClass('button');
	$("input[name*='jaar'],input[name*='aantal'],input[name*='rente']").css('width', '27px');
	$("input:parent:contains('EUR')").css('background-color', '#fc0');
	$('input[type=text]').each( function(i)
	{
		if ( $(this).parent().html().indexOf('EUR', 0) >= 0 )
			$(this).css('width', '50px');
	});
	
	$('a[@rel=external]').each( function(i)
	{
		$(this).attr('target', '_blank');
		if ( $(this).find('img').length == 0 )	// afbeeldingen moeten de class niet meekrijgen
			$(this).addClass('external');
	});
	
	if ( $('#content').length > 0 )
		$('a[rel=lightbox]').lightBox();
	
}
;