/**
* 2007-2020 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@buy-addons.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author    Buy-addons    <contact@buy-addons.com>
* @copyright 2007-2020 Buy-addons
* @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/

function isValidEmailTest(emailTest) {
        var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
        return pattern.test(emailTest);
};

function save_setting(){
		
		var email_admin = jQuery('.email_adm_class').val();
		var email_from = jQuery('.email_from_class').val();
		var check = 1;

		var name_from = jQuery('.name_adm_class').val();
		if(email_admin == '' || email_from == '' || name_from == ''){
		
			if(email_admin == ''){
				jQuery(".email_adm_class").css("border-color", "red");
				check = 0;
			}
			if(email_admin != ''){
				jQuery(".email_adm_class").css("border-color", "#d6d4d4");
				if(isValidEmailTest(email_admin) == false ){
					
			 		jQuery(".email_adm_class").css("border-color", "red");	
			 		check = 0;
				}else{
					
			 		jQuery(".email_adm_class").css("border-color", "#d6d4d4");
				}
			}
			if(email_from == ''){
				jQuery(".email_from_class").css("border-color", "red");	
				check = 0;
				
			}
			if(email_from != '')
			{
				if(isValidEmailTest(email_from) == false){
			 		jQuery(".email_from_class").css("border-color", "red");
			 		check = 0;
				}else{
		 			jQuery(".email_from_class").css("border-color", "#d6d4d4");
				}
			}
			if(name_from == ''){
				jQuery(".name_adm_class").css("border-color", "red");
				check = 0;
			
			}
			if(name_from != ''){
				jQuery(".name_adm_class").css("border-color", "#d6d4d4");			
			}
			
		}else{
			if(isValidEmailTest(email_admin) == false ){
				jQuery(".email_adm_class").css("border-color", "red");	
			 	check = 0;
			}else{
				jQuery(".email_adm_class").css("border-color", "#d6d4d4");
			}	
			if(isValidEmailTest(email_from) == false){
			 	jQuery(".email_from_class").css("border-color", "red");
			 	check = 0;
			}else{
		 		jQuery(".email_from_class").css("border-color", "#d6d4d4");
			}
		}
		if(check == 0){
			return false;
		}else{
			return true;
		}
	}



