$(document).ready(function(){
    
        
    	// Contact form
	$("form#question").submit(function() {
		
		//Setup any needed variables
		//var input_name  = $('#name_footer').val(),
        var selectedval  = $('#question option:selected').val(),
        //alert(selectedval);
        response_text   = $('#ansv');
/*
      if (input_name == "" || input_name == "Ваше имя: (*)") {
      $("span#name_error").show();
      $("input#name_footer").focus();
      return false;
    }*/
       response_text.html('<p>Обработка...</p>').show();
		//Make AJAX request
		$.post('/phpmailer/statistic.php', {selectedval: selectedval}, function(data){
			response_text.html(data);
            //$("#validate_form").empty();
		});

		//Cancel default action
		return false;
		
	});

	// Contact form
	$("form#order_form").submit(function() {
		
		//Setup any needed variables
		var input_name  = $('#name_field').val(),
		input_email     = $('#email_field').val(),
        input_phone     = $('#phone_field').val(),
        input_model     = $('#model_field').val(),
		input_message   = $('#message_field').val(),
        input_price     = $('#price_order').val(),
        input_article   = $('#article_order').val(),
        type = "order_form",
		response_text   = $('#result');
        
      if (input_name == "") {
      $("span#name_error").show();
      $("input#name_field").focus();
      return false;
    }
            

	  if (input_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_field").focus();
      return false;
    }
	
	  if (input_message == "") {
	  $("span#msg_error").show();
	  $("textarea#message_field").focus();
	  return false;
    } 
        
		//Hide any previous response text
		//response_text.hide();

		//Change response text to 'loading...'
		response_text.html('<p>Обработка...</p>').show();
        
        //    alert("da");
		//Make AJAX request
		$.post('/phpmailer/sendmail.php', {name_order: input_name, email_order: input_email, phone_order: input_phone, model_order: input_model, message_order:input_message, price_order:input_price, article_order: input_article, type:type}, function(data){
			response_text.html(data);
		});

		//Cancel default action
		return false;
		
	});
    
    	// Contact form
	$("form#partners_form").submit(function() {
		
		//Setup any needed variables
		var input_organization  = $('#organization_field').val(),
        input_name  = $('#name_field').val(),
        input_phone     = $('#phone_field').val(),
        input_email     = $('#email_field').val(),
		input_message   = $('#message_field').val(),
        type = "partners_form",
		response_text   = $('#result');

        
      if (input_organization == "") {
      $("span#name_error").show();
      $("input#organization_field").focus();
      return false;
    }
        
      if (input_name == "") {
      $("span#name_error").show();
      $("input#name_field").focus();
      return false;
    }
    
     if (input_phone == "" || input_phone == "Контактный телефон: (*)") {
      $("span#phone_error").show();
      $("input#phone_field").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_message == "" || input_message == "Дополнительная информация: (*)") {
	  $("span#msg_error").show();
	  $("textarea#message_field").focus();
	  return false;
    } 
        
		//Hide any previous response text
		//response_text.hide();

		//Change response text to 'loading...'
		response_text.html('<p>Обработка...</p>').show();
        
        //    alert("da");
		//Make AJAX request
		$.post('/phpmailer/sendmail.php', {organization_partners: input_organization, name_partners: input_name, phone_partners: input_phone, email_partners: input_email, message_partners:input_message, type:type}, function(data){
			response_text.html(data);
		});

		//Cancel default action
		return false;
		
	});
    
        
    	// Contact form
	$("form#contact_form").submit(function() {
		
		//Setup any needed variables
		var input_name  = $('#name_field').val(),
		input_email     = $('#email_field').val(),
        input_phone     = $('#phone_field').val(),
		input_message   = $('#message_field').val(),
        type = "contact_form",
		response_text   = $('#result');
      if (input_name == "" || input_name == "Ваше имя: (*)") {
      $("span#name_error").show();
      $("input#name_field").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 == "" || input_phone == "Контактный телефон: (*)") {
      $("span#phone_error").show();
      $("input#phone_field").focus();
      return false;
    }
	
	  if (input_message == "" || input_message == "Дополнительная информация: (*)") {
	  $("span#msg_error").show();
	  $("textarea#message_field").focus();
	  return false;
    } 
        
		//Hide any previous response text
		//response_text.hide();

		//Change response text to 'loading...'
		response_text.html('<p>Обработка...</p>').show();
        
        //    alert("da");
		//Make AJAX request
		$.post('/phpmailer/sendmail.php', {name: input_name, email: input_email, phone: input_phone, message:input_message, type:type}, function(data){
			response_text.html(data);
		});

		//Cancel default action
		return false;
		
	});
    
    
    
    
    
    
    
            
    	// Contact form
	$("form#ordercatalog_form").submit(function() {
		
		//Setup any needed variables
		var input_name  = $('#ordercatalogname_field').val(),
		input_email     = $('#ordercatalogemail_field').val(),
        input_phone     = $('#ordercatalogphone_field').val(),
		input_message   = $('#ordercatalogmessage_field').val(),
        type = "ordercatalog_form",
		response_text   = $('#ordercatalogresult');
        
      if (input_name == "" || input_name == "Ваше имя: (*)") {
      response_text.html('<b style=\"color:red;font-size:14px;\">Введите Имя</b>').show();
      $("input#ordercatalogname_field").focus();
      return false;
    }
            

	  if (input_email == "" || input_email == "Email: (*)") {
      response_text.html('<b style=\"color:red;font-size:14px;\">Введите Email</b>').show();
      $("input#ordercatalogemail_field").focus();
      return false;
    }
	
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	if(!emailReg.test(input_email)) {
	response_text.html('<b style=\"color:red;font-size:14px;\">Введите корректный Email</b>').show();
    $("input#ordercatalogemail_field").focus();
      return false;
	}
    
     if (input_phone == "" || input_phone == "Контактный телефон: (*)") {
      response_text.html('<b style=\"color:red;font-size:14px;\">Введите телефон</b>').show();
      $("input#ordercatalogphone_field").focus();
      return false;
    }
	/*
	  if (input_message == "" || input_message == "Дополнительная информация: (*)") {
	  $("span#msg_error").show();
	  $("textarea#ordercatalogmessage_field").focus();
	  return false;
    } */
        
		//Hide any previous response text
		//response_text.hide();

		//Change response text to 'loading...'
		response_text.html('<p>Обработка...</p>').show();
        
        //    alert("da");
		//Make AJAX request
		$.post('/phpmailer/sendmail.php', {name: input_name, email: input_email, phone: input_phone, message:input_message, type:type}, function(data){
			response_text.html(data);
            $('#fade , #popuprel , #popuprel2 , #popuprel3').fadeOut("slow");
		});

		//Cancel default action
		return false;
		
	});
    
    
    
    
    
    
    
    
        
    
    
    
    
    
    
            
    	// Contact form
	$("form#pricelist_form").submit(function() {
		
		//Setup any needed variables
		var input_name  = $('#pricelistname_field').val(),
		input_email     = $('#pricelistemail_field').val(),
        input_phone     = $('#pricelistphone_field').val(),
		input_message   = $('#pricelistmessage_field').val(),
        type = "pricelist_form",
		response_text   = $('#pricelistresult');
        
      if (input_name == "" || input_name == "Ваше имя: (*)") {
      response_text.html('<b style=\"color:red;font-size:14px;\">Введите Имя</b>').show();
      $("input#pricelistname_field").focus();
      return false;
    }
            

	  if (input_email == "" || input_email == "Email: (*)") {
      response_text.html('<b style=\"color:red;font-size:14px;\">Введите Email</b>').show();
      $("input#pricelistemail_field").focus();
      return false;
    }
	
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	if(!emailReg.test(input_email)) {
	response_text.html('<b style=\"color:red;font-size:14px;\">Введите корректный Email</b>').show();
    $("input#pricelistemail_field").focus();
      return false;
	}
    
     if (input_phone == "" || input_phone == "Контактный телефон: (*)") {
      response_text.html('<b style=\"color:red;font-size:14px;\">Введите телефон</b>').show();
      $("input#pricelistphone_field").focus();
      return false;
    }
	/*
	  if (input_message == "" || input_message == "Дополнительная информация: (*)") {
	  $("span#msg_error").show();
	  $("textarea#ordercatalogmessage_field").focus();
	  return false;
    } */
        
		//Hide any previous response text
		//response_text.hide();

		//Change response text to 'loading...'
		response_text.html('<p>Обработка...</p>').show();
        
        //    alert("da");
		//Make AJAX request
		$.post('/phpmailer/sendmail.php', {name: input_name, email: input_email, phone: input_phone, message:input_message, type:type}, function(data){
			response_text.html(data);
            $('#fade , #popuprel , #popuprel2 , #popuprel3').fadeOut("slow");
		});

		//Cancel default action
		return false;
		
	});
    
    
    
    
    
    
    
    
    
      	// Contact form
	$("form#reservation_form").submit(function() {
		
		//Setup any needed variables
		var input_organization  = $('#name_field').val(),
        input_name  = $('#face_field').val(),
        input_phone     = $('#phone_reservation').val(),
        input_company_url     = $('#company_url_field').val(),
        input_email     = $('#email_reservation').val(),
		input_message   = $('#message_field').val(),
        type = "reservation_form",
		response_text   = $('#result');

        
      if (input_organization == "") {
      $("span#name_error").show();
      $("input#name_field").focus();
      return false;
    }
        
      if (input_name == "") {
      $("span#name_error").show();
      $("input#face_field").focus();
      return false;
    }
    
     if (input_phone == "") {
      $("span#phone_error").show();
      $("input#phone_reservation").focus();
      return false;
    }  
    
    if (input_email == "" || input_email == "Email: (*)") {
      $("span#phone_error").show();
      $("input#email_reservation").focus();
      return false;
    }
	
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	if(!emailReg.test(input_email)) {
    $("span#phone_error").show();
    $("input#email_reservation").focus();
      return false;
	}
    
	
	  if (input_message == "" || input_message == "Дополнительная информация: (*)") {
	  $("span#msg_error").show();
	  $("textarea#message_field").focus();
	  return false;
    } 
        
		//Hide any previous response text
		//response_text.hide();

		//Change response text to 'loading...'
		response_text.html('<p>Обработка...</p>').show();
        
        //    alert("da");
		//Make AJAX request
		$.post('/phpmailer/sendmail.php', {organization_reservation: input_organization, name_reservation: input_name, phone_reservation: input_phone, email_reservation: input_email, company_url_reservation: input_company_url, message_reservation:input_message, type:type}, function(data){
			response_text.html(data);
		});

		//Cancel default action
		return false;
		
	});

    
    	// Contact form
	$("form#validate_form_footer").submit(function() {
		
		//Setup any needed variables
		var input_name  = $('#name_footer').val(),
        input_phone     = $('#phone_footer').val(),
		input_message   = $('#message_footer').val(),
        input_address   = $('#address').val(),
        type            = "validate_form_footer",
        response_text   = $('#result_footer');

      if (input_name == "" || input_name == "Ваше имя: (*)") {
      $("span#name_error").show();
      $("input#name_footer").focus();
      return false;
    }
            
     if (input_phone == "" || input_phone == "Контактный телефон: (*)") {
      $("span#phone_error").show();
      $("input#phone_footer").focus();
      return false;
    }
	
	  if (input_message == "" || input_message == "Дополнительная информация: (*)") {
	  $("span#msg_error").show();
	  $("textarea#message_footer").focus();
	  return false;
    } 
        
		//Hide any previous response text
		//response_text.hide();

		//Change response text to 'loading...'
		//response_text.html('<p>Loading...</p>').show();

		//Make AJAX request
		$.post('/phpmailer/sendmail.php', {name: input_name, phone : input_phone, message: input_message, type:type}, function(data){
			response_text.html(data);
            //$("#validate_form").empty();
		});

		//Cancel default action
		return false;
		
	});
	
});
