$(document).ready(function(){
	// Send EMail
	$("#snd-eml").click(function() {
		$('#emailform').css({opacity:0.3});
		$('p.error').remove();
		$('.response').fadeOut('fast')
		var uuuu     = $('#name').attr('value');
		var htme     = $('#email').attr('value');
		var sup      = $('#subject').attr('value');
		var yo       = $('#message').attr('value');
		var hcheck   = $('#human').attr('value');
		var datastr = 'uuuu=' + uuuu + '&htme=' + htme + '&sup=' + sup + '&yo=' + yo + '&hcheck=' + hcheck;
		
			$.ajax({
				type: "POST",
				url: "send-mail.php",
				data: datastr,
				dataType: "json",
				
				// Success
				success: function(data){       
						if(data.status == 'error') {
								$('#emailform').css({opacity:1.0});
                                $('.response').fadeIn().html('<p class="fix-error">' + data.message + '</p>');
                                $.each(data.errors, function(index, value) { 
                                        $('input[id="' + index + '"]').after('<p class="error">' + value + '</p>');
										$('textarea[id="' + index + '"]').after('<p class="error">' + value + '</p>');
                                });
                        } else {
                                $('.response').fadeIn().addClass('success').html(data.message);
                                $('#emailform').hide('slow');
                        }
                }


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