Component.QuizTabs=Class.create({initialize:function(A){this.element=$(A);
this.period=this.element.readAttribute("period");
this.limit=this.element.readAttribute("limit");
this.quizType=this.element.readAttribute("quizType");
this.element.observe("period:click",this.onPeriodClick.bindAsEventListener(this));
this.element.observe("limit:click",this.onLimitClick.bindAsEventListener(this));
},onPeriodClick:function(A){A.stop();
this.period=A.memo.period;
this.element.select(".subtabsLink").each(function(B){var C=B.readAttribute("period");
if(C==this.period){B.addClassName("selected");
}else{B.removeClassName("selected");
}}.bind(this));
this.refresh();
},onLimitClick:function(A){A.stop();
this.limit=A.memo.limit;
this.element.select(".subtabAction").each(function(C){var B=C.readAttribute("limit");
if(B==this.limit){C.addClassName("selected");
}else{C.removeClassName("selected");
}}.bind(this));
this.refresh();
},refresh:function(){var A={limit:this.limit,period:this.period};
new View.RemoteView(this.element.up("div").down(".quizzes"),{url:Flixster.server+"/quizzes/"+this.quizType,parameters:A});
}});
Component.RandomRecentMyoqsLink=Class.create(Component.Link,{onClick:function(A){A.stop();
new View.RemoteView(this.element.up("div"),{url:Flixster.server+"/quizzes/recent"});
}});
function ChoiceSelector(){this.choices=[];
}ChoiceSelector.prototype={addChoice:function(A){this.choices.push($(A));
Event.observe(A,"click",this.onClick.bind(this));
},onClick:function(B){for(var A=0;
A<this.choices.length;
A++){this.choices[A].removeClassName("selected");
}if(B.target.getElementsByTagName("INPUT")[0]){B.stop();
B.target.getElementsByTagName("INPUT")[0].checked="true";
B.target.addClassName("selected");
}else{B.target.checked="true";
B.target.parentNode.addClassName("selected");
}}};
Component.QuizCommentForm=Class.create(Component.Form,{onSubmit:function(A){A.stop();
var B=this.element.serialize(true);
this.element.down("span").update(B.quizComment);
new Ajax.Request("/quizzes/action/update-comment",{parameters:B,method:"post",onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
this.element.down("blockquote").show();
this.element.down("fieldset").hide();
},onSuccess:function(A){console.log("success!");
},onFailure:function(A){console.log("fail!");
}});
Component.QuizCommentEditLink=Class.create(Component.Link,{onClick:function(A){A.stop();
this.element.up("form").down("blockquote").hide();
this.element.up("form").down("fieldset").show();
}});
Component.MctRating=Class.create({initialize:function(A){this.element=$(A);
this.element.observe("rating:score",this.onRate.bindAsEventListener(this));
this.movie=this.element.readAttribute("movie");
},onRate:function(A){A.stop();
$("score"+this.movie).value=A.memo.score;
}});
Component.Rating=Class.create({initialize:function(A){this.form=$(A);
this.userField=this.form.select("input[name=user]").first();
this.movieField=this.form.select("input[name=movie]").first();
this.scoreField=this.form.select("input[name=score]").first();
this.sourceField=this.form.select("input[name=source]").first();
this.rating={user:$F(this.userField),movie:$F(this.movieField),source:$F(this.sourceField)};
this.form.observe("rating:score",this.onRate.bindAsEventListener(this));
this.form.observe("rating:clear",this.onClear.bindAsEventListener(this));
this.form.observe("review:save",this.onSave.bindAsEventListener(this));
},onRate:function(A){this.rating.score=A.memo.score;
if(this.rating.user==null||this.rating.user.blank()){alert("Install Flixster to Save Ratings!");
}else{if(this.form.down("TEXTAREA")){this.rating.review=$F(this.form.down("TEXTAREA"));
RatingsApi.updateRatingAndReview(this.rating);
}else{RatingsApi.updateRating(this.rating);
}}A.memo.rating=this.rating;
},onClear:function(A){this.rating.score=-1;
this.rating.review="";
RatingsApi.clearRating(this.rating);
A.memo.rating=this.rating;
},onSave:function(A){this.rating.review=$F(this.form.select("TEXTAREA").first());
RatingsApi.updateReview(this.rating);
A.memo.rating=this.rating;
}});
Component.RatingButton=Class.create({SCORE:-1,initialize:function(B,A){this.button=$(B);
this.score=$F(this.button);
this.controller=A?$(A):this.button.up("*[component]");
this.button.observe("click",this.onClick.bindAsEventListener(this));
this.controller.observe("rating:score",this.onRate.bindAsEventListener(this));
this.controller.observe("rating:clear",this.onRate.bindAsEventListener(this));
},onClick:function(A){Event.stop(A);
A.target.fire("rating:score",{score:this.SCORE});
},onRate:function(A){this.score=A.memo.score;
this.button.value=this.score;
this.paint(this.score);
},onClear:function(A){this.score=-1;
this.button.value=this.score;
this.paint(this.score);
}});
Component.RatingWtsButton=Class.create(Component.RatingButton,{SCORE:12,paint:function(A){if(A==this.SCORE){this.button.src=Flixster.server+"/static/images/rating/ws.on.gif";
}else{this.button.src=Flixster.server+"/static/images/rating/ws.off.gif";
}}});
Component.RatingNiButton=Class.create(Component.RatingButton,{SCORE:11,paint:function(A){if(A==this.SCORE){$(this.button).src=Flixster.server+"/static/images/rating/ni.on.gif";
}else{$(this.button).src=Flixster.server+"/static/images/rating/ni.off.gif";
}}});
Component.RatingStars=Class.create(Component.RatingButton,{initialize:function(B,A){this.button=$(B);
this.score=parseInt($F(this.button));
this.controller=A?$(A):this.button.up("*[component]");
this.button.observe("mousemove",this.onMousemove.bindAsEventListener(this));
this.button.observe("mouseout",this.onMouseout.bindAsEventListener(this));
this.button.observe("click",this.onClick.bindAsEventListener(this));
this.controller.observe("rating:score",this.onRate.bindAsEventListener(this));
this.controller.observe("rating:clear",this.onClear.bindAsEventListener(this));
},onMousemove:function(A){this.paint(this.map(A));
},onMouseout:function(A){this.paint(this.score);
},onClick:function(A){A.stop();
var B=this.map(A);
if(B==this.score){B=-1;
}A.target.fire("rating:score",{score:B});
},map:function(E){var C=Event.element(E);
var D=C.cumulativeOffset();
var A=0;
if(E.offsetX){A=E.offsetX;
}else{if(C.offsetX!=null){var B=C.offsetX;
A=E.layerX-B;
}else{if(E.layerX){var B=D[0];
A=E.layerX-B;
C.offsetX=B;
}}}if($R(0,7).include(A)){return 6;
}else{if($R(8,14).include(A)){return 1;
}else{if($R(15,22).include(A)){return 7;
}else{if($R(23,29).include(A)){return 2;
}else{if($R(30,37).include(A)){return 8;
}else{if($R(38,44).include(A)){return 3;
}else{if($R(45,52).include(A)){return 9;
}else{if($R(53,59).include(A)){return 4;
}else{if($R(60,66).include(A)){return 10;
}else{if($R(67,74).include(A)){return 5;
}else{return -1;
}}}}}}}}}}},paint:function(A){switch(A){case 1:$(this.button).src=Flixster.server+"/static/images/rating/1.0.gif";
break;
case 2:$(this.button).src=Flixster.server+"/static/images/rating/2.0.gif";
break;
case 3:$(this.button).src=Flixster.server+"/static/images/rating/3.0.gif";
break;
case 4:$(this.button).src=Flixster.server+"/static/images/rating/4.0.gif";
break;
case 5:$(this.button).src=Flixster.server+"/static/images/rating/5.0.gif";
break;
case 6:$(this.button).src=Flixster.server+"/static/images/rating/0.5.gif";
break;
case 7:$(this.button).src=Flixster.server+"/static/images/rating/1.5.gif";
break;
case 8:$(this.button).src=Flixster.server+"/static/images/rating/2.5.gif";
break;
case 9:$(this.button).src=Flixster.server+"/static/images/rating/3.5.gif";
break;
case 10:$(this.button).src=Flixster.server+"/static/images/rating/4.5.gif";
break;
default:$(this.button).src=Flixster.server+"/static/images/rating/0.0.gif";
}}});
Component.ForgotPassword=Class.create({MARKER_START:'<div id="passwordStatus">',MARKER_END:"</div>",initialize:function(A){this.element=$(A);
this.element.observe("click",this.onClick.bindAsEventListener(this));
},onClick:function(A){var C=$F("userauthEmail");
if(!TextUtils.hasText(C)){$("regStatus").update("Please enter your username or email address below to retrieve your password.");
$("regStatus").style.color="red";
showRow("statusRow");
}else{$("regStatus").update("Retrieving password...");
$("regStatus").style.color="green";
showRow("statusRow");
var B=Form.serialize("forgotPasswordForm")+"&userauthEmail="+C;
new Ajax.Request($("forgotPasswordForm").action,{parameters:B,onSuccess:this.processPasswordResponse.bind(this),onTimeout:this.onTimeout.bind(this),onFailure:this.onFailure.bind(this)});
}},processPasswordResponse:function(A){var D=A.responseText.indexOf(this.MARKER_START)+this.MARKER_START.length;
var B=A.responseText.indexOf(this.MARKER_END,D);
var C=A.responseText.substring(D,B).strip();
$("regStatus").update(C);
showRow("statusRow");
},onTimeout:function(A){$("regStatus").update("Whoops, your request timed out. Please check your network connection and try again.");
$("regStatus").style.color="red";
showRow("statusRow");
},onFailure:function(A){$("regStatus").update("Whoops, our servers coughed.  Please try again.");
$("regStatus").style.color="red";
showRow("statusRow");
}});
Component.BaseQuizShare=Class.create(Component,{initialize:function($super,A){$super(A);
this.friends=A.friends;
this.pendingFriends=A.pendingFriend;
Event.observe("selectAll","click",this.onSelectAll.bindAsEventListener(this));
A.observe("submit",this.onSubmit.bindAsEventListener(this));
A.observe("form:submit",this.onSubmit.bindAsEventListener(this));
},onSelectAll:function(A){if(this.friends!=null){FormUtils.checkAll(this.friends);
}if(this.pendingFriends!=null){FormUtils.checkAll(this.pendingFriends);
}},onSubmit:function(A){return true;
}});
Component.QuizShare=Class.create(Component.BaseQuizShare,{initialize:function($super,A){$super(A);
if($("confirmationToggle")!=null){Event.observe("confirmationToggle","click",this.onToggleConfirmation.bindAsEventListener(this));
}},onToggleConfirmation:function(A){Element.show("friendsPane");
Element.show("submitShare");
Element.hide("confirmation");
},onSubmit:function(A){if(FormUtils.isAtleastOneChecked(this.friends)||FormUtils.isAtleastOneChecked(this.pendingFriends)){return true;
}else{A.stop();
alert("Whoops, you forgot to choose the friends to share with.");
}},getSource:function(){return"Share";
}});
Component.QuizEasyShare=Class.create(Component.BaseQuizShare,{initialize:function($super,C){$super(C);
Event.observe("unselectAll","click",this.onUnselectAll.bindAsEventListener(this));
var B=this.friends.length==undefined?1:this.friends.length;
for(var A=0;
A<B;
A++){Event.observe("thumbnail"+A,"click",this.onThumbnailClick.bindAsEventListener(this));
}},onUnselectAll:function(A){if(this.friends!=null){FormUtils.uncheckAll(this.friends);
}if(this.pendingFriends!=null){FormUtils.uncheckAll(this.pendingFriends);
}},onThumbnailClick:function(C){var B=Event.element(C);
var A=B.id.substring(9);
$("friend"+A).click();
},getSource:function(){return"EasyShare";
}});
Component.QuizShareFromResults=Class.create(Component,{initialize:function($super,A){$super(A);
Event.observe("selectAll","click",this.onSelectAll.bindAsEventListener(this));
A.observe("submit",this.onSubmit.bindAsEventListener(this));
},onSelectAll:function(A){FormUtils.checkAll(this.element.friends);
},onSubmit:function(A){if(FormUtils.isAtleastOneChecked(this.element.friends)){return true;
}else{A.stop();
alert("Whoops, you forgot to choose the friends to share with.");
}}});
var Flixster={};
Flixster.server="";
Component.QuizBasicsForm=Class.create(Component.Form,{onSubmit:function(C){if(!TextUtils.hasText($F("quizTitle"))||$F("quizTitle")==$("quizTitle").readAttribute("default")){new View.ErrorPopup(this.element,{title:"Whoops",content:"Don't forget to give your quiz a name!"});
C.stop();
return false;
}if($F("quizCategory")=="M"){var A=$("associationM").select("input").find(function(D){return D.checked;
});
if(!A){new View.ErrorPopup(this.element,{title:"Whoops",content:"You forgot to tell us which movie this quiz is about."});
C.stop();
return false;
}}else{if($F("quizCategory")=="A"){var B=$("associationA").select("input").find(function(D){return D.checked;
});
if(!B){new View.ErrorPopup(this.element,{title:"Whoops",content:"You forgot to tell us which actor this quiz is about."});
C.stop();
return false;
}}}return true;
}});
Component.QuizCategorySelect=Class.create(Component.Select,{onChange:function(A){switch($F(this.element)){case"G":$("associationM").hide();
$("associationA").hide();
break;
case"M":$("associationA").hide();
$("associationM").show();
break;
case"A":$("associationM").hide();
$("associationA").show();
break;
case"O":$("associationM").hide();
$("associationA").hide();
break;
}}});
var QuestionSearchWidget=Class.create();
QuestionSearchWidget.prototype={STATES:{READY:0,SEARCHING:1},page:1,parameters:"",initialize:function(){Event.observe($("questionSearchField"),"keypress",this.handleEnter.bind(this));
Event.observe($("questionSearchBtn"),"click",this.handleSearchClick.bind(this));
},handleEnter:function(A){if(A.keyCode==Event.KEY_RETURN){this.page=1;
this.handleSearch();
Event.stop(A);
return false;
}else{return true;
}},handleSearchClick:function(){this.page=1;
this.handleSearch();
},handleSearch:function(){this.state=this.STATES.SEARCHING;
this.paint();
this.parameters=Form.serialize("questionSearch");
var A=this.parameters+"&pageNav="+this.page;
new Ajax.Request("/myoq.sv",{parameters:A,onComplete:this.processSearch.bind(this)});
},handlePageClick:function(A){this.state=this.STATES.SEARCHING;
this.paint();
this.page=A;
var B=this.parameters+"&pageNav="+this.page;
new Ajax.Request("/myoq.sv",{parameters:B,onComplete:this.processSearch.bind(this)});
},processSearch:function(A){$("questions").update(A.responseText);
this.state=this.STATES.READY;
this.paint();
},paint:function(){switch(this.state){case this.STATES.READY:$("loading").hide();
$("questions").show();
break;
case this.STATES.SEARCHING:$("questions").hide();
$("loading").show();
break;
}}};
var QuestionAddWidget=Class.create();
QuestionAddWidget.prototype={STATES:{READY:0,SAVING:1,SAVED:2},initialize:function(C,A,B){this.quizId=C;
this.questionId=A;
this.link=B;
Event.observe($(this.link),"click",this.handleAdd.bind(this));
this.state=this.STATES.READY;
this.paint();
},handleAdd:function(){this.state=this.STATES.SAVING;
this.paint();
var A="quizAction=addQuestion&quizId="+quizId+"&questionId="+this.questionId;
new Ajax.Request("/myoq.sv",{parameters:A,onComplete:this.processAdd.bind(this)});
},processAdd:function(A){this.state=this.STATES.SAVED;
this.paint();
},paint:function(){switch(this.state){case this.STATES.READY:$("addLink"+this.questionId).show();
$("savingLink"+this.questionId).hide();
$("savedLink"+this.questionId).hide();
break;
case this.STATES.SAVING:$("addLink"+this.questionId).hide();
$("savedLink"+this.questionId).hide();
$("savingLink"+this.questionId).show();
break;
case this.STATES.SAVED:$("addLink"+this.questionId).hide();
$("savingLink"+this.questionId).hide();
$("savedLink"+this.questionId).show();
break;
}}};
var SearchWidget=Class.create();
SearchWidget.prototype={STATES:{READY:0,SEARCHING:1},setOptions:function(A){this.options={parent:"search",action:"searchMovies",url:"/myoq.sv"};
Object.extend(this.options,A||{});
},initialize:function(A){this.setOptions(A);
this.search=$A($(this.options.parent).getElementsByClassName("search")).first();
Event.observe(this.search,"focus",this.handleFocus.bind(this));
Event.observe(this.search,"blur",this.handleBlur.bind(this));
Event.observe(this.search,"keypress",this.handleEnter.bind(this));
this.text=this.search.value;
this.button=$A($(this.options.parent).getElementsByClassName("jbutton")).first();
Event.observe(this.button,"click",this.handleSearch.bind(this));
this.results=$A($(this.options.parent).getElementsByClassName("results")).first();
this.loading=$A($(this.options.parent).getElementsByClassName("loading")).first();
},handleFocus:function(){if($F(this.search)==this.text){this.search.value="";
}},handleBlur:function(){if(!TextUtils.hasText($F(this.search))){this.search.value=this.text;
}},handleEnter:function(A){if(A.keyCode==Event.KEY_RETURN){this.handleSearch();
Event.stop(A);
return false;
}else{return true;
}},handleSearch:function(){var A="quizAction="+this.options.action+"&"+Form.Element.serialize(this.search);
new Ajax.Request(this.options.url,{parameters:A,onComplete:this.processSearch.bind(this)});
this.state=this.STATES.SEARCHING;
this.paint();
},processSearch:function(A){$(this.results).update(A.responseText);
this.state=this.STATES.READY;
this.paint();
},paint:function(){switch(this.state){case this.STATES.READY:$(this.loading).hide();
$(this.results).show();
break;
case this.STATES.SEARCHING:$(this.results).hide();
$(this.loading).show();
break;
}}};
var QuizRatingWidget=Class.create();
QuizRatingWidget.prototype={STATES:{READY:0,RATED:1},setOptions:function(A){this.options={form:"ratings",results:"averages"};
Object.extend(this.options,A||{});
},handleRate:function(){var A=Form.serialize(this.options.form);
new Ajax.Request("/myoq.sv",{parameters:A,onComplete:this.processRate.bind(this)});
},processRate:function(){this.state=this.STATES.RATED;
this.paint();
},initialize:function(A){this.setOptions(A);
this.table=$A($(this.options.form).getElementsByTagName("table")).first();
this.ratings=$A($(this.options.form).getElementsByTagName("input"));
this.ratings.each(function(C,B){if($(C).type=="radio"){Event.observe($(C),"click",this.handleRate.bind(this));
}}.bind(this));
this.state=this.STATES.READY;
},paint:function(){switch(this.state){case this.STATES.READY:$(this.options.results).hide();
$(this.table).show();
break;
case this.STATES.RATED:$(this.table).hide();
$(this.options.results).show();
break;
}}};
Component.MyoqRemoveMovieAssociationLink=Class.create(Component.Link,{onClick:function(A){A.stop();
var B="quizAction=removeMovie&quizId="+this.element.readAttribute("quiz");
new Ajax.Request("/myoq.sv",{parameters:B});
this.element.replace("Removed Movie!");
}});
Component.MyoqRemoveActorAssociationLink=Class.create(Component.Link,{onClick:function(A){A.stop();
var B="quizAction=removeActor&quizId="+this.element.readAttribute("quiz");
new Ajax.Request("/myoq.sv",{parameters:B});
this.element.replace("Removed Actor!");
}});
Component.RemoveQuizLink=Class.create(Component.Link,{onClick:function(A){A.stop();
new View.ConfirmationPopup(this.element,{content:"Are you sure you want to do this?",onConfirm:this.onConfirm.bindAsEventListener(this)});
},onConfirm:function(){var A={quizAction:"removeQuiz",quizId:this.element.readAttribute("quiz"),cancel:this.element.readAttribute("cancel")};
new Ajax.Request("/myoq.sv",{parameters:A,onSuccess:this.onSuccess.bind(this)});
},onSuccess:function(A){this.element.replace(A.responseText);
}});
Component.PrivatizeQuizLink=Class.create(Component.Link,{onClick:function(A){A.stop();
new View.ConfirmationPopup(this.element,{content:"Are you sure you want to do this?",onConfirm:this.onConfirm.bindAsEventListener(this)});
},onConfirm:function(){var A={quizAction:"privatizeQuiz",quizId:this.element.readAttribute("quiz"),privatize:this.element.readAttribute("privatize")};
new Ajax.Request("/myoq.sv",{parameters:A,onSuccess:this.onSuccess.bind(this)});
},onSuccess:function(A){this.element.replace(A.responseText);
}});
Component.AdsEnableQuizLink=Class.create(Component.Link,{onClick:function(A){A.stop();
new View.ConfirmationPopup(this.element,{content:"Are you sure you want to do this?",onConfirm:this.onConfirm.bindAsEventListener(this)});
},onConfirm:function(){var A={quizAction:"adsEnableQuiz",quizId:this.element.readAttribute("quiz"),enable:this.element.readAttribute("enable")};
new Ajax.Request("/myoq.sv",{parameters:A,onSuccess:this.onSuccess.bind(this)});
},onSuccess:function(A){this.element.replace(A.responseText);
}});
Component.CancelQuestionLink=Class.create(Component.Link,{onClick:function(A){A.stop();
new View.ConfirmationPopup(this.element,{content:"Are you sure you want to cancel this question?",onConfirm:this.onConfirm.bindAsEventListener(this)});
},onConfirm:function(){var A={quizAction:"removeQuestion",questionId:this.element.readAttribute("question")};
new Ajax.Request("/myoq.sv",{parameters:A,onSuccess:this.onSuccess.bind(this)});
},onSuccess:function(A){this.element.replace(A.responseText);
}});
var reorderWidget={items:new Array(),setupList:function(){Sortable.create("questions",{scroll:window,constraint:false});
},handleSubmit:function(){$("saveOrderBtn1").disabled=true;
$("saveOrderBtn2").disabled=true;
var B=Sortable.serialize($("questions")).toQueryParams("&");
var A=B["questions[]"];
if(A==null){this.items=new Array();
}else{if(A.indexOf(",")<0){this.items=new Array(A);
}else{this.items=A.toArray();
}}$("questionIds").value=this.items;
return true;
}};
Component.QuestionContentTypeSelect=Class.create(Component.Select,{onChange:function(A){$("contentI").hide();
$("contentA").hide();
$("contentV").hide();
switch($("contentType").value){case"I":$("contentI").show();
break;
case"A":$("contentA").show();
break;
case"V":$("contentV").show();
break;
}}});
Component.QuestionAnswerTypeSelect=Class.create(Component.Select,{onChange:function(A){$("answerC").hide();
$("answerM").hide();
$("answerP").hide();
switch($("answerType").value){case"C":$("answerC").show();
break;
case"M":$("answerM").show();
break;
case"P":$("answerP").show();
break;
}}});
Component.MyoqActivationForm=Class.create(Component.Form,{onSubmit:function(A){A.stop();
if(parseInt($("questionCount").value)<3){new View.ErrorPopup(this.element,{title:"Add More Questions",content:"You need at least 3 questions to activate your quiz.  Add more questions :)"});
}else{new View.ConfirmationPopup(this.element,{content:"Once activated, you will no longer be able to edit your quiz.  Are you sure you are done?",onConfirm:this.onConfirm.bindAsEventListener(this)});
}},onConfirm:function(A){this.element.submit();
}});
Component.MyoqQuestionForm=Class.create(Component.Form,{onSubmit:function(A){if(!TextUtils.hasText($("question").value)){A.stop();
new View.ErrorPopup(this.element,{title:"Missing Question",content:"Whoops, you forgot to type in a question."});
return false;
}else{$("questionSubmitBtn").disabled=true;
return true;
}}});
Component.YesButton=Class.create(Component,{initialize:function($super,A){$super(A);
A.observe("click",this.onClick.bindAsEventListener(this));
},onClick:function(A){var B="lsrc=rl.myoq.results.yes";
new Ajax.Request("/account/accept-photo",{parameters:B,asynchronous:true,evalScript:true,onLoading:displayWaiting,onComplete:displaySuccessMsg});
}});
function displayWaiting(){$("isThisYou").hide();
$("waiting").show();
$("imgAccepted").hide();
}function displaySuccessMsg(){$("isThisYou").hide();
$("waiting").hide();
$("imgAccepted").show();
}Component.NoButton=Class.create(Component,{initialize:function($super,A){$super(A);
A.observe("click",this.onClick.bindAsEventListener(this));
},onClick:function(A){var B=this.element.id;
window.location="/splash/select-profile-img?lsrc=rl.myoq.results.no&src=qrpage&qrId="+B;
}});
function showRow(A){$(A).style.display=(navigator.userAgent.indexOf("Firefox")==-1)?"block":"table-row";
}function showCell(A){$(A).style.display=(navigator.userAgent.indexOf("Firefox")==-1)?"block":"table-cell";
}var quizWidget={STATES:{READY:0,SUBMITTING:1},ANON_SUBMISSION_TYPE:{REG:0,LOGIN:1},UPDATE_MSG_INTERVAL:1500,MARKER_START:'<div id="authStatus">',MARKER_END:"</div>",handleAnonSubmit:function(A){if(this.anonSubmissionType==this.ANON_SUBMISSION_TYPE.REG&&!validateForm(A)){return false;
}this.state=this.STATES.SUBMITTING;
$("time").value=new Date().getTime()-quizStartDate.getTime();
var B=Form.serialize("anonRegForm");
new Ajax.Request($("anonRegForm").action,{parameters:B,onSuccess:this.processAuthenticationResponse.bind(this),onTimeout:this.onTimeout.bind(this),onFailure:this.onFailure.bind(this)});
$("quizSubmitBtn").disabled=true;
$("myoq").style.cursor="wait";
showRow("statusRow");
if(this.anonSubmissionType==this.ANON_SUBMISSION_TYPE.REG){$("regStatus").update("Processing registration");
Tracker.trackPageview("MYOQ_Viral_Action_Register");
}else{if(this.anonSubmissionType==this.ANON_SUBMISSION_TYPE.LOGIN){$("regStatus").update("Attempting to log you in");
Tracker.trackPageview("MYOQ_Viral_Action_Login");
}}$("regStatus").style.color="green";
this.drawSubmissionTicker();
Clicker.counter=0;
return false;
},drawSubmissionTicker:function(){if(quizWidget.state==quizWidget.STATES.SUBMITTING){$("regStatus").innerHTML=$("regStatus").innerHTML+". ";
setTimeout(function(){quizWidget.drawSubmissionTicker();
},quizWidget.UPDATE_MSG_INTERVAL);
}},processAuthenticationResponse:function(A){var D=A.responseText.indexOf(this.MARKER_START)+this.MARKER_START.length;
var C=A.responseText.indexOf(this.MARKER_END,D);
var B=A.responseText.substring(D,C).strip();
$("regStatus").update(B);
showRow("statusRow");
if(B.search(/successful/i)>=0){$("regStatus").style.color="green";
this.state=this.STATES.SUBMITTING;
this.drawSubmissionTicker();
setTimeout(function(){quizWidget.handleNormalSubmit();
},500);
}else{this.allowPostErrorResubmission();
}},allowPostErrorResubmission:function(){$("regStatus").style.color="red";
this.state=this.STATES.READY;
$("quizSubmitBtn").disabled=false;
$("myoq").style.cursor="default";
if($("captchaFields")){$("captchaFields").down(".captcha img").fire("captcha:refresh");
}},onTimeout:function(A){$("regStatus").update("Whoops, your request timed out. Please check your network connection and try again.");
showRow("statusRow");
this.allowPostErrorResubmission();
},onFailure:function(A){$("regStatus").update("Whoops, our servers coughed.  Please try again.");
showRow("statusRow");
this.allowPostErrorResubmission();
},toggleAnonAuth:function(B,A){if(B!=null){Event.stop(B);
}if(this.state==this.STATES.SUBMITTING){alert("Sorry, we are currently processing your prior "+(this.anonSubmissionType==this.ANON_SUBMISSION_TYPE.REG?"registration":"login")+" attempt.");
return false;
}$("regStatus").innerHTML="";
if(A){$("loginToggle").style.display="block";
$("registerToggle").style.display="none";
$("regTableTitle").update("Save your results");
showRow("regSpecificFields");
showRow("otherFields");
if($("regSpecificFieldsPrepop")){$("regSpecificFieldsPrepop").style.display="none";
}if($("otherFieldsPrepop")){$("otherFieldsPrepop").style.display="none";
}showRow("otherFields");
if($("usernameLabel")){showCell("usernameLabel");
}if($("usernameInput")){showCell("usernameInput");
}$("usernameLabel").update("Email");
$("passwordLabel").update("Choose<br/>Password");
if($("captchaFields")){showRow("captchaFields");
}showRow("disclaimer");
showRow("dobFields");
$("newsletter").style.display="inline";
$("forgotPassword").style.display="none";
$("anonRegForm").action="/userAuth.do?userauthAction=doRegister&flowType=MYQ";
$("anonSubmitType").value="reg";
this.anonSubmissionType=this.ANON_SUBMISSION_TYPE.REG;
}else{$("loginToggle").style.display="none";
$("registerToggle").style.display="block";
$("regTableTitle").update("Login to save your results");
if($("regSpecificFieldsPrepop")){$("regSpecificFieldsPrepop").style.display="none";
}if($("otherFieldsPrepop")){$("otherFieldsPrepop").style.display="none";
}$("regSpecificFields").style.display="none";
showRow("otherFields");
if($("usernameLabel")){showCell("usernameLabel");
}if($("usernameInput")){showCell("usernameInput");
}$("usernameLabel").update("Username");
$("passwordLabel").update("Password");
if($("captchaFields")){$("captchaFields").style.display="none";
}$("dobFields").style.display="none";
$("disclaimer").style.display="none";
$("newsletter").style.display="none";
$("forgotPassword").style.display="inline";
$("anonRegForm").action="/userAuth.do?userauthAction=doLogin&flowType=MYQ";
$("anonSubmitType").value="login";
this.anonSubmissionType=this.ANON_SUBMISSION_TYPE.LOGIN;
}return false;
},handleNormalSubmit:function(){var A=$A(document.getElementsByClassName("questionForm"));
var B=new Array();
A.each(function(D,C){B.push(Form.serialize(D));
});
$("quizAnswers").value=B;
$("quizForm").submit();
},handleNewsletterCheck:function(){},handleEditName:function(){if($("regSpecificFieldsPrepop")){$("regSpecificFieldsPrepop").style.display="none";
}showRow("regSpecificFields");
},handleEditEmail:function(){if($("otherFieldsPrepop")){$("otherFieldsPrepop").style.display="none";
}showRow("otherFields");
if($("usernameLabel")){showCell("usernameLabel");
}if($("usernameInput")){showCell("usernameInput");
}}};
quizWidget.anonSubmissionType=quizWidget.ANON_SUBMISSION_TYPE.REG;
var quizStartDate=new Date();
function quizInvitePageToggleAddressBook(A){$("instructionAddressBookType").innerHTML=A;
}function doIqQuiz(){Tracker.trackPageview("MYOQ_Click_IQQuiz");
window.open("http://www.socialtrack.net/redir.aspx?CID=11190&AFID=42960&DID=50439&SID=vquiz");
}Component.CopyPasteTextarea=Class.create(Component.Textarea,{initialize:function(A){this.element=$(A);
this.element.observe("focus",this.onFocus.bindAsEventListener(this));
},onFocus:function(A){this.element.select();
Tracker.trackEvent(this.element.readAttribute("tag"),"Focus",this.element.readAttribute("feature"));
},onClick:function(A){this.element.select();
}});
var sponsoredQuiz={sponsoredQuizzes:new Array(),handleQuizLoad:function(){var A="gameAction=getSponsoredQuizzes&quizIds="+this.sponsoredQuizzes;
new Ajax.Request("/quiz.sv",{parameters:A,onComplete:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this),onTimeout:this.onTimeout.bind(this)});
},onSuccess:function(A){$("sponsoredQuizzes").update(A.responseText);
$("sponsoredQuizzes").show();
$("noQuizzes").hide();
},onFailure:function(A){$("sponsoredQuizzes").update("FAILED: "+A.responseText);
},onTimeout:function(A){$("sponsoredQuizzes").update("TIMEOUT: "+A.responseText);
}};




