$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#E8E8E8"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $(".buttonlinksenden").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var name = $("input#linksend_name").val();
		if (name == "") {
      $("label#linksend_name_error").show();
      $("input#linksend_name").focus();
      return false;
    }
		var email = $("input#linksend_email").val();
		if (email == "") {
      $("label#linksend_email_error").show();
      $("input#linksend_email").focus();
      return false;
    }
		var name_recipient = $("input#name_recipient").val();
		if (name_recipient == "") {
      $("label#name_recipient_error").show();
      $("input#name_recipient").focus();
      return false;
    }
    
		var name_recipientemail = $("input#name_recipientemail").val();
		if (name_recipientemail == "") {
      $("label#name_recipientemail_error").show();
      $("input#name_recipientemail").focus();
      return false;
    }
    
    
    
    	var mailmessage = document.getElementById("linksend_mailmessage").value;
    	var linksend_url = document.getElementById("linksend_url").value;
    	
    	
    
   	
		// var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone;		
		// alert (dataString);return false;

		
		$.ajax({
      type: "POST",
      url: "/de/_phpmailer/linksend_process.php",
      
      // data: dataString,
      data: 'name='+name+'&email='+email+'&name_recipient='+name_recipient+'&mailmessage='+mailmessage+'&linksend_url='+linksend_url+'&name_recipientemail='+name_recipientemail+'',

      success: function() {
        $('#linksend_form').html("<div id='successmessage'></div>");        
        $('#successmessage').html("<h6>Vielen Dank für Ihr Interesse...</h6>")
        
        .hide()
        .fadeIn(2500, function() {
          $('#successmessage').append("<img id='checkpicture' src='/stylesheets/css/screen/images/check.png' />");
          $('#successmessage').append("<p>Ihre Nachricht wurde versendet.</p>")
        });

      
        
      }
     });
    return false;
	});
});
