$(document).ready(
	function()
	{
		// Slideshow 
		$('#fade').cycle();
		
		// Thumbnails detailpagina
		$(".left3 a").click( function() 
		{
			if( $(this).attr('rel') != 'nol')
			{
				var changeSrc = $(this).attr("href");
				$("img.main").attr("src", changeSrc);
				return false;
			}
			else
			{
				document.location.href=$(this).attr('href')+'&mn='+document.getElementById('mnImg').src;
				return false;
			}
		});
		
		// Thumbnails fotopagina
		$(".content3 a").click( function() 
		{
			if( $(this).hasClass('album') == false )
			{
				var changeSrc = $(this).attr("href");			
				var img = new Image();
				img.src = changeSrc;
			
				loadImage( img );
				return false;
			}
		});
		
		// Click op tr in aanbod en volg de link naar de details
		$(".aanbodtabel tr.record").click( function(){
			document.location.href = $(this).find(".omschrijving a").attr("href");
		});
		
		// Click op de a in de aanbodtabel wordt gewoon gevolgd
		$(".aanbodtabel a").click( function(){
			document.location.href = $(this).attr("href");
		});
		
		// Click op de a in de overzichtblokken wordt gewoon gevolgd
		$(".product_full_block").click( function(){
			document.location.href = $(this).find("a.leesverder").attr("href");
		});
		
		// Albumlinks openen in FancyBox
		$("a.album").fancybox({
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'titlePosition' 	: 'over',
			'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		   	 	return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '<br />' + title + '</span>';
			}
		});
		
		// Zoekveld focus
		$("input.zoekveld").focus
		(
			function(e)
			{
				if( $(this).val() == $(this).attr('title') )
				{
					$(this).val('');
				}
			}
		);
		
		// Zoekveld verlaten
		$("input.zoekveld").blur
		(
			function(e)
			{
				if( $(this).val() == '' )
				{
					$(this).val( $(this).attr('title') );
				}
			}
		);
		
		// Laatste LI in het menu met actieve link
		if( $('#menu ul li:last a').attr('class') == 'active' )
		{
			if( $("#menu ul li:last a").offset().left>1080 )
			{
				$('#menu').css('background-image', 'url(img/bgmenu_rechts.png)');
			}
		}
		
		// Eerste LI in het menu met actieve link
		if( $('#menu ul li:first a').attr('class') == 'active' )
		{
			$('#menu').css('background-image', 'url(img/bgmenu_links.png)');
		}
		
		
		
		$('#menu ul li:first a').hover
		(
			function(e)
			{
				if( $('#menu ul li:first a').attr('class') != 'active' )
				{
					$('#menu').css('background-image', 'url(img/bgmenu_links.png)');
				}
			},
			
			function(e)
			{
				if( $('#menu ul li:first a').attr('class') != 'active' )
				{
					$('#menu').css('background-image', 'url(img/bgmenu.png)');
				}
			}
		);
		
		
		$('#menu ul li:last a').hover
		(
			function(e)
			{
				if( $('#menu ul li:last a').attr('class') != 'active' )
				{
					//$('#menu').css('background-image', 'url(img/bgmenu_rechts.png)');
					if( $("#menu ul li:last a").offset().left>1080 )
					{
						$('#menu').css('background-image', 'url(img/bgmenu_rechts.png)');
					}
				}
			},
			
			function(e)
			{
				if( $('#menu ul li:last a').attr('class') != 'active' )
				{
					$('#menu').css('background-image', 'url(img/bgmenu.png)');
				}
			}
		);
	}
);

function showFlash(name, width, height, bgcolor) 
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ID="base" WIDTH="'+width+'" HEIGHT="'+height+'">');
	document.write('<param name="wmode" value="transparent"><param name="movie" VALUE="'+name+'"><param name="quality" value="high"> <param name="bgcolor" value="'+bgcolor+'"><param name="menu" value="false"> <embed src="'+name+'" quality="high" bgcolor="'+bgcolor+'" width="'+width+'" height="'+height+'" menu="false" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>');
	document.write('</object>');
}
