function AfbeeldingOpslaan(nummer, filename, na1, na2, na3){
	document.getElementById('foto').value = filename;
}

function validate(){
	var chain = "";
	$(".verplicht").each(function(){
		if(this.type == "text" || this.type == "password" || this.type == "select-multiple" || this.type == "select" || this.type == "file"){
			if ((this.value.length==0) || (this.value==null) || (this.value=="http://")) {
				$(this).css("border","2px dashed #f33").css("background-color","#FF8585");
				chain += this.name;
			} else {
				$(this).css("border","1px solid #ABADB3").css("background-color","#fff");
			}
		} else if (this.type == "checkbox"){
			if ((this.checked == false)) {
				$(this).css("outline","2px dashed #f33");
				chain += this.name;
			} else {
				$(this).css("outline","0");
			}
		}
		else if (this.type == "radio"){
			var name = this.name;
			var path = eval('document.getElementById("inschrijfform").' + name);
			checked = false;
			for(i=0; i<path.length; i++){
			    if(path[i].checked){
			        checked=true;
			    }
			}
			if ((checked != true)) {
				$(this).css("outline","2px dashed #f33");
				chain += this.name;
			} else {
				$(this).css("outline","0");
			}
		} else {
			if ((this.value.length==0) || (this.value==null) || (this.value=="http://")) {
				$(this).css("border","2px dashed #f33").css("background-color","#FF8585");
				chain += this.name;
			} else {
				$(this).css("border","1px solid #ABADB3").css("background-color","#fff");
			}
		}
	});	
	if(chain == ""){
		var ww1 = $("#ww").val();
		var ww2 = $("#check_ww").val();
		if(ww1 == ww2){
			document.getElementById('inschrijfform').submit();
		}
		else {
			alert("Je wachtwoorden komen niet overeen.");
		}
	}
	if(chain != ""){
		alert("Vul a.u.b. de in rood gemarkeerde velden in.");
	}
}

function validateAd(){
	var chain = "";
	$(".verplicht").each(function(){
		if(this.type == "text" || this.type == "password" || this.type == "select-multiple" || this.type == "select" || this.type == "file"){
			if ((this.value.length==0) || (this.value==null) || (this.value=="http://")) {
				$(this).css("border","2px dashed #f33").css("background-color","#FF8585");
				chain += this.name;
			} else {
				$(this).css("border","1px solid #ABADB3").css("background-color","#fff");
			}
		} else if (this.type == "checkbox"){
			if ((this.checked == false)) {
				$(this).css("outline","2px dashed #f33");
				chain += this.name;
			} else {
				$(this).css("outline","0");
			}
		}
		else if (this.type == "radio"){
			var name = this.name;
			var path = eval('document.getElementById("inschrijfform").' + name);
			checked = false;
			for(i=0; i<path.length; i++){
			    if(path[i].checked){
			        checked=true;
			    }
			}
			if ((checked != true)) {
				$(this).css("outline","2px dashed #f33");
				chain += this.name;
			} else {
				$(this).css("outline","0");
			}
		}
	});	
	if(chain == ""){
		document.getElementById('inschrijfform').submit();
	}
	if(chain != ""){
		alert("Vul a.u.b. de in rood gemarkeerde velden in.");
	}
}

function zoeken(){
	var chain = "";
	$(".verplicht").each(function(){
		if (this[this.selectedIndex].value=='0') {
			$(this).css("border","2px dashed #f33").css("background-color","#FF8585");
			chain += this.name;
		} else {
			$(this).css("border","1px solid #ABADB3").css("background-color","#fff");
		}
	});
	if(chain == ""){
		document.getElementById('zoekform').submit();
	}
	if(chain != ""){
		alert("Vul a.u.b. de in rood gemarkeerde velden in.");
	}
}

function validateWijzig(){
	if(document.wijzigform.ww.value != ""){
		var ww1 = $("#ww").val();
		var ww2 = $("#check_ww").val();
		if(ww1 == ww2){
			document.getElementById('wijzigform').submit();
		}
		else {
			alert("Je wachtwoorden komen niet overeen.");
		}
	} else {
		document.getElementById('wijzigform').submit();
	}
}

function customZoeken(){
	var values = $("#customzoekform").serialize();
	$.ajax({
		url: '/formprocess.php?submit=true',
		type: 'POST',
		data: values,

		success: function(result) {
			$(".zoekblok").fadeOut();
			$(".zoekblok").fadeOut("normal",function(){
				$(".zoekblok").html('<br />' + result).fadeIn();
			});
		}
	});
	return false;
}

function customZoekenex(){
	var values = $("#customzoekformex").serialize();
	$.ajax({
		url: '/formprocess.php?submit=true',
		type: 'POST',
		data: values,

		success: function(result) {
			$(".zoekblok").fadeOut();
			$(".zoekblok").fadeOut("normal",function(){
				$(".zoekblok").html('<br />' + result).fadeIn();
			});
		}
	});
	return false;
}

