$(document).ready(function() {
	initLigtbox();
	showThumbrollover();
});

function initLigtbox() {
	$('a.lightbox').lightBox();
};

function showThumbrollover() {
	$('.thumb').hover(function(){
		$(this).children('.rollover').fadeIn('fast');
	}, function(){
		$(this).children('.rollover').fadeOut('fast');
	});
}

function saveForm(form) {

	var options = {
		url: "includes/request.php",
		type: "POST",
		success: function(data) {
			sRequest = data;
			aRequest = sRequest.split('|');
			if(aRequest[0] == 'succes') {
				$('#message').html(aRequest[1]);
				updateLast();
				$(form).clearForm();
			} else {
				$('#message').html(aRequest[1]);
			}
			$('#message').show();
		},
		error: function(message){
			//alert('error'+message);
		}

	}
	
	$(form).ajaxSubmit(options);
}

function updateLast() {
	$.ajax({
		url: "includes/request.php",
		type: "POST",
		data: "action=update&message=last",
		success: function(data){
			$('#laatste').html(data);
			if($("#laatste").is(":hidden")) {
				$('#laatste').slideDown("slow", function() {
					updateNav(1);
				});
			}
		},
		error: function(message){
			alert('error'+message);
		}
	});
	return false;

}


function updateNav(page) {
	$.ajax({
		type: "POST",
		url: "includes/request.php",
		data: "action=update&page="+page,
		success: function(msg){
			$('#berichten').html(msg);
		},
		error: function(message){
			alert('error'+message);
		}
	});

}
