﻿Ext.namespace('BYB.UI.Create');BYB.UI.Create.app=function(){function initUI(){var fn=$('#inputFirstName');var ln=$('#inputLastName');var un=$('#inputUsername');var em=$('#inputAcctEmail');var pw=$('#inputAcctPassword').keypress(function(event){if(event.keyCode=='13'){submitCreateForm();}});if(BYB.Util.isDefined('newuser')){fn.val(newuser.FirstName);ln.val(newuser.LastName);un.val(newuser.Handle);}var is21=new Ext.form.Checkbox({boxLabel:'I VERIFY THAT I AM 18 YEARS OLD',checked:false,width:300});var terms=new Ext.form.Checkbox({style:'padding-top:5px; padding-bottom:5px',boxLabel:'I agree to <a href="javascript:showTerms()">Terms and Conditions</a>',checked:false,width:300});is21.on('check',allowBut);terms.on('check',allowBut);var okBtn=new Ext.Button({text:'OK',disabled:true});function allowBut(cb,checked){if(terms.getValue()&&is21.getValue()){okBtn.setDisabled(false);}else{okBtn.setDisabled(true);}}$('#createBtn').button();$('#createBtn').click(function(){submitCreateForm();});function submitCreateForm(){var ok=true;if(fn.val()==''){fzalert('Ooops','You must enter a first name');ok=false;}else{if(ln.val()==''){fzalert('Ooops','You must enter a last name');ok=false;}else{if(un.val().length>13){fzalert('Ooops','Your handle must be between 5-13 characters');ok=false;}else{if(pw.val().length<5){fzalert('Ooops','Your password must be at least 5 characters');ok=false;}}}}if(ok){var wind=new Ext.Window({items:[is21,terms], width:300, height:120,title:'Please Verify',buttons:[okBtn]});wind.show();}}okBtn.on('click',function(){if(!BYB.Util.isDefined('existUserId')){var existUserId=null;}Ext.Msg.wait('Creating account...');BYB.Util.ajax('/Account/CreateAccount/',{firstName:fn.val(),lastName:ln.val(),email:em.val(),sendEmail:true,handle:un.val(),country:'USA',existUser:existUserId,promo:null,pw:pw.val()},function(ret){var response=Ext.decode(ret.responseText);if(response.Error==false){if(BYB.Util.isDefined('newuser')){if(BYB.Util.isDefined('redir')){document.location.href=redir;}if(BYB.Util.isDefined('betredir')){document.location.href='/challenge/match/'+betredir+'/';}else{if(BYB.Util.isDefined('customredir')){document.location.href='/challenge/custom/'+customredir+'/';}else{document.location.href='/franchise/'+un.val()+'/';}}}else{Ext.Msg.wait('Redirecting...');document.location.href='/franchise/'+un.val()+'/';}}else{fzalert('Small Problem...',response.Message,function(){if(response.Message.indexOf('pending invite')>-1){Ext.Msg.wait('redirecting...');document.location.href='/account/acceptinvite/?u='+response.ReturnObject.ID;}});}});});}return{init:function(){initUI();},unVal:function(val){if(val.length<5||val.length>13){return'Username must be between 5-13 characters';}else{return true;}}};}();Ext.onReady(BYB.UI.Create.app.init);function showTerms(){var win=new Ext.Window({width:500,height:350,title:'Fanzooka.com Terms and Conditions',autoLoad:{url:'/about/UsageAgreementCtrl/'},autoScroll:true,modal:true});win.show();win.center();}
