$(document).ready(function(){
	// Infield labels
	$("label.infield").inFieldLabels();
		
	// Accordion 
	$('div.question').click(function() {	
		if($(this).next().is(':visible')) {
			$('div.answer').slideUp(350);
		} else {
			$('div.answer').slideUp(350);	
			$(this).next().slideDown(350);
		}
	}); 
	$("div.answer").hide();
});

// POPUP SCRIPT

var win = null;

function openPopup(theURL,winName,w,h){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes, resizable=no'
	win = window.open(theURL,winName,settings)
}

//Check forms

function checkData(){
	var correct = true
	var regexpemail =/^[a-zA-Z0-9\-\.\_]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; //regexp for e-mail address
	var str = document.contactform.email.value; // value to compare
	if (document.contactform.voornaam.value == '') {correct = false; alert("Vul uw voornaam in.");document.contactform.voornaam.focus(); return correct}
	if (document.contactform.achternaam.value == '') {correct = false; alert("Vul uw achternaam in.");document.contactform.achternaam.focus(); return correct}
	if (document.contactform.bedrijf.value == '') {correct = false; alert("Vul een bedrijfsnaam in.");document.contactform.bedrijf.focus(); return correct}
	if (document.contactform.functie.value == '') {correct = false; alert("Vul uw functie in.");document.contactform.functie.focus(); return correct}
	if (document.contactform.adres_bezoek.value == '') {correct = false; alert("Vul het bezoekadres in.");document.contactform.adres_bezoek.focus(); return correct}
	if (document.contactform.postcode_bezoek.value == '') {correct = false; alert("Vul de postcode van het bezoekadres in.");document.contactform.postcode_bezoek.focus(); return correct}
	if (document.contactform.plaats_bezoek.value == '') {correct = false; alert("Vul de plaatnaam van het bezoekadres in.");document.contactform.plaats_bezoek.focus(); return correct}
	if (document.contactform.telefoonnummer_algemeen.value == '') {correct = false; alert("Vul een telefoonnummer in.");document.contactform.telefoonnummer_algemeen.focus(); return correct}
	//if (document.contactform.akkoord.checked == false) {correct = false; alert("U dient akkoord te gaan met de voorwaarden.");document.contactform.akkoord.focus(); return correct}
	if (regexpemail.test(str) == false){
	correct = false; alert("Vul een geldig e-mailadres in.");document.contactform.email.focus(); return correct}
	return correct;
}

function checkData_loginform(){
	var correct = true
	var regexpemail =/^[a-zA-Z0-9\-\.\_]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; //regexp for e-mail address
	var str = document.loginform.username.value; // value to compare
	if (regexpemail.test(str) == false){
	correct = false; alert("Vul uw e-mailadres in.");document.loginform.username.focus(); return correct}
	if (document.loginform.password.value == '') {correct = false; alert("Vul uw toegangscode in.");document.loginform.password.focus(); return correct}
	return correct;
}

function checkData_lostpass(){
	var correct = true
	var regexpemail =/^[a-zA-Z0-9\-\.\_]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; //regexp for e-mail address
	var str = document.lostpass.email.value; // value to compare
	if (regexpemail.test(str) == false){
	correct = false; alert("Vul uw e-mailadres in.");document.lostpass.email.focus(); return correct}
	return correct;
}
