// Contactformulier

$(function() {
		$('#contactsubmit').click(function() {
			  var naam = $("#naam").val();
			  var email = $("#email").val();
			  var bericht = $("#bericht").val();
			  $.ajax({
				url: 'contact.php?submit=true',
				type: 'POST',
				data: 'naam=' + naam + '&email=' + email + '&bericht=' + bericht,
				
				success: function(result) {
				$('#response').hide();
				$('#response').append(result);
				$('#contentdiv').fadeThenSlideToggle('normal', function() {
					$('#contentdiv').hide();
					$('#response').fadeIn('normal', function() {
						   this.style.removeAttribute('filter');
					});
				});
				}
			  });
			return false;
		});
 });
 
	jQuery.fn.fadeThenSlideToggle = function(speed, easing, callback){
		return this.fadeTo(speed, 0, easing).slideUp(speed, easing, callback);
	};
	
	function clearText(field){
		if (field.defaultValue == field.value){
			field.value = ""
		}
	}
	
	function showText(field){
		if (field.value == "") {
			field.value = field.defaultValue;
		}
	}
	
// Veilige e-mailadresweergave
$(document).ready(function(){
		$('a.email').each(function(){
			e = this.rel.replace('/','@');
			this.href = 'mailto:' + e;
		});
	});
	
// Uitklappen van kunstenaarsinfo
$(document).ready(function(){
	$('.kunstenaarnaam').click(function(){
		$('#mapframe').attr("src","");
		var id = $(this).attr("rel");
			$.ajax({
				url: 'kaartframe.php',
				type: 'GET',
				data: 'kunstenaar=' + id,
				beforeSend: function(){
					$('#mapoverlay').show();
					$('#loader').show();
				},
				success: function(result) {
					$('#mapframe').fadeOut(function() {
						$('#mapframe').empty();
						var url = 'kaartframe.php?kunstenaar=' + id;
						$('#mapframe').attr("src",url);
					});
				}
			});
		$('.kunstenaarinfo').each(function(){
			$(this).slideUp();
		});
		$('.kunstenaarnaam').each(function(){
			$(this).css("color","#EA5B0C");
		});
		$(this).css("color","#3f3f3f");
		$(this).parent().parent().find('.kunstenaarinfo').slideToggle();
	});
});