function getFuncties(){
	var beroep = $("#beroep").val();
	$.ajax({
		url: '/scripts/getlist.php',
		type: 'POST',
		data: 'beroep=' + beroep + '&type=functies',

		success: function(result) {
			$("#functie").append(result);
		}
	});
	return false;
}

function getRegios(){
	var beroep = $("#beroep").val();
	var functie = $("#functie").val();
	$.ajax({
		url: '/scripts/getlist.php',
		type: 'POST',
		data: 'beroep=' + beroep + '&functie=' + functie + '&type=regios',

		success: function(result) {
			$("#regio").append(result);
		}
	});
	return false;
}

function registerNieuwsbrief(){
	$("#n_email").each(function(){
		if ((this.value.length==0) || (this.value==null) || (this.value=="http://")) {
			$(this).css("border","2px dashed #f33").css("background-color","#FF8585");
		} else {
			document.getElementById('nieuwsbriefform').submit();
		}
	});
}

function stem(){
	var pollid = $("#pollid").val();
	var antwoord = $('input:radio[name=poll]:checked').val();
	if(antwoord==null){
		alert("Je hebt nog geen antwoord ingevuld!");
		return false;
	} else {
		$.ajax({
			url: 'poll.php',
			type: 'POST',
			data: 'pollid=' + pollid + '&antwoord=' + antwoord,
	
			success: function(result) {
				$('#pollblok').fadeOut("normal",function(){
					$(this).empty().html(result).fadeIn();
				});
			}
		});
		return false;
	}
}

$(document).ready( function() {
	
	$('.nav li').each(function(){
		$(this).click(function(){
			window.location.href = $(this).find("a").attr("href");
		});
	});

	$('.wrapper').each(function(){
		var wHeight = 1;
		$(this).children('.contentblok').each(function(){
			if($(this).height()>wHeight){
				wHeight = $(this).height();
			}
		});
		$(this).find('.contentblok').css('height',wHeight);
	});
	
	$("#emailduplicator").keyup(function(){
		var val = $(this).val();
		$("#gebruikersnaam").text(val);
	});
	
	$('.tweetContainer').tweet5('.tweetContainer', {
		username: '',
		searchTerm: 'femailrecruits',
		numberOfTweets: 3, // 20=max
		showUsername: 'false',
		showUserAvatar: 'true',
		showTweetTime: 'false',
		showRetweets: 'true',
		showReplyButton: 'false',
		showRetweetButton: 'false',
		showLocation: 'false',
		replyButtonText: 'reply',
		retweetButtonText: 'retweet',
		iconColor: 'white', //black or white
		refreshTime: 60, // time in seconds, minimum is 60
		updateAvailable: 'Er zijn nieuwe tweets beschikbaar.'
	});

// Contact submit
	$("#contactsubmit").click( function() {
		var values = $("#contactformulier").serialize();
		$.ajax({
			url: '/formprocess.php?submit=true',
			type: 'POST',
			data: values,

			success: function(result) {
				$('#contactform').append('<p id="response">' + result + '</p>');
				$('#response').hide();
				$('#contactformulier').fadeOut('normal', function() {
					$('#response').fadeIn('normal');
				});
			}
		});
		return false;
	});
	
// Datepicker
	
	$("#ingangsdatum").datepicker({ dateFormat: 'dd MM yy', altField: '#realingangsdatum', altFormat: 'yymmdd', nextText: 'Volgende maand', prevText: 'Vorige maand', dayNamesMin: ['Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'], monthNames: ['januari','februari','maart','april','mei','juni','juli','augustus','september','oktober','november','december'] });
	
// Placeholder support
	if (Modernizr.input.placeholder)
		return;

	$('input[placeholder]').focus( function() {
		if ($(this).hasClass('placeholder')) {
			if ($(this).val() == $(this).attr('placeholder'))
				$(this).val('');
			$(this).removeClass('placeholder');
		}
	});
	$('input[placeholder]').keypress( function() {
		if ($(this).hasClass('placeholder')) {
			if ($(this).val() == $(this).attr('placeholder'))
				$(this).val('');
			$(this).removeClass('placeholder');
		}
	});
	$('input[placeholder]').blur( function() {
		if ($(this).val() !='')
			return;
		$(this).addClass('placeholder');
		$(this).val($(this).attr('placeholder'));
	});
	$('input[placeholder]').each( function() {
		if ($(this).val() !='' && $(this).val() != $(this).attr('placeholder'))
			return;
		$(this).val($(this).attr('placeholder')).addClass('placeholder');
	});
	$('form').submit( function() {
		$(this).find('placeholder').each( function() {
			$(this).removeClass('placeholder');
			$(this).val('');
		});
	});
});

function goBackContact(){
	$("#response").remove();
	$("#contactformulier").show();
}
