$(function(){

		$('input[type="text"]').focus(function() {
			$(this).removeClass('inputBlur').removeClass('inputBlurEmpty ').addClass('inputFocus');
			if (this.value == "Angabe notwendig") {
				$(this).val('')
			}
		});
		$('input[type="text"]').blur(function() {
			$(this).removeClass('inputFocus').addClass('inputBlur');
		});
		$('textarea').focus(function() {
			$(this).removeClass('inputBlur').removeClass('inputBlurEmpty ').addClass('inputFocus');
			if (this.value == "Angabe notwendig") {
				$(this).val('')
			}
		});
		$('textarea').blur(function() {
			$(this).removeClass('inputFocus').addClass('inputBlur');
		});
		
	
	
   	$(".form-submit").live("click", function(e) {
  	 	e.preventDefault();
  	 	//alert($('#commentform').attr('action'));
   		
   		var Author = $('input[name=author]').val();
		var Comment = $('textarea[name=comment]').val();
						
		//Mussfelder	
		if(Author == "Angabe notwendig"){
			Author = "";	
		}
		if(Comment == "Angabe notwendig"){
			Comment = "";	
		}
		
		

		


		
				if(Author == "" || Comment == "" ){
			
			if (Author == "") {
				$('input[name=author]').val('Angabe notwendig') ;
				$('input[name=author]').removeClass('inputBlur').addClass('inputBlurEmpty ');
			}
			
			if (Comment == "") {
				$('textarea[name=comment]').val('Angabe notwendig') ;
				$('textarea[name=comment]').removeClass('inputBlur').addClass('inputBlurEmpty ');
			}
			
			return false;
		}
	
		var comment_post_ID = $('input[name=comment_post_ID]').val();
		var formAction = $('#commentform').attr('action');

		//var dataString = 'author='+ Author + '&comment=' + Comment+ '&submit=' + 'Senden' + '&comment_post_ID=' + '286' + '&comment_post_ID' + '=' + '286' + '&comment_parent=' + '0';
		var dataString = 'author='+ Author + '&comment=' + Comment+ '&submit=' + $('input[name=submit]').val() + '&comment_post_ID=' +comment_post_ID + '&comment_post_ID=' +  $('input[name=comment_post_ID]').val() + '&comment_parent=' +  $('input[name=comment_parent]').val();
		
		
		//var dataString = 'name='+ name + '&Email=' + Email + '&phone=' + phone;
		//alert (dataString);
			//this.form.submit();
					$.ajax({
					  type: "POST",
					  url: formAction+"/wp-comments-post.php",
					  data: dataString,
					  success: function() {
					  	$("#content").remove();
						$("#page").append("<div id='content'> </div>");
					  //	$("#content").load("http://www.waldstock.ch/?page_id=286 #element",  function(e){
					  	$("#content").load(formAction+"/?page_id="+comment_post_ID+"&ajaxReq=1",  function(e){
						//	alert(formAction+"/?page_id="+comment_post_ID+"&ajaxReq=1");
							 
							//$('#content').attr("style", "");
							//$('#content').attr("class", "");
							 $("#content").masonry({
    						    columnWidth: 250
   							 });
   							 
	   						$(".text_1_column:first").hide();
	   						$(".text_1_column:first").fadeIn();
	   						var contentFormHeight = 	$('#commentform').height();
						  	//alert(contentFormHeight); 
						  	$('input[name=author]').hide();
						  	$('textarea[name=comment]').hide();
						  	$('input[name=submit]').hide();
						  	$('.form-label').hide();
						  	$('#comment-notes').hide();
						  	$('#comment-notes').html("Vielen Dank f&uuml;r die R&uuml;ckmeldung.");
						  	$('#comment-notes').css('color','#219704');
						  	$('#comment-notes').fadeIn();
						  	$('#commentform').css('height', contentFormHeight)

						});
					  


					  }
					 });		

   	
   	
   	
  
   	});
   	

   	
   	
	
});
  




