$(function() {
	$("#btnSend").click(function() {
		if (!ValidateFormFeedback()) {
			alert(VALIDATE_ERROR);
			return false;
		}
		
		var userName = $("#inline2 input[name='username']").val();
		var userEmail = $("#inline2 input[name='email']").val();
		var message = $("#inline2 [name='message']").val();
		
		$.ajax({
			type: "POST",
			data: "username="+userName+"&user_email="+userEmail+"&message="+message,
			url: "ajax/pages/feedback",
			dataType: "json",
			success: function(response) {
				if (response.success) {
					$("#inline2 .share div[class!='messages'], #btnSend").hide();
					$("#inline2 .messages .ajaxSuccess").show();
					setTimeout(CloseFancyBox, 2000);
				} 
			}
		});
	});
});




function CloseFancyBox()
{
	$.fancybox.close();
}


function ValidateFormFeedback()
{
	var numErrors = 0;
	
	if (!$("#inline2 [name='username']").val().length) numErrors++;
	if (!$("#inline2 [name='email']").val().length) numErrors++;
	if (!$("#inline2 [name='message']").val().length) numErrors++;
	
	if (numErrors) return false;
	
	return true;
}









