
function startGallery() {
	var myGallery = new gallery($('slideshow'), {
		timed: true,
		embedLinks: false,
		textShowCarousel: 'Afbeeldingen'
	});
}
function showPopup(caption, url, rel) {
	TB_show(caption, url, rel);
}
window.addEvent('domready',startGallery);
function iprint(ptarget) {
	ptarget.focus();
	ptarget.print();
}
function displaymail() {
	var x=document.getElementById("mailform");
	x.style.display = "block";
}
function sendmail() {
	alert(document.getElementById("sendToEmail").value);
	alert(document.getElementById("naam").value);
	var myRequest = new Request({method: 'get', url: 'requestHandler.php'});
	myRequest.send('name=john&lastname=dorian'); //obscure scrubs reference!
}
        
var $_ = jQuery.noConflict();
$_(document).ready(function(){
	//scroll slideshow-images automatically
	$_("#slideshow").scrollFollow({container: 'container'});
    
	/* submit a form (via ajax) */
	$_("#contactform").submit(function(event) {
		event.preventDefault();
		
		var formID = 'contactform';
		$_("#" + formID + " button").html("Bezig met verzenden");
		var data = $_("#" + formID).serialize();
		$_("#" + formID + " input, #" + formID + " textarea, #" + formID + " button").attr("disabled", "disabled");
		$_.ajax({
			url: 'mail.php',
			type: 'POST',
			dataType: "json",
			data: data,
			success: function(json){
				if (json.mail != 'error') {
					$_("#" + formID).addClass("submitted");
					$_("#" + formID + " button").html("Succesvol verzonden!");
				} else {
					$_("#" + formID).addClass("failed");
					$_("#" + formID + " input, #" + formID + " textarea, #" + formID + " button").removeAttr("disabled");
					$_("#" + formID + " button").html("Fout! Nogmaals verzenden");					
				}
			}
		});
	});
	$_("#contactform button").click(function(){
		$_("#contactform").submit();
	});

});
