// JavaScript Document


$(document).ready(function()
{
	$(".subMenu").attr({"top": "0px"});
	
	showSubMenu = function()
	{
		$(".subMenu").slideDown("slow");
	}
	
	setTimeout(showSubMenu, 500);
	
	// Vragen box
	$('#boxSlide').click(function(){
		if ($.browser.msie && $.browser.version == '7.0') { $('#boxSlide').hide(); }
		if ($.browser.safari) { 
			$('label.error').css('margin-top','-25px'); 
		} else if ( $.browser.mozilla) {
			$('label.error').css('margin-top','-10px'); 	
		}
		
		if($('#boxSlide').html() == 'open') {
			$('#clearBox').slideDown("slow", function()
			{
				
				$('#boxSlide').html('dicht');
				if ($.browser.msie && $.browser.version == '7.0') { $('#boxSlide').show(); }
				
			});
			//$('#boxArrow').attr('src','/images/content/pijl_boven.gif'); 
		} else { 
			$('#clearBox').slideUp("slow", function()
			{
				$('#boxSlide').html('open');
				if ($.browser.msie && $.browser.version == '7.0') { $('#boxSlide').show(); }
			});
			//$('#boxArrow').attr('src','/images/content/pijl_bottom.gif'); 
		};
		
		
		
	});
	
	

	// setup overlay actions to links
	$("a.aOverlay, h3.aOverlay").overlay();			
			
			
			
	// Voor IE6  en IE7 een hack voor het naar beneden schuiven	
	if ($.browser.msie && $.browser.version == '7.0') { $('#boxSlide').hide(); }
	$('#clearBox').slideDown("slow", function(){
		if ($.browser.msie && $.browser.version == '7.0') { $('#boxSlide').show(); }
	});


	// Formulier voor vragen

		
		$.validator.setDefaults({
			submitHandler: function() { 
				
				var naam = $('#naam').val();
				var email = $('#email').val();
				var telefoon = $('#telefoon').val();
				var bericht = $('#bericht').val();
				var segment = $('#segment').val();
				
				$.ajax({   
				   //See serialize here http://docs.jquery.com/Ajax/serialize   
				   // The url you are going to submit to   
				   type: "GET",
				   url: '/__ajax/submit_vraag.php', 
				   data: "naam="+ naam +"&email="+ email+"&telefoon="+telefoon+"&bericht="+bericht+"&segment="+segment,
				   timeout: 2000,   
				   // Sends a message to the console if it failed for testing purposes.   
				   error: function() {   
				   	 $('#clearBox').html(response);   
				   },   
				   // If successful you can do something here. You can change elements, update text, or  simply alert the response to first test to see if it worked.   
				   success: function(response) {   
					  $('#clearBox').html(response);   
				   }
				   
				});
			
			}
		});
		
	

	
	$('#sendFAQ').click(function(){
	
	
				$("#faqBox").validate({
					rules: {
						// no quoting necessary
						naam: "required",
						email: {  
								required: true,  
								email: true
						},
						telefoon: {
								required: true,  
								digits: true,  
								minLength: 10,  
								maxLength: 10  
						}
					},
					messages: {  
						 naam: "Geen naam opgegeven! ",  
						 email: {
							 required: "Geen  email adres opgegeven!",
							 email: "Geen geldig email adres opgegeven!"
						 },
						 telefoon: {  
							 required: "Geen telefoonnummer opgegeven!", 
							 digits: "Alleen cijfers!", 
							 minlength: "Minimaal 10 cijfers!",
							 maxlength: "Maximaal 10 cijfers!"   
						 }
				   
					}
			  });
	
			  if($("#faqBox").valid() == true) {
				//$.unexpose();
				//$("#faqBox").submit();
			  } else {
				$("#faqBox").expose({
						onClose: function () {
							 $('label.error').hide();
						}
				});
				return false;
			  }
	  
	 
	});


	$('#blanket').click(function(){
		$('#_overlayImage').hide();
		//alert('blanket');
	});

	
});


