$(document).ready(function(){ 

	var re_email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;	
	$('#promt-form').submit(function () {
		this.email.value = jQuery.trim(this.email.value);
		var valid = re_email.test(this.email.value);
		$this = $(this);
		if (!valid) {			
			$this.find('.mail-input').addClass('email-error');
			$('#dy-msg-error').show();
			return false;			
		} else {
			AmourAjax(window.location.href, $this.serialize(), function (result, message) {
				if (result == 'OK') {
					$('#dy-email').text($this.find('input[name=email]').val());
					$('#email-check').hide();
					$('#email-sent').show();
				} else {
					
				}
			});
			return false;
		}		
	});
	$('#newpwd-form').submit(function  () {		
		$this = $(this);
		var $el = $this.find('[name=new_pwd]');
		var str = jQuery.trim($el.val());
		$el.val(str);
		if (str.length < 6 || str.length > 30) {
			$this.find('.new-pass-field').addClass('email-error');
			return false;
		} else {
			AmourAjax(window.location.href, $this.serialize(), function (result, message) {
				if (result == 'OK') {
					window.location.href = '/';
				} else {
					$this.find('.new-pass-field').addClass('email-error');
				}
			});
		}
	});
});