/* Author: 
	David Verhulst
*/
$(document).ready(function(){
	$('#naam').focus();
	$('#mailing').focus(function(){
		$(this).css('background-color','#fff');	
	})
	$('#mailing').blur(function(){
		if($(this).val() == ""){
			$(this).css('background','none');
		}
	})
	$("#sendtomailinglist").click(function(){
		if($('#mailing').val() != "" && $('#mailing').val() != "ENTER YOUR E-MAIL" && $('#mailing').val().indexOf("@") != -1){
			$.post("newsletter.php", { nieuwsbrief: $('#mailing').val() },
			   function(data) {
			     alert(data);
				 $('#mailing').val("");
				 $('#mailing').css('background','none');
			   });
			$('#mailing').val("");	
		}else{
			alert("Gelieve een geldig emailadres in te vullen.");	
		}
	})
	$('#naam').focus();
	$('#button').click(function(e) {
        if($('#naam').val() != "" && $('#email').val() != "" && $('#onderwerp').val() != "" && $('#boodschap').val()){
		  	var nieuws;
			if($('#nieuwsbrief').is(':checked')){
				nieuws = 1;	
			}else{
				nieuws = 0;	
			}
			$.post("mail.php", { naam: $('#naam').val(), email: $('#email').val(), onderwerp: $('#onderwerp').val(), boodschap: $('#boodschap').val(), nieuwsbrief: nieuws },
			   function(data) {
			     $('#bericht').show();
				 $('#bericht').html(data);
				 $('#formtable').hide();
			   });
		}else{
			alert("Gelieve alle velden van het formulier in te vullen.")	
		}
    });
	
$('#clubs').click(function(e) {
        if($('#adres').val() != "" && $('#land').val() != "" && $('#stad').val() != "" && $('#naam2').val() != "" && $('#naam').val() != "" && $('#email').val() != "" && $('#postcode').val() != "" && $('#boodschap').val()){
		  	var nieuws;
			if($('#nieuwsbrief').is(':checked')){
				nieuws = 1;	
			}else{
				nieuws = 0;	
			}
			$.post("mail_clubs.php", { land: $('#land').val(),stad: $('#stad').val(),adres: $('#adres').val(),vereniging: $('#naam').val(),naam: $('#naam2').val(), email: $('#email').val(), postcode: $('#postcode').val(), boodschap: $('#boodschap').val(), nieuwsbrief: nieuws },
			   function(data) {
			     $('#bericht').show();
				 $('#bericht').html(data);
				 $('#formtable').hide();
			   });
		}else{
			alert("Gelieve alle velden van het formulier in te vullen.")	
		}
    });	
	
$('#winkels').click(function(e) {
        if($('#adres').val() != "" && $('#land').val() != "" && $('#stad').val() != "" && $('#naam2').val() != "" && $('#naam').val() != "" && $('#email').val() != "" && $('#postcode').val() != "" && $('#boodschap').val()){
		  	var nieuws;
			if($('#nieuwsbrief').is(':checked')){
				nieuws = 1;	
			}else{
				nieuws = 0;	
			}
			$.post("mail_winkels.php", { land: $('#land').val(),stad: $('#stad').val(),adres: $('#adres').val(),vereniging: $('#naam').val(),naam: $('#naam2').val(), email: $('#email').val(), postcode: $('#postcode').val(), boodschap: $('#boodschap').val(), nieuwsbrief: nieuws },
			   function(data) {
			     $('#bericht').show();
				 $('#bericht').html(data);
				 $('#formtable').hide();
			   });
		}else{
			alert("Gelieve alle velden van het formulier in te vullen.")	
		}
    });
	
	
	$('#cart').click(function(){
		$.post("wfCart-1.6/jqcart.php", { id: $(this).attr("rel") },
			   function(data) {
			     alert(data);
				 location.reload();
			   }
		);
	})

	$('#bevestigen').click(function(e) {
        if($('#voornaam13').val() != "" && $('#naam13').val() != "" && $('#adres13').val() != "" && $('#gemeente13').val() != "" && $('#postcode13').val() != "" && $('#email13').val() != "" && $('#email13').val().indexOf("@") != -1){
		var antwoord = confirm("Wenst u uw bestelling te finaliseren?");
		if(antwoord){
$.post("wfCart-1.6/placeorder.php", { voornaam: $('#voornaam13').val(), naam: $('#naam13').val(), adres:  $('#adres13').val(), gemeente:  $('#gemeente13').val(), postcode:  $('#postcode13').val(), email: $('#email13').val(), opmerking: $('#opmerkingen13').val() },
				   function(data) {
				     alert(data);
					 window.location.replace("http://trisport.be/");
				   }
			);	
		}
		}else{
  			alert("Gelieve de velden met een * correct in te vullen.");			
		}
    });


})
























