YAHOO.watchValue=function(g){var c=Math.round(g/100)%10;var e=(g-(g%1000))/1000;var f=e%60;var b=(e-f)/60;var d=b%60;var a=(b-d)/60;return{toTime:function(){var h=["s"];if(c){h.unshift(c);h.unshift(".")}h.unshift(f);if(b>0){h.unshift("m:");h.unshift(d)}if(a){h.unshift("h:");h.unshift(a)}return h.join("")}}};YAHOO.stopwatch=function(){var b=0;var c=0;var a=0;return{toTime:function(){return YAHOO.watchValue(b).toTime()},start:function(){if(!this.running){this.running=true;c=new Date().getTime()}return this},stop:function(){if(this.running){this.running=false;a=new Date().getTime();b+=a-c}return this},running:false,time:function(){return b},reset:function(){this.stop();c=0;a=0;b=0}}}();(function(){var n=YAHOO.util.Event,h=YAHOO.util.Dom,e=YAHOO.lang,d=YAHOO.util.Cookie,o=YAHOO.util.KeyListener,g=YAHOO.util.Dom.get;var j=g("source");var q={each:function(r,t){for(var s=0;s<r.length;s++){t(r[s],s)}return r},collect:function(r,t){var s=[];this.each(r,function(v,u){s.push(t(v,u))});return s},map:function(r,u,s){var t=[];this.each(r,function(w,v){if(u(w,v)){t.push(s(w,v))}});return t}};var c=function(r){return q.map(r,function(s){return(s.replace(/\s*/,"").length>0)},function(s){return s.replace(/\s*/,"")})};var k={fixationsPerLine:3,wordsPerFixation:3,wpm:300,avgWordLength:5.1,fontSize:18,scrollable:true,playing:false,linesShowing:1,lineHeight:1.4,longestFragment:0,centerScrolling:true,scrollType:"topScroll",sourceClass:"default-style"};var b={wasPlaying:false};var a=1000;var m;var f=readingSource.word_count;var p=function(){m=1;g("source").innerHTML="";var r=[];k.longestFragment=0;k.longestWord=0;q.each(readingSource.text,function(w){var v=c(w);r.push("<p>");for(var s=0,t=1;s<v.length;s++,m++,t++){r.push("<span id='section_");r.push(m);r.push("'");var u=v[s]?v[s]:"";while(v[s+1]&&(u.length+v[s+1].length)<=((k.avgWordLength*k.wordsPerFixation)+(k.avgWordLength/2))){s++;u+=" "+v[s]}if(k.longestFragment<u.length){k.longestFragment=u.length}if(((t%k.fixationsPerLine)==0)||(s==v.length-1)){r.push("class='last' ")}r.push(">");r.push(u);r.push("</span> ");if((t%k.fixationsPerLine)==0){r.push("<br /> ")}}r.push("</p>")});j.innerHTML=r.join("")+"<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>"};h.addClass(g("section_1"),"showing");var l=0;var i;n.onDOMReady(function(){var L=false;var E=YAHOO.stopwatch;var s=["fixationsPerLine","wordsPerFixation","wpm","fontSize","scrollable","linesShowing","lineHeight","centerScrolling","scrollType","sourceClass"];k.anim=new YAHOO.util.Scroll("source",{scroll:{to:[0,0]}},1);k.anim.animate();var N=d.get("aSettings");if(N){q.each(s,function(T){k[T]=d.getSub("aSettings",T)});k.scrollable=(k.scrollable=="true");k.centerScrolling=(k.centerScrolling=="true")}var H=function(){d.setSubs("aSettings",k,{expires:new Date("January 1, 2025"),path:"/",domain:"eyercize.com"})};var P=function(){if(l<m){K(l+1)}else{Q();r.set("checked",false);congratulations()}};congratulations=function(){var W=function(){this.hide()};YAHOO.stopwatch.stop().time();var Y=Math.round((f*60000)/YAHOO.stopwatch.time());var X="Congratulations, you read "+f+" words at approx: "+Y+"wpm in "+YAHOO.stopwatch.toTime()+"<Br />";var V=YAHOO.stopwatch.time();var T=f*300;X+="You read the text ";if(V>T){X+=YAHOO.watchValue(V-T).toTime()+" slower "}else{X+=YAHOO.watchValue(T-V).toTime()+" faster "}X+="than average.";E.reset();var U=new YAHOO.widget.SimpleDialog("congratulation",{width:"300px",fixedcenter:true,visible:false,draggable:true,close:true,text:X,icon:YAHOO.widget.SimpleDialog.ICON_HELP,constraintoviewport:true,buttons:[{text:"Ok",handler:W,isDefault:true}]});U.setHeader("Congratulations");U.render("congrats");U.show()};var B=function(){var U=function(){this.hide()};var T=new YAHOO.widget.SimpleDialog("stats",{width:"300px",fixedcenter:true,visible:false,draggable:true,close:true,text:"This text consists of "+f+" words<Br />Out of which "+readingSource.unique_word_count+" are unique<Br />"+readingSource.most_common_count+" words are among the most common words in the English language.",constraintoviewport:true,buttons:[{text:"Ok",handler:U,isDefault:true}]});T.setHeader("Text Statistics");T.render("congrats");T.show()};var K=function(T){h.removeClass(g("section_"+l),"showing");if(h.hasClass("section_"+l,"last")){M(T)}l=T;h.addClass(g("section_"+l),"showing")};var M=function(W){if(k.scrollable==true){var T=k.anim.getAttribute("scroll")[1];var V=k.linesShowing*k.fontSize*k.lineHeight;var U=h.getY("section_"+W)-h.getY("section_1");if(k.scrollType=="pageMode"&&k.linesShowing>1){if((U-T)>(V-4)||(U<T)){k.anim.setAttribute("scroll",[0,U],"px")}}else{if(k.linesShowing>2&&k.scrollType=="centerScroll"){U-=((k.linesShowing-(2-(k.linesShowing%2)))*(k.fontSize*k.lineHeight))/2}k.anim.setAttribute("scroll",[0,U],"px")}}};var J=function(){Q();E.reset();y()};var Q=function(){I();M(1);K(1)};function w(){return(60000/k.wpm)*k.wordsPerFixation}var C=function(){g("source").style.fontSize=k.fontSize+"px";var U="648px";var T=((k.wordsPerFixation*k.fixationsPerLine)+(k.wordsPerFixation*k.fixationsPerLine*k.avgWordLength*k.fontSize))/648;if(T>1.82){U=((k.wordsPerFixation*k.fixationsPerLine*k.avgWordLength*0.55)+1)+"em"}g("source").style.width=U;h.setStyle("source","lineHeight",k.lineHeight);h.setStyle("source","height",k.linesShowing*(k.fontSize*k.lineHeight)+"px");H()};var y=function(T){E.start();if(!i){i=setInterval(P,w());k.playing=true;r.set("checked",true);r.set("label","Stop");return i}return false};var I=function(){i=clearInterval(i)||false;k.playing=false;r.set("checked",false);r.set("label","Play");E.stop()};n.on("source","dblclick",function(U){var T=n.getTarget(U);if(T.id.match(/section_(\d*)/)){var V=parseInt(T.id.match(/section_(\d*)/)[1]);K(V);M(V)}});var F=0;var t=160;var u=10;var O=20;var A=function(U,W){var V=YAHOO.widget.Slider.getHorizSlider(U,"slider-"+U+"-thumb",F,t);V.firstTime=true;V.getRealValue=W.getRealValue;var T=W.setValue||20;try{T=W.setTranslatedValue()}catch(X){}V.setValue(T);V.subscribe("slideStart",W.slideStart||I);V.subscribe("slideEnd",W.slideEnd||p);V.subscribe("change",function(Y){h.get("slider-"+U).innerHTML=k[U]=V.getRealValue();if(f<1000){C()}});return V};var G=A("wpm",{getRealValue:function(){if(this.getValue()<=100){return Math.round(this.getValue()*u*1.5+100)}else{return 1700+Math.round((this.getValue()-100)*55)}},slideEnd:function(){if(!this.firstTime){if(b.wasPlaying){y()}H()}else{p();this.firstTime=false}},slideStart:function(){b.wasPlaying=k.playing;I()},setTranslatedValue:function(U){var T=U||k.wpm;if(T>1600){return((T-1700)/55)+100}return(T-100)/15}});A("wordsPerFixation",{getRealValue:function(){return Math.round(this.getValue()/10+1)},slideEnd:function(){if(!this.firstTime){p();C();M(l)}else{this.firstTime=false}},setTranslatedValue:function(U){var T=U||k.wordsPerFixation;return(T-1)*10}});A("fixationsPerLine",{getRealValue:function(){return Math.round(this.getValue()/20+1)},slideEnd:function(){if(!this.firstTime){p();M(l)}else{this.firstTime=false}},setTranslatedValue:function(U){var T=U||k.fixationsPerLine;return(T-1)*20}});A("fontSize",{getRealValue:function(){return Math.round(this.getValue()/5+10)},setValue:40,slideEnd:function(){if(!this.firstTime){C();M(l)}else{this.firstTime=false}},setTranslatedValue:function(U){var T=U||k.fontSize;return(T-10)*5}});A("lineHeight",{getRealValue:function(){return((Math.round(this.getValue()/5)/10)+1)},setValue:0,slideEnd:function(){if(!this.firstTime){C();M(l)}else{this.firstTime=false}},setTranslatedValue:function(U){var T=U||k.lineHeight;return(T-1)*50}});A("linesShowing",{getRealValue:function(){return Math.round(this.getValue()/5+1)},setValue:1,slideEnd:function(){if(this.firstTime){this.firstTime=false;p()}C();M(l)},setTranslatedValue:function(U){var T=U||k.linesShowing;return(T-1)*5}});var r=new YAHOO.widget.Button("startBtn",{label:"Play",checked:false});r.on("click",function(T){if(k.playing){I()}else{y()}});new YAHOO.widget.Button("restartBtn",{label:"Restart",onclick:{fn:function(){J()}}});var R={p:function(){k.playing?I():y()},r:J,s:I,a:function(){z.set("checked",!z.get("checked"));R.ab()},ab:function(){if(z.get("checked")){h.addClass("autoscroll","yui-checkbox-button-checked")}else{h.removeClass("autoscroll","yui-checkbox-button-checked")}k.scrollable=z.get("checked");H()},h:function(){if(h.hasClass("source","default-style")){k.sourceClass="no-style";h.removeClass("source","default-style")}else{h.addClass("source","default-style");k.sourceClass="default-style"}H()},plus:function(){G.setValue(G.getValue()+5)},minus:function(){G.setValue(G.getValue()-5)},holder:[],disable:function(){for(var T=0;T<this.holder.length;T++){this.holder[T].disable()}},enable:function(){for(var T=0;T<this.holder.length;T++){this.holder[T].enable()}}};var D=function(V,U,T){k.scrollType=T.value;H()};var S=[{text:"Top Scroll",value:"topScroll",onclick:{fn:D}},{text:"Center Scroll",value:"centerScroll",onclick:{fn:D}},{text:"Page Mode",value:"pageMode",onclick:{fn:D}}];var x=new YAHOO.widget.SimpleDialog("new_text_dialog",{width:"580px",fixedcenter:true,visible:true,draggable:true,close:false,constraintoviewport:true,postmethod:"form"});x.cfg.queueProperty("buttons",[{text:"Now Read It!",handler:function(){R.enable();this.submit()},isDefault:true},{text:"Cancel",handler:function(){R.enable();this.cancel()}}]);h.setStyle("new_text_dialog","display","block");if(!h.hasClass("source",k.sourceClass)){h.removeClass("source","default-style");h.addClass("source",k.sourceClass)}var v=new YAHOO.widget.Button("newtext",{label:"New",onclick:{fn:function(){R.disable();x.render();x.show()}}});var z=new YAHOO.widget.Button("autoscroll",{label:"Autoscrolling",type:"split",menu:S,checked:(k.scrollable==true),onclick:{fn:R.a}});R.ab();R.holder.push(new o(document,{keys:80},{fn:R.p}));R.holder.push(new o(document,{keys:72},{fn:R.h}));R.holder.push(new o(document,{keys:83},{fn:R.s}));R.holder.push(new o(document,{keys:65},{fn:R.a}));R.holder.push(new o(document,{keys:82},{fn:R.r}));R.holder.push(new o(document,{keys:73},{fn:R.plus}));R.holder.push(new o(document,{keys:68},{fn:R.minus}));R.enable();n.on("statsBtn","click",B)})})();