function del(id){
	$.post("../ajax/blog",{dell : 'true', id: id},
	   		function(data){
	   		$("."+id).fadeOut("slow");
	   });
}

$(document).ready(function () {
	
	$("ul.sf-menu").superfish(); 
	
	
	
	$('.showteken').click(function(){
			$("#tekendiv").toggle("slow");
	});	
		
	    
 	$("#bericht").focus(function () {
 		$("#bericht").val('');
 	    $("#bericht").unbind();
	});
	
	
 	
  	$('#tekenform').submit(function() { 
        var hasError = false;
        var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
      
        var naamVal = $("#naam").val();
        if(naamVal == '') {
			$(".nm").html(' <span class="error"> U heeft geen naam ingevoerd!</span>');
			$("#naam").keydown(function () { if($("#naam").val() != '') $(".nm").html('');});
			hasError = true;
		}else $(".nm").html('');
        
        var emailVal = $("#email").val();
       	if(emailVal != '' && !emailReg.test(emailVal)) {	
			$(".em").html(' <span class="error"> U heeft geen geldig email adres ingevoerd</span>');
			$("#email").keypress(function () { if($("#email").val() != '' && emailReg.test($("#email").val())) $(".em").html('');
											  else if ($("#email").val() == '')  $(".em").html(' (optioneel)');
											  else $(".em").html('<span class="error"> U heeft geen geldig email adres ingevoerd</span>');  });
			hasError = true;
		}else $(".em").html(' (optioneel)');
        
        var berichtVal = $("#bericht").val();
        if(berichtVal == '' || berichtVal == 'Type hier uw bericht...') {
			$(".bm").html(' <span class="error"> U heeft geen bericht ingevoerd!</span>');
			$("#bericht").keydown(function () { if($("#bericht").val() != '') $(".bm").html('');});
			hasError = true;
        }else if (berichtVal.match("href") || berichtVal.match("Href") || berichtVal.match("<url") || berichtVal.match("url>") || 
				berichtVal.match("HREF") || berichtVal.match("http") || berichtVal.match("<a")  || berichtVal.match("</a>") || berichtVal.match("www")){
			$(".bm").html(' <span class="error"> Het is helaas niet mogelijk om links om te nemen in het bericht!</span>');
			hasError = true;
		}else $(".bm").html('');
        
        if(hasError == false) {
	        
	        var blog_idVal = $("#blog_id").val();
	        
	        $.post("../ajax/blog",{naam: naamVal, email: emailVal, bericht: berichtVal, blog_id: blog_idVal},
	   		function(data){
				$("#bericht").focus(function () {
		 		$("#bericht").val('');
		 	    $("#bericht").unbind();});  
		 	    
		 	    bericht = '<tbody class="nieuw"><tr class="titel" ><td  class="naam datum" width="700px" colspan="2">Geplaatst door '+$("#naam").val()+'</td></tr>' +
						  '<tr class="bericht"><td colspan="2">'+data+'</td></tr>' +
						  '<tr class="spacer"><td colspan="2"></td></tr></tbody>';
				
				$(".nobericht").hide();
				$(".einde").after(bericht);
				$(".nieuw").fadeIn("slow");
						  
		 	  			 	    			
			});
        };
      	return false;
    }); 
    
        
    
});