//<![CDATA[
Shadowbox.loadSkin('ct', 'include/shadowbox/skin');
Shadowbox.loadLanguage('nl', 'include/shadowbox/lang');
Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], 'include/shadowbox/player');


window.addEvent('domready', function() {
	
	Shadowbox.init();
	
	if( $('search') != null )
		init_home(); // modules/search_engine/javascript/ajax.js
	
	if( $('top10') != null )
		init_top10(); // modules/top10/javascript/ajax.js
	
		/* Checking if browser is IE6 or lower, apply patch so listboxes don't cover menu */
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ieversion<=6)
		{
			var list = $$('.menuitem');
			list.each(function(element) {
				element.addEvent('mouseenter', function(){
					if( $('dropdown_search') != null )
						$('dropdown_search').style.visibility = 'hidden';
				});
				element.addEvent('mouseleave', function(){
					if( $('dropdown_search') != null )
						$('dropdown_search').style.visibility = 'visible';
				});
			});
		}
	}
	
	var list = $$('.parent-menu');
	list.each(function(element) {
		/* Create Opacity Effect and Child Menu Objects */
		var childFX = new Fx.Tween(element.id+'-child', {duration:300, wait:false});
		var elementChild = $(element.id+'-child');
		
		/* Hide, the element and apply styling. Doing this now allows browsers without javascript enabled to downgrade nicely */
		childFX.set('opacity', 0);
		childFX.set('text-transform', 'none');
		
		/* Create the Mouse events, allowing the flyout to appear and disappear appropriately */
		element.addEvent('mouseenter', function(){ childFX.start('opacity',0,.85); });
		element.addEvent('mouseleave', function(){ childFX.start('opacity',.85,0); });

		elementChild.addEvent('mouseenter', function(){ childFX.start('opacity',.85,.85); });
		elementChild.addEvent('mouseleave', function(){ childFX.start('opacity',.85,0); });
	});
	
	if( typeof Slideshow != "undefined" )
	{
		// Load your images here
		var data = {
		'slideshow1.jpg': { caption: 'Schitterende schepen...' }, 
		'slideshow2.jpg': { caption: '... Ruime luxe hutten!' }, 
		'slideshow3.jpg': { caption: 'Relaxen aan het zwembad....' }, 
		'slideshow4.jpg': { caption: '... of in de sauna' },
		'slideshow5.jpg': { caption: 'Aan uw kinderen wordt ook gedacht..' }, 
		'slideshow6.jpg': { caption: 'en voor u is er ook genoeg te doen!' }, 
		'slideshow7.jpg': { caption: 'Kortom.....' }, 
		'slideshow8.jpg': { caption: 'Grenzeloos genieten!' }	  
		};
		var myShow = new Slideshow('show', data, { captions: true, controller: true, height: 208, hu: 'images/slideshow_photos/', width: 299, delay: 5000 });
	}
	
	if( $('newsletter_form') != null )
	{
		$('newsletter_form').addEvent('submit',function(e)
		{
			new Event(e).stop();
	
			var request = new Request({ url: '/modules/newsletter_form/mail_form.php', 
			                            method: 'post', 
			                            onSuccess: function(responseText){ 
			                            	if( responseText == '1' ) //NOTIFICATION_EMAIL_INCORRECT
			                            	{
			                            		shadowbox_notification( 'check.png', 'Nieuwsbrief registratie', 'Bedankt voor uw inschrijving op onze wekelijkse nieuwsbrief.' );
										        
										        $('newsletter_email').value = 'Uw emailadres';
			                            	}
			                            	else if( responseText == '2' ) //NOTIFICATION_EMAIL_EXISTS
			                            	{
			                            		shadowbox_notification( 'error.png', 'Nieuwsbrief registratie', 'Dit emailadres bestaat al in ons systeem.' );
			                            	}
			                            	else if( responseText == '3' ) //NOTIFICATION_EMAIL_INCORRECT
			                            	{
			                            		shadowbox_notification( 'error.png', 'Nieuwsbrief registratie', 'Er is een fout opgetreden tijdens deze bewerking.' );
			                            	}
			                            	else if( responseText == '4' ) //NOTIFICATION_EMAIL_INCORRECT
			                            	{		                            		
			                            		shadowbox_notification( 'error.png', 'Nieuwsbrief registratie', 'Het opgegeven emailadres is niet correct.' );
			                            	}
			                            },
			                            onFailure: function(){ 
			                            	shadowbox_notification( 'error.png', 'Nieuwsbrief registratie', 'Er is een fout opgetreden tijdens deze bewerking.' );
	 									}
									  }).send($('newsletter_form')); 
		});
	}
});

/**
 * shadowbox_notification( type, notification )
 * 
 * Function opens shadowbox with a notification. Any piece of text can be put into it
 */
function shadowbox_notification( type, title, notification )
{	
	Shadowbox.open({
			        player:     'html',
			        title: title,
			        content:    '<table width="100%" height="100%">'+
			        			 	'<tr>'+
			        			 		'<td align="center" width="30%"><img src="images/'+type+'" align="absmiddle"></td>'+
			        			 		'<td width="70%">'+notification+'</td>'+
			        			 	'</tr>'+
			        			 '</table>',
			        height:     150,
			        width:      400
		        },
		        {
		        	animate:	false
		        });
};

//]]>
