function send_mail_response(){
	$(".system_msg").html("Сообщение отправлено, и в ближайшее время будет просмотрено!");
	$("#name").attr("value","");
	$("#tel").attr("value","");
	$("#phone").attr("value","");
	$("#mail").attr("value","");
	$("#city").attr("value","");
	$("#company").attr("value","");
	$("#message").attr("value","");

}

function sendMessage(){
	fio_ = $("#name").attr("value");
	email_ = $("#mail").attr("value");
	phone_ = $("#tel").attr("value");
	city_ = $("#city").attr("value");
	company_ = $("#company").attr("value");
	message_ = $("#message").attr("value");

	
	if (!fio_ || !email_ || !phone_ || !message_ || !company_ || !phone_ || !city_ )
	{
		$(".system_msg").html("<span class='err'>Пожалуйста, заполните все поля!</span>");

	}
	else
	{
			
		$.ajax({
        type:'POST',
        url: "/include/module/msg.php",
        dataType : "text",
			data:"fio="+fio_+"&email="+email_+"&phone="+phone_+"&message="+message_+"&company="+company_+"&city="+city_,
	        beforeSend:function(){},
        success: function(data) {
			send_mail_response();
            }
    });	
	}
	return false;
} 

function send_action_response()
{
	$("#system_msg").html("Сообщение отправлено, теперь Вы ожете распечатать купон на скидку.");
	$("#act_fio").attr("value","");
	$("#act_org").attr("value","");
	$("#act_city").attr("value","");
	$("#act_adress").attr("value","");
	$("#act_tel").attr("value","");
	$("#act_msg").attr("value","");
	window.open('/cupon', 'Купон на скидку','width=600,height=400, menubar=yes');
}



function sendAction()
{
	fio_ = $("#act_fio").attr("value");
	org_ = $("#act_org").attr("value");
	city_ = $("#act_city").attr("value");
	adress_ = $("#act_adress").attr("value");
	tel_ = $("#act_tel").attr("value");
	msg_ = $("#act_msg").attr("value");
	
	if (!fio_ ||!org_ ||!city_ ||!adress_ ||!tel_)
	{
		$("#system_msg").html("Пожалуйста, заполните обязательные поля!");
	}
	else
	{
		$.post("/include/module/action.php",
			{
			   fio:fio_,
			   org:org_,
			   city:city_,
			   adress:adress_,
			   tel:tel_,
			   msg:msg_
			},send_action_response);
	}
	return false;
}
