/*    HTTP Host:  static.ak.fbcdn.net                                          */
/*    Generated:  December 2nd 2008 1:34:11 PM PST                             */
/*      Machine:  10.16.140.109                                                */
/*       Source:  Backing Store                                                */
/*     Location:  js/reg_util.js r121802                                       */
/*       Locale:  nu_ll                                                        */
/*         Path:  js/reg_util.js                                               */


var RegUtil={get_captcha:function() {if( _proxy_jslib_handle($('captcha_response'), 'value', '', 0, 0)){return this.finish_captcha();}
if(this.validate_data()){this.hide_error();this.show_captcha();}},register_no_captcha:function() {if(this.validate_data()){this.register();}},validate_data:function() {var name=this.get_full_name(),month= _proxy_jslib_handle($('birthday_month'), 'value', '', 0, 0),day= _proxy_jslib_handle($('birthday_day'), 'value', '', 0, 0),year= _proxy_jslib_handle($('birthday_year'), 'value', '', 0, 0),email=this.normalize_email( _proxy_jslib_handle($('reg_email__'), 'value', '', 0, 0)),pwd=this.normalize_password( _proxy_jslib_handle($('reg_passwd__'), 'value', '', 0, 0)),pwd2=ge('reg_passwd2__')?this.normalize_password( _proxy_jslib_handle($('reg_passwd2__'), 'value', '', 0, 0)):undefined;error_code='';if(((!this.validate_name(name))&&(error_code='name'))||((!this.validate_birthday(month,day,year))&&(error_code='birthday'))||((!this.validate_email(email))&&(error_code='email'))||((!this.validate_password(pwd,pwd2))&&(error_code='password'))){if(error_code){data={'error_code':error_code,'name':name,'month':month,'email':email};new (AsyncSignal)('/ajax/register/logging.php',data).send();}
return false;}
return true;},finish_captcha:function() {if( _proxy_jslib_handle($('captcha_response'), 'value', '', 0, 0)){this.register();}else{this.show_error('captcha_response',tx('sre02'));return;}},register:function() {this.show_progress();$('reg').submit();},show_captcha:function() {this.hide_reg_form();create_captcha();show('reg_captcha');if(ge('reg_captcha_buttons')){show('reg_captcha_buttons');}
try{$('captcha_response').focus();}catch(ignore){}},hide_captcha:function() {hide('reg_captcha');if(ge('reg_captcha_buttons')){hide('reg_captcha_buttons');}
this.hide_error();},show_progress:function() {this.hide_error();this.hide_reg_form();this.hide_captcha();show('reg_progress');},hide_progress:function() {hide('reg_progress');},show_error:function(field,msg) {var reg_error=$('reg_error');if(field){if(field=='captcha_response'){this.show_captcha();}else{this.show_reg_form();}
try{$(field).focus();}catch(ignore){}}else{try{if(ge('name')){$('name').focus();}else{$('firstname').focus();}}catch(ignore){}
this.show_reg_form();}
if(typeof animation=='function'){if(shown(reg_error)){DOM.setContent(reg_error,msg);if(CSS.getOpacity(reg_error)==0){animation(reg_error).show().from('opacity',0).to('opacity',1).duration(500).go();}}else{DOM.setContent(reg_error,msg);CSS.setOpacity(reg_error,0);animation(reg_error).show().from('height','0').to('height','15').duration(100).checkpoint().from('opacity',0).to('opacity',1.0).duration(400).go();}}else{show(reg_error);}},hide_error:function() {if(shown($('reg_error'))&&CSS.getOpacity($('reg_error'))>0){animation($('reg_error')).from('opacity',1.0).to('opacity',0).duration(400).go();}},show_reg_form:function() {show('reg_form_box');},hide_reg_form:function() {hide('reg_form_box');},normalize_name:function(name) {name= _proxy_jslib_handle(name, 'replace', '', 1, 0)(/^\s+|\s+$/g,'');name= _proxy_jslib_handle(name, 'replace', '', 1, 0)(/\s+/g,' ');return name;},normalize_email:function(email) {return email;},normalize_password:function(pwd) {return pwd;},validate_name:function(name,allow_empty_name) {var kMinWords=2;var kMaxWords=4;var words=name?name.split(' '):[];var error=null;if(!name){if(allow_empty_name){return true;}
error=tx('sre05');}else if(ge('firstname')&&(! _proxy_jslib_handle($('firstname'), 'value', '', 0, 0)||! _proxy_jslib_handle($('lastname'), 'value', '', 0, 0))){error=tx('sre06');}else if(words.length==2&&words[0]==words[1]){error=tx('sre06');}else if(words.length>kMaxWords){error=tx('sre07');}
if(!error){for(word in words){len=word.length
if(len==1){continue;}
c= _proxy_jslib_handle(word, (len-1), 0, 0);if('A'<=c&&c<='Z'){error=tx('sre11');}}}
if(error){this.show_error('name',error);}
return!error;},validate_email:function(email) {var error=null;if(!email)
error=tx('sre15');else if(email.indexOf('@')==-1)
error=tx('sre16');if(error)
this.show_error('reg_email__',error);return!error;},validate_password:function(pwd,pwd2) {var kMinLength=6;var kDisallowedWords=['password','facebook'];var error=name=null;if(!pwd){error=tx('sre17');}else if(pwd.length<kMinLength){error=tx('sre19');}else if(pwd2!=undefined&&pwd!=pwd2){error=tx('sre21');}else{var name=this.get_full_name();var names=name.toLowerCase().split(' ');var disallowed=names.concat(kDisallowedWords);for(var i=0;i<disallowed.length;(i= _proxy_jslib_assign_rval('++', 'i', '', '', i))){if(pwd.toLowerCase()== _proxy_jslib_handle(disallowed, (i), 0, 0)){error=tx('sre18');break;}}}
if(error)
this.show_error('reg_passwd__',error);return!error;},get_full_name:function() {if(ge('name')){return this.normalize_name( _proxy_jslib_handle($('name'), 'value', '', 0, 0));}
return this.normalize_name( _proxy_jslib_handle($('firstname'), 'value', '', 0, 0)+' '+
 _proxy_jslib_handle($('lastname'), 'value', '', 0, 0));},validate_birthday:function(month,day,year) {var error=null;if(month==-1||day==-1||year==-1){error=tx('sre01');}else if(year<=1910){error=tx('sre20');}
if(error)
this.show_error('birthday_month',error);return!error;},show_birthday_help:function() {birthday_popup=new (pop_dialog)('birthday_warning_popup');html='<div class="dialog_body">'
+tx('sre22')+'<br /><br />'+tx('sre23')+' <a href="/pages/create.php" title="Create a Page">'+tx('sre24')+'</a>.'
+'</div>'
+'<div id="dialog_buttons" class="dialog_buttons">'
+'<input type="button" class="inputsubmit" id="dialog_button1" onclick="birthday_popup.hide();" value="'+tx('sre26')+'"/></div>';birthday_popup.show_prompt(tx('sre25'),html);}}
function RegKeyPressListen() {var reg_form_box=ge('reg_form_box');if(reg_form_box){reg_form_box.listen('keypress',function(event) {if(event.keyCode==KEYS.RETURN&&shown(reg_form_box)){RegUtil.get_captcha();}});}}
function CaptchaBoxKeyPressListen() {var reg_captcha=ge('reg_captcha');if(reg_captcha){reg_captcha.listen('keypress',function(event) {if(event.keyCode==KEYS.RETURN&&shown(reg_captcha)){RegUtil.finish_captcha();}});}}

if (window.Bootloader) { Bootloader.done(["js\/reg_util.js"]); } ;
_proxy_jslib_flush_write_buffers() ;