var Account={};Account.stop_validation=false;Account.submit_account=function(){document.login.submit();};Account.submit_register_step_1=function(){Account.validated=true;var current_form=document.register_step_1;var inputs=current_form.getElementsByTagName('input');for(var i=0;i<inputs.length;i++){var classnames=inputs[i].className.split(' ');var validated=true;if(classnames.length>=2){var required_type=classnames[1];if(required_type=='required_text'){if(inputs[i].value==""){validated=false;}}if(required_type=='required_email'){if(!Validator_Element.is_email(inputs[i].value)){validated=false;}}if(validated){inputs[i].className=classnames[0]+' '+classnames[1]+'';}else{inputs[i].className=classnames[0]+' '+classnames[1]+' error_field';Account.validated=false;}}}if(current_form.home_phone.value==""&&current_form.work_phone.value==""){current_form.home_phone.className='register_field error_field';Account.validated=false;}else{current_form.home_phone.className='register_field';}if(current_form.pass_1.value!=""){if(current_form.pass_1.value==current_form.pass_2.value){current_form.pass_2.className='register_field';}else{current_form.pass_2.className='register_field error_field';Account.validated=false;}if(current_form.pass_1.value.length<=3){current_form.pass_1.className='register_field error_field';Interface.alert_pop(PHPVars.get('account_error_password'));Account.validated=false;}else{current_form.pass_1.className='register_field';}}else{current_form.pass_2.className='register_field';}if(Account.validated){Account.current_form=current_form;Account.validate_submit_register_step_1();}};Account.validate_submit_register_step_1=function(){var req=new AJAX.Request(Request.get('basepath')+'account/api_validate_submit_register_step_1/',{method:'POST',json:true,parameters:['email='+escape(Account.current_form.email.value)],onComplete:function(response){Account.responseJSON=response.responseJSON;Account._validate_submit_register_step_1();}});};Account._validate_submit_register_step_1=function(){if(Account.responseJSON.validated==1){Account.current_form.email.className='register_field required_email';Account.current_form.submit();}else{Account.current_form.email.className='register_field required_email error_field';Interface.alert_pop(Account.email_aready_exists_text);}};Account.popup_region=function(){$('register_iga_other_region_select').style.display='inline';$('register_iga_other_region').parentNode.removeChild($('register_iga_other_region'));};Account.check_first=function(){var current_form=document.register_step_2;for(var i=0;i<current_form.length;i++){if(current_form[i].name=='branch_id'){current_form[i].checked=true;break;}}};Account.update_branches=function(){var region=$('register_iga_other_region_select').value;var req=new AJAX.Request(Request.get('basepath')+'account/api_update_branches/',{method:'POST',json:true,parameters:['region='+region],onComplete:function(response){Account.responseJSON=response.responseJSON;Account._update_branches();}});};Account._update_branches=function(){$('div_branches').innerHTML=Account.responseJSON.branches_html;Account.check_first();};Account.submit_register_step_2=function(){var inputs=$('div_branches').getElementsByTagName('input');for(var i=0;i<inputs.length;i++){if(inputs[i].checked){document.register_step_2.submit();return true;}}Interface.alert_pop(PHPVars.get('error_no_branch_selected'));};Account.send_email_password=function(){var input_email=document.send_email_password.email;if(input_email.value==''||!Validator_Element.is_email(input_email.value)){input_email.className='error_field';}else{input_email.className='';var email_value=escape(input_email.value);var req=new AJAX.Request(Request.get('basepath')+CURRENT_LANG+'/account/send_email_password/',{method:'POST',json:true,parameters:['email='+email_value],onComplete:function(response){Account.responseJSON=response.responseJSON;Account._send_email_password();}});}};Account._send_email_password=function(){if(Account.responseJSON.is_member_found == 1){Interface.alert_pop(PHPVars.get('account_send_email'));}else{Interface.alert_pop(PHPVars.get('account_send_email_error'));}};Account.validate_reset_password=function(){if(document.reset_password.pass_1.value.length<4){document.reset_password.pass_1.className='error_field';document.reset_password.pass_2.className='';Interface.alert_pop(PHPVars.get('account_error_password'));return false;}if(document.reset_password.pass_1.value!=document.reset_password.pass_2.value){document.reset_password.pass_1.className='';document.reset_password.pass_2.className='error_field';return false;}document.reset_password.pass_2.className='';$('form_reset_password').submit();};
