$(document).ready(function()
{
	// Slider (home)	
	$('#slides').slides({
		preload: true,
		preloadImage: 'img/loading.gif',
		play: 6000,
		pause: 2500,
		hoverPause: true,
		animationStart: function(){
			$('.caption').animate({
				bottom:-75
			},100);
		},
		animationComplete: function(current){
			$('.caption').animate({
				bottom:0
			},200);
			if (window.console && console.log) {
				//console.log(current);
			};
		}
	});
	
	// Nav hover
	$('ul#topmenu li').mouseover(function()
	{
		$(this).css('cursor','pointer');
		/*
		$(this).click(function() {
			$(this).find('a').trigger('click');
		});		
		*/
		if($(this).hasClass('selected') == false)
		{
			$(this).addClass('selected').mouseout(function() {
				$(this).removeClass('selected');
			});
		}
	});
	
	// Event Galleries
	if($('div.gallery').length)
	{
		$('div.gallery a').fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'		:	400, 
			'speedOut'		:	200,
			'overlayColor'	: 	'#333',
			'overlayOpacity':	0.6,
			'titlePosition'	:	'over'
		});
	}
	
	// Location google map
	if($('div#locationmap').length)
	{
		var map = new GMap2(document.getElementById("locationmap"));
		map.addControl(new GSmallMapControl());
		//map.removeMapType(G_HYBRID_MAP);
		//map.addControl(new GMapTypeControl());		
		var location = new GLatLng($('input#lat').val(), $('input#long').val());
		map.setCenter(location, 15);
		var locationMarker = new GMarker(location);
		map.addOverlay(locationMarker);
	}
	
});

// Custom functions
function od_makeEditable(txt, defaultVal, colorVal) {
	if (txt.value == defaultVal) { txt.value = ''; txt.style.color = colorVal; txt.focus(); }
}
function terugDefault(txt, defaultVal, colorVal) {
	if (txt.value == '') { txt.value = defaultVal; txt.style.color = colorVal; }
}
function validateEmailOptin(form,lang)
{
	var email = form.EmailAddress.value;
	if(email.match(/^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/gi)) {
		return true;
	} else {
		var error = '';
		(lang == 'fr') ? error = 'Adresse non valable.' : error = 'Ongeldig e-mailadres.';
		$('form.optin p.error').remove();
		$('form.optin').append('<p class="error">'+error+'</p>');
		return false;
	}
}
