// JavaScript Document

$(document).ready(function($)
{
	/*var nonselectableobject = document.getElementById('content');
	nonselectableobject.onmousedown = nonselectableobject.onselectstart = function(){return false;}*/
						
	$('.venster').click(function()
	{
		if($(this).attr('data') != 'active')
		{
			$(this).find('.venster_show').show(200, 'swing');
			$(this).attr('data', 'active').children(':first').attr('src', $(this).children(':first').attr('src').replace ('1.', '2.'));
		}
		else
		{
			$(this).find('.venster_show').hide(200, 'swing');
			$(this).attr('data', '').children(':first').attr('src', $(this).children(':first').attr('src').replace ('2.', '1.'));
		}
		return false;
	});
	
	$('.venster .venster_content .venster_show ul li a').click(function()
	{
		if($(this).attr('target') == '_blank')
		{
			newWindow = window.open($(this).attr('href'));
		}
		else
		{
			window.location.href = $(this).attr('href');
		}
		return false;
	});
	
	$('div#approve img').mouseover(function()
	{
		$(this).attr('src', $(this).attr('src').replace('1.', '2.'));
	}).mouseout(function()
	{
		$(this).attr('src', $(this).attr('src').replace('2.', '1.'));
	});
	
	$('.niveau1_fotos li').mouseover(function()
	{
		$(this).find('img:last').attr('src', $(this).find('img:last').attr('src').replace('1.', '2.'));
	}).mouseout(function()
	{
		$(this).find('img:last').attr('src', $(this).find('img:last').attr('src').replace('2.', '1.'));
	});
	
	$('.niveau1_fotos li').mouseover(function()
	{
		$(this).find('img:last').attr('src', $(this).find('img:last').attr('src').replace('1.', '2.'));
	}).mouseout(function()
	{
		$(this).find('img:last').attr('src', $(this).find('img:last').attr('src').replace('2.', '1.'));
	});
	
	$('div#right header img.header_img:first').css('display', 'block').attr('data', 'active');
	
	if($('div#right header img.header_img').length > 1)
	{
		setInterval(doHeader, 10000);
	}
		
	$('.niveau_3_content li a').click(function()
	{
		$(this).next().toggle(300).parent().siblings().each(function()
		{
			$(this).children('.nodisplay:visible').hide(300);
		});
		return false;
	});
	
	$('[rel="lightbox"]').colorbox();
	
	$('header .header_sub').each(function()
	{
		var temp = $(this).prevAll('.header_sub').length * 95 + 9;
		$(this).css('left', temp + 'px');
	}).mouseover(function()
	{
		var zindex = $("header .header_sub").length+1;
		$(this).addClass('header_temp_active');
		if(!$(this).hasClass('header_sub_active'))
		{
			$(this).find('img').attr('src', $(this).find('img').attr('src').replace('1.', '2.'));
		}
	}).mouseout(function()
	{
		$(this).removeClass('header_temp_active')
		if(!$(this).hasClass('header_sub_active'))
		{
			$(this).find('img').attr('src', $(this).find('img').attr('src').replace('2.', '1.'));
		}
	});
	
	$('.header_sub_active').prev().addClass('header_side_active');
	$('.header_sub_active').next().addClass('header_side_active');
	
	$('.werknemer_overlay').click(function()
	{
		if($(this).parent().siblings('img.werknemer_bg').css('top') == '157px')
		{
			$(this).parent().siblings('img.werknemer_bg').animate ({ top: '0px' });
			$(this).parent().siblings('.werknemer_less').fadeOut(300, function()
			{
				$(this).siblings('.werknemer_more').fadeIn(400);
			});
		}
		else
		{
			$(this).parent().siblings('img.werknemer_bg').animate ({ top: '157px' }, 300);
			$(this).parent().siblings('.werknemer_more').fadeOut(300, function()
			{
				$(this).siblings('.werknemer_less').fadeIn(400);
			});
		}
		return false;
	});
	
	$('.rekenmodule').mouseover(function()
	{
		$(this).find('img').attr('src', $(this).find('img').attr('src').replace('1.', '2.'));
	}).mouseout(function()
	{
		$(this).find('img').attr('src', $(this).find('img').attr('src').replace('2.', '1.'));
	});
	
	$('.doorklik_sluiten').click(function()
	{
		$(this).parent().fadeOut(300);
		return false;
	});
	
	$('.doorklik_li a').click(function()
	{
		var position  = $(this).parent().position();
		var position2 = $(this).parent().parent().position();
		position = position.top + position2.top;
		var pagina_id = $(this).parent().attr('data');
		if($('.doorklik_' + pagina_id).is(':visible'))
		{
			$('.doorklik_' + pagina_id).fadeOut(300);
		}
		else
		{
			$('.doorklik_' + pagina_id).css('top', position + 'px').fadeIn(300);
		}
		$('.doorklik:not(.doorklik_' + pagina_id + ')').fadeOut(300);
		return false;
	});
	
	$('.hypotheekvorm_doorklik').click(function()
	{
		var position  = $(this).parent().parent().parent().parent().position().top;
		var pagina_id = $(this).attr('data');
		if ($('.doorklik_' + pagina_id).is(':visible'))
		{
			$('.doorklik_' + pagina_id).fadeOut(300);
		}
		else
		{
			$('.doorklik_' + pagina_id).css('top', position + 'px').fadeIn(300);
		}
		$('.doorklik:not(.doorklik_' + pagina_id + ')').fadeOut(300);
		return false;
	});
});
