var Login=function(){var handleLogin=function(){$('.login-form').validate({errorElement:'span',errorClass:'help-block',focusInvalid:false,rules:{username:{required:true},password:{required:true},remember:{required:false}},messages:{username:{required:"Username is required."},password:{required:"Password is required."}},invalidHandler:function(event,validator){$('.alert-danger',$('.login-form')).show();},highlight:function(element){$(element)
.closest('.form-group').addClass('has-error');},success:function(label){label.closest('.form-group').removeClass('has-error');label.remove();},errorPlacement:function(error,element){error.insertAfter(element.closest('.input-icon'));},submitHandler:function(form){form.submit();}});$('.login-form input').keypress(function(e){if(e.which==13){if($('.login-form').validate().form()){$('.login-form').submit();}
return false;}});}
var handleForgetPassword=function (){$('.forget-form').validate({errorElement:'span',errorClass:'help-block',focusInvalid:false,ignore:"",rules:{email:{required:true,email:true}},messages:{email:{required:"Email is required."}},invalidHandler:function(event,validator){},highlight:function(element){$(element)
.closest('.form-group').addClass('has-error');},success:function(label){label.closest('.form-group').removeClass('has-error');label.remove();},errorPlacement:function(error,element){error.insertAfter(element.closest('.input-icon'));},submitHandler:function(form){form.submit();}});$('.forget-form input').keypress(function(e){if(e.which==13){if($('.forget-form').validate().form()){$('.forget-form').submit();}
return false;}});jQuery('#forget-password').click(function(){jQuery('.login-form').hide();jQuery('.forget-form').show();});jQuery('#back-btn').click(function(){jQuery('.login-form').show();jQuery('.forget-form').hide();});}
var handleRegister=function(){function format(state){if(!state.id)return state.text;return "<img class='flag' src='../../assets/global/img/flags/"+state.id.toLowerCase()+".png'/>&nbsp;&nbsp;"+state.text;}
$("#select2_sample4").select2({placeholder:'<i class="fa fa-map-marker"></i>&nbsp;Select a Country',allowClear:true,formatResult:format,formatSelection:format,escapeMarkup:function(m){return m;}});$('#select2_sample4').change(function(){$('.register-form').validate().element($(this));});$('.register-form').validate({errorElement:'span',errorClass:'help-block',focusInvalid:false,ignore:"",rules:{fullname:{required:true},email:{required:true,email:true},address:{required:true},city:{required:true},country:{required:true},username:{required:true},password:{required:true},rpassword:{equalTo:"#register_password"},tnc:{required:true}},messages:{tnc:{ required:"Please accept TNC first."}},invalidHandler:function(event,validator){},highlight:function(element){$(element)
.closest('.form-group').addClass('has-error');},success:function(label){label.closest('.form-group').removeClass('has-error');label.remove();},errorPlacement:function(error,element){if(element.attr("name")=="tnc"){error.insertAfter($('#register_tnc_error'));}else if(element.closest('.input-icon').size()===1){error.insertAfter(element.closest('.input-icon'));}else{error.insertAfter(element);}},submitHandler:function(form){form.submit();}});$('.register-form input').keypress(function(e){if(e.which==13){if($('.register-form').validate().form()){$('.register-form').submit();}
return false;}});jQuery('#register-btn').click(function(){jQuery('.login-form').hide();jQuery('.register-form').show();});jQuery('#register-back-btn').click(function(){jQuery('.login-form').show();jQuery('.register-form').hide();});}
return{init:function(){handleLogin();handleForgetPassword();handleRegister();}};}();