jQuery(document).ready(function($){"use strict";$(document).find('.ct-user-form-login .login-group').on('keypress','input',function(e){var keycode=(e.keyCode?e.keyCode:e.which);if(keycode=='13'){user_press_login($(this))}});$(document).find('.ct-user-form-login .login-group').on('keypress','input',function(e){wl_alert($(this),'','hide')});$(document).find('.ct-user-form').on('click','.button-login',function(e){e.preventDefault();user_press_login($(this))});$(document).find('.ct-user-form-register').on('click','.btn-up-register',function(e){e.preventDefault();user_press_register($(this))});$(document).find('.ct-user-form-register').on('keypress','input',function(e){wl_alert($(this),'','hide')});$(document).find('.ct-user-form').on('keypress','input',function(e){var keycode=(e.keyCode?e.keyCode:e.which);if(keycode=='13'){user_press_register($(this))}});function user_press_register(e){var _form=e.parents('.ct-user-form-register');var input_user=_form.find('input#res_user');var input_pass=_form.find('input#res_pass1');var input_passconfirm=_form.find('input#res_pass2');var input_email=_form.find('input#res_email');var register_data=register_validation(input_user,input_pass,input_passconfirm,input_email);if(register_data!==!1){user_press_disabled(_form);$.post(userpress.ajax,{'action':'form_ajax_register','data':register_data,'_ajax_nonce':userpress.nonce},function(response){if(response.error==!0){if(response.user_null!=undefined)
wl_alert(input_user,response.user_null);if(response.pass_null!=undefined)
wl_alert(input_pass,response.pass_null);if(response.email_null!=undefined)
wl_alert(input_email,response.email_null);if(response.passconfirm!=undefined)
wl_alert(input_passconfirm,response.passconfirm);if(response.user_invalid!=undefined)
wl_alert(input_user,response.user_invalid);if(response.user_exists!=undefined)
wl_alert(input_user,response.user_exists);if(response.email_exists!=undefined)
wl_alert(input_email,response.email_exists)}else{location.reload()}});user_press_enable(_form)}}
function register_validation(input_user,input_pass,input_passconfirm,input_email){var is_form_valid=!0;var input_user_val=input_user.val().trim();var input_pass_val=input_pass.val().trim();var input_passconfirm_val=input_passconfirm.val().trim();var input_email_val=input_email.val().trim();if(input_user_val==''){wl_alert(input_user,input_user.data('validate'));is_form_valid=!1}else if(4>input_user_val.length){wl_alert(input_user,input_user.data('user-length'));is_form_valid=!1}
if(input_pass_val==''){wl_alert(input_pass,input_pass.data('validate'));is_form_valid=!1}else if(5>input_pass_val.length){wl_alert(input_pass,input_pass.data('pass-length'));is_form_valid=!1}else if(input_pass_val!=input_passconfirm_val){wl_alert(input_passconfirm,input_passconfirm.data('pass-confirm'));is_form_valid=!1}
if(input_email_val==''){wl_alert(input_email,input_email.data('validate'));is_form_valid=!1}else if(validateEmail(input_email_val)===!1){wl_alert(input_email,input_email.data('email-format'));is_form_valid=!1}
if(is_form_valid===!0){var register_data={};register_data.user=input_user_val;register_data.pass=input_pass_val;register_data.email=input_email_val;register_data.passconfirm=input_passconfirm_val;return register_data}else{return!1}}
function user_press_login(e){var login_data={};var _form=e.parents('.ct-user-form');var input_user=_form.find('input.user_name');var input_pass=_form.find('input.password');var input_user_val=input_user.val();var input_pass_val=input_pass.val();if(input_user_val=='')
wl_alert(input_user,input_user.data('validate'));if(input_pass_val=='')
wl_alert(input_pass,input_pass.data('validate'));login_data.user=input_user_val;login_data.pass=input_pass_val;login_data.rememberme=_form.find('input.rememberme').val();if(login_data.user&&login_data.pass){user_press_disabled(_form);$.post(userpress.ajax,{'action':'user_press_login','data':login_data,'_ajax_nonce':userpress.nonce},function(response){if(response.error==!0){if(response.user!=undefined){wl_alert(input_user,response.user)}
if(response.pass!=undefined){wl_alert(input_pass,response.pass)}}else{location.reload()}
user_press_enable(_form)})}}
function user_press_disabled(_form){_form.find('input, button, select').each(function(){$(this).prop('disabled',!0)})}
function user_press_enable(_form){_form.find('input, button, select').each(function(){$(this).prop('disabled',!1)})}
function validateEmail(email){var re=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;return re.test(email)}
function wl_alert(obj,message,mode){mode=(mode)?mode:'show';if(mode=='show'){if(obj.next().hasClass('wpcf7-not-valid-tip')===!1){obj.after('<span role="alert" class="wpcf7-not-valid-tip" style="display:none">'+message+'</span>');obj.next().fadeIn('slow')}else{if(obj.parent().find('.wpcf7-not-valid-tip').length>0){obj.parent().find('.wpcf7-not-valid-tip').remove();obj.after('<span role="alert" class="wpcf7-not-valid-tip" style="display:none">'+message+'</span>');obj.next().fadeIn('slow')}}}else{if(obj.parent().find('.wpcf7-not-valid-tip').length>0){obj.parent().find('.wpcf7-not-valid-tip').fadeOut('slow')}}}})