$(document).ready(function(){
    
	// Request call
	$("form#request_call").submit(function() {
		//Setup any needed variables
		var input_name  = $('#name_call').val(),
        input_phone     = $('#phone_call').val(),
		input_message   = $('#message_call').val(),
        input_type = "request_call",
		response_text   = $('div#response_request_call');
        
      if (input_name == "") {
      $("span#name_error").show();
      $("input#name_call").focus();
      return false;
    }
            
/*
	  if (input_email == "" || input_email == "Email: (*)") {
      $("span#email_error").show();
      $("input#email_field").focus();
      return false;
    }
	
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	if(!emailReg.test(input_email)) {
	$("span#email_error2").show();
    $("input#email_field").focus();
      return false;
	}*/
    
     if (input_phone == "") {
      $("span#phone_error").show();
      $("input#phone_call").focus();
      return false;
    }
	/*
	  if (input_message == "") {
	  $("span#msg_error").show();
	  $("input#message_call").focus();
	  return false;
    } */
        
		//Hide any previous response text
		//response_text.hide();

		//Change response text to 'loading...'
		response_text.html('<p>Обработка запроса...</p>').show();

		//Make AJAX request
		$.post('/phpmailer/sendmail.php', {name: input_name, phone : input_phone, message: input_message, type:input_type}, function(data){
			response_text.html(data);
            //$("#validate_form").empty();
		});

		//Cancel default action
		return false;
		
	});
    
    
	// Request odrer
	$("form#request_order").submit(function() {
		//Setup any needed variables
		var input_name  = $('#name_order').val(),
        input_phone    = $('#phone_order').val(),
		input_model  = $('#model_order').val(),
		input_price  = $('#price').val(),
		input_article  = $('#article').val(),
		input_name_good  = $('#name_good').val(),
		input_name_category  = $('#name_category').val(),
        input_type = "request_order",
		response_text   = $('div#response_request_order');
        
      if (input_name == "") {
      $("span#name_error").show();
      $("input#name_order").focus();
      return false;
    }
    
     if (input_phone == "") {
      $("span#phone_error").show();
      $("input#phone_order").focus();
      return false;
    }
    
		//Hide any previous response text
		//response_text.hide();

		//Change response text to 'loading...'
		response_text.html('<p>Обработка запроса...</p>').show();

		//Make AJAX request
		$.post('/phpmailer/sendmail.php', {name: input_name, phone : input_phone, model: input_model, type:input_type, price: input_price, article: input_article, name_good: input_name_good, name_category: input_name_category}, function(data){
			response_text.html(data);
            //$("#validate_form").empty();
		});

		//Cancel default action
		return false;
		
	});
    
	
});
