window.addEvent('domready', function() {

	// Alle links met een class 'externe-link' openen in een nieuw venster
	$$('a.externe-link').each( function(el) {
		el.target =  '_blank';
	});
	
	$$('dd.prod').each( function(el) {
		el.addEvent('mouseover', function() {
			this.addClass('hover');
		});

		el.addEvent('mouseout', function() {
			this.removeClass('hover');
		});
	});

	// Shopping basket
	$('winkelwagentoggle').addEvent('mouseover', function() {
		$('winkelwagentoggle').setStyle('cursor','pointer');
	});

	$('winkelwagentoggle').addEvent('mouseout', function() {
		$('winkelwagentoggle').setStyle('cursor','normal');
	});

	$('winkelwagentoggle').addEvent('click', function() {
		$('winkelwageninhoud').setStyle('display', ($('winkelwageninhoud').getStyle('display') == 'none') ? 'block':'none' );
	});

	// minifoto to grote foto's
	$$('div#thumbnails a').each( function(el) {
		if(!el.hasClass('nozoom')) {
			el.addEvent('click', function(){
				// switch the image
				var tmpSrc,tmpUrl;
				
				tmpUrl = "/uploads/product";
				
				var bigImg = $('placeholderimg');				
				
				tmpSrc = bigImg.get('rel');				
				
				// big image
				bigImg.set('src',tmpUrl + "/" + el.getFirst().get('rel'));
				bigImg.set('rel',el.getFirst().get('rel'));				
				
				// big images <a> (for lightbox src)
				bigImg.getParent().set('href', tmpUrl + "groot/" + el.getFirst().get('rel'));				
				
				// small image			
				el.getFirst().set('src', tmpUrl + "klein/" + tmpSrc);
				el.getFirst().set('rel', tmpSrc);
					
				return false;
			});
		}
	});	
	
	/**
	 * You can provide preset options here ... if you want.
	 * You can SqueezeBox.assign without calling initialize, but
	 * not if you create the SqueezeBox with SqueezeBox.setContent
	 * (because initialize creates the used elements).
	 */
//	SqueezeBox.initialize();
// 
//	$$('form.bestelformulier').each( function( form ) {
//		form.addEvent( 'submit' , function( event ) {
//			new Event( event ).stop();			
////			//	formulier posten naar lightbox
//			SqueezeBox.open( form.action , {
//				handler: 'ajax' ,
//				size: {x: 300, y: 200},
//				ajaxOptions: {
//					method: 'post'					
//				}
//			});
//		});
//	});
	
	/**
	 * That CSS selector will find all <a> elements with the
	 * attribute rel="boxed"
	 *
	 * The second argument sets additional options.
	 */
	SqueezeBox.assign($$('a.bestellink'), {
		size: {x: 430, y: 400},
		ajaxOptions: {
			method: 'get' // we use GET for requesting plain HTML (you can skip it, it is the default value)
		},
		onClose : function () {
			window.location.reload(true); // reload parent window to update shopping basket
		}
	});
	
//	/*	Bestelbevestiging in een lightbox-achtige venster openen: */
//	$$('form.bestelformulier').each( function( form ) {
//		form.addEvent( 'submit' , function( event ) {
//			new Event( event ).stop();			
//			//	formulier posten naar lightbox
//			alert( 'versturen!' );
//		});
//	});
//	
//	$$('a.bestellink').each( function( a ) {
//		a.addEvent( 'click' , function( event ) {			
//			new Event( event ).stop();
//			//	link openen in lightbox
//			alert( 'popup regelen' );
//			initializePopUp( event , 'close' , a.getProperty('href') , 300 );
//		});
//	});
	
});




