/*
HTTP Host: b.static.ak.fbcdn.net
Generated: March 20th 2010 7:31:28 AM PDT
Machine: 10.16.139.107
Locale: nu_ll
Path: js/reg_util.js
*/

if (window.CavalryLogger) { CavalryLogger.start_js(["js\/reg_util.js"]); }

function RegUtil(){}RegUtil.genderFemale=1;RegUtil.genderMale=2;RegUtil.errorFields=[];RegUtil.DAY_FIELD='birthday_day';RegUtil.MONTH_FIELD='birthday_month';RegUtil.YEAR_FIELD='birthday_year';RegUtil.PASSWORD_FIELD='reg_passwd__';RegUtil.NAME_FIELD='name';RegUtil.FIRSTNAME_FIELD='firstname';RegUtil.LASTNAME_FIELD='lastname';RegUtil.EMAIL_FIELD='reg_email__';RegUtil.GENDER_FIELD='sex';RegUtil.errorFields[6]=RegUtil.PASSWORD_FIELD;RegUtil.errorFields[7]=RegUtil.PASSWORD_FIELD;RegUtil.errorFields[8]=RegUtil.PASSWORD_FIELD;RegUtil.errorFields[9]=RegUtil.PASSWORD_FIELD;RegUtil.errorFields[40]=RegUtil.PASSWORD_FIELD;RegUtil.errorFields[10]=RegUtil.NAME_FIELD;RegUtil.errorFields[48]=RegUtil.NAME_FIELD;RegUtil.errorFields[15]=RegUtil.YEAR_FIELD;RegUtil.errorFields[16]=RegUtil.EMAIL_FIELD;RegUtil.errorFields[18]=RegUtil.EMAIL_FIELD;RegUtil.errorFields[25]=RegUtil.EMAIL_FIELD;RegUtil.errorFields[26]=RegUtil.EMAIL_FIELD;RegUtil.errorFields[27]=RegUtil.EMAIL_FIELD;RegUtil.errorFields[37]=RegUtil.EMAIL_FIELD;RegUtil.errorFields[43]=RegUtil.GENDER_FIELD;RegUtil.getInstance=function(){if(!RegUtil._instance)RegUtil._instance=new RegUtil();return RegUtil._instance;};RegUtil.prototype.get_captcha=function(){if($('captcha_response').value)return this.finish_captcha();if(this.validate_data()){this.hide_error();this.show_captcha();}};RegUtil.prototype.register_no_captcha=function(){if(this.validate_data())this.register();};RegUtil.prototype.ajax_validate_data=function(_L0,_L1,_L2){var reg=this;var _L4=function(_L7){hide('async_status');hide('captcha_async_status');var _L8=_L7.getPayload();if(_L8['redirect']){goURI(_L8['redirect']);}else if(_L8['field_validation_succeeded']){reg.hide_error();reg.show_captcha();}else if(_L8['bad_captcha']){DOM.setContent($('outer_captcha_box'),HTML(_L8['html']));reg.show_error('captcha_response',_L8['error']);}else if(_L8['tooyoung']){DOM.setContent($(_L1),HTML(_L8['html']));}else if(_L8['registration_succeeded']){if(_L2){var _L9=$('confirmation_email_form');var _La=$('confirmation_email');_La.value=_L8['email'];_L9.submit();}else DOM.setContent($(_L1),HTML(_L8['html']));CSS.setStyle($('fb_menubar_aux'),'visibility','hidden');}else{if(ge(RegUtil.FIRSTNAME_FIELD))RegUtil.errorFields[10]=[RegUtil.FIRSTNAME_FIELD,RegUtil.LASTNAME_FIELD];var _La=RegUtil.errorFields[_L8['error_code']];reg.show_error(_La,_L8['error']);}};var _L5=$('reg');var _L6=serialize_form(_L5);if(_L0&&_L0['ignore'])_L6['ignore']=_L0['ignore'].join('|');show('async_status');show('captcha_async_status');if(!this._async_request)this._async_request=new AsyncRequest();this._async_request.setURI('/ajax/register.php').setData(_L6).setReadOnly(true).setHandler(_L4).send();};RegUtil.prototype.validate_data=function(){this.hide_error();var _L0={'fullname':this.get_full_name(),'firstname':ge('firstname')?$('firstname').value:'','lastname':ge('lastname')?$('lastname').value:'','month':$(RegUtil.MONTH_FIELD).value,'day':$(RegUtil.DAY_FIELD).value,'year':$(RegUtil.YEAR_FIELD).value,'email':this.normalize_email($('reg_email__').value),'gender':$('sex').value};if(ge('reg_instance'))_L0['reg_instance']=$('reg_instance').value;var pwd=this.normalize_password($('reg_passwd__').value),_L2=ge('reg_passwd2__')?this.normalize_password($('reg_passwd2__').value):undefined;var _L3=null;_L3=this.validate_name(_L0['fullname'])||this.validate_birthday(_L0['month'],_L0['day'],_L0['year'])||this.validate_email(_L0['email'])||this.validate_password(pwd,_L2)||this.validate_gender(_L0['gender']);_L0['error_code']=_L3||-1;var req=new AsyncRequest().setURI('/ajax/register/logging.php').setData(_L0).setReadOnly(true).send();return !_L3;};RegUtil.prototype.finish_captcha=function(){if($('captcha_response').value){this.register();}else{this.show_error('captcha_response',_tx("Text v okne nie je zadan\u00fd spr\u00e1vne."));return;}};RegUtil.prototype.register=function(){this.show_progress();$('reg').submit();};RegUtil.prototype.show_captcha=function(){this.hide_reg_form();create_captcha();show('reg_captcha');if(ge('tos_container'))CSS.removeClass($('tos_container'),'hidden_elem');if(ge('reg_pages_msg'))hide($('reg_pages_msg'));if(ge('reg_captcha_buttons'))show('reg_captcha_buttons');if(ge('captcha_buttons'))show('captcha_buttons');try{$('captcha_response').focus();}catch(ignore){}};RegUtil.prototype.hide_captcha=function(){hide('reg_captcha');if(ge('tos_container'))CSS.addClass($('tos_container'),'hidden_elem');if(ge('reg_captcha_buttons'))hide('reg_captcha_buttons');if(ge('captcha_buttons'))hide('captcha_buttons');this.hide_error();};RegUtil.prototype.show_progress=function(msg){this.hide_error();this.hide_reg_form();this.hide_captcha();if(msg)DOM.setContent($('progress_msg'),HTML(msg));show('reg_progress');};RegUtil.prototype.hide_progress=function(){hide('reg_progress');};RegUtil.prototype.attach_error_to_field=function(_L0,msg){var _L2=[];var _L3='UIErrorFlag';if(_L0 instanceof Array){_L3+=' UIErrorFlag_MultiField';for(var k=0;k<_L0.length;k++)_L2[k]=$(_L0[k]);}else _L2[0]=$(_L0);var _L5=$N('div',{className:'UIErrorFlag_Inner'});_L5.innerHTML=msg;var _L6=$N('div',{className:_L3},_L5);var _L7=(_L2[0].parentNode.offsetWidth)+8;var _L8=_L7+'px';var _L9=(_L7+7)+'px';var _La='left';if(intl_locale_is_rtl()){_La='right';_L6.style.right=_L9;}else _L6.style.left=_L9;DOM.insertAfter(_L2[0],_L6);for(var k=0;k<_L2.length;k++)CSS.addClass(_L2[k].parentNode,'error_field');animation(_L6).from(_La,_L9).to(_La,_L8).duration(300).ease(function(p){return -1*Math.sin(11*p);}).go();};RegUtil.prototype.show_error=function(_L0,msg){if(_L0==undefined)_L0='';if(ge('reg_pages_msg'))CSS.addClass($('reg_pages_msg'),'hidden_elem');var _L2=CSS.hasClass(document.body,'registration');if(_L0&&_L2){this.hide_error();this.attach_error_to_field(_L0,msg);}if(_L0){if(_L0=='captcha_response'){this.show_captcha();}else this.show_reg_form();try{$(_L0).focus();}catch(ignore){}}if(!_L2||!_L0){var _L3=$('reg_error');var _L4=$('reg_error_inner');try{if(ge('name')){$('name').focus();}else $('firstname').focus();}catch(ignore){}if(_L0!='captcha_response')this.show_reg_form();if(typeof animation=='function'){DOM.setContent(_L4,HTML(msg));CSS.setOpacity(_L3,0);animation(_L3).show().to('height','auto').duration(100).checkpoint().from('opacity',0).to('opacity',1).duration(400).go();}else show(_L3);}};RegUtil.prototype.hide_error=function(){if(shown($('reg_error'))&&CSS.getOpacity($('reg_error'))>0)hide($('reg_error'));var _L0=DOM.scry(document,'div.error_field');_L0.each(function(c){CSS.removeClass(c,'error_field');});var _L1=DOM.scry(document,'div.UIErrorFlag');_L1.each(function(e){DOM.remove(e);});};RegUtil.prototype.show_reg_form=function(){show('reg_form_box');if(ge('reg_pages_msg'))show($('reg_pages_msg'));};RegUtil.prototype.hide_reg_form=function(){hide('reg_form_box');};RegUtil.prototype.normalize_name=function(_L0){_L0=_L0.replace(/^\s+|\s+$/g,'');_L0=_L0.replace(/\s+/g,' ');return _L0;};RegUtil.prototype.normalize_email=function(_L0){return _L0;};RegUtil.prototype.normalize_password=function(pwd){return pwd;};RegUtil.prototype.validate_name=function(_L0,_L1){var _L2=2;var _L3=4;var _L4=_L0?_L0.split(' '):[];var _L5=null;var _L6=null;if(!_L0){if(_L1)return true;_L5=_tx("Pros\u00edm zadajte svoje cel\u00e9 meno.");}else if(ge('firstname')&&(!$('firstname').value||!$('lastname').value)){_L5=_tx("Mus\u00edte zada\u0165 svoje cel\u00e9 meno.");}else if(_L4.length==2&&_L4[0]==_L4[1]){_L5=_tx("Mus\u00edte zada\u0165 svoje cel\u00e9 meno.");}else if(_L4.length>_L3)_L5=_tx("Meno obsahuje pr\u00edli\u0161 ve\u013ea slov.");if(!_L5)for(word in _L4){len=word.length;if(len==1)continue;c=word[len-1];if('A'<=c&&c<='Z')_L5=_tx("Meno obsahuje pr\u00edli\u0161 ve\u013ea ve\u013ek\u00fdch p\u00edsmen.");}if(_L5){this.show_error('name',_L5);_L6=10;}return _L6;};RegUtil.prototype.validate_email=function(_L0){var _L1=null;var _L2=null;if(!_L0){_L1=_tx("Zadajte svoju e-mailov\u00fa adresu");_L2=12;}else if(_L0.indexOf('@')==-1){_L1=_tx("Zadajte platn\u00fa e-mailov\u00fa adresu");_L2=16;}else{var _L3=_L0.split('@');var _L4=_L3[1];if(_L4=='facebook.com'){_L1=_tx("Vlo\u017ete va\u0161u osobn\u00fa e-mailov\u00fa adresu, pros\u00edm.");_L2=50;}}if(_L1)this.show_error('reg_email__',_L1);return _L2;};RegUtil.prototype.validate_gender=function(_L0){var _L1=null;var _L2=null;if(_L0!=RegUtil.genderMale&&_L0!=RegUtil.genderFemale){_L1=_tx("Vyberte bu\u010f Mu\u017e alebo \u017dena.");_L2=43;}if(_L1)this.show_error('sex',_L1);return _L2;};RegUtil.prototype.validate_password=function(pwd,_L1){var _L2=6;var _L3=['password','facebook'];var _L4=null;var _L5=null;var _L6=null;if(!pwd){_L4=_tx("Vytvorte heslo pre Facebook");_L6=6;}else if(pwd.length<_L2){_L4=_tx("Heslo mus\u00ed ma\u0165 minim\u00e1lne 6 znakov.");_L6=8;}else if(_L1!=undefined&&pwd!=_L1){_L4=_tx("Hesl\u00e1 sa nezhoduj\u00fa. Sk\u00faste to znova.");_L6=40;}else{var _L5=this.get_full_name();var _L7=_L5.toLowerCase().split(' ');var _L8=_L7.concat(_L3);for(var i=0;i<_L8.length;++i)if(pwd.toLowerCase()==_L8[i]){_L4=_tx("Va\u0161e heslo by malo by\u0165 bezpe\u010dnej\u0161ie.");_L6=9;break;}}if(_L4)this.show_error('reg_passwd__',_L4);return _L6;};RegUtil.prototype.get_full_name=function(){if(ge('name'))return this.normalize_name($('name').value);return this.normalize_name($('firstname').value+' '+$('lastname').value);};RegUtil.prototype.validate_birthday=function(_L0,day,_L2){var _L3=null;var _L4=null;if(_L0==-1||day==-1||_L2==-1){_L3=_tx("Zadajte pros\u00edm v\u00e1\u0161 cel\u00fd n\u00e1tum narodenia.");}else if(_L2<=1910)_L3=_tx("Pros\u00edm vlo\u017ete v\u00e1\u0161 skuto\u010dn\u00fd d\u00e1tum narodenia.");if(_L3){this.show_error(RegUtil.monthField,_L3);_L4=15;}return _L4;};RegUtil.prototype.set_topper_content=function(_L0){DOM.replace($('UIContentTopper'),HTML(_L0));};RegUtil.prototype.show_reg_area=function(){CSS.removeClass($('simple_registration_container'),'hidden_elem');};RegUtil.prototype.hide_reg_area=function(){CSS.addClass($('simple_registration_container'),'hidden_elem');};RegUtil.prototype.show_openid_area=function(){if(ge('openid_welcome_area'))CSS.removeClass($('openid_welcome_area'),'hidden_elem');};RegUtil.prototype.hide_openid_area=function(){if(ge('openid_welcome_area'))CSS.addClass($('openid_welcome_area'),'hidden_elem');};RegUtil.prototype.set_form_field=function(_L0,_L1){if(ge(_L0))$(_L0).value=_L1;};RegUtil.prototype.set_openid_field=function(_L0){$('openid_token').value=_L0;};function RegKeyPressListen(_L0){var _L1=ge('reg_form_box');if(_L1)_L1.listen('keypress',function(_L2){if(_L2.keyCode==KEYS.RETURN&&shown(_L1)){if(_L0){RegUtil.getInstance().ajax_validate_data({ignore:['captcha']});}else RegUtil.getInstance().get_captcha();return false;}});}function CaptchaBoxKeyPressListen(_L0,_L1,_L2){var _L3=ge('reg_captcha');if(_L3)_L3.listen('keypress',function(_L4){if(_L4.keyCode==KEYS.RETURN&&shown(_L3)){if(_L0){RegUtil.getInstance().ajax_validate_data(null,_L1,_L2);}else RegUtil.getInstance().finish_captcha();return false;}});}function regform_focused(_L0){if(!regform_focused.called){var _L1='';if(ge('reg_instance'))_L1=$('reg_instance').value;new AsyncRequest().setURI('/ajax/register/logging.php').setData({action:_L0,reg_instance:_L1}).setOption('asynchronous',false).setReadOnly(true).send();regform_focused.called=true;}}function regform_listen_focus(_L0,_L1){var _L2=ge(_L0);if(_L2){var _L3=fireonce(function(){return regform_focused(_L1);});Event.listen(_L2,'click',_L3);Event.listen(_L2,'keypress',_L3);}}

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