(function(){"use strict";function e(e,a){this.MobileWidget(e,a);this._create()}e.prototype={submit:function(e){var a=e.data,n={username:a.UserName,password:a.Password,language:a.Language};if(this.storeCredentials&&window.localStorage){localStorage.setItem("u8/credentials/submit",JSON.stringify(n))}},_create:function(){var e=$(this.element);e.find("#Language").on("change",this._onLanguageChange.bind(this));e.find("span.form-icon").click(function(){$(this).next("input,select").focus()});var a=e.is("[data-failed]");if(this.storeCredentials&&window.localStorage){localStorage.removeItem("u8/credentials/submit");if(!a){var n=localStorage.getItem("u8/credentials");if(n){var i=JSON.parse(n);e.find("#UserName").val(i.username);e.find("#Password").val(i.password);if(e.find("#Language option[value='"+i.language+"']").length){e.find("#Language").val(i.language)}e.submit()}}else{localStorage.removeItem("u8/credentials")}}},_onLanguageChange:function(){var e=$(this.element),a=e.find("#UserName").val(),n=e.find("#Password").val(),i=e.find("#Language").val();var t=new u8.Base.Uri(window.location.href);t.set("language",i);u8.application.navigate({url:t.toString_()},function(){$("form #UserName").val(a);$("form #Password").val(n)})}};e.makeClass({name:"Login",deriveFrom:u8.Mobile.Widgets.MobileWidget})})();