window.addEvent('domready', function()
{
	/* Cufon startup */
	Cufon('h3,h4',
	{
		fontFamily: 'Copperplate Gothic Bold'
	});
	
	Cufon.replace('#head_menu li,#footer li',
	{
		fontFamily: 'Copperplate Gothic Light',
		hover: true	
	});
	
	Cufon.replace('#spreuk',
	{
		fontFamily: 'Rage Italic',
		hover: true	
	});
	
	var SubmitForm = function(formres)
	{
		if(formres)
		{
			$('contact_form').set('send', 
			{
				onComplete: function(response) 
				{			
					switch(response)
					{
						case 'err':
							$('info').setStyle('display','block').set('html','<h2>Uw bericht is niet verzonden.</h2>');
						  break;
						
						default:
						 	$('info').setStyle('display','block').set('html','<img src="/images/layout/icons/Envelope.png"/><h2>Uw bericht is succesvol verzonden.</h2>');
					}
				}
			});
			$('contact_form').send();
		}
	}
	
  	if($('contact_form'))
	{
		MooTools.lang.setLanguage("nl-NL");
		
		new FormValidator.Inline('contact_form',
		{
			 onFormValidate: SubmitForm
		});
		
		$('contact_form').addEvent('submit', function(e)
		{
			e.stop();
		});
	}
	
	if($$('.photos'))
	{
		new Lightbox(
		{ 
			relString: 'lightbox' 
		},$$('.photos').getElements('a'));
	}
	
		
	function startGalleryRotation(selector,delay)
	{ 
		var i = 0; 
		var layers = $$(selector); 
		var laylen = layers.length;
		
		delay = (delay == undefined)? 6000:delay; 
		setInterval(function()
		{ 
			layers[i].setStyle('display','none'); 
			i = (i == layers.length-1)? 0 : i+1; 
			layers[i].setStyle('display','block'); 
		},delay); 
	} 
	
	startGalleryRotation('#opdrachten li',4000);
	
});

