if(!window.Kidzbop)Kidzbop={};Kidzbop.SignUp={setGender:function(gender){$$('.gender a').each(function(el){el.removeClassName('selected');});var selected=$('gender_'+gender);if(selected){selected.addClassName('selected');}
$('user_sex').value=gender;},checkUsername:function(){if($('signup-username').value.length<4){return this.setErrorMessage('login-check',false,'Oops! You need to create a membername.');}else if($('signup-username').value.match(/[^a-zA-Z0-9\-_]/)){return this.setErrorMessage('login-check',false,'Oops! Your membername can include only letters and numbers.');}
new Ajax.Request('/join/username_available',{asynchronous:false,evalScripts:true,parameters:{login:$('signup-username').value}});return true;},checkPassword:function(still_typing){if($('signup-username').value==$('signup-password').value){return this.setErrorMessage('pass-check',false,'Oops! You need to create a password.');}else if(!still_typing&&$('signup-password').value.length<4){return this.setErrorMessage('pass-check',false,'Oops! You need to create a password.');}else if(!still_typing){return this.setErrorMessage('pass-check',true,'Cool now be sure to remember it!');}else{return this.resetErrorMessage('pass-check');}},checkPasswordConfirm:function(on_submit){if($('signup-password').value==""){return this.setErrorMessage('pass_confirm-check',false,'Oops! You need to create a password.');}
else if($('signup-password').value==$('signup-password-confirm').value){return this.setErrorMessage('pass_confirm-check',true,'Good memory. It\'s a match!');}else{return this.setErrorMessage('pass_confirm-check',false,'Oops! It didn\'t match. Please retype.');}},checkGender:function(){if($('user_sex').value!='boy'&&$('user_sex').value!='girl'){return this.setErrorMessage('gender-check',false,'Oops! You forgot to tell us.');}else{return this.resetErrorMessage('gender-check');}},checkBirthDate:function(){if($('user_birth_date_1i').value==''||$('user_birth_date_2i').value==''||$('user_birth_date_3i').value==''){return this.setErrorMessage('birth_date-check',false,'Oops! You forgot to tell us.');}else{return this.resetErrorMessage('birth_date-check');}},checkParentEmail:function(under_thirteen){if(under_thirteen){if($('parents_email').value==''){return this.setErrorMessage('parent_email-check',false,'Oops! You forgot to tell us.');}else if(!isEmailValid($('parents_email').value)){return this.setErrorMessage('parent_email-check',false,'Oops! That\'s not a real email. Please re-enter.');}else{this.emailIsBanned('parents_email','parent_email-check','Thanks we\'ll be in touch with them.');return true;}}else{return true;}},checkParentEmailConfirm:function(under_thirteen){if(under_thirteen){if($('parents_email').value==""&&$('parents_email_confirm').value==""){return this.setErrorMessage('parent_email_confirm-check',false,'Oops! You forgot to tell us.');}else if($('parents_email').value!=$('parents_email_confirm').value){return this.setErrorMessage('parent_email_confirm-check',false,'Oops! they don\'t match. Please re-type.');}else{return this.setErrorMessage('parent_email_confirm-check',true,'Good memory. It\'s a match!');}}else{return true;}},checkUserEmail:function(under_thirteen){if(under_thirteen){if($('user_email').value!=''){if(!isEmailValid($('user_email').value)){return this.setErrorMessage('user_email-check',false,'Oops! That\'s not a real email. Please re-enter.');}else if($('user_email').value==$('parents_email').value){return this.setErrorMessage('user_email-check',false,'Oops! That\'s the same email as your parent.');}else{this.emailIsBanned('user_email','user_email-check','Thanks we\'ll be in touch with you!');return true;}}else{return this.resetErrorMessage('user_email-check');}}else{if($('user_email').value==''){return this.setErrorMessage('user_email-check',false,'Oops! You forgot to tell us.');}else if(!isEmailValid($('user_email').value)){return this.setErrorMessage('user_email-check',false,'Oops! That\'s not a real email. Please re-enter.');}else{this.emailIsBanned('user_email','user_email-check','Thanks we\'ll be in touch with you!');return true;}}},checkUserEmailConfirm:function(under_thirteen){if($('user_email').value==''&&$('user_email_confirm').value==''){if(under_thirteen){return this.resetErrorMessage('user_email_confirm-check');}else{return this.setErrorMessage('user_email_confirm-check',false,'Oops! You forgot to tell us.');}}else{if($('user_email').value==$('user_email_confirm').value){return this.setErrorMessage('user_email_confirm-check',true,'Good memory. It\'s a match!');}else{return this.setErrorMessage('user_email_confirm-check',false,'Oops! they don\'t match. Please re-type.');}}},emailIsBanned:function(element_id,element_info_id,success_message){new Ajax.Request('/join/email_is_banned',{asynchronous:false,evalScripts:true,parameters:{email:$(element_id).value,element_info_id:element_info_id,success_message:success_message}});},validateStep1:function(){return!!(this.checkUsername()&this.checkPassword()&this.checkPasswordConfirm()&this.checkGender()&this.checkBirthDate());},validateStep2:function(under_thirteen){return!!(this.checkParentEmail(under_thirteen)&this.checkParentEmailConfirm(under_thirteen)&this.checkUserEmail(under_thirteen)&this.checkUserEmailConfirm(under_thirteen));},showSpinner:function(element_id){Element.replace(element_id,'<img src="/images/spinner.gif" id="spinner" />');},setErrorMessage:function(error_id,success,message){var error_container=$(error_id);if(error_container){if(success){error_container.update('<p class="success">'+message+'</p>');}else{error_container.update('<p class="error">'+message+'</p>');}}
return success;},resetErrorMessage:function(error_id){var error_container=$(error_id);if(error_container){error_container.update('');}
return true;},tooglePadlock:function(padlock_id,bar){$(padlock_id).toggle();Element.extend(bar);bar.toggleClassName('active');}};Kidzbop.Parents={goToParentsSection:function(link,element_id){if(scrollbar){scrollbar.scrollToElement(element_id);}
$$('.parents_left_nav li a').each(function(e){e.className='';});link.className='active';},checkParentFeedbackFrom:function(form_id){var form_ok=true;error_message='';var form=$(form_id);if(form.email.value==''||!isEmailValid(form.email.value)){form_ok=false;$('email_error').show();}else{$('email_error').hide();}
if(form.fe_message.value.length<1){form_ok=false;$('comment_error').show();}else{$('comment_error').hide();}
return form_ok;}};function getElementsByTagNames(list,obj){if(!obj)obj=document;var tagNames=list.split(',');var resultArray=new Array();for(var i=0;i<tagNames.length;i++){var tags=obj.getElementsByTagName(tagNames[i]);for(var j=0;j<tags.length;j++){resultArray.push(tags[j]);}}
return resultArray;}
if(!Scrolling)var Scrolling={};Scrolling.createScroll=function(scroller_id,scrollbar_id,width,height){var scroller=new Scrolling.Scroller(document.getElementById(scroller_id),width,height,new Scrolling.ScrollTween());var scrollbar=new Scrolling.Scrollbar(document.getElementById(scrollbar_id),scroller,new Scrolling.ScrollTween());return[scroller,scrollbar];};Scrolling.Scrollbar=function(o,s,t){var self=this;var _components={};var _dimensions={};var _temporary={};var _hasTween=t?true:false;var _timer,_ratio;this.onMouseDown=function(){};this.onMouseUp=function(){};this.onScroll=function(){};this.scrollAmount=5;this.scrollSpeed=30;this.disabled=false;function initialize(){var c=_components;var d=_dimensions;var g=s.getDimensions();s.scrollBar=self;c.up=findComponent("Scrollbar-Up",o);c.down=findComponent("Scrollbar-Down",o);c.track=findComponent("Scrollbar-Track",o);c.handle=findComponent("Scrollbar-Handle",c.track);c.spinner=findComponent("Scrollbar-Preloader",o)||false;d.trackTop=findOffsetTop(c.track);d.trackHeight=c.track.offsetHeight;d.handleHeight=c.handle.offsetHeight;d.x=0;d.y=0;if(_hasTween)t.apply(self);addEvent(s.getContent(),"mousewheel",scrollbarWheel);addEvent(o,"mousedown",scrollbarClickPrimer);self.reset();};function findOffsetTop(o){var t=0;if(o.offsetParent){while(o.offsetParent){t+=o.offsetTop;o=o.offsetParent;}}
return t;};function addEvent(o,t,f){if(o.attachEvent)o.attachEvent('on'+t,f);else o.addEventListener(t,f,false);};function removeEvent(o,t,f){if(o.detachEvent)o.detachEvent('on'+t,f);else o.removeEventListener(t,f,false);};function findComponent(c,o){var kids=o.childNodes;for(var i=0;i<kids.length;i++){if(kids[i].className&&kids[i].className.indexOf(c)>=0){return kids[i];}}};function scroll(y){if(y<0)y=0;if(y>_dimensions.trackHeight-_dimensions.handleHeight)
y=_dimensions.trackHeight-_dimensions.handleHeight;_components.handle.style.top=y+"px";_dimensions.y=y;s.scrollTo(0,Math.round(_dimensions.y*_ratio));self.onScroll();};function scrollbarClickPrimer(e){if(self.disabled)return false;e=e?e:event;if(!e.target)e.target=e.srcElement;scrollbarClick(e.target.className,e);};function scrollbarClick(c,e){var d=_dimensions;var t=_temporary;var cy=e.clientY+document.body.scrollTop;if(c.indexOf("Scrollbar-Up")>=0)
startScroll(-self.scrollAmount);if(c.indexOf("Scrollbar-Down")>=0)
startScroll(self.scrollAmount);if(c.indexOf("Scrollbar-Track")>=0)
if(_hasTween)self.tweenTo((cy-d.trackTop-d.handleHeight/2)*_ratio);else scroll(cy-d.trackTop-d.handleHeight/2);if(c.indexOf("Scrollbar-Handle")>=0){t.grabPoint=cy-findOffsetTop(_components.handle);addEvent(document,"mousemove",scrollbarDrag,false);}
t.target=e.target;t.select=document.onselectstart;document.onselectstart=function(){return false;};self.onMouseDown(e.target,c,e);addEvent(document,"mouseup",stopScroll);};function scrollbarDrag(e){e=e?e:event;var d=_dimensions;var t=parseInt(_components.handle.style.top);var v=e.clientY+document.body.scrollTop-d.trackTop;if(v>=d.trackHeight-d.handleHeight+_temporary.grabPoint)
v=d.trackHeight-d.handleHeight;else if(v<=_temporary.grabPoint)
v=0;else v=v-_temporary.grabPoint;scroll(v);};function scrollbarWheel(e){if(self.disabled)return false;e=e?e:event;var dir=0;if(e.wheelDelta>=120)dir=-1;if(e.wheelDelta<=-120)dir=1;self.scrollBy(dir*20);e.returnValue=false;};function startScroll(y){_temporary.disty=y;_timer=window.setInterval(function(){self.scrollBy(_temporary.disty);},self.scrollSpeed);};function stopScroll(e){e=e?e:event;removeEvent(document,"mousemove",scrollbarDrag);removeEvent(document,"mouseup",stopScroll);document.onselectstart=_temporary.select;if(_timer)window.clearInterval(_timer);self.onMouseUp(_temporary.target,_temporary.target.className,e);};this.reset=function(){var d=_dimensions;var c=_components;var g=s.getDimensions();_ratio=(g.theight-g.vheight)/(d.trackHeight-d.handleHeight);var pos=Math.round(g.y/_ratio);c.handle.style.top=pos+"px";c.handle.ondragstart=function(){return false;};c.handle.onmousedown=function(){return false;};s.reset();if(g.theight<g.vheight){this.disabled=true;o.className+=" Scrollbar-Disabled";}};this.scrollTo=function(y){scroll(y/_ratio);};this.scrollBy=function(y){scroll((s.getDimensions().y+y)/_ratio);};this.scrollToElement=function(element_id){var element=$(element_id);if(element){this.scrollTo(element.positionedOffset()[1]);}};this.swapContent=function(n,w,h){o=n;s.swapContent(o,w,h);initialize();};this.disable=function(){this.disabled=true;o.className+="Scrollbar-Disabled";};this.enable=function(){this.disabled=false;o.className=o.className.replace(/Scrollbar\-Disabled/,"");};this.getContent=function(){return s.getContent();};this.getComponents=function(){return _components;};this.getDimensions=function(){var d=s.getDimensions();d.trackHeight=_dimensions.trackHeight;d.handleHeight=_dimensions.handleHeight;return d;};this.showSpinner=function(flag){if(_components.spinner){if(flag){_components.spinner.style.display='block';}else{_components.spinner.style.display='none';}}};this.resetBar=function(){this.reset();};initialize();};if(!Scrolling)var Scrolling={};Scrolling.Scroller=function(o,w,h,t){var list=getElementsByTagNames("div,ul",o);for(var i=0;i<list.length;i++){if(list[i].className.indexOf("Scroller-Container")>-1){o=list[i];}}
var self=this;var _vwidth=w;var _vheight=h;var _o=o;var _twidth=o.offsetWidth;var _theight=o.offsetHeight;var _hasTween=t?true:false;var _requesting=false;var _timer,_x,_y;this.onScrollStart=function(){};this.onScrollStop=function(){};this.onScroll=function(){};this.scrollBar=false;this.scrollSpeed=30;this.preloadDistance=100;this.fetchUrl=false;this.preloadElements=10;this.totalElements=0;this.actualElements=getNumOfItems();this.resetScrollBar=false;function setPosition(x,y){if(x<_vwidth-_twidth)
x=_vwidth-_twidth;if(x>0)x=0;if(y<_vheight-_theight)
y=_vheight-_theight;if(y>0)y=0;if(!_requesting&&self.fetchUrl&&self.actualElements<self.totalElements&&(_theight-_vheight+y)<self.preloadDistance){_requesting=true;self.scrollBar.showSpinner(true);_fetchItemsRequest();}
_x=x;_y=y;o.style.left=_x+"px";o.style.top=_y+"px";};function _fetchItemsRequest(){new Ajax.Request(self.fetchUrl,{method:'get',parameters:'offset='+self.actualElements,requestHeaders:{Accept:'text/html'},onComplete:function(response){_fetchNewItemsResponse(response);}});}
function _fetchNewItemsResponse(response){o.innerHTML+=response.responseText;self.actualElements=getNumOfItems();_twidth=o.offsetWidth;_theight=o.offsetHeight;self.scrollBar.resetBar();_requesting=false;self.scrollBar.showSpinner(false);}
function getNumOfItems(){var num=0;for(var i=0;i<o.childNodes.length;i++){if(o.childNodes[i].nodeName.search(/.*(div|li).*/i)!=-1)num++;}
return num;}
this.setAjaxPreloader=function(url,preloadNum,totalNum,preloadDistance){this.preloadDistance=preloadDistance;this.fetchUrl=url;this.preloadElements=preloadNum;this.totalElements=totalNum;};this.scrollBy=function(x,y){setPosition(_x-x,_y-y);this.onScroll();};this.scrollTo=function(x,y){setPosition(-x,-y);this.onScroll();};this.startScroll=function(x,y){this.stopScroll();this.onScrollStart();_timer=window.setInterval(function(){self.scrollBy(x,y);},this.scrollSpeed);};this.stopScroll=function(){if(_timer)window.clearInterval(_timer);this.onScrollStop();};this.reset=function(){_twidth=o.offsetWidth;_theight=o.offsetHeight;_x=0;_y=0;if(_hasTween)t.apply(this);};this.swapContent=function(c,w,h){o=c;var list=getElementsByTagNames("div,ul",o);for(var i=0;i<list.length;i++){if(list[i].className.indexOf("Scroller-Container")>-1){o=list[i];}}
if(w)_vwidth=w;if(h)_vheight=h;reset();};this.getDimensions=function(){return{vwidth:_vwidth,vheight:_vheight,twidth:_twidth,theight:_theight,x:-_x,y:-_y};};this.getContent=function(){return o;};this.reset();};if(!Scrolling)var Scrolling={};Scrolling.ScrollTween=function(){var self=this;var _steps=[0,25,50,70,85,95,97,99,100];var _values=[];var _idle=true;var o,_inc,_timer;function tweenTo(y){if(!_idle)return false;var d=o.getDimensions();if(y<0)y=0;if(y>d.theight-d.vheight)
y=d.theight-d.vheight;var dist=y-d.y;_inc=0;_timer=null;_values=[];_idle=false;for(var i=0;i<_steps.length;i++){_values[i]=Math.round(d.y+dist*(_steps[i]/100));}
_timer=window.setInterval(function(){o.scrollTo(_values[_inc]);if(_inc==_steps.length-1){window.clearInterval(_timer);_idle=true;}else _inc++;},o.stepSpeed);};function tweenBy(y){o.tweenTo(o.getDimensions().y+y);};function setSteps(s){_steps=s;};this.apply=function(p){o=p;o.tweenTo=tweenTo;o.tweenBy=tweenBy;o.setSteps=setSteps;o.stepSpeed=30;};};function scrollToSectionHandler(event){var link=Event.findElement(event,'a');var element_id='l-'+link.href.split('#').last();if(scrollbar){scrollbar.scrollToElement(element_id);}
var linkList=Event.findElement(event,'ul');linkList.select('a').each(function(e){e.className='';});link.className='active';Event.stop(event);}