$(document).ready(function() {
	/**
	 *	IMG hover op home page
	 */	 	
	$('.imageOverLink')
		.hover(
			function() 
			{
				$(this)
					.attr("src", "/Skins/Groepsmediation/Content/Images/Home/links_over_" + $(this).attr("name") + ".jpg");
				$(this)
					.css({
						cursor: 'pointer'
					});
			},
			function() 
			{
				$(this)
					.attr("src", "/Skins/Groepsmediation/Content/Images/Home/home_" + $(this).attr("name") + ".jpg");
				$(this)
					.css({
						cursor: 'default'
					});
			}
		);
		
	/**
	 *	Home link hover op standaard pagina's
	 */	 	
	$('.homeLink')
		.hover(
			function() 
			{
				$(this).attr("src", "/Skins/Groepsmediation/Content/Images/Standaard/links_over_04.jpg");
			},
			function() 
			{
				$(this).attr("src", "/Skins/Groepsmediation/Content/Images/Standaard/standaard_04.jpg");
			}
		);
	
	/**
	 *	Tooltip voor links met subpagina's op de home page
	 */	 	
	$(".tooltip")
		.hover(
			function() 
			{	
				var id = $(this).attr('id');
				
				var imgOffset = $(this).find('img').offset();
				var imgTop = imgOffset.top;
				var imgLeft = imgOffset.left;
				
				var windowBreedte = $(window).width();
				var wrapperBreedte = 800;
				var verschil = windowBreedte - wrapperBreedte;
				var verschilPerKant = verschil / 2;
				
				imgLeft = imgLeft - verschilPerKant;			 				
				
				if (id == 'Boek')
				{
					var top = imgTop + 130;
					var left = imgLeft + 1;
				}
				else if (id == 'Netwerk')
				{
					var top = imgTop + 93;
					var left = imgLeft - 2;
				}
				else if (id == 'Training')
				{
					var top = imgTop + 77;
					var left = imgLeft + 20;
				}
				else if (id == 'Reacties')
				{
					var top = imgTop + 91;
					var left = imgLeft - 2;
				}
				else if (id == 'Auteurs')
				{
					var top = imgTop + 50;
					var left = imgLeft + 3;
				}
				
				$('img:first', this)
					.attr("src", "/Skins/Groepsmediation/Content/Images/Home/links_over_" + $('img', this).attr("name") + ".jpg");
				
	        	if ($(".hover", this).css("display") == "block")
				{ 
					return false; 
				}
			
	        	$(".hover", this)
					.css({
						top: top + "px", 
						left: left + "px"
					})
					.show();
		    },
		    function()
		    {
				$('.hover', this)
					.hide();
				
				$('img:first', this)
					.attr("src", "/Skins/Groepsmediation/Content/Images/Home/home_" + $('img', this).attr("name") + ".jpg");
			}
		);
	
	$('.subLink')
		.hover(
			function()
			{
				$(this)
					.attr('src', '/Skins/Groepsmediation/Content/Images/Home/Tooltip_Links/' + $(this).attr('name') + '_over.jpg');
			},
			function()
			{
				if ($(this).attr('class') != 'subLink current')
				{
					$(this)
						.attr('src', '/Skins/Groepsmediation/Content/Images/Home/Tooltip_Links/' + $(this).attr('name') + '.jpg');
				}
			}
		);
	
	/**
	 *	Animatie van de omslag op de homepagina
	 */	 
	$('.boek')
		.click(function()
		{
			if ($('.omslag img').css('width') == '90px')
			{
				$('.omslag img')
					.fadeIn()
					.animate({
						width: '391px',
						height: '561px'
						},
						1000
					);
			}
			else 
			{
				$('.omslag img')
					.animate({
						width: '90px',
						height: '130px'
						},
						1000
					)
					.fadeOut();
			}
		});
	
	$.ajax({
		type: "GET", 
		url: "/Skins/Groepsmediation/Content/Includes/wait.inc.php", 
		data: { actie: 'checkEerste', url: location.href }, 
		success: function(data) 
				{
					if (data == 'true')
					{
						$('.omslag')
							.css({
								display: 'block'
							});
					}
				}
	});
	
	$('.omslag img')
		.ready(function()
		{
			$.ajax({
				type: "GET", 
				url: "/Skins/Groepsmediation/Content/Includes/wait.inc.php", 
				data: { sec: 2, url: location.href }, 
				success: function(data) 
						{
							if (data == 'gelukt')
							{
								$('.omslag img')
									.animate({
										width: '90px',
										height: '130px'
										},
										1000
									)
									.fadeOut();
							}
						}
			});
		});
});
