jQuery(document).ready(function() {

	/*
	*   Examples - images
	*/
	
	j$("a#example1").fancybox({
		'titleShow'     : false
	});
		
	j$("a#example2").fancybox({
		'titleShow'     : false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'easingIn'      : 'easeOutBack',
		'easingOut'     : 'easeInBack'
	});
	
	j$("a#example3").fancybox({
	    'titleShow'     : false,
		'transitionIn'	: 'none',
		'transitionOut'	: 'none'
	});
	
	j$("a#example4").fancybox();
	
	j$("a#example5").fancybox({
		'titlePosition'  : 'inside'
	});
	
	j$("a#example6").fancybox({
		'titlePosition'  : 'over'
	});
	
	j$("a[rel=example_group]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
		}
	});
	
	/*
	*   Examples - various
	*/
	
	j$("#various1").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
	
	j$("#various2").fancybox({
		'modal' : true
	});
	
	j$(".various3").fancybox({
				'padding'		: 0,
				'width'			: 830,
				'height'		: 532,
		        	'autoScale'     	: false,
		        	'transitionIn'		: 'none',
				'transitionOut'		: 'fade',
				'type'			: 'iframe'
			});
	
	j$(".portfolio").fancybox({
				'padding'		: 0,
				'width'			: 905,
				'height'		: 532,
		        	'autoScale'     	: false,
		        	'transitionIn'		: 'none',
				'transitionOut'		: 'fade',
				'type'			: 'iframe',
				'overlayOpacity'	: 0.9
			});

	j$(".brochure").fancybox({
				'padding'		: 0,
				'width'			: 1005,
				'height'		: 532,
		        	'autoScale'     	: false,
		        	'transitionIn'		: 'none',
				'transitionOut'		: 'fade',
				'type'			: 'iframe',
				'overlayOpacity'	: 0.9
			});
	
	j$(".ideeen").fancybox({
				'padding'		: 0,
				'width'			: 772,
				'height'		: 532,
		        	'autoScale'     	: false,
		        	'transitionIn'		: 'none',
				'transitionOut'		: 'fade',
				'type'			: 'iframe'
			});

	j$("#various4").fancybox({
		ajax : {
		    type	: "POST"
		}
	});
			
	j$("#various5").fancybox({
		'width'				: '75%',
		'height'			: '75%',
        	'autoScale'     		: false,
        	'transitionIn'			: 'none',
		'transitionOut'			: 'none',
		'type'				: 'iframe'
	});
	
	j$("#various6").fancybox({
	    'padding'           : 0,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
	
	j$("#various7").fancybox({
		onStart		:	function() {
			return window.confirm('Continue?');
		},
		onCancel	:	function() {
			alert('Canceled!');
		},
		onComplete	:	function() {
            alert('Completed!');
		},
		onCleanup	:	function() {
            return window.confirm('Close?');
		},
		onClosed	:	function() {
            alert('Closed!');
		}
	});
	
	j$("#various8, #various9").fancybox();
	
	/*
	*   Examples - manual call
	*/

    j$("#portret").click(function() {
		j$.fancybox([
			{
				'href'	: 'fotogalerij/1.jpg',
				'title'	: '1 Morsen'},
			{
				'href'	: 'fotogalerij/2.jpg',
				'title'	: '2 Open'},
			{
				'href'	: 'fotogalerij/3.jpg',
				'title'	: '3 Verleiding'},
			{
				'href'	: 'fotogalerij/4.jpg',
				'title'	: '4 Ontspan'},
			{
				'href'	: 'fotogalerij/5.jpg',
				'title'	: '5 Losmaken'},
			{
				'href'	: 'fotogalerij/6.jpg',
				'title'	: '6 Gelukkig'},
			{
				'href'	: 'fotogalerij/20.jpg',
				'title'	: '20 Visie'},
			{
				'href'	: 'fotogalerij/26.jpg',
				'title'	: '26 Arbeid'},
			{
				'href'	: 'fotogalerij/21.jpg',
				'title'	: '21 Toverfee'},
			{
				'href'	: 'fotogalerij/22.jpg',
				'title'	: '22 Kwetsbaar'},
			{
				'href'	: 'fotogalerij/23.jpg',
				'title'	: '23 Afwegen'}	
	], {
			'padding'		: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              	: 'image',
			'changeFade'        	: 0,
			'titlePosition'	    	: 'over'
		});
	});

    j$("#locatie").click(function() {
		j$.fancybox([
			{
				'href'	: 'fotogalerij/9.jpg',
				'title'	: '9 Plaza de Espaņa'},	
			{
				'href'	: 'fotogalerij/10.jpg',
				'title'	: '10 Woestijn'},	
			{
				'href'	: 'fotogalerij/14.jpg',
				'title'	: '14 De lente'},
			{	
				'href'	: 'fotogalerij/13.jpg',
				'title'	: '13 Natuurschoon'},
			{
				'href'	: 'fotogalerij/15.jpg',
				'title'	: '15 Holland'},
			{
				'href'	: 'fotogalerij/25.jpg',
				'title'	: '25 Industrie'},
			{
				'href'	: 'fotogalerij/39.jpg',
				'title'	: '39 Welgelegen'},
			{
				'href'	: 'fotogalerij/38.jpg',
				'title'	: '38 Splinternieuw'},
			{
				'href'	: 'fotogalerij/33.jpg',
				'title'	: '33 Dagje uit'},
			{
				'href'	: 'fotogalerij/31.jpg',
				'title'	: '31 Bruinen'},
			{
				'href'	: 'fotogalerij/28.jpg',
				'title'	: '28 Schoonheid'}
	], {
			'padding'		: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              	: 'image',
			'changeFade'        	: 0,
			'titlePosition'	    	: 'over'
		});
	});

    j$("#objecten").click(function() {
		j$.fancybox([
			{
				'href'	: 'fotogalerij/8.jpg',
				'title'	: '8 Scherpte'},
			{
				'href'	: 'fotogalerij/41.jpg',
				'title'	: '41 Stukgebroken'},	
			{
				'href'	: 'fotogalerij/45.jpg',
				'title'	: '45 Gevouwen'},
			{
				'href'	: 'fotogalerij/34.jpg',
				'title'	: '34 Hoognodig'},
			{
				'href'	: 'fotogalerij/42.jpg',
				'title'	: '42 Kleurrijk'},
			{
				'href'	: 'fotogalerij/30.jpg',
				'title'	: '30 Linnengoed'},
			{
				'href'	: 'fotogalerij/18.jpg',
				'title'	: '18 Tactisch'},
			{
				'href'	: 'fotogalerij/29.jpg',
				'title'	: '29 Tubes'}
	], {
			'padding'		: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              	: 'image',
			'changeFade'        	: 0,
			'titlePosition'	    	: 'over'
		});
	});

    j$("#art").click(function() {
		j$.fancybox([
			{
				'href'	: 'fotogalerij/11.jpg',
				'title'	: '11 Vang me'},
			{
				'href'	: 'fotogalerij/12.jpg',
				'title'	: '12 Boefje'},
			{
				'href'	: 'fotogalerij/7.jpg',
				'title'	: '7 Zakelijkheid'},	
			{
				'href'	: 'fotogalerij/17.jpg',
				'title'	: '17 Fictief'},
			{
				'href'	: 'fotogalerij/37.jpg',
				'title'	: '37 Hoogrood'},
			{
				'href'	: 'fotogalerij/44.jpg',
				'title'	: '44 Licht'},
			{
				'href'	: 'fotogalerij/24.jpg',
				'title'	: '24 Kader'}
	], {
			'padding'		: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              	: 'image',
			'changeFade'        	: 0,
			'titlePosition'	    	: 'over'
		});
	});

					
	/*
	*   Tips & Tricks
	*/
	
	j$("#tip3").fancybox({
	    'transitionIn'	: 'none',
		'transitionOut'	: 'none',
		'titlePosition'	: 'over',
		'onComplete'	: function() {
			j$("#fancybox-wrap").hover(function() {
				j$("#fancybox-title").show();
			}, function() {
				j$("#fancybox-title").hide();
			});
		}
	});

	j$("#tip4").click(function() {
		j$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			    'wmode'				: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

		return false;
	});

    j$("#tip5").fancybox({
		'scrolling' : 'no',
		'titleShow'	: false,
		'onClosed'	: function() {
		    j$("#login_error").hide();
		}
	});
    
	j$("#login_form").bind("submit", function() {
	
	    if (j$("#login_name").val().length < 1 || j$("#login_pass").val().length < 1) {
	        j$("#login_error").show();
	        j$.fancybox.resize();
	        return false;
	    }
	    
	    j$.fancybox.showActivity();

		j$.ajax({
			type	: "POST",
			cache	: false,
			url		: "/data/login.php",
			data	: j$(this).serializeArray(),
			success: function(data) {
				j$.fancybox(data);
			}
		});

		return false;
	});
	
	j$("#tip6").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'autoScale'     	: false,
		'type'				: 'iframe',
		'width'				: 500,
		'height'			: 500,
		'scrolling'   		: 'no'
	});
	
	function formatTitle(title, currentArray, currentIndex, currentOpts) {
	    return '<div id="tip7-title"><span><a href="javascript:;" onclick="j$.fancybox.close();"><img src="/data/closelabel.gif" /></a></span>' + (title && title.length ? '<b>' + title + '</b>' : '' ) + 'Image ' + (currentIndex + 1) + ' of ' + currentArray.length + '</div>';
	}

	j$(".tip7").fancybox({
	    'showCloseButton'   : false,
		'titlePosition' 	: 'inside',
		'titleFormat'		: formatTitle
	});
	
	/*
	*   Donate link
	*/
	j$("a#donate").bind("click", function() {
		j$("#donate_form").submit();
		return false;
	});

	/*
	*   Zebra-stripping table
	*/
	
	j$("table.options tr:nth-child(even)").addClass('even');

});
