function getPageSize() {
		
	 var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {    
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {    // all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight + 150;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}    
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){    
		pageWidth = xScroll;        
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}

$(document).ready(function(){
	$('.gallery2 li').each(function() {

		if($(this).html().length < 5) {
			$(this).remove();
		}
	});
	
	$('.gallery li').each(function() {

		if($(this).html().length < 5) {
			$(this).remove();
		}
	});
	
    $('div.gallery').galleryScroll({
        btPrev:'a.left',
        btNext:'a.right'
    });
    $('div.gallery2').galleryScroll({
        btPrev:'a.left2',
        btNext:'a.right2'
    });
    $('div.gallery ul a').lightBox();
    $('div.gallery2 ul a').lightBox();
	
	/*var height = 0;
	$('.gallery2 ul li img').each(function() {
		height = $(this).height();
		height = (196 - height) / 2;
		
		if(height > 0) {
			$(this).css('margin-top', height + 'px');
		}
	});*/
});

jQuery(function() {
	jQuery('#ni_inschrijven').click(function() {
		var ni_email = jQuery('#ni_email').val();
		var ni_name = jQuery('#ni_name').val();
		var errors = 0;
		
		var email_regex = /[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i;
		if (!email_regex.test(ni_email)) {
			jQuery('#ni_email_error').show(0);
			errors++;
			var errorEmail = 'Vul een geldig e-mail adres in. ';
		} else {
			var errorEmail = '';
		}
		
		if(ni_name.length == 0) {
			jQuery('#ni_name_error').show(0);
			errors++;
			var errorName = 'U heeft geen naam ingevuld. ';
		} else {
			var errorName = '';
		}
		
		if(errors == 0) {
			jQuery.ajax({
				type: 'POST',
				cache: false,
				url: '/nieuwsbrief/optin/signup_submit.php',
				dataType: 'text',
				data: 'name=' + ni_name + '&email=' + ni_email,
				success: function(resp) {
					if(resp == 'success') {
						jQuery('#ni_thanks').show(0);
						jQuery('#ni_form').hide(0);
					} else {
						if(resp == 'error') {
							jQuery('#ni_thanks').hide(0);
							jQuery('#ni_form').hide(0);
							alert('Er is iets misgegaan, probeer het later opnieuw.');
						} else {
							alert('U bent al ingeschreven voor de nieuwsbrief.');
						}
					}
				}
			});
		} else {
			alert(errorEmail + errorName);
		}
	});
});
