var FamiliarizeMode=StudyMode.extend({initialize:function(b){this.timer=false;this.terms=b;
this.showing="definition";this.hiding="word";this.termIndex=0;this.curTerm=this.terms[this.termIndex];
document.onkeydown=this.keyPress.bind(this);document.onkeyup=this.endWhile.bind(this);
var a=$("next-button");a.onmousedown=this.startWhile.pass(this.changeCard.pass("next",this),this);
a.onmouseup=a.onmouseout=this.endWhile.bind(this);a=$("previous-button");a.onmousedown=this.startWhile.pass(this.changeCard.pass("prev",this),this);
a.onmouseup=a.onmouseout=this.endWhile.bind(this);$("term-first").onclick=$("show-both").onclick=this.showCard.bind(this);
$("toggle-button").onclick=this.toggleTerms.bind(this);this.showCard()},showCard:function(){if($("navButtons").hasClass("dnone")){return
}this.showing=$("term-first").checked?"word":"definition";this.hiding=this.showing=="word"?"definition":"word";
var a=$("outer-word").setHTML(""),d=$("show-both").checked,e=this.getSide(this.showing),b=d?this.getSide(this.hiding):false,c=$("editLink");
if(this.curTerm.can_edit){$("editButtons").addClass("dnone");$("navButtons").removeClass("dnone");
$("editLink").setStyle("visibility","visible").onclick=this.editThis.bind(this);$("cantEdit").setStyle("visibility","hidden")
}else{if(c){c.style.visibility="hidden";$("cantEdit").style.visibility="visible"}}if(d){a.adopt(e.addClass("hr"),b)
}else{a.adopt(e)}$("completed").innerHTML=(this.termIndex+1)+"/"+this.terms.length+"		<div><span style='width: "+((this.termIndex+1)/this.terms.length*100)+"%'></span></div>";
$("next-button").className=(this.termIndex+1==this.terms.length)?"disabled":"";$("previous-button").className=(this.termIndex==0)?"disabled":"";
$("toggle-button").className=$("show-both").checked?"disabled":""},getSide:function(a){return new Element("div").setStyle("font-size",this.calcFontSize(this.curTerm[a])).setHTML(this.display_item(this.curTerm,a,"m"))
},toggleTerms:function(){if($("show-both").checked||$("navButtons").hasClass("dnone")){return false
}this.showing=this.showing=="word"?"definition":"word";var a=$("toggle-button");a.innerHTML=a.innerHTML=="Show Term"?"Show Definition":"Show Term";
$("outer-word").setHTML("").adopt(this.getSide(this.showing))},changeCard:function(a){if(a=="next"&&this.termIndex!=this.terms.length-1){this.termIndex++
}else{if(a=="prev"&&this.termIndex!=0){this.termIndex--}else{return false}}this.curTerm=this.terms[this.termIndex];
this.showCard();return false},keyPress:function(c){var a=c||window.event,b=a.srcElement||a.target;
if((b.value&&b.type!="checkbox")||a.metaKey){return true}switch(a.keyCode){case 37:case 80:case 65:this.startWhile(this.changeCard.pass("prev",this));
return false;break;case 39:case 78:case 68:this.startWhile(this.changeCard.pass("next",this));
return false;break;case 38:case 83:case 87:case 40:this.toggleTerms();return false;
break}return true},startWhile:function(a,b){a();this.endWhile();if(arguments.length==1){b=450
}if(b>40){b*=0.9}this.timer=setTimeout(this.startWhile.pass([a,b],this),b)},endWhile:function(){clearTimeout(this.timer)
},editThis:function(){$("editButtons").removeClass("dnone");$("navButtons").addClass("dnone");
$("editLink").setStyle("visibility","hidden");$("cancel-edit").onclick=this.cancelEdit.bind(this);
$("save-edit-button").onclick=this.saveEdit.bind(this);var d=$("show-both").checked,b=$("term-first").checked,f=new Element("input",{type:"text",value:this.curTerm[this.showing],"class":"value",id:"editing-"+this.showing,styles:{"font-size":this.calcFontSize(this.curTerm[this.showing])}}),c=d?new Element("input",{type:"text",value:this.curTerm[this.hiding],"class":"value",id:"editing-"+this.hiding,styles:{"font-size":this.calcFontSize(this.curTerm[this.hiding])}}):false,e=new Element("form",{method:"get",action:""}).adopt(f);
if(d){f.setStyle("margin-bottom","3px");e.adopt(c)}e.adopt(new Element("input",{"class":"dnone",type:"submit"}));
e.onsubmit=this.saveEdit.bind(this);$("outer-word").setHTML("").adopt(e);if(this.curTerm.photo){var a=$("editing-definition");
if(a){new Element("div").setHTML(this.display_item(this.curTerm,"photo_only","m")).injectBefore(a)
}}f.focus();return false},saveEdit:function(){this.parent({word:(x=$("editing-word"))?x.value:this.curTerm.word,definition:(x=$("editing-definition"))?x.value:this.curTerm.definition,curTerm:this.curTerm,onFail:this.cancelEdit.bind(this),onComplete:function(a){var c=$("editing-word");
if(c){this.curTerm.word=this.terms[this.termIndex].word=c.value}c=$("editing-definition");
if(c){this.curTerm.definition=this.terms[this.termIndex].definition=c.value}c=$("editSave");
if(c){c.remove()}c=new Element("div").setProperty("id","editSave").appendText(a).injectAfter("editLink");
var b=new Fx.Style(c,"opacity",{duration:2200});b.start.pass([1,0],b).delay(800,b);
this.cancelEdit()}.bind(this)});return false},cancelEdit:function(){$("editButtons").addClass("dnone");
$("navButtons").removeClass("dnone");$("editLink").style.visibility="visible";var a=$("term-first").checked?this.showing=="definition":this.showing=="word";
this.showCard();if(a){this.toggleTerms()}return false},calcFontSize:function(b){var a=b.length;
return((a<15)?40:(a<25)?32:(a<60)?24:16)+"px"}});