var texts={tutorial_welcome_header:"Welcome!",tutorial_welcome_text:"...to the world's most exciting Quiz experience! Here you can have fun with millions of players around the globe!",tutorial_time_header:"Timer",tutorial_time_text:"Answer before the time runs out!",tutorial_level_header:"Your Level",tutorial_level_text:"Answer questions to collect points and level up! Can you get to level 60?",tutorial_streak_header:"Streak",tutorial_streak_text:"Several correct answers in a row gives you higher points.",tutorial_friends_header:"Your Friends",tutorial_friends_text:"Here you can see what your Planeto-playing friends are doing.",tutorial_actionbar_header:"Action Bar",tutorial_actionbar_text:"You can can remove two of the false answers or skip a tricky question &#45; but you have to pay for it with your Gold.",tutorial_gold_header:"Your Gold",tutorial_gold_text:"You get gold when you level up, but if you want more you can click here.",tutorial_medals_header:"Medals",tutorial_medals_text:"Medals are pretty. Can you collect them all?",tutorial_friendslist_header:"Friends List",tutorial_friendslist_text:"This is all of your friends who are also playing Planeto Quiz, sorted by their level. Can you get to the top?",tutorial_clickfriend_header:"Click a Friend",tutorial_clickfriend_text:"Click your friends to view their stats &#45; or challenge them to a duel if they are online!",tutorial_treasure_header:"New Treasure",tutorial_treasure_text:"Congratulations! The longer your streak, the higher your chance to get treasures.",tutorial_attire_header:"Attire",tutorial_attire_text:"Some items give permanent bonuses while equipped on your avatar. You can click it and select 'Equip'.",tutorial_actioncards_header:"Action Cards",tutorial_actioncards_text:"If you have received an action card you can place it in your action bar. Click any card in the action bar and select 'Use'.",tutorial_inventory_header:"Inventory",tutorial_inventory_text:"If you click any received item and selet 'To inventory', it is stored here.",tutorial_enjoy_header:"Enjoy!",tutorial_enjoy_text:"That's all for now. There are still more things to learn, but you'll have to do that on your own. Never hesitate to click around."};var activeScroller;function Scroller(A,D,B,C){this.container=A;this.scrollArea=D;this.leftButton=B;this.rightButton=C;this.leftButton.scroller=this;this.rightButton.scroller=this;this.leftButton.live("click",{ref:this},this.scrollTabsLeft);this.rightButton.live("click",{ref:this},this.scrollTabsRight);this.currentIndex=0;this.setScrollButtonState();}Scroller.prototype.scrollTabsRight=function(B){var A=B.data.ref;A.scrollToTab(A.currentIndex+1);};Scroller.prototype.scrollTabsLeft=function(B){var A=B.data.ref;A.scrollToTab(A.currentIndex-1);};Scroller.prototype.scrollToTab=function(A){if(A<0||A>(this.scrollArea.find(".chatTabs").length-1)){return ;}var B=-this.getTabLeftOffset(A);if(B>0){B=0;}this.scrollArea.animate({"margin-left":B+"px"},200,onAnimateComplete);activeScroller=this;this.currentIndex=A;};function onAnimateComplete(){activeScroller.setScrollButtonState();}Scroller.prototype.setScrollButtonState=function(){var A=this.scrollArea.find(".chatTabs").length-1;this.leftButton.removeClass("disabled hide");this.rightButton.removeClass("disabled hide");if(this.currentIndex<=0){this.leftButton.addClass("disabled");}if(this.currentIndex>=A){this.rightButton.addClass("disabled");}};Scroller.prototype.getTabLeftOffset=function(B){var A=this.container.width();width=0,leftOffset=0;this.scrollArea.find(".chatTabs").each(function(C){if(C>=B){return false;}width+=$(this).outerWidth(true);});leftOffset=width;return leftOffset;};Scroller.prototype.getTotalTabsWidth=function(){var A=0;this.scrollArea.find(".chatTabs").each(function(){A+=$(this).outerWidth(false);});return A;};var resource_default_domain_pic_png="/media/img/default_domain_pic_6876.png",resource_leaderboard_fragment="/fragment/leaderboard_5972.fragment",resource_duel_fragment="/fragment/duel_6555.fragment",resource_multiplayer_templates="/fragment/multiplayer_templates_6967.html",resource_null_gif="/media/img/null_26.gif",resource_times_up="/media/img/time_up_icon_6220.png",resource_qs_default_42="/media/img/QS_default_icon_42x42_5820.png",resource_qs_default_90="/media/img/QS_default_icon_90x90_5820.png",resource_qs_default_plain="/media/img/QS_default_icon_plain_5820.png",resource_sq_default_42="/media/img/SQ_default_icon_42x42_6033.png",resource_sq_default_90="/media/img/SQ_default_icon_90x90_6020.png",resource_sq_default_plain="/media/img/SQ_default_icon_plain_6020.png",resource_guestavatar_jpg="/media/img/guestavatar.jpg",resource_multiplayer_unknownplayer="/media/img/unknown_player_6537.png",resource_picturequiz_box="/media/img/picturequiz_box_6612.png",resource_picturequiz_box_selected="/media/img/picturequiz_box_selected_6615.png",resource_starhunt_effect_focusdrain_png="/media/img/starhunt/effect_focusdrain_6693.png";
resource_starhunt_effect_focusgain_png="/media/img/starhunt/effect_focusgain_6693.png";resource_starhunt_effect_gamble_png="/media/img/starhunt/effect_gamble_6693.png";resource_starhunt_effect_scramble_png="/media/img/starhunt/effect_scramble_6693.png";resource_starhunt_effect_star_png="/media/img/starhunt/effect_star_6693.png";resource_starhunt_effect_start_png="/media/img/starhunt/effect_start_6693.png";resource_starhunt_effect_streakblock_png="/media/img/starhunt/effect_streakblock_6693.png";resource_starhunt_effect_teleport_png="/media/img/starhunt/effect_teleport_6693.png";resource_starhunt_effect_trigger_png="/media/img/starhunt/effect_trigger_6693.png";resource_starhunt_effect_triggeredblock_png="/media/img/starhunt/effect_triggeredblock_6693.png";resource_starhunt_square_artsandlitterature_png="/media/img/starhunt/square_artsandlitterature_6693.png";resource_starhunt_square_disfavored_png="/media/img/starhunt/square_disfavored_6694.png";resource_starhunt_square_empty_png="/media/img/starhunt/square_empty_6714.png";resource_starhunt_square_entertainment_png="/media/img/starhunt/square_entertainment_6693.png";resource_starhunt_square_favored_png="/media/img/starhunt/square_favored_6694.png";resource_starhunt_square_geography_png="/media/img/starhunt/square_geography_6693.png";resource_starhunt_square_history_png="/media/img/starhunt/square_history_6693.png";resource_starhunt_square_mastery_png="/media/img/starhunt/square_mastery_6694.png";resource_starhunt_square_random_png="/media/img/starhunt/square_random_6694.png";resource_starhunt_square_sciencenature_png="/media/img/starhunt/square_sciencenature_6693.png";resource_starhunt_square_sportsleisure_png="/media/img/starhunt/square_sportsleisure_6693.png";resource_starhunt_hubble="/media/img/hubble_6674.jpg";resource_sfx_en_inhotseat="/media/sfx/en/yourturn_6553.wav",resource_sfx_en_second="/media/sfx/en/second_6426.wav",resource_sfx_en_timer="/media/sfx/en/tick_6553.wav",resource_sfx_klingon_timer="/media/sfx/klingon/torpedoes_6426.wav",facebook_connect_xd_receiver_htm="/facebook_connect/xd_receiver_595.htm",resource_banner=new Array(3),ext_resource_feed_lost_streak_jpg="feed_lost_streak.jpg",ext_resource_feed_invite_friend_jpg="invite_fb_icon.png",ext_resource_feed_leaderboard_passing_jpg="feed_leaderboard_passing.jpg",ext_resource_feed_levelup_icon_jpg="feed_levelup_icon.jpg",ext_resource_feed_duel_won_jpg="feed_duel_won.jpg",ext_resource_feed_duel_lost_jpg="feed_duel_lost.jpg",ext_resource_feed_duel_draw_jpg="feed_duel_draw.jpg",ext_resource_feed_logout_icon_jpg="feed_logout_icon.jpg",ext_resource_feed_jackpot_icon_jpg="feed_jackpot_icon.jpg",ext_resource_feed_quest_completed_icon_jpg="feed_quest_completed_icon.jpg",ext_resource_default_domain_pic_png="default_domain_pic.png",logout_address="/logout/index_5932.html",duel_ready_icon="/media/img/button_icon_ready_4376.png",tab_button_divider="/media/img/tab_button_divider_4277.png",socketlog_address="/socketlogger_6796.htm",facebook_login_callback_url="/facebook_window_6987.htm",WEB_SOCKET_SWF_LOCATION="/js/lib/gimite/WebSocketMain_4087.swf",resource_fb_channel_page="/facebook_connect/channel_6941.html",resource_banner[0]="/media/banners/banner_planeto_tips_01_3277.jpg",resource_banner[1]="/media/banners/banner_planeto_tips_02_3277.jpg",resource_banner[2]="/media/banners/banner_planeto_fanpage_3273.jpg",resource_banner[3]="/media/banners/banner_planeto_iq_iphone_7040.jpg";
/*
 * jQuery JavaScript Library v1.5.2
 * http://jquery.com/
 *
 * Copyright 2011, John Resig
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 * Copyright 2011, The Dojo Foundation
 * Released under the MIT, BSD, and GPL Licenses.
 *
 * Date: Thu Mar 31 15:28:23 2011 -0400
 */
(function(Aq,Ao){function AF(A){return Ak.isWindow(A)?A:A.nodeType===9?A.defaultView||A.parentWindow:!1;}function AL(B){if(!BN[B]){var A=Ak("<"+B+">").appendTo("body"),C=A.css("display");A.remove();
if(C==="none"||C===""){C="block";}BN[B]=C;}return BN[B];}function AN(B,A){var C={};Ak.each(AO.concat.apply([],AO.slice(0,A)),function(){C[this]=B;});return C;}function B2(){try{return new Aq.ActiveXObject("Microsoft.XMLHTTP");}catch(A){}}function BU(){try{return new Aq.XMLHttpRequest;}catch(A){}}function BW(){Ak(Aq).unload(function(){for(var A in BZ){BZ[A](0,1);}});}function Bi(N,M){N.dataFilter&&(M=N.dataFilter(M,N.dataType));var L=N.dataTypes,K={},J,I,H=L.length,G,F=L[0],E,D,C,B,A;for(J=1;J<H;J++){if(J===1){for(I in N.converters){typeof I==="string"&&(K[I.toLowerCase()]=N.converters[I]);}}E=F,F=L[J];if(F==="*"){F=E;}else{if(E!=="*"&&E!==F){D=E+" "+F,C=K[D]||K["* "+F];if(!C){A=Ao;for(B in K){G=B.split(" ");if(G[0]===E||G[0]==="*"){A=K[G[1]+" "+F];if(A){B=K[B],B===!0?C=A:A===!0&&(C=B);break;}}}}!C&&!A&&Ak.error("No conversion from "+D.replace(" "," to ")),C!==!0&&(M=C?C(M):A(B(M)));}}}return M;}function Bj(J,I,H){var G=J.contents,F=J.dataTypes,E=J.responseFields,D,C,B,A;for(C in E){C in H&&(I[E[C]]=H[C]);}while(F[0]==="*"){F.shift(),D===Ao&&(D=J.mimeType||I.getResponseHeader("content-type"));}if(D){for(C in G){if(G[C]&&G[C].test(D)){F.unshift(C);break;}}}if(F[0] in H){B=F[0];}else{for(C in H){if(!F[0]||J.converters[C+" "+F[0]]){B=C;break;}A||(A=C);}B=B||A;}if(B){B!==F[0]&&F.unshift(B);return H[B];}}function Bk(B,A,E,D){if(Ak.isArray(A)&&A.length){Ak.each(A,function(F,G){E||Ap.test(B)?D(B,G):Bk(B+"["+(typeof G==="object"||Ak.isArray(G)?F:"")+"]",G,E,D);});}else{if(E||A==null||typeof A!=="object"){D(B,A);}else{if(Ak.isArray(A)||Ak.isEmptyObject(A)){D(B,"");}else{for(var C in A){Bk(B+"["+C+"]",A[C],E,D);}}}}}function Bl(K,J,I,H,G,F){G=G||J.dataTypes[0],F=F||{},F[G]=!0;var E=K[G],D=0,C=E?E.length:0,B=K===Br,A;for(;D<C&&(B||!A);D++){A=E[D](J,I,H),typeof A==="string"&&(!B||F[A]?A=Ao:(J.dataTypes.unshift(A),A=Bl(K,J,I,H,A,F)));}(B||!A)&&!F["*"]&&(A=Bl(K,J,I,H,"*",F));return A;}function Bm(A){return function(B,I){typeof B!=="string"&&(I=B,B="*");if(Ak.isFunction(I)){var H=B.toLowerCase().split(Bx),G=0,F=H.length,E,D,C;for(;G<F;G++){E=H[G],C=/^\+/.test(E),C&&(E=E.substr(1)||"*"),D=A[E]=A[E]||[],D[C?"unshift":"push"](I);}}};}function At(B,A,E){var D=A==="width"?A0:Ay,C=A==="width"?B.offsetWidth:B.offsetHeight;if(E==="border"){return C;}Ak.each(D,function(){E||(C-=parseFloat(Ak.css(B,"padding"+this))||0),E==="margin"?C+=parseFloat(Ak.css(B,"margin"+this))||0:C-=parseFloat(Ak.css(B,"border"+this+"Width"))||0;});return C;}function BG(B,A){A.src?Ak.ajax({url:A.src,async:!1,dataType:"script"}):Ak.globalEval(A.text||A.textContent||A.innerHTML||""),A.parentNode&&A.parentNode.removeChild(A);}function BI(A){return"getElementsByTagName" in A?A.getElementsByTagName("*"):"querySelectorAll" in A?A.querySelectorAll("*"):[];}function BK(B,A){if(A.nodeType===1){var C=A.nodeName.toLowerCase();A.clearAttributes(),A.mergeAttributes(B);if(C==="object"){A.outerHTML=B.outerHTML;}else{if(C!=="input"||B.type!=="checkbox"&&B.type!=="radio"){if(C==="option"){A.selected=B.defaultSelected;}else{if(C==="input"||C==="textarea"){A.defaultValue=B.defaultValue;}}}else{B.checked&&(A.defaultChecked=A.checked=B.checked),A.value!==B.value&&(A.value=B.value);}}A.removeAttribute(Ak.expando);}}function As(I,H){if(H.nodeType===1&&Ak.hasData(I)){var G=Ak.expando,F=Ak.data(I),E=Ak.data(H,F);if(F=F[G]){var D=F.events;E=E[G]=Ak.extend({},F);if(D){delete E.handle,E.events={};for(var C in D){for(var B=0,A=D[C].length;B<A;B++){Ak.event.add(H,C+(D[C][B].namespace?".":"")+D[C][B].namespace,D[C][B],D[C][B].data);}}}}}}function B1(B,A){return Ak.nodeName(B,"table")?B.getElementsByTagName("tbody")[0]||B.appendChild(B.ownerDocument.createElement("tbody")):B;}function BH(B,A,D){if(Ak.isFunction(A)){return Ak.grep(B,function(E,G){var F=!!A.call(E,G,E);return F===D;});}if(A.nodeType){return Ak.grep(B,function(E,F){return E===A===D;});}if(typeof A==="string"){var C=Ak.grep(B,function(E){return E.nodeType===1;});if(BP.test(A)){return Ak.filter(A,C,!D);}A=Ak.filter(A,C);}return Ak.grep(B,function(E,F){return Ak.inArray(E,A)>=0===D;
});}function BJ(A){return !A||!A.parentNode||A.parentNode.nodeType===11;}function BT(B,A){return(B&&B!=="*"?B+".":"")+A.replace(AJ,"`").replace(AH,"&");}function BV(R){var Q,P,O,N,M,L,K,J,I,H,G,F,E,D=[],C=[],B=Ak._data(this,"events");if(R.liveFired!==this&&B&&B.live&&!R.target.disabled&&(!R.button||R.type!=="click")){R.namespace&&(F=new RegExp("(^|\\.)"+R.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),R.liveFired=this;var A=B.live.slice(0);for(K=0;K<A.length;K++){M=A[K],M.origType.replace(AM,"")===R.type?C.push(M.selector):A.splice(K--,1);}N=Ak(R.target).closest(C,R.currentTarget);for(J=0,I=N.length;J<I;J++){G=N[J];for(K=0;K<A.length;K++){M=A[K];if(G.selector===M.selector&&(!F||F.test(M.namespace))&&!G.elem.disabled){L=G.elem,O=null;if(M.preType==="mouseenter"||M.preType==="mouseleave"){R.type=M.preType,O=Ak(R.relatedTarget).closest(M.selector)[0];}(!O||O!==L)&&D.push({elem:L,handleObj:M,level:G.level});}}}for(J=0,I=D.length;J<I;J++){N=D[J];if(P&&N.level>P){break;}R.currentTarget=N.elem,R.data=N.handleObj.data,R.handleObj=N.handleObj,E=N.handleObj.origHandler.apply(N.elem,arguments);if(E===!1||R.isPropagationStopped()){P=N.level,E===!1&&(Q=!1);if(R.isImmediatePropagationStopped()){break;}}}return Q;}}function Ba(A,D,C){var B=Ak.extend({},C[0]);B.type=A,B.originalEvent={},B.liveFired=Ao,Ak.event.handle.call(D,B),B.isDefaultPrevented()&&C[0].preventDefault();}function AB(){return !0;}function AC(){return !1;}function Aa(B){for(var A in B){if(A!=="toJSON"){return !1;}}return !0;}function Ac(A,D,C){if(C===Ao&&A.nodeType===1){C=A.getAttribute("data-"+D);if(typeof C==="string"){try{C=C==="true"?!0:C==="false"?!1:C==="null"?null:Ak.isNaN(C)?Ae.test(C)?Ak.parseJSON(C):C:parseFloat(C);}catch(B){}Ak.data(A,D,C);}else{C=Ao;}}return C;}var Am=Aq.document,Ak=function(){function M(){if(!CB.isReady){try{Am.documentElement.doScroll("left");}catch(A){setTimeout(M,1);return ;}CB.ready();}}var CB=function(B,A){return new CB.fn.init(B,A,B8);},CA=Aq.jQuery,B9=Aq.$,B8,B7=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,B6=/\S/,B5=/^\s+/,B4=/\s+$/,B3=/\d/,b=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,a=/^[\],:{}\s]*$/,Z=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,Y=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,W=/(?:^|:|,)(?:\s*\[)+/g,U=/(webkit)[ \/]([\w.]+)/,S=/(opera)(?:.*version)?[ \/]([\w.]+)/,Q=/(msie) ([\w.]+)/,O=/(mozilla)(?:.*? rv:([\w.]+))?/,L=navigator.userAgent,K,J,I,H=Object.prototype.toString,X=Object.prototype.hasOwnProperty,V=Array.prototype.push,T=Array.prototype.slice,R=String.prototype.trim,P=Array.prototype.indexOf,N={};CB.fn=CB.prototype={constructor:CB,init:function(A,G,F){var E,D,C,B;if(!A){return this;}if(A.nodeType){this.context=this[0]=A,this.length=1;return this;}if(A==="body"&&!G&&Am.body){this.context=Am,this[0]=Am.body,this.selector="body",this.length=1;return this;}if(typeof A==="string"){E=B7.exec(A);if(!E||!E[1]&&G){return !G||G.jquery?(G||F).find(A):this.constructor(G).find(A);}if(E[1]){G=G instanceof CB?G[0]:G,B=G?G.ownerDocument||G:Am,C=b.exec(A),C?CB.isPlainObject(G)?(A=[Am.createElement(C[1])],CB.fn.attr.call(A,G,!0)):A=[B.createElement(C[1])]:(C=CB.buildFragment([E[1]],[B]),A=(C.cacheable?CB.clone(C.fragment):C.fragment).childNodes);return CB.merge(this,A);}D=Am.getElementById(E[2]);if(D&&D.parentNode){if(D.id!==E[2]){return F.find(A);}this.length=1,this[0]=D;}this.context=Am,this.selector=A;return this;}if(CB.isFunction(A)){return F.ready(A);}A.selector!==Ao&&(this.selector=A.selector,this.context=A.context);return CB.makeArray(A,this);},selector:"",jquery:"1.5.2",length:0,size:function(){return this.length;},toArray:function(){return T.call(this,0);},get:function(A){return A==null?this.toArray():A<0?this[this.length+A]:this[A];},pushStack:function(B,A,D){var C=this.constructor();CB.isArray(B)?V.apply(C,B):CB.merge(C,B),C.prevObject=this,C.context=this.context,A==="find"?C.selector=this.selector+(this.selector?" ":"")+D:A&&(C.selector=this.selector+"."+A+"("+D+")");return C;},each:function(B,A){return CB.each(this,B,A);
},ready:function(A){CB.bindReady(),J.done(A);return this;},eq:function(A){return A===-1?this.slice(A):this.slice(A,+A+1);},first:function(){return this.eq(0);},last:function(){return this.eq(-1);},slice:function(){return this.pushStack(T.apply(this,arguments),"slice",T.call(arguments).join(","));},map:function(A){return this.pushStack(CB.map(this,function(B,C){return A.call(B,C,B);}));},end:function(){return this.prevObject||this.constructor(null);},push:V,sort:[].sort,splice:[].splice},CB.fn.init.prototype=CB.fn,CB.extend=CB.fn.extend=function(){var n,m,d,G,F,E,D=arguments[0]||{},C=1,B=arguments.length,A=!1;typeof D==="boolean"&&(A=D,D=arguments[1]||{},C=2),typeof D!=="object"&&!CB.isFunction(D)&&(D={}),B===C&&(D=this,--C);for(;C<B;C++){if((n=arguments[C])!=null){for(m in n){d=D[m],G=n[m];if(D===G){continue;}A&&G&&(CB.isPlainObject(G)||(F=CB.isArray(G)))?(F?(F=!1,E=d&&CB.isArray(d)?d:[]):E=d&&CB.isPlainObject(d)?d:{},D[m]=CB.extend(A,E,G)):G!==Ao&&(D[m]=G);}}}return D;},CB.extend({noConflict:function(A){Aq.$=B9,A&&(Aq.jQuery=CA);return CB;},isReady:!1,readyWait:1,ready:function(A){A===!0&&CB.readyWait--;if(!CB.readyWait||A!==!0&&!CB.isReady){if(!Am.body){return setTimeout(CB.ready,1);}CB.isReady=!0;if(A!==!0&&--CB.readyWait>0){return ;}J.resolveWith(Am,[CB]),CB.fn.trigger&&CB(Am).trigger("ready").unbind("ready");}},bindReady:function(){if(!J){J=CB._Deferred();if(Am.readyState==="complete"){return setTimeout(CB.ready,1);}if(Am.addEventListener){Am.addEventListener("DOMContentLoaded",I,!1),Aq.addEventListener("load",CB.ready,!1);}else{if(Am.attachEvent){Am.attachEvent("onreadystatechange",I),Aq.attachEvent("onload",CB.ready);var A=!1;try{A=Aq.frameElement==null;}catch(B){}Am.documentElement.doScroll&&A&&M();}}}},isFunction:function(A){return CB.type(A)==="function";},isArray:Array.isArray||function(A){return CB.type(A)==="array";},isWindow:function(A){return A&&typeof A==="object"&&"setInterval" in A;},isNaN:function(A){return A==null||!B3.test(A)||isNaN(A);},type:function(A){return A==null?String(A):N[H.call(A)]||"object";},isPlainObject:function(A){if(!A||CB.type(A)!=="object"||A.nodeType||CB.isWindow(A)){return !1;}if(A.constructor&&!X.call(A,"constructor")&&!X.call(A.constructor.prototype,"isPrototypeOf")){return !1;}var B;for(B in A){}return B===Ao||X.call(A,B);},isEmptyObject:function(B){for(var A in B){return !1;}return !0;},error:function(A){throw A;},parseJSON:function(A){if(typeof A!=="string"||!A){return null;}A=CB.trim(A);if(a.test(A.replace(Z,"@").replace(Y,"]").replace(W,""))){return Aq.JSON&&Aq.JSON.parse?Aq.JSON.parse(A):(new Function("return "+A))();}CB.error("Invalid JSON: "+A);},parseXML:function(A,C,B){Aq.DOMParser?(B=new DOMParser,C=B.parseFromString(A,"text/xml")):(C=new ActiveXObject("Microsoft.XMLDOM"),C.async="false",C.loadXML(A)),B=C.documentElement,(!B||!B.nodeName||B.nodeName==="parsererror")&&CB.error("Invalid XML: "+A);return C;},noop:function(){},globalEval:function(B){if(B&&B6.test(B)){var A=Am.head||Am.getElementsByTagName("head")[0]||Am.documentElement,C=Am.createElement("script");CB.support.scriptEval()?C.appendChild(Am.createTextNode(B)):C.text=B,A.insertBefore(C,A.firstChild),A.removeChild(C);}},nodeName:function(B,A){return B.nodeName&&B.nodeName.toUpperCase()===A.toUpperCase();},each:function(A,d,G){var F,E=0,D=A.length,C=D===Ao||CB.isFunction(A);if(G){if(C){for(F in A){if(d.apply(A[F],G)===!1){break;}}}else{for(;E<D;){if(d.apply(A[E++],G)===!1){break;}}}}else{if(C){for(F in A){if(d.call(A[F],F,A[F])===!1){break;}}}else{for(var B=A[0];E<D&&d.call(B,E,B)!==!1;B=A[++E]){}}}return A;},trim:R?function(A){return A==null?"":R.call(A);}:function(A){return A==null?"":(A+"").replace(B5,"").replace(B4,"");},makeArray:function(B,A){var D=A||[];if(B!=null){var C=CB.type(B);B.length==null||C==="string"||C==="function"||C==="regexp"||CB.isWindow(B)?V.call(D,B):CB.merge(D,B);}return D;},inArray:function(B,A){if(A.indexOf){return A.indexOf(B);}for(var D=0,C=A.length;D<C;D++){if(A[D]===B){return D;}}return -1;
},merge:function(A,E){var D=A.length,C=0;if(typeof E.length==="number"){for(var B=E.length;C<B;C++){A[D++]=E[C];}}else{while(E[C]!==Ao){A[D++]=E[C++];}}A.length=D;return A;},grep:function(B,A,G){var F=[],E;G=!!G;for(var D=0,C=B.length;D<C;D++){E=!!A(B[D],D),G!==E&&F.push(B[D]);}return F;},map:function(B,A,G){var F=[],E;for(var D=0,C=B.length;D<C;D++){E=A(B[D],D,G),E!=null&&(F[F.length]=E);}return F.concat.apply([],F);},guid:1,proxy:function(A,C,B){arguments.length===2&&(typeof C==="string"?(B=A,A=B[C],C=Ao):C&&!CB.isFunction(C)&&(B=C,C=Ao)),!C&&A&&(C=function(){return A.apply(B||this,arguments);}),A&&(C.guid=A.guid=A.guid||C.guid||CB.guid++);return C;},access:function(l,d,G,F,E,D){var C=l.length;if(typeof d==="object"){for(var B in d){CB.access(l,B,d[B],F,E,G);}return l;}if(G!==Ao){F=!D&&F&&CB.isFunction(G);for(var A=0;A<C;A++){E(l[A],d,F?G.call(l[A],A,E(l[A],d)):G,D);}return l;}return C?E(l[0],d):Ao;},now:function(){return(new Date).getTime();},uaMatch:function(B){B=B.toLowerCase();var A=U.exec(B)||S.exec(B)||Q.exec(B)||B.indexOf("compatible")<0&&O.exec(B)||[];return{browser:A[1]||"",version:A[2]||"0"};},sub:function(){function B(D,E){return new B.fn.init(D,E);}CB.extend(!0,B,this),B.superclass=this,B.fn=B.prototype=this(),B.fn.constructor=B,B.subclass=this.subclass,B.fn.init=function A(D,E){E&&E instanceof CB&&!(E instanceof B)&&(E=B(E));return CB.fn.init.call(this,D,E,C);},B.fn.init.prototype=B.fn;var C=B(Am);return B;},browser:{}}),CB.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(B,A){N["[object "+A+"]"]=A.toLowerCase();}),K=CB.uaMatch(L),K.browser&&(CB.browser[K.browser]=!0,CB.browser.version=K.version),CB.browser.webkit&&(CB.browser.safari=!0),P&&(CB.inArray=function(B,A){return P.call(A,B);}),B6.test(" ")&&(B5=/^[\s\xA0]+/,B4=/[\s\xA0]+$/),B8=CB(Am),Am.addEventListener?I=function(){Am.removeEventListener("DOMContentLoaded",I,!1),CB.ready();}:Am.attachEvent&&(I=function(){Am.readyState==="complete"&&(Am.detachEvent("onreadystatechange",I),CB.ready());});return CB;}(),Ai="then done fail isResolved isRejected promise".split(" "),Ag=[].slice;Ak.extend({_Deferred:function(){var B=[],A,E,D,C={done:function(){if(!D){var K=arguments,J,I,H,G,F;A&&(F=A,A=0);for(J=0,I=K.length;J<I;J++){H=K[J],G=Ak.type(H),G==="array"?C.done.apply(C,H):G==="function"&&B.push(H);}F&&C.resolveWith(F[0],F[1]);}return this;},resolveWith:function(G,F){if(!D&&!A&&!E){F=F||[],E=1;try{while(B[0]){B.shift().apply(G,F);}}finally{A=[G,F],E=0;}}return this;},resolve:function(){C.resolveWith(this,arguments);return this;},isResolved:function(){return E||A;},cancel:function(){D=1,B=[];return this;}};return C;},Deferred:function(B){var A=Ak._Deferred(),D=Ak._Deferred(),C;Ak.extend(A,{then:function(E,F){A.done(E).fail(F);return this;},fail:D.done,rejectWith:D.resolveWith,reject:D.resolve,isRejected:D.isResolved,promise:function(E){if(E==null){if(C){return C;}C=E={};}var F=Ai.length;while(F--){E[Ai[F]]=A[Ai[F]];}return E;}}),A.done(D.cancel).fail(A.cancel),delete A.cancel,B&&B.call(A,A);return A;},when:function(B){function C(H){return function(I){A[H]=arguments.length>1?Ag.call(arguments,0):I,--E||D.resolveWith(D,Ag.call(A,0));};}var A=arguments,G=0,F=A.length,E=F,D=F<=1&&B&&Ak.isFunction(B.promise)?B:Ak.Deferred();if(F>1){for(;G<F;G++){A[G]&&Ak.isFunction(A[G].promise)?A[G].promise().then(C(G),D.reject):--E;}E||D.resolveWith(D,A);}else{D!==B&&D.resolveWith(D,F?[B]:[]);}return D.promise();}}),function(){Ak.support={};var K=Am.createElement("div");K.style.display="none",K.innerHTML="   <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";var J=K.getElementsByTagName("*"),I=K.getElementsByTagName("a")[0],H=Am.createElement("select"),G=H.appendChild(Am.createElement("option")),F=K.getElementsByTagName("input")[0];if(J&&J.length&&I){Ak.support={leadingWhitespace:K.firstChild.nodeType===3,tbody:!K.getElementsByTagName("tbody").length,htmlSerialize:!!K.getElementsByTagName("link").length,style:/red/.test(I.getAttribute("style")),hrefNormalized:I.getAttribute("href")==="/a",opacity:/^0.55$/.test(I.style.opacity),cssFloat:!!I.style.cssFloat,checkOn:F.value==="on",optSelected:G.selected,deleteExpando:!0,optDisabled:!1,checkClone:!1,noCloneEvent:!0,noCloneChecked:!0,boxModel:null,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableHiddenOffsets:!0,reliableMarginRight:!0},F.checked=!0,Ak.support.noCloneChecked=F.cloneNode(!0).checked,H.disabled=!0,Ak.support.optDisabled=!G.disabled;
var E=null;Ak.support.scriptEval=function(){if(E===null){var L=Am.documentElement,O=Am.createElement("script"),N="script"+Ak.now();try{O.appendChild(Am.createTextNode("window."+N+"=1;"));}catch(M){}L.insertBefore(O,L.firstChild),Aq[N]?(E=!0,delete Aq[N]):E=!1,L.removeChild(O);}return E;};try{delete K.test;}catch(D){Ak.support.deleteExpando=!1;}!K.addEventListener&&K.attachEvent&&K.fireEvent&&(K.attachEvent("onclick",function C(){Ak.support.noCloneEvent=!1,K.detachEvent("onclick",C);}),K.cloneNode(!0).fireEvent("onclick")),K=Am.createElement("div"),K.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";var B=Am.createDocumentFragment();B.appendChild(K.firstChild),Ak.support.checkClone=B.cloneNode(!0).cloneNode(!0).lastChild.checked,Ak(function(){var M=Am.createElement("div"),L=Am.getElementsByTagName("body")[0];if(L){M.style.width=M.style.paddingLeft="1px",L.appendChild(M),Ak.boxModel=Ak.support.boxModel=M.offsetWidth===2,"zoom" in M.style&&(M.style.display="inline",M.style.zoom=1,Ak.support.inlineBlockNeedsLayout=M.offsetWidth===2,M.style.display="",M.innerHTML="<div style='width:4px;'></div>",Ak.support.shrinkWrapBlocks=M.offsetWidth!==2),M.innerHTML="<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";var N=M.getElementsByTagName("td");Ak.support.reliableHiddenOffsets=N[0].offsetHeight===0,N[0].style.display="",N[1].style.display="none",Ak.support.reliableHiddenOffsets=Ak.support.reliableHiddenOffsets&&N[0].offsetHeight===0,M.innerHTML="",Am.defaultView&&Am.defaultView.getComputedStyle&&(M.style.width="1px",M.style.marginRight="0",Ak.support.reliableMarginRight=(parseInt(Am.defaultView.getComputedStyle(M,null).marginRight,10)||0)===0),L.removeChild(M).style.display="none",M=N=null;}});var A=function(M){var L=Am.createElement("div");M="on"+M;if(!L.attachEvent){return !0;}var N=M in L;N||(L.setAttribute(M,"return;"),N=typeof L[M]==="function");return N;};Ak.support.submitBubbles=A("submit"),Ak.support.changeBubbles=A("change"),K=J=I=null;}}();var Ae=/^(?:\{.*\}|\[.*\])$/;Ak.extend({cache:{},uuid:0,expando:"jQuery"+(Ak.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(A){A=A.nodeType?Ak.cache[A[Ak.expando]]:A[Ak.expando];return !!A&&!Aa(A);},data:function(J,I,H,G){if(Ak.acceptData(J)){var F=Ak.expando,E=typeof I==="string",D,C=J.nodeType,B=C?Ak.cache:J,A=C?J[Ak.expando]:J[Ak.expando]&&Ak.expando;if((!A||G&&A&&!B[A][F])&&E&&H===Ao){return ;}A||(C?J[Ak.expando]=A=++Ak.uuid:A=Ak.expando),B[A]||(B[A]={},C||(B[A].toJSON=Ak.noop));if(typeof I==="object"||typeof I==="function"){G?B[A][F]=Ak.extend(B[A][F],I):B[A]=Ak.extend(B[A],I);}D=B[A],G&&(D[F]||(D[F]={}),D=D[F]),H!==Ao&&(D[I]=H);if(I==="events"&&!D[I]){return D[F]&&D[F].events;}return E?D[I]:D;}},removeData:function(I,H,G){if(Ak.acceptData(I)){var F=Ak.expando,E=I.nodeType,D=E?Ak.cache:I,C=E?I[Ak.expando]:Ak.expando;if(!D[C]){return ;}if(H){var B=G?D[C][F]:D[C];if(B){delete B[H];if(!Aa(B)){return ;}}}if(G){delete D[C][F];if(!Aa(D[C])){return ;}}var A=D[C][F];Ak.support.deleteExpando||D!=Aq?delete D[C]:D[C]=null,A?(D[C]={},E||(D[C].toJSON=Ak.noop),D[C][F]=A):E&&(Ak.support.deleteExpando?delete I[Ak.expando]:I.removeAttribute?I.removeAttribute(Ak.expando):I[Ak.expando]=null);}},_data:function(B,A,C){return Ak.data(B,A,C,!0);},acceptData:function(B){if(B.nodeName){var A=Ak.noData[B.nodeName.toLowerCase()];if(A){return A!==!0&&B.getAttribute("classid")===A;}}return !0;}}),Ak.fn.extend({data:function(A,H){var G=null;if(typeof A==="undefined"){if(this.length){G=Ak.data(this[0]);if(this[0].nodeType===1){var F=this[0].attributes,E;for(var D=0,C=F.length;D<C;D++){E=F[D].name,E.indexOf("data-")===0&&(E=E.substr(5),Ac(this[0],E,G[E]));}}}return G;}if(typeof A==="object"){return this.each(function(){Ak.data(this,A);});}var B=A.split(".");B[1]=B[1]?"."+B[1]:"";if(H===Ao){G=this.triggerHandler("getData"+B[1]+"!",[B[0]]),G===Ao&&this.length&&(G=Ak.data(this[0],A),G=Ac(this[0],A,G));
return G===Ao&&B[1]?this.data(B[0]):G;}return this.each(function(){var I=Ak(this),J=[B[0],H];I.triggerHandler("setData"+B[1]+"!",J),Ak.data(this,A,H),I.triggerHandler("changeData"+B[1]+"!",J);});},removeData:function(A){return this.each(function(){Ak.removeData(this,A);});}}),Ak.extend({queue:function(B,A,D){if(B){A=(A||"fx")+"queue";var C=Ak._data(B,A);if(!D){return C||[];}!C||Ak.isArray(D)?C=Ak._data(B,A,Ak.makeArray(D)):C.push(D);return C;}},dequeue:function(B,A){A=A||"fx";var D=Ak.queue(B,A),C=D.shift();C==="inprogress"&&(C=D.shift()),C&&(A==="fx"&&D.unshift("inprogress"),C.call(B,function(){Ak.dequeue(B,A);})),D.length||Ak.removeData(B,A+"queue",!0);}}),Ak.fn.extend({queue:function(A,B){typeof A!=="string"&&(B=A,A="fx");if(B===Ao){return Ak.queue(this[0],A);}return this.each(function(C){var D=Ak.queue(this,A,B);A==="fx"&&D[0]!=="inprogress"&&Ak.dequeue(this,A);});},dequeue:function(A){return this.each(function(){Ak.dequeue(this,A);});},delay:function(B,A){B=Ak.fx?Ak.fx.speeds[B]||B:B,A=A||"fx";return this.queue(A,function(){var C=this;setTimeout(function(){Ak.dequeue(C,A);},B);});},clearQueue:function(A){return this.queue(A||"fx",[]);}});var AZ=/[\n\t\r]/g,AY=/\s+/,AX=/\r/g,AW=/^(?:href|src|style)$/,AV=/^(?:button|input)$/i,AT=/^(?:button|input|object|select|textarea)$/i,AR=/^a(?:rea)?$/i,AP=/^(?:radio|checkbox)$/i;Ak.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"},Ak.fn.extend({attr:function(B,A){return Ak.access(this,B,A,!0,Ak.attr);},removeAttr:function(B,A){return this.each(function(){Ak.attr(this,B,""),this.nodeType===1&&this.removeAttribute(B);});},addClass:function(I){if(Ak.isFunction(I)){return this.each(function(J){var K=Ak(this);K.addClass(I.call(this,J,K.attr("class")));});}if(I&&typeof I==="string"){var H=(I||"").split(AY);for(var G=0,F=this.length;G<F;G++){var E=this[G];if(E.nodeType===1){if(E.className){var D=" "+E.className+" ",C=E.className;for(var B=0,A=H.length;B<A;B++){D.indexOf(" "+H[B]+" ")<0&&(C+=" "+H[B]);}E.className=Ak.trim(C);}else{E.className=I;}}}}return this;},removeClass:function(B){if(Ak.isFunction(B)){return this.each(function(I){var J=Ak(this);J.removeClass(B.call(this,I,J.attr("class")));});}if(B&&typeof B==="string"||B===Ao){var H=(B||"").split(AY);for(var G=0,F=this.length;G<F;G++){var E=this[G];if(E.nodeType===1&&E.className){if(B){var D=(" "+E.className+" ").replace(AZ," ");for(var C=0,A=H.length;C<A;C++){D=D.replace(" "+H[C]+" "," ");}E.className=Ak.trim(D);}else{E.className="";}}}}return this;},toggleClass:function(B,A){var D=typeof B,C=typeof A==="boolean";if(Ak.isFunction(B)){return this.each(function(F){var E=Ak(this);E.toggleClass(B.call(this,F,E.attr("class"),A),A);});}return this.each(function(){if(D==="string"){var I,H=0,G=Ak(this),F=A,E=B.split(AY);while(I=E[H++]){F=C?F:!G.hasClass(I),G[F?"addClass":"removeClass"](I);}}else{if(D==="undefined"||D==="boolean"){this.className&&Ak._data(this,"__className__",this.className),this.className=this.className||B===!1?"":Ak._data(this,"__className__")||"";}}});},hasClass:function(B){var A=" "+B+" ";for(var D=0,C=this.length;D<C;D++){if((" "+this[D].className+" ").replace(AZ," ").indexOf(A)>-1){return !0;}}return !1;},val:function(K){if(!arguments.length){var J=this[0];if(J){if(Ak.nodeName(J,"option")){var I=J.attributes.value;return !I||I.specified?J.value:J.text;}if(Ak.nodeName(J,"select")){var H=J.selectedIndex,G=[],F=J.options,E=J.type==="select-one";if(H<0){return null;}for(var D=E?H:0,C=E?H+1:F.length;D<C;D++){var B=F[D];if(B.selected&&(Ak.support.optDisabled?!B.disabled:B.getAttribute("disabled")===null)&&(!B.parentNode.disabled||!Ak.nodeName(B.parentNode,"optgroup"))){K=Ak(B).val();if(E){return K;}G.push(K);}}if(E&&!G.length&&F.length){return Ak(F[H]).val();}return G;}if(AP.test(J.type)&&!Ak.support.checkOn){return J.getAttribute("value")===null?"on":J.value;}return(J.value||"").replace(AX,"");
}return Ao;}var A=Ak.isFunction(K);return this.each(function(L){var O=Ak(this),N=K;if(this.nodeType===1){A&&(N=K.call(this,L,O.val())),N==null?N="":typeof N==="number"?N+="":Ak.isArray(N)&&(N=Ak.map(N,function(P){return P==null?"":P+"";}));if(Ak.isArray(N)&&AP.test(this.type)){this.checked=Ak.inArray(O.val(),N)>=0;}else{if(Ak.nodeName(this,"select")){var M=Ak.makeArray(N);Ak("option",this).each(function(){this.selected=Ak.inArray(Ak(this).val(),M)>=0;}),M.length||(this.selectedIndex=-1);}else{this.value=N;}}}});}}),Ak.extend({attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(J,I,H,G){if(!J||J.nodeType===3||J.nodeType===8||J.nodeType===2){return Ao;}if(G&&I in Ak.attrFn){return Ak(J)[I](H);}var F=J.nodeType!==1||!Ak.isXMLDoc(J),E=H!==Ao;I=F&&Ak.props[I]||I;if(J.nodeType===1){var D=AW.test(I);if(I==="selected"&&!Ak.support.optSelected){var C=J.parentNode;C&&(C.selectedIndex,C.parentNode&&C.parentNode.selectedIndex);}if((I in J||J[I]!==Ao)&&F&&!D){E&&(I==="type"&&AV.test(J.nodeName)&&J.parentNode&&Ak.error("type property can't be changed"),H===null?J.nodeType===1&&J.removeAttribute(I):J[I]=H);if(Ak.nodeName(J,"form")&&J.getAttributeNode(I)){return J.getAttributeNode(I).nodeValue;}if(I==="tabIndex"){var B=J.getAttributeNode("tabIndex");return B&&B.specified?B.value:AT.test(J.nodeName)||AR.test(J.nodeName)&&J.href?0:Ao;}return J[I];}if(!Ak.support.style&&F&&I==="style"){E&&(J.style.cssText=""+H);return J.style.cssText;}E&&J.setAttribute(I,""+H);if(!J.attributes[I]&&(J.hasAttribute&&!J.hasAttribute(I))){return Ao;}var A=!Ak.support.hrefNormalized&&F&&D?J.getAttribute(I,2):J.getAttribute(I);return A===null?Ao:A;}E&&(J[I]=H);return J[I];}});var AM=/\.(.*)$/,AK=/^(?:textarea|input|select)$/i,AJ=/\./g,AH=/ /g,AE=/[^\w\s.|`]/g,AD=function(A){return A.replace(AE,"\\$&");};Ak.event={add:function(O,N,M,L){if(O.nodeType!==3&&O.nodeType!==8){try{Ak.isWindow(O)&&(O!==Aq&&!O.frameElement)&&(O=Aq);}catch(K){}if(M===!1){M=AC;}else{if(!M){return ;}}var J,I;M.handler&&(J=M,M=J.handler),M.guid||(M.guid=Ak.guid++);var H=Ak._data(O);if(!H){return ;}var G=H.events,F=H.handle;G||(H.events=G={}),F||(H.handle=F=function(P){return typeof Ak!=="undefined"&&Ak.event.triggered!==P.type?Ak.event.handle.apply(F.elem,arguments):Ao;}),F.elem=O,N=N.split(" ");var E,D=0,C;while(E=N[D++]){I=J?Ak.extend({},J):{handler:M,data:L},E.indexOf(".")>-1?(C=E.split("."),E=C.shift(),I.namespace=C.slice(0).sort().join(".")):(C=[],I.namespace=""),I.type=E,I.guid||(I.guid=M.guid);var B=G[E],A=Ak.event.special[E]||{};if(!B){B=G[E]=[];if(!A.setup||A.setup.call(O,L,C,F)===!1){O.addEventListener?O.addEventListener(E,F,!1):O.attachEvent&&O.attachEvent("on"+E,F);}}A.add&&(A.add.call(O,I),I.handler.guid||(I.handler.guid=M.guid)),B.push(I),Ak.event.global[E]=!0;}O=null;}},global:{},remove:function(S,R,Q,P){if(S.nodeType!==3&&S.nodeType!==8){Q===!1&&(Q=AC);var O,N,M,L,K=0,J,I,H,G,F,E,D,C=Ak.hasData(S)&&Ak._data(S),B=C&&C.events;if(!C||!B){return ;}R&&R.type&&(Q=R.handler,R=R.type);if(!R||typeof R==="string"&&R.charAt(0)==="."){R=R||"";for(N in B){Ak.event.remove(S,N+R);}return ;}R=R.split(" ");while(N=R[K++]){D=N,E=null,J=N.indexOf(".")<0,I=[],J||(I=N.split("."),N=I.shift(),H=new RegExp("(^|\\.)"+Ak.map(I.slice(0).sort(),AD).join("\\.(?:.*\\.)?")+"(\\.|$)")),F=B[N];if(!F){continue;}if(!Q){for(L=0;L<F.length;L++){E=F[L];if(J||H.test(E.namespace)){Ak.event.remove(S,D,E.handler,L),F.splice(L--,1);}}continue;}G=Ak.event.special[N]||{};for(L=P||0;L<F.length;L++){E=F[L];if(Q.guid===E.guid){if(J||H.test(E.namespace)){P==null&&F.splice(L--,1),G.remove&&G.remove.call(S,E);}if(P!=null){break;}}}if(F.length===0||P!=null&&F.length===1){(!G.teardown||G.teardown.call(S,I)===!1)&&Ak.removeEvent(S,N,C.handle),O=null,delete B[N];}}if(Ak.isEmptyObject(B)){var A=C.handle;A&&(A.elem=null),delete C.events,delete C.handle,Ak.isEmptyObject(C)&&Ak.removeData(S,Ao,!0);}}},trigger:function(N,M,L){var K=N.type||N,J=arguments[3];if(!J){N=typeof N==="object"?N[Ak.expando]?N:Ak.extend(Ak.Event(K),N):Ak.Event(K),K.indexOf("!")>=0&&(N.type=K=K.slice(0,-1),N.exclusive=!0),L||(N.stopPropagation(),Ak.event.global[K]&&Ak.each(Ak.cache,function(){var O=Ak.expando,P=this[O];
P&&P.events&&P.events[K]&&Ak.event.trigger(N,M,P.handle.elem);}));if(!L||L.nodeType===3||L.nodeType===8){return Ao;}N.result=Ao,N.target=L,M=Ak.makeArray(M),M.unshift(N);}N.currentTarget=L;var I=Ak._data(L,"handle");I&&I.apply(L,M);var H=L.parentNode||L.ownerDocument;try{L&&L.nodeName&&Ak.noData[L.nodeName.toLowerCase()]||L["on"+K]&&L["on"+K].apply(L,M)===!1&&(N.result=!1,N.preventDefault());}catch(G){}if(!N.isPropagationStopped()&&H){Ak.event.trigger(N,M,H,!0);}else{if(!N.isDefaultPrevented()){var F,E=N.target,D=K.replace(AM,""),C=Ak.nodeName(E,"a")&&D==="click",B=Ak.event.special[D]||{};if((!B._default||B._default.call(L,N)===!1)&&!C&&!(E&&E.nodeName&&Ak.noData[E.nodeName.toLowerCase()])){try{E[D]&&(F=E["on"+D],F&&(E["on"+D]=null),Ak.event.triggered=N.type,E[D]());}catch(A){}F&&(E["on"+D]=F),Ak.event.triggered=Ao;}}}},handle:function(L){var K,J,I,H,G,F=[],E=Ak.makeArray(arguments);L=E[0]=Ak.event.fix(L||Aq.event),L.currentTarget=this,K=L.type.indexOf(".")<0&&!L.exclusive,K||(I=L.type.split("."),L.type=I.shift(),F=I.slice(0).sort(),H=new RegExp("(^|\\.)"+F.join("\\.(?:.*\\.)?")+"(\\.|$)")),L.namespace=L.namespace||F.join("."),G=Ak._data(this,"events"),J=(G||{})[L.type];if(G&&J){J=J.slice(0);for(var D=0,C=J.length;D<C;D++){var B=J[D];if(K||H.test(B.namespace)){L.handler=B.handler,L.data=B.data,L.handleObj=B;var A=B.handler.apply(this,E);A!==Ao&&(L.result=A,A===!1&&(L.preventDefault(),L.stopPropagation()));if(L.isImmediatePropagationStopped()){break;}}}}return L.result;},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(A){if(A[Ak.expando]){return A;}var F=A;A=Ak.Event(F);for(var E=this.props.length,D;E;){D=this.props[--E],A[D]=F[D];}A.target||(A.target=A.srcElement||Am),A.target.nodeType===3&&(A.target=A.target.parentNode),!A.relatedTarget&&A.fromElement&&(A.relatedTarget=A.fromElement===A.target?A.toElement:A.fromElement);if(A.pageX==null&&A.clientX!=null){var C=Am.documentElement,B=Am.body;A.pageX=A.clientX+(C&&C.scrollLeft||B&&B.scrollLeft||0)-(C&&C.clientLeft||B&&B.clientLeft||0),A.pageY=A.clientY+(C&&C.scrollTop||B&&B.scrollTop||0)-(C&&C.clientTop||B&&B.clientTop||0);}A.which==null&&(A.charCode!=null||A.keyCode!=null)&&(A.which=A.charCode!=null?A.charCode:A.keyCode),!A.metaKey&&A.ctrlKey&&(A.metaKey=A.ctrlKey),!A.which&&A.button!==Ao&&(A.which=A.button&1?1:A.button&2?3:A.button&4?2:0);return A;},guid:100000000,proxy:Ak.proxy,special:{ready:{setup:Ak.bindReady,teardown:Ak.noop},live:{add:function(A){Ak.event.add(this,BT(A.origType,A.selector),Ak.extend({},A,{handler:BV,guid:A.handler.guid}));},remove:function(A){Ak.event.remove(this,BT(A.origType,A.selector),A);}},beforeunload:{setup:function(B,A,C){Ak.isWindow(this)&&(this.onbeforeunload=C);},teardown:function(B,A){this.onbeforeunload===A&&(this.onbeforeunload=null);}}}},Ak.removeEvent=Am.removeEventListener?function(B,A,C){B.removeEventListener&&B.removeEventListener(A,C,!1);}:function(B,A,C){B.detachEvent&&B.detachEvent("on"+A,C);},Ak.Event=function(A){if(!this.preventDefault){return new Ak.Event(A);}A&&A.type?(this.originalEvent=A,this.type=A.type,this.isDefaultPrevented=A.defaultPrevented||A.returnValue===!1||A.getPreventDefault&&A.getPreventDefault()?AB:AC):this.type=A,this.timeStamp=Ak.now(),this[Ak.expando]=!0;},Ak.Event.prototype={preventDefault:function(){this.isDefaultPrevented=AB;var A=this.originalEvent;A&&(A.preventDefault?A.preventDefault():A.returnValue=!1);},stopPropagation:function(){this.isPropagationStopped=AB;var A=this.originalEvent;A&&(A.stopPropagation&&A.stopPropagation(),A.cancelBubble=!0);},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=AB,this.stopPropagation();},isDefaultPrevented:AC,isPropagationStopped:AC,isImmediatePropagationStopped:AC};
var AA=function(B){var A=B.relatedTarget;try{if(A&&A!==Am&&!A.parentNode){return ;}while(A&&A!==this){A=A.parentNode;}A!==this&&(B.type=B.data,Ak.event.handle.apply(this,arguments));}catch(C){}},Bh=function(A){A.type=A.data,Ak.event.handle.apply(this,arguments);};Ak.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(B,A){Ak.event.special[B]={setup:function(C){Ak.event.add(this,A,C&&C.selector?Bh:AA,B);},teardown:function(C){Ak.event.remove(this,A,C&&C.selector?Bh:AA);}};}),Ak.support.submitBubbles||(Ak.event.special.submit={setup:function(B,A){if(this.nodeName&&this.nodeName.toLowerCase()!=="form"){Ak.event.add(this,"click.specialSubmit",function(D){var C=D.target,E=C.type;(E==="submit"||E==="image")&&Ak(C).closest("form").length&&Ba("submit",this,arguments);}),Ak.event.add(this,"keypress.specialSubmit",function(D){var C=D.target,E=C.type;(E==="text"||E==="password")&&Ak(C).closest("form").length&&D.keyCode===13&&Ba("submit",this,arguments);});}else{return !1;}},teardown:function(A){Ak.event.remove(this,".specialSubmit");}});if(!Ak.support.changeBubbles){var Bg,Be=function(B){var A=B.type,C=B.value;A==="radio"||A==="checkbox"?C=B.checked:A==="select-multiple"?C=B.selectedIndex>-1?Ak.map(B.options,function(D){return D.selected;}).join("-"):"":B.nodeName.toLowerCase()==="select"&&(C=B.selectedIndex);return C;},Bc=function Bc(A){var D=A.target,C,B;if(AK.test(D.nodeName)&&!D.readOnly){C=Ak._data(D,"_change_data"),B=Be(D),(A.type!=="focusout"||D.type!=="radio")&&Ak._data(D,"_change_data",B);if(C===Ao||B===C){return ;}if(C!=null||B){A.type="change",A.liveFired=Ao,Ak.event.trigger(A,arguments[1],D);}}};Ak.event.special.change={filters:{focusout:Bc,beforedeactivate:Bc,click:function(B){var A=B.target,C=A.type;(C==="radio"||C==="checkbox"||A.nodeName.toLowerCase()==="select")&&Bc.call(this,B);},keydown:function(B){var A=B.target,C=A.type;(B.keyCode===13&&A.nodeName.toLowerCase()!=="textarea"||B.keyCode===32&&(C==="checkbox"||C==="radio")||C==="select-multiple")&&Bc.call(this,B);},beforeactivate:function(B){var A=B.target;Ak._data(A,"_change_data",Be(A));}},setup:function(B,A){if(this.type==="file"){return !1;}for(var C in Bg){Ak.event.add(this,C+".specialChange",Bg[C]);}return AK.test(this.nodeName);},teardown:function(A){Ak.event.remove(this,".specialChange");return AK.test(this.nodeName);}},Bg=Ak.event.special.change.filters,Bg.focus=Bg.beforeactivate;}Am.addEventListener&&Ak.each({focus:"focusin",blur:"focusout"},function(B,A){function C(E){var F=Ak.event.fix(E);F.type=A,F.originalEvent={},Ak.event.trigger(F,null,F.target),F.isDefaultPrevented()&&E.preventDefault();}var D=0;Ak.event.special[A]={setup:function(){D++===0&&Am.addEventListener(B,C,!0);},teardown:function(){--D===0&&Am.removeEventListener(B,C,!0);}};}),Ak.each(["bind","one"],function(A,B){Ak.fn[B]=function(C,I,H){if(typeof C==="object"){for(var G in C){this[B](G,I,C[G],H);}return this;}if(Ak.isFunction(I)||I===!1){H=I,I=Ao;}var F=B==="one"?Ak.proxy(H,function(J){Ak(this).unbind(J,F);return H.apply(this,arguments);}):H;if(C==="unload"&&B!=="one"){this.one(C,I,H);}else{for(var E=0,D=this.length;E<D;E++){Ak.event.add(this[E],C,F,I);}}return this;};}),Ak.fn.extend({unbind:function(B,A){if(typeof B!=="object"||B.preventDefault){for(var D=0,C=this.length;D<C;D++){Ak.event.remove(this[D],B,A);}}else{for(var E in B){this.unbind(E,B[E]);}}return this;},delegate:function(B,A,D,C){return this.live(A,D,C,B);},undelegate:function(B,A,C){return arguments.length===0?this.unbind("live"):this.die(A,null,C,B);},trigger:function(B,A){return this.each(function(){Ak.event.trigger(B,A,this);});},triggerHandler:function(B,A){if(this[0]){var C=Ak.Event(B);C.preventDefault(),C.stopPropagation(),Ak.event.trigger(C,A,this[0]);return C.result;}},toggle:function(B){var A=arguments,C=1;while(C<A.length){Ak.proxy(B,A[C++]);}return this.click(Ak.proxy(B,function(E){var D=(Ak._data(this,"lastToggle"+B.guid)||0)%C;Ak._data(this,"lastToggle"+B.guid,D+1),E.preventDefault();return A[D].apply(this,arguments)||!1;
}));},hover:function(B,A){return this.mouseenter(B).mouseleave(A||B);}});var BY={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};Ak.each(["live","die"],function(A,B){Ak.fn[B]=function(P,O,N,M){var L,K=0,J,I,H,G=M||this.selector,F=M?this:Ak(this.context);if(typeof P==="object"&&!P.preventDefault){for(var E in P){F[B](E,O,P[E],G);}return this;}Ak.isFunction(O)&&(N=O,O=Ao),P=(P||"").split(" ");while((L=P[K++])!=null){J=AM.exec(L),I="",J&&(I=J[0],L=L.replace(AM,""));if(L==="hover"){P.push("mouseenter"+I,"mouseleave"+I);continue;}H=L,L==="focus"||L==="blur"?(P.push(BY[L]+I),L=L+I):L=(BY[L]||L)+I;if(B==="live"){for(var D=0,C=F.length;D<C;D++){Ak.event.add(F[D],"live."+BT(L,G),{data:O,selector:G,handler:N,origType:L,origHandler:N,preType:H});}}else{F.unbind("live."+BT(L,G),N);}}return this;};}),Ak.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),function(B,A){Ak.fn[A]=function(C,D){D==null&&(D=C,C=null);return arguments.length>0?this.bind(A,C,D):this.trigger(A);},Ak.attrFn&&(Ak.attrFn[A]=!0);}),function(){function B(m,l,k,Z,Y,X){for(var W=0,V=Z.length;W<V;W++){var U=Z[W];if(U){var T=!1;U=U[m];while(U){if(U.sizcache===k){T=Z[U.sizset];break;}if(U.nodeType===1){X||(U.sizcache=k,U.sizset=W);if(typeof l!=="string"){if(U===l){T=!0;break;}}else{if(L.filter(l,[U]).length>0){T=U;break;}}}U=U[m];}Z[W]=T;}}}function C(m,l,k,Z,Y,X){for(var W=0,V=Z.length;W<V;W++){var U=Z[W];if(U){var T=!1;U=U[m];while(U){if(U.sizcache===k){T=Z[U.sizset];break;}U.nodeType===1&&!X&&(U.sizcache=k,U.sizset=W);if(U.nodeName.toLowerCase()===l){T=U;break;}U=U[m];}Z[W]=T;}}}var S=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,R=0,Q=Object.prototype.toString,P=!1,O=!0,N=/\\/g,M=/\W/;[0,0].sort(function(){O=!1;return 0;});var L=function(m,k,f,a){f=f||[],k=k||Am;var Z=k;if(k.nodeType!==1&&k.nodeType!==9){return[];}if(!m||typeof m!=="string"){return f;}var Y,X,W,V,U,T,B4,B3,z=!0,v=L.isXML(k),p=[],l=m;do{S.exec(""),Y=S.exec(l);if(Y){l=Y[3],p.push(Y[1]);if(Y[2]){V=Y[3];break;}}}while(Y);if(p.length>1&&J.exec(m)){if(p.length===2&&K.relative[p[0]]){X=A(p[0]+p[1],k);}else{X=K.relative[p[0]]?[k]:L(p.shift(),k);while(p.length){m=p.shift(),K.relative[m]&&(m+=p.shift()),X=A(m,X);}}}else{!a&&p.length>1&&k.nodeType===9&&!v&&K.match.ID.test(p[0])&&!K.match.ID.test(p[p.length-1])&&(U=L.find(p.shift(),k,v),k=U.expr?L.filter(U.expr,U.set)[0]:U.set[0]);if(k){U=a?{expr:p.pop(),set:G(a)}:L.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&k.parentNode?k.parentNode:k,v),X=U.expr?L.filter(U.expr,U.set):U.set,p.length>0?W=G(X):z=!1;while(p.length){T=p.pop(),B4=T,K.relative[T]?B4=p.pop():T="",B4==null&&(B4=k),K.relative[T](W,B4,v);}}else{W=p=[];}}W||(W=X),W||L.error(T||m);if(Q.call(W)==="[object Array]"){if(z){if(k&&k.nodeType===1){for(B3=0;W[B3]!=null;B3++){W[B3]&&(W[B3]===!0||W[B3].nodeType===1&&L.contains(k,W[B3]))&&f.push(X[B3]);}}else{for(B3=0;W[B3]!=null;B3++){W[B3]&&W[B3].nodeType===1&&f.push(X[B3]);}}}else{f.push.apply(f,W);}}else{G(W,f);}V&&(L(V,Z,f,a),L.uniqueSort(f));return f;};L.uniqueSort=function(U){if(E){P=O,U.sort(E);if(P){for(var T=1;T<U.length;T++){U[T]===U[T-1]&&U.splice(T--,1);}}}return U;},L.matches=function(U,T){return L(U,null,null,T);},L.matchesSelector=function(U,T){return L(T,null,null,[U]).length>0;},L.find=function(l,k,Z){var Y;if(!l){return[];}for(var X=0,W=K.order.length;X<W;X++){var V,U=K.order[X];if(V=K.leftMatch[U].exec(l)){var T=V[1];V.splice(1,1);if(T.substr(T.length-1)!=="\\"){V[1]=(V[1]||"").replace(N,""),Y=K.find[U](V,k,Z);if(Y!=null){l=l.replace(K.match[U],"");break;}}}}Y||(Y=typeof k.getElementsByTagName!=="undefined"?k.getElementsByTagName("*"):[]);return{set:Y,expr:l};},L.filter=function(B3,z,w,v){var u,l,k=B3,b=[],Z=z,Y=z&&z[0]&&L.isXML(z[0]);while(B3&&z.length){for(var X in K.filter){if((u=K.leftMatch[X].exec(B3))!=null&&u[2]){var W,V,U=K.filter[X],T=u[1];
l=!1,u.splice(1,1);if(T.substr(T.length-1)==="\\"){continue;}Z===b&&(b=[]);if(K.preFilter[X]){u=K.preFilter[X](u,Z,w,b,v,Y);if(u){if(u===!0){continue;}}else{l=W=!0;}}if(u){for(var B5=0;(V=Z[B5])!=null;B5++){if(V){W=U(V,u,B5,Z);var B4=v^!!W;w&&W!=null?B4?l=!0:Z[B5]=!1:B4&&(b.push(V),l=!0);}}}if(W!==Ao){w||(Z=b),B3=B3.replace(K.match[X],"");if(!l){return[];}break;}}}if(B3===k){if(l==null){L.error(B3);}else{break;}}k=B3;}return Z;},L.error=function(T){throw"Syntax error, unrecognized expression: "+T;};var K=L.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(T){return T.getAttribute("href");},type:function(T){return T.getAttribute("type");}},relative:{"+":function(U,T){var j=typeof T==="string",Z=j&&!M.test(T),Y=j&&!Z;Z&&(T=T.toLowerCase());for(var X=0,W=U.length,V;X<W;X++){if(V=U[X]){while((V=V.previousSibling)&&V.nodeType!==1){}U[X]=Y||V&&V.nodeName.toLowerCase()===T?V||!1:V===T;}}Y&&L.filter(T,U,!0);},">":function(U,T){var Z,Y=typeof T==="string",X=0,W=U.length;if(Y&&!M.test(T)){T=T.toLowerCase();for(;X<W;X++){Z=U[X];if(Z){var V=Z.parentNode;U[X]=V.nodeName.toLowerCase()===T?V:!1;}}}else{for(;X<W;X++){Z=U[X],Z&&(U[X]=Y?Z.parentNode:Z.parentNode===T);}Y&&L.filter(T,U,!0);}},"":function(U,T,Y){var X,W=R++,V=B;typeof T==="string"&&!M.test(T)&&(T=T.toLowerCase(),X=T,V=C),V("parentNode",T,W,U,X,Y);},"~":function(U,T,Y){var X,W=R++,V=B;typeof T==="string"&&!M.test(T)&&(T=T.toLowerCase(),X=T,V=C),V("previousSibling",T,W,U,X,Y);}},find:{ID:function(U,T,W){if(typeof T.getElementById!=="undefined"&&!W){var V=T.getElementById(U[1]);return V&&V.parentNode?[V]:[];}},NAME:function(U,T){if(typeof T.getElementsByName!=="undefined"){var Y=[],X=T.getElementsByName(U[1]);for(var W=0,V=X.length;W<V;W++){X[W].getAttribute("name")===U[1]&&Y.push(X[W]);}return Y.length===0?null:Y;}},TAG:function(U,T){if(typeof T.getElementsByTagName!=="undefined"){return T.getElementsByTagName(U[1]);}}},preFilter:{CLASS:function(U,T,j,Z,Y,X){U=" "+U[1].replace(N,"")+" ";if(X){return U;}for(var W=0,V;(V=T[W])!=null;W++){V&&(Y^(V.className&&(" "+V.className+" ").replace(/[\t\n\r]/g," ").indexOf(U)>=0)?j||Z.push(V):j&&(T[W]=!1));}return !1;},ID:function(T){return T[1].replace(N,"");},TAG:function(U,T){return U[1].replace(N,"").toLowerCase();},CHILD:function(U){if(U[1]==="nth"){U[2]||L.error(U[0]),U[2]=U[2].replace(/^\+|\s*/g,"");var T=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(U[2]==="even"&&"2n"||U[2]==="odd"&&"2n+1"||!/\D/.test(U[2])&&"0n+"+U[2]||U[2]);U[2]=T[1]+(T[2]||1)-0,U[3]=T[3]-0;}else{U[2]&&L.error(U[0]);}U[0]=R++;return U;},ATTR:function(U,T,Z,Y,X,W){var V=U[1]=U[1].replace(N,"");!W&&K.attrMap[V]&&(U[1]=K.attrMap[V]),U[4]=(U[4]||U[5]||"").replace(N,""),U[2]==="~="&&(U[4]=" "+U[4]+" ");return U;},PSEUDO:function(T,Y,X,W,V){if(T[1]==="not"){if((S.exec(T[3])||"").length>1||/^\w/.test(T[3])){T[3]=L(T[3],null,null,Y);}else{var U=L.filter(T[3],Y,X,!0^V);X||W.push.apply(W,U);return !1;}}else{if(K.match.POS.test(T[0])||K.match.CHILD.test(T[0])){return !0;}}return T;},POS:function(T){T.unshift(!0);return T;}},filters:{enabled:function(T){return T.disabled===!1&&T.type!=="hidden";},disabled:function(T){return T.disabled===!0;},checked:function(T){return T.checked===!0;},selected:function(T){T.parentNode&&T.parentNode.selectedIndex;return T.selected===!0;},parent:function(T){return !!T.firstChild;},empty:function(T){return !T.firstChild;},has:function(U,T,V){return !!L(V[3],U).length;
},header:function(T){return/h\d/i.test(T.nodeName);},text:function(U){var T=U.getAttribute("type"),V=U.type;return"text"===V&&(T===V||T===null);},radio:function(T){return"radio"===T.type;},checkbox:function(T){return"checkbox"===T.type;},file:function(T){return"file"===T.type;},password:function(T){return"password"===T.type;},submit:function(T){return"submit"===T.type;},image:function(T){return"image"===T.type;},reset:function(T){return"reset"===T.type;},button:function(T){return"button"===T.type||T.nodeName.toLowerCase()==="button";},input:function(T){return/input|select|textarea|button/i.test(T.nodeName);}},setFilters:{first:function(U,T){return T===0;},last:function(U,T,W,V){return T===V.length-1;},even:function(U,T){return T%2===0;},odd:function(U,T){return T%2===1;},lt:function(U,T,V){return T<V[3]-0;},gt:function(U,T,V){return T>V[3]-0;},nth:function(U,T,V){return V[3]-0===T;},eq:function(U,T,V){return V[3]-0===T;}},filter:{PSEUDO:function(k,j,Z,Y){var X=j[1],W=K.filters[X];if(W){return W(k,Z,j,Y);}if(X==="contains"){return(k.textContent||k.innerText||L.getText([k])||"").indexOf(j[3])>=0;}if(X==="not"){var V=j[3];for(var U=0,T=V.length;U<T;U++){if(V[U]===k){return !1;}}return !0;}L.error(X);},CHILD:function(m,l){var k=l[1],Z=m;switch(k){case"only":case"first":while(Z=Z.previousSibling){if(Z.nodeType===1){return !1;}}if(k==="first"){return !0;}Z=m;case"last":while(Z=Z.nextSibling){if(Z.nodeType===1){return !1;}}return !0;case"nth":var Y=l[2],X=l[3];if(Y===1&&X===0){return !0;}var W=l[0],V=m.parentNode;if(V&&(V.sizcache!==W||!m.nodeIndex)){var U=0;for(Z=V.firstChild;Z;Z=Z.nextSibling){Z.nodeType===1&&(Z.nodeIndex=++U);}V.sizcache=W;}var T=m.nodeIndex-X;return Y===0?T===0:T%Y===0&&T/Y>=0;}},ID:function(U,T){return U.nodeType===1&&U.getAttribute("id")===T;},TAG:function(U,T){return T==="*"&&U.nodeType===1||U.nodeName.toLowerCase()===T;},CLASS:function(U,T){return(" "+(U.className||U.getAttribute("class"))+" ").indexOf(T)>-1;},ATTR:function(U,T){var Z=T[1],Y=K.attrHandle[Z]?K.attrHandle[Z](U):U[Z]!=null?U[Z]:U.getAttribute(Z),X=Y+"",W=T[2],V=T[4];return Y==null?W==="!=":W==="="?X===V:W==="*="?X.indexOf(V)>=0:W==="~="?(" "+X+" ").indexOf(V)>=0:V?W==="!="?X!==V:W==="^="?X.indexOf(V)===0:W==="$="?X.substr(X.length-V.length)===V:W==="|="?X===V||X.substr(0,V.length+1)===V+"-":!1:X&&Y!==!1;},POS:function(U,T,Y,X){var W=T[2],V=K.setFilters[W];if(V){return V(U,Y,T,X);}}}},J=K.match.POS,I=function(U,T){return"\\"+(T-0+1);};for(var H in K.match){K.match[H]=new RegExp(K.match[H].source+/(?![^\[]*\])(?![^\(]*\))/.source),K.leftMatch[H]=new RegExp(/(^(?:.|\r|\n)*?)/.source+K.match[H].source.replace(/\\(\d+)/g,I));}var G=function(U,T){U=Array.prototype.slice.call(U,0);if(T){T.push.apply(T,U);return T;}return U;};try{Array.prototype.slice.call(Am.documentElement.childNodes,0)[0].nodeType;}catch(F){G=function(U,T){var X=0,W=T||[];if(Q.call(U)==="[object Array]"){Array.prototype.push.apply(W,U);}else{if(typeof U.length==="number"){for(var V=U.length;X<V;X++){W.push(U[X]);}}else{for(;U[X];X++){W.push(U[X]);}}}return W;};}var E,D;Am.documentElement.compareDocumentPosition?E=function(U,T){if(U===T){P=!0;return 0;}if(!U.compareDocumentPosition||!T.compareDocumentPosition){return U.compareDocumentPosition?-1:1;}return U.compareDocumentPosition(T)&4?-1:1;}:(E=function(m,l){var g,Z,Y=[],X=[],W=m.parentNode,V=l.parentNode,U=W;if(m===l){P=!0;return 0;}if(W===V){return D(m,l);}if(!W){return -1;}if(!V){return 1;}while(U){Y.unshift(U),U=U.parentNode;}U=V;while(U){X.unshift(U),U=U.parentNode;}g=Y.length,Z=X.length;for(var T=0;T<g&&T<Z;T++){if(Y[T]!==X[T]){return D(Y[T],X[T]);}}return T===g?D(m,X[T],-1):D(Y[T],l,1);},D=function(U,T,W){if(U===T){return W;}var V=U.nextSibling;while(V){if(V===T){return -1;}V=V.nextSibling;}return 1;}),L.getText=function(U){var T="",W;for(var V=0;U[V];V++){W=U[V],W.nodeType===3||W.nodeType===4?T+=W.nodeValue:W.nodeType!==8&&(T+=L.getText(W.childNodes));}return T;},function(){var T=Am.createElement("div"),V="script"+(new Date).getTime(),U=Am.documentElement;
T.innerHTML="<a name='"+V+"'/>",U.insertBefore(T,U.firstChild),Am.getElementById(V)&&(K.find.ID=function(W,Z,Y){if(typeof Z.getElementById!=="undefined"&&!Y){var X=Z.getElementById(W[1]);return X?X.id===W[1]||typeof X.getAttributeNode!=="undefined"&&X.getAttributeNode("id").nodeValue===W[1]?[X]:Ao:[];}},K.filter.ID=function(X,W){var Y=typeof X.getAttributeNode!=="undefined"&&X.getAttributeNode("id");return X.nodeType===1&&Y&&Y.nodeValue===W;}),U.removeChild(T),U=T=null;}(),function(){var T=Am.createElement("div");T.appendChild(Am.createComment("")),T.getElementsByTagName("*").length>0&&(K.find.TAG=function(V,U){var Y=U.getElementsByTagName(V[1]);if(V[1]==="*"){var X=[];for(var W=0;Y[W];W++){Y[W].nodeType===1&&X.push(Y[W]);}Y=X;}return Y;}),T.innerHTML="<a href='#'></a>",T.firstChild&&typeof T.firstChild.getAttribute!=="undefined"&&T.firstChild.getAttribute("href")!=="#"&&(K.attrHandle.href=function(U){return U.getAttribute("href",2);}),T=null;}(),Am.querySelectorAll&&function(){var U=L,T=Am.createElement("div"),W="__sizzle__";T.innerHTML="<p class='TEST'></p>";if(!T.querySelectorAll||T.querySelectorAll(".TEST").length!==0){L=function(w,v,u,t){v=v||Am;if(!t&&!L.isXML(v)){var p=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(w);if(p&&(v.nodeType===1||v.nodeType===9)){if(p[1]){return G(v.getElementsByTagName(w),u);}if(p[2]&&K.find.CLASS&&v.getElementsByClassName){return G(v.getElementsByClassName(p[2]),u);}}if(v.nodeType===9){if(w==="body"&&v.body){return G([v.body],u);}if(p&&p[3]){var l=v.getElementById(p[3]);if(!l||!l.parentNode){return G([],u);}if(l.id===p[3]){return G([l],u);}}try{return G(v.querySelectorAll(w),u);}catch(k){}}else{if(v.nodeType===1&&v.nodeName.toLowerCase()!=="object"){var d=v,a=v.getAttribute("id"),Z=a||W,Y=v.parentNode,X=/^\s*[+~]/.test(w);a?Z=Z.replace(/'/g,"\\$&"):v.setAttribute("id",Z),X&&Y&&(v=v.parentNode);try{if(!X||Y){return G(v.querySelectorAll("[id='"+Z+"'] "+w),u);}}catch(z){}finally{a||d.removeAttribute("id");}}}}return U(w,v,u,t);};for(var V in U){L[V]=U[V];}T=null;}}(),function(){var U=Am.documentElement,T=U.matchesSelector||U.mozMatchesSelector||U.webkitMatchesSelector||U.msMatchesSelector;if(T){var X=!T.call(Am.createElement("div"),"div"),W=!1;try{T.call(Am.documentElement,"[test!='']:sizzle");}catch(V){W=!0;}L.matchesSelector=function(Y,d){d=d.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!L.isXML(Y)){try{if(W||!K.match.PSEUDO.test(d)&&!/!=/.test(d)){var b=T.call(Y,d);if(b||!X||Y.document&&Y.document.nodeType!==11){return b;}}}catch(Z){}}return L(d,null,null,[Y]).length>0;};}}(),function(){var T=Am.createElement("div");T.innerHTML="<div class='test e'></div><div class='test'></div>";if(T.getElementsByClassName&&T.getElementsByClassName("e").length!==0){T.lastChild.className="e";if(T.getElementsByClassName("e").length===1){return ;}K.order.splice(1,0,"CLASS"),K.find.CLASS=function(V,U,W){if(typeof U.getElementsByClassName!=="undefined"&&!W){return U.getElementsByClassName(V[1]);}},T=null;}}(),Am.documentElement.contains?L.contains=function(U,T){return U!==T&&(U.contains?U.contains(T):!0);}:Am.documentElement.compareDocumentPosition?L.contains=function(U,T){return !!(U.compareDocumentPosition(T)&16);}:L.contains=function(){return !1;},L.isXML=function(U){var T=(U?U.ownerDocument||U:0).documentElement;return T?T.nodeName!=="HTML":!1;};var A=function(U,T){var j,Z=[],Y="",X=T.nodeType?[T]:T;while(j=K.match.PSEUDO.exec(U)){Y+=j[0],U=U.replace(K.match.PSEUDO,"");}U=K.relative[U]?U+"*":U;for(var W=0,V=X.length;W<V;W++){L(U,X[W],Z);}return L.filter(Y,Z);};Ak.find=L,Ak.expr=L.selectors,Ak.expr[":"]=Ak.expr.filters,Ak.unique=L.uniqueSort,Ak.text=L.getText,Ak.isXMLDoc=L.isXML,Ak.contains=L.contains;}();var BS=/Until$/,BR=/^(?:parents|prevUntil|prevAll)/,BQ=/,/,BP=/^.[^:#\[\.,]*$/,BO=Array.prototype.slice,BM=Ak.expr.match.POS,BL={children:!0,contents:!0,next:!0,prev:!0};Ak.fn.extend({find:function(B){var A=this.pushStack("","find",B),G=0;for(var F=0,E=this.length;F<E;F++){G=A.length,Ak.find(B,this[F],A);if(F>0){for(var D=G;
D<A.length;D++){for(var C=0;C<G;C++){if(A[C]===A[D]){A.splice(D--,1);break;}}}}}return A;},has:function(B){var A=Ak(B);return this.filter(function(){for(var C=0,D=A.length;C<D;C++){if(Ak.contains(this,A[C])){return !0;}}});},not:function(A){return this.pushStack(BH(this,A,!1),"not",A);},filter:function(A){return this.pushStack(BH(this,A,!0),"filter",A);},is:function(A){return !!A&&Ak.filter(A,this).length>0;},closest:function(K,J){var I=[],H,G,F=this[0];if(Ak.isArray(K)){var E,D,C={},B=1;if(F&&K.length){for(H=0,G=K.length;H<G;H++){D=K[H],C[D]||(C[D]=Ak.expr.match.POS.test(D)?Ak(D,J||this.context):D);}while(F&&F.ownerDocument&&F!==J){for(D in C){E=C[D],(E.jquery?E.index(F)>-1:Ak(F).is(E))&&I.push({selector:D,elem:F,level:B});}F=F.parentNode,B++;}}return I;}var A=BM.test(K)?Ak(K,J||this.context):null;for(H=0,G=this.length;H<G;H++){F=this[H];while(F){if(A?A.index(F)>-1:Ak.find.matchesSelector(F,K)){I.push(F);break;}F=F.parentNode;if(!F||!F.ownerDocument||F===J){break;}}}I=I.length>1?Ak.unique(I):I;return this.pushStack(I,"closest",K);},index:function(A){if(!A||typeof A==="string"){return Ak.inArray(this[0],A?Ak(A):this.parent().children());}return Ak.inArray(A.jquery?A[0]:A,this);},add:function(B,A){var D=typeof B==="string"?Ak(B,A):Ak.makeArray(B),C=Ak.merge(this.get(),D);return this.pushStack(BJ(D[0])||BJ(C[0])?C:Ak.unique(C));},andSelf:function(){return this.add(this.prevObject);}}),Ak.each({parent:function(B){var A=B.parentNode;return A&&A.nodeType!==11?A:null;},parents:function(A){return Ak.dir(A,"parentNode");},parentsUntil:function(B,A,C){return Ak.dir(B,"parentNode",C);},next:function(A){return Ak.nth(A,2,"nextSibling");},prev:function(A){return Ak.nth(A,2,"previousSibling");},nextAll:function(A){return Ak.dir(A,"nextSibling");},prevAll:function(A){return Ak.dir(A,"previousSibling");},nextUntil:function(B,A,C){return Ak.dir(B,"nextSibling",C);},prevUntil:function(B,A,C){return Ak.dir(B,"previousSibling",C);},siblings:function(A){return Ak.sibling(A.parentNode.firstChild,A);},children:function(A){return Ak.sibling(A.firstChild);},contents:function(A){return Ak.nodeName(A,"iframe")?A.contentDocument||A.contentWindow.document:Ak.makeArray(A.childNodes);}},function(B,A){Ak.fn[B]=function(F,E){var D=Ak.map(this,A,F),C=BO.call(arguments);BS.test(B)||(E=F),E&&typeof E==="string"&&(D=Ak.filter(E,D)),D=this.length>1&&!BL[B]?Ak.unique(D):D,(this.length>1||BQ.test(E))&&BR.test(B)&&(D=D.reverse());return this.pushStack(D,B,C.join(","));};}),Ak.extend({filter:function(B,A,C){C&&(B=":not("+B+")");return A.length===1?Ak.find.matchesSelector(A[0],B)?[A[0]]:[]:Ak.find.matches(B,A);},dir:function(A,E,D){var C=[],B=A[E];while(B&&B.nodeType!==9&&(D===Ao||B.nodeType!==1||!Ak(B).is(D))){B.nodeType===1&&C.push(B),B=B[E];}return C;},nth:function(B,A,E,D){A=A||1;var C=0;for(;B;B=B[E]){if(B.nodeType===1&&++C===A){break;}}return B;},sibling:function(B,A){var C=[];for(;B;B=B.nextSibling){B.nodeType===1&&B!==A&&C.push(B);}return C;}});var BF=/ jQuery\d+="(?:\d+|null)"/g,BD=/^\s+/,BB=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,A9=/<([\w:]+)/,A7=/<tbody/i,A5=/<|&#?\w+;/,A3=/<(?:script|object|embed|option|style)/i,A1=/checked\s*(?:[^=]|=\s*.checked.)/i,Az={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};Az.optgroup=Az.option,Az.tbody=Az.tfoot=Az.colgroup=Az.caption=Az.thead,Az.th=Az.td,Ak.support.htmlSerialize||(Az._default=[1,"div<div>","</div>"]),Ak.fn.extend({text:function(A){if(Ak.isFunction(A)){return this.each(function(B){var C=Ak(this);C.text(A.call(this,B,C.text()));});}if(typeof A!=="object"&&A!==Ao){return this.empty().append((this[0]&&this[0].ownerDocument||Am).createTextNode(A));}return Ak.text(this);},wrapAll:function(B){if(Ak.isFunction(B)){return this.each(function(C){Ak(this).wrapAll(B.call(this,C));
});}if(this[0]){var A=Ak(B,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&A.insertBefore(this[0]),A.map(function(){var C=this;while(C.firstChild&&C.firstChild.nodeType===1){C=C.firstChild;}return C;}).append(this);}return this;},wrapInner:function(A){if(Ak.isFunction(A)){return this.each(function(B){Ak(this).wrapInner(A.call(this,B));});}return this.each(function(){var B=Ak(this),C=B.contents();C.length?C.wrapAll(A):B.append(A);});},wrap:function(A){return this.each(function(){Ak(this).wrapAll(A);});},unwrap:function(){return this.parent().each(function(){Ak.nodeName(this,"body")||Ak(this).replaceWith(this.childNodes);}).end();},append:function(){return this.domManip(arguments,!0,function(A){this.nodeType===1&&this.appendChild(A);});},prepend:function(){return this.domManip(arguments,!0,function(A){this.nodeType===1&&this.insertBefore(A,this.firstChild);});},before:function(){if(this[0]&&this[0].parentNode){return this.domManip(arguments,!1,function(B){this.parentNode.insertBefore(B,this);});}if(arguments.length){var A=Ak(arguments[0]);A.push.apply(A,this.toArray());return this.pushStack(A,"before",arguments);}},after:function(){if(this[0]&&this[0].parentNode){return this.domManip(arguments,!1,function(B){this.parentNode.insertBefore(B,this.nextSibling);});}if(arguments.length){var A=this.pushStack(this,"after",arguments);A.push.apply(A,Ak(arguments[0]).toArray());return A;}},remove:function(B,A){for(var D=0,C;(C=this[D])!=null;D++){if(!B||Ak.filter(B,[C]).length){!A&&C.nodeType===1&&(Ak.cleanData(C.getElementsByTagName("*")),Ak.cleanData([C])),C.parentNode&&C.parentNode.removeChild(C);}}return this;},empty:function(){for(var B=0,A;(A=this[B])!=null;B++){A.nodeType===1&&Ak.cleanData(A.getElementsByTagName("*"));while(A.firstChild){A.removeChild(A.firstChild);}}return this;},clone:function(B,A){B=B==null?!1:B,A=A==null?B:A;return this.map(function(){return Ak.clone(this,B,A);});},html:function(A){if(A===Ao){return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(BF,""):null;}if(typeof A!=="string"||A3.test(A)||!Ak.support.leadingWhitespace&&BD.test(A)||Az[(A9.exec(A)||["",""])[1].toLowerCase()]){Ak.isFunction(A)?this.each(function(E){var F=Ak(this);F.html(A.call(this,E,F.html()));}):this.empty().append(A);}else{A=A.replace(BB,"<$1></$2>");try{for(var D=0,C=this.length;D<C;D++){this[D].nodeType===1&&(Ak.cleanData(this[D].getElementsByTagName("*")),this[D].innerHTML=A);}}catch(B){this.empty().append(A);}}return this;},replaceWith:function(A){if(this[0]&&this[0].parentNode){if(Ak.isFunction(A)){return this.each(function(B){var D=Ak(this),C=D.html();D.replaceWith(A.call(this,B,C));});}typeof A!=="string"&&(A=Ak(A).detach());return this.each(function(){var B=this.nextSibling,C=this.parentNode;Ak(this).remove(),B?Ak(B).before(A):Ak(C).append(A);});}return this.length?this.pushStack(Ak(Ak.isFunction(A)?A():A),"replaceWith",A):this;},detach:function(A){return this.remove(A,!0);},domManip:function(L,K,J){var I,H,G,F,E=L[0],D=[];if(!Ak.support.checkClone&&arguments.length===3&&typeof E==="string"&&A1.test(E)){return this.each(function(){Ak(this).domManip(L,K,J,!0);});}if(Ak.isFunction(E)){return this.each(function(N){var M=Ak(this);L[0]=E.call(this,N,K?M.html():Ao),M.domManip(L,K,J);});}if(this[0]){F=E&&E.parentNode,Ak.support.parentNode&&F&&F.nodeType===11&&F.childNodes.length===this.length?I={fragment:F}:I=Ak.buildFragment(L,this,D),G=I.fragment,G.childNodes.length===1?H=G=G.firstChild:H=G.firstChild;if(H){K=K&&Ak.nodeName(H,"tr");for(var C=0,B=this.length,A=B-1;C<B;C++){J.call(K?B1(this[C],H):this[C],I.cacheable||B>1&&C<A?Ak.clone(G,!0,!0):G);}}D.length&&Ak.each(D,BG);}return this;}}),Ak.buildFragment=function(B,A,G){var F,E,D,C=A&&A[0]?A[0].ownerDocument||A[0]:Am;B.length===1&&typeof B[0]==="string"&&B[0].length<512&&C===Am&&B[0].charAt(0)==="<"&&!A3.test(B[0])&&(Ak.support.checkClone||!A1.test(B[0]))&&(E=!0,D=Ak.fragments[B[0]],D&&(D!==1&&(F=D))),F||(F=C.createDocumentFragment(),Ak.clean(B,C,F,G)),E&&(Ak.fragments[B[0]]=D?F:1);
return{fragment:F,cacheable:E};},Ak.fragments={},Ak.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(B,A){Ak.fn[B]=function(I){var H=[],G=Ak(I),F=this.length===1&&this[0].parentNode;if(F&&F.nodeType===11&&F.childNodes.length===1&&G.length===1){G[A](this[0]);return this;}for(var E=0,D=G.length;E<D;E++){var C=(E>0?this.clone(!0):this).get();Ak(G[E])[A](C),H=H.concat(C);}return this.pushStack(H,B,G.selector);};}),Ak.extend({clone:function(B,A,G){var F=B.cloneNode(!0),E,D,C;if((!Ak.support.noCloneEvent||!Ak.support.noCloneChecked)&&(B.nodeType===1||B.nodeType===11)&&!Ak.isXMLDoc(B)){BK(B,F),E=BI(B),D=BI(F);for(C=0;E[C];++C){BK(E[C],D[C]);}}if(A){As(B,F);if(G){E=BI(B),D=BI(F);for(C=0;E[C];++C){As(E[C],D[C]);}}}return F;},clean:function(N,M,L,K){M=M||Am,typeof M.createElement==="undefined"&&(M=M.ownerDocument||M[0]&&M[0].ownerDocument||Am);var J=[];for(var I=0,H;(H=N[I])!=null;I++){typeof H==="number"&&(H+="");if(!H){continue;}if(typeof H!=="string"||A5.test(H)){if(typeof H==="string"){H=H.replace(BB,"<$1></$2>");var G=(A9.exec(H)||["",""])[1].toLowerCase(),F=Az[G]||Az._default,E=F[0],D=M.createElement("div");D.innerHTML=F[1]+H+F[2];while(E--){D=D.lastChild;}if(!Ak.support.tbody){var C=A7.test(H),B=G==="table"&&!C?D.firstChild&&D.firstChild.childNodes:F[1]==="<table>"&&!C?D.childNodes:[];for(var A=B.length-1;A>=0;--A){Ak.nodeName(B[A],"tbody")&&!B[A].childNodes.length&&B[A].parentNode.removeChild(B[A]);}}!Ak.support.leadingWhitespace&&BD.test(H)&&D.insertBefore(M.createTextNode(BD.exec(H)[0]),D.firstChild),H=D.childNodes;}}else{H=M.createTextNode(H);}H.nodeType?J.push(H):J=Ak.merge(J,H);}if(L){for(I=0;J[I];I++){!K||!Ak.nodeName(J[I],"script")||J[I].type&&J[I].type.toLowerCase()!=="text/javascript"?(J[I].nodeType===1&&J.splice.apply(J,[I+1,0].concat(Ak.makeArray(J[I].getElementsByTagName("script")))),L.appendChild(J[I])):K.push(J[I].parentNode?J[I].parentNode.removeChild(J[I]):J[I]);}}return J;},cleanData:function(J){var I,H,G=Ak.cache,F=Ak.expando,E=Ak.event.special,D=Ak.support.deleteExpando;for(var C=0,B;(B=J[C])!=null;C++){if(B.nodeName&&Ak.noData[B.nodeName.toLowerCase()]){continue;}H=B[Ak.expando];if(H){I=G[H]&&G[H][F];if(I&&I.events){for(var A in I.events){E[A]?Ak.event.remove(B,A):Ak.removeEvent(B,A,I.handle);}I.handle&&(I.handle.elem=null);}D?delete B[Ak.expando]:B.removeAttribute&&B.removeAttribute(Ak.expando),delete G[H];}}}});var BE=/alpha\([^)]*\)/i,BC=/opacity=([^)]*)/,BA=/-([a-z])/ig,A8=/([A-Z]|^ms)/g,A6=/^-?\d+(?:px)?$/i,A4=/^-?\d/,A2={position:"absolute",visibility:"hidden",display:"block"},A0=["Left","Right"],Ay=["Top","Bottom"],Ax,Aw,Av,Au=function(B,A){return A.toUpperCase();};Ak.fn.css=function(A,B){if(arguments.length===2&&B===Ao){return this;}return Ak.access(this,A,B,!0,function(C,E,D){return D!==Ao?Ak.style(C,E,D):Ak.css(C,E);});},Ak.extend({cssHooks:{opacity:{get:function(B,A){if(A){var C=Ax(B,"opacity","opacity");return C===""?"1":C;}return B.style.opacity;}}},cssNumber:{zIndex:!0,fontWeight:!0,opacity:!0,zoom:!0,lineHeight:!0},cssProps:{"float":Ak.support.cssFloat?"cssFloat":"styleFloat"},style:function(I,H,G,F){if(I&&I.nodeType!==3&&I.nodeType!==8&&I.style){var E,D=Ak.camelCase(H),C=I.style,B=Ak.cssHooks[D];H=Ak.cssProps[D]||D;if(G===Ao){if(B&&"get" in B&&(E=B.get(I,!1,F))!==Ao){return E;}return C[H];}if(typeof G==="number"&&isNaN(G)||G==null){return ;}typeof G==="number"&&!Ak.cssNumber[D]&&(G+="px");if(!B||!("set" in B)||(G=B.set(I,G))!==Ao){try{C[H]=G;}catch(A){}}}},css:function(A,F,E){var D,C=Ak.camelCase(F),B=Ak.cssHooks[C];F=Ak.cssProps[C]||C;if(B&&"get" in B&&(D=B.get(A,!0,E))!==Ao){return D;}if(Ax){return Ax(A,F,C);}},swap:function(B,A,E){var D={};for(var C in A){D[C]=B.style[C],B.style[C]=A[C];}E.call(B);for(C in A){B.style[C]=D[C];}},camelCase:function(A){return A.replace(BA,Au);}}),Ak.curCSS=Ak.css,Ak.each(["height","width"],function(B,A){Ak.cssHooks[A]={get:function(C,F,E){var D;if(F){C.offsetWidth!==0?D=At(C,A,E):Ak.swap(C,A2,function(){D=At(C,A,E);
});if(D<=0){D=Ax(C,A,A),D==="0px"&&Av&&(D=Av(C,A,A));if(D!=null){return D===""||D==="auto"?"0px":D;}}if(D<0||D==null){D=C.style[A];return D===""||D==="auto"?"0px":D;}return typeof D==="string"?D:D+"px";}},set:function(D,C){if(!A6.test(C)){return C;}C=parseFloat(C);if(C>=0){return C+"px";}}};}),Ak.support.opacity||(Ak.cssHooks.opacity={get:function(B,A){return BC.test((A&&B.currentStyle?B.currentStyle.filter:B.style.filter)||"")?parseFloat(RegExp.$1)/100+"":A?"1":"";},set:function(B,A){var E=B.style;E.zoom=1;var D=Ak.isNaN(A)?"":"alpha(opacity="+A*100+")",C=E.filter||"";E.filter=BE.test(C)?C.replace(BE,D):E.filter+" "+D;}}),Ak(function(){Ak.support.reliableMarginRight||(Ak.cssHooks.marginRight={get:function(B,A){var C;Ak.swap(B,{display:"inline-block"},function(){A?C=Ax(B,"margin-right","marginRight"):C=B.style.marginRight;});return C;}});}),Am.defaultView&&Am.defaultView.getComputedStyle&&(Aw=function(A,F,E){var D,C,B;E=E.replace(A8,"-$1").toLowerCase();if(!(C=A.ownerDocument.defaultView)){return Ao;}if(B=C.getComputedStyle(A,null)){D=B.getPropertyValue(E),D===""&&!Ak.contains(A.ownerDocument.documentElement,A)&&(D=Ak.style(A,E));}return D;}),Am.documentElement.currentStyle&&(Av=function(B,A){var F,E=B.currentStyle&&B.currentStyle[A],D=B.runtimeStyle&&B.runtimeStyle[A],C=B.style;!A6.test(E)&&A4.test(E)&&(F=C.left,D&&(B.runtimeStyle.left=B.currentStyle.left),C.left=A==="fontSize"?"1em":E||0,E=C.pixelLeft+"px",C.left=F,D&&(B.runtimeStyle.left=D));return E===""?"auto":E;}),Ax=Aw||Av,Ak.expr&&Ak.expr.filters&&(Ak.expr.filters.hidden=function(B){var A=B.offsetWidth,C=B.offsetHeight;return A===0&&C===0||!Ak.support.reliableHiddenOffsets&&(B.style.display||Ak.css(B,"display"))==="none";},Ak.expr.filters.visible=function(A){return !Ak.expr.filters.hidden(A);});var Ar=/%20/g,Ap=/\[\]$/,An=/\r?\n/g,Al=/#.*$/,Aj=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,Ah=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,Af=/^(?:about|app|app\-storage|.+\-extension|file|widget):$/,Ad=/^(?:GET|HEAD)$/,Ab=/^\/\//,B0=/\?/,Bz=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,By=/^(?:select|textarea)/i,Bx=/\s+/,Bw=/([?&])_=[^&]*/,Bv=/(^|\-)([a-z])/g,Bu=function(B,A,C){return A+C.toUpperCase();},Bt=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,Bs=Ak.fn.load,Br={},Bq={},Bp,Bo;try{Bp=Am.location.href;}catch(Bn){Bp=Am.createElement("a"),Bp.href="",Bp=Bp.href;}Bo=Bt.exec(Bp.toLowerCase())||[],Ak.fn.extend({load:function(A,G,F){if(typeof A!=="string"&&Bs){return Bs.apply(this,arguments);}if(!this.length){return this;}var E=A.indexOf(" ");if(E>=0){var D=A.slice(E,A.length);A=A.slice(0,E);}var C="GET";G&&(Ak.isFunction(G)?(F=G,G=Ao):typeof G==="object"&&(G=Ak.param(G,Ak.ajaxSettings.traditional),C="POST"));var B=this;Ak.ajax({url:A,type:C,dataType:"html",data:G,complete:function(I,H,J){J=I.responseText,I.isResolved()&&(I.done(function(K){J=K;}),B.html(D?Ak("<div>").append(J.replace(Bz,"")).find(D):J)),F&&B.each(F,[J,H,I]);}});return this;},serialize:function(){return Ak.param(this.serializeArray());},serializeArray:function(){return this.map(function(){return this.elements?Ak.makeArray(this.elements):this;}).filter(function(){return this.name&&!this.disabled&&(this.checked||By.test(this.nodeName)||Ah.test(this.type));}).map(function(B,A){var C=Ak(this).val();return C==null?null:Ak.isArray(C)?Ak.map(C,function(D,E){return{name:A.name,value:D.replace(An,"\r\n")};}):{name:A.name,value:C.replace(An,"\r\n")};}).get();}}),Ak.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(B,A){Ak.fn[A]=function(C){return this.bind(A,C);};}),Ak.each(["get","post"],function(A,B){Ak[B]=function(C,F,E,D){Ak.isFunction(F)&&(D=D||E,E=F,F=Ao);return Ak.ajax({type:B,url:C,data:F,success:E,dataType:D});};}),Ak.extend({getScript:function(A,B){return Ak.get(A,Ao,B,"script");},getJSON:function(B,A,C){return Ak.get(B,A,C,"json");},ajaxSetup:function(B,A){A?Ak.extend(!0,B,Ak.ajaxSettings,A):(A=B,B=Ak.extend(!0,Ak.ajaxSettings,A));
for(var C in {context:1,url:1}){C in A?B[C]=A[C]:C in Ak.ajaxSettings&&(B[C]=Ak.ajaxSettings[C]);}return B;},ajaxSettings:{url:Bp,isLocal:Af.test(Bo[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":Aq.String,"text html":!0,"text json":Ak.parseJSON,"text xml":Ak.parseXML}},ajaxPrefilter:Bm(Br),ajaxTransport:Bm(Bq),ajax:function(W,V){function D(g,d,Z,Y){if(H!==2){H=2,J&&clearTimeout(J),K=Ao,M=Y||"",E.readyState=g?4:0;var X,k,j,h=Z?Bj(U,E,Z):Ao,f,e;if(g>=200&&g<300||g===304){if(U.ifModified){if(f=E.getResponseHeader("Last-Modified")){Ak.lastModified[O]=f;}if(e=E.getResponseHeader("Etag")){Ak.etag[O]=e;}}if(g===304){d="notmodified",X=!0;}else{try{k=Bi(U,h),d="success",X=!0;}catch(b){d="parsererror",j=b;}}}else{j=d;if(!d||g){d="error",g<0&&(g=0);}}E.status=g,E.statusText=d,X?R.resolveWith(T,[k,d,E]):R.rejectWith(T,[E,d,j]),E.statusCode(P),P=Ao,G&&S.trigger("ajax"+(X?"Success":"Error"),[E,U,X?k:j]),Q.resolveWith(T,[E,d]),G&&(S.trigger("ajaxComplete",[E,U]),--Ak.active||Ak.event.trigger("ajaxStop"));}}typeof W==="object"&&(V=W,W=Ao),V=V||{};var U=Ak.ajaxSetup({},V),T=U.context||U,S=T!==U&&(T.nodeType||T instanceof Ak)?Ak(T):Ak.event,R=Ak.Deferred(),Q=Ak._Deferred(),P=U.statusCode||{},O,N={},M,L,K,J,I,H=0,G,F,E={readyState:0,setRequestHeader:function(Y,X){H||(N[Y.toLowerCase().replace(Bv,Bu)]=X);return this;},getAllResponseHeaders:function(){return H===2?M:null;},getResponseHeader:function(X){var Y;if(H===2){if(!L){L={};while(Y=Aj.exec(M)){L[Y[1].toLowerCase()]=Y[2];}}Y=L[X.toLowerCase()];}return Y===Ao?null:Y;},overrideMimeType:function(X){H||(U.mimeType=X);return this;},abort:function(X){X=X||"abort",K&&K.abort(X),D(0,X);return this;}};R.promise(E),E.success=E.done,E.error=E.fail,E.complete=Q.done,E.statusCode=function(Y){if(Y){var X;if(H<2){for(X in Y){P[X]=[P[X],Y[X]];}}else{X=Y[E.status],E.then(X,X);}}return this;},U.url=((W||U.url)+"").replace(Al,"").replace(Ab,Bo[1]+"//"),U.dataTypes=Ak.trim(U.dataType||"*").toLowerCase().split(Bx),U.crossDomain==null&&(I=Bt.exec(U.url.toLowerCase()),U.crossDomain=I&&(I[1]!=Bo[1]||I[2]!=Bo[2]||(I[3]||(I[1]==="http:"?80:443))!=(Bo[3]||(Bo[1]==="http:"?80:443)))),U.data&&U.processData&&typeof U.data!=="string"&&(U.data=Ak.param(U.data,U.traditional)),Bl(Br,U,V,E);if(H===2){return !1;}G=U.global,U.type=U.type.toUpperCase(),U.hasContent=!Ad.test(U.type),G&&Ak.active++===0&&Ak.event.trigger("ajaxStart");if(!U.hasContent){U.data&&(U.url+=(B0.test(U.url)?"&":"?")+U.data),O=U.url;if(U.cache===!1){var C=Ak.now(),B=U.url.replace(Bw,"$1_="+C);U.url=B+(B===U.url?(B0.test(U.url)?"&":"?")+"_="+C:"");}}if(U.data&&U.hasContent&&U.contentType!==!1||V.contentType){N["Content-Type"]=U.contentType;}U.ifModified&&(O=O||U.url,Ak.lastModified[O]&&(N["If-Modified-Since"]=Ak.lastModified[O]),Ak.etag[O]&&(N["If-None-Match"]=Ak.etag[O])),N.Accept=U.dataTypes[0]&&U.accepts[U.dataTypes[0]]?U.accepts[U.dataTypes[0]]+(U.dataTypes[0]!=="*"?", */*; q=0.01":""):U.accepts["*"];for(F in U.headers){E.setRequestHeader(F,U.headers[F]);}if(U.beforeSend&&(U.beforeSend.call(T,E,U)===!1||H===2)){E.abort();return !1;}for(F in {success:1,error:1,complete:1}){E[F](U[F]);}K=Bl(Bq,U,V,E);if(K){E.readyState=1,G&&S.trigger("ajaxSend",[E,U]),U.async&&U.timeout>0&&(J=setTimeout(function(){E.abort("timeout");},U.timeout));try{H=1,K.send(N,D);}catch(A){status<2?D(-1,A):Ak.error(A);}}else{D(-1,"No Transport");}return E;},param:function(A,E){var D=[],C=function(G,F){F=Ak.isFunction(F)?F():F,D[D.length]=encodeURIComponent(G)+"="+encodeURIComponent(F);};E===Ao&&(E=Ak.ajaxSettings.traditional);if(Ak.isArray(A)||A.jquery&&!Ak.isPlainObject(A)){Ak.each(A,function(){C(this.name,this.value);});}else{for(var B in A){Bk(B,A[B],E,C);}}return D.join("&").replace(Ar,"+");
}}),Ak.extend({active:0,lastModified:{},etag:{}});var Bf=Ak.now(),Bd=/(\=)\?(&|$)|\?\?/i;Ak.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return Ak.expando+"_"+Bf++;}}),Ak.ajaxPrefilter("json jsonp",function(K,J,I){var H=typeof K.data==="string";if(K.dataTypes[0]==="jsonp"||J.jsonpCallback||J.jsonp!=null||K.jsonp!==!1&&(Bd.test(K.url)||H&&Bd.test(K.data))){var G,F=K.jsonpCallback=Ak.isFunction(K.jsonpCallback)?K.jsonpCallback():K.jsonpCallback,E=Aq[F],D=K.url,C=K.data,B="$1"+F+"$2",A=function(){Aq[F]=E,G&&Ak.isFunction(E)&&Aq[F](G[0]);};K.jsonp!==!1&&(D=D.replace(Bd,B),K.url===D&&(H&&(C=C.replace(Bd,B)),K.data===C&&(D+=(/\?/.test(D)?"&":"?")+K.jsonp+"="+F))),K.url=D,K.data=C,Aq[F]=function(L){G=[L];},I.then(A,A),K.converters["script json"]=function(){G||Ak.error(F+" was not called");return G[0];},K.dataTypes[0]="json";return"script";}}),Ak.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(A){Ak.globalEval(A);return A;}}}),Ak.ajaxPrefilter("script",function(A){A.cache===Ao&&(A.cache=!1),A.crossDomain&&(A.type="GET",A.global=!1);}),Ak.ajaxTransport("script",function(A){if(A.crossDomain){var C,B=Am.head||Am.getElementsByTagName("head")[0]||Am.documentElement;return{send:function(E,D){C=Am.createElement("script"),C.async="async",A.scriptCharset&&(C.charset=A.scriptCharset),C.src=A.url,C.onload=C.onreadystatechange=function(F,G){if(!C.readyState||/loaded|complete/.test(C.readyState)){C.onload=C.onreadystatechange=null,B&&C.parentNode&&B.removeChild(C),C=Ao,G||D(200,"success");}},B.insertBefore(C,B.firstChild);},abort:function(){C&&C.onload(0,1);}};}});var Bb=Ak.now(),BZ,BX;Ak.ajaxSettings.xhr=Aq.ActiveXObject?function(){return !this.isLocal&&BU()||B2();}:BU,BX=Ak.ajaxSettings.xhr(),Ak.support.ajax=!!BX,Ak.support.cors=BX&&"withCredentials" in BX,BX=Ao,Ak.support.ajax&&Ak.ajaxTransport(function(A){if(!A.crossDomain||Ak.support.cors){var B;return{send:function(H,G){var F=A.xhr(),E,D;A.username?F.open(A.type,A.url,A.async,A.username,A.password):F.open(A.type,A.url,A.async);if(A.xhrFields){for(D in A.xhrFields){F[D]=A.xhrFields[D];}}A.mimeType&&F.overrideMimeType&&F.overrideMimeType(A.mimeType),!A.crossDomain&&!H["X-Requested-With"]&&(H["X-Requested-With"]="XMLHttpRequest");try{for(D in H){F.setRequestHeader(D,H[D]);}}catch(C){}F.send(A.hasContent&&A.data||null),B=function(Q,P){var O,N,M,L,K;try{if(B&&(P||F.readyState===4)){B=Ao,E&&(F.onreadystatechange=Ak.noop,delete BZ[E]);if(P){F.readyState!==4&&F.abort();}else{O=F.status,M=F.getAllResponseHeaders(),L={},K=F.responseXML,K&&K.documentElement&&(L.xml=K),L.text=F.responseText;try{N=F.statusText;}catch(J){N="";}O||!A.isLocal||A.crossDomain?O===1223&&(O=204):O=L.text?200:404;}}}catch(I){P||G(-1,I);}L&&G(O,N,L,M);},A.async&&F.readyState!==4?(BZ||(BZ={},BW()),E=Bb++,F.onreadystatechange=BZ[E]=B):B();},abort:function(){B&&B(0,1);}};}});var BN={},AU=/^(?:toggle|show|hide)$/,AS=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,AQ,AO=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];Ak.fn.extend({show:function(B,A,G){var F,E;if(B||B===0){return this.animate(AN("show",3),B,A,G);}for(var D=0,C=this.length;D<C;D++){F=this[D],E=F.style.display,!Ak._data(F,"olddisplay")&&E==="none"&&(E=F.style.display=""),E===""&&Ak.css(F,"display")==="none"&&Ak._data(F,"olddisplay",AL(F.nodeName));}for(D=0;D<C;D++){F=this[D],E=F.style.display;if(E===""||E==="none"){F.style.display=Ak._data(F,"olddisplay")||"";}}return this;},hide:function(B,A,F){if(B||B===0){return this.animate(AN("hide",3),B,A,F);}for(var E=0,D=this.length;E<D;E++){var C=Ak.css(this[E],"display");C!=="none"&&!Ak._data(this[E],"olddisplay")&&Ak._data(this[E],"olddisplay",C);}for(E=0;E<D;E++){this[E].style.display="none";}return this;},_toggle:Ak.fn.toggle,toggle:function(B,A,D){var C=typeof B==="boolean";Ak.isFunction(B)&&Ak.isFunction(A)?this._toggle.apply(this,arguments):B==null||C?this.each(function(){var E=C?B:Ak(this).is(":hidden");
Ak(this)[E?"show":"hide"]();}):this.animate(AN("toggle",3),B,A,D);return this;},fadeTo:function(B,A,D,C){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:A},B,D,C);},animate:function(B,A,E,D){var C=Ak.speed(A,E,D);if(Ak.isEmptyObject(B)){return this.each(C.complete);}return this[C.queue===!1?"each":"queue"](function(){var F=Ak.extend({},C),L,K=this.nodeType===1,J=K&&Ak(this).is(":hidden"),I=this;for(L in B){var H=Ak.camelCase(L);L!==H&&(B[H]=B[L],delete B[L],L=H);if(B[L]==="hide"&&J||B[L]==="show"&&!J){return F.complete.call(this);}if(K&&(L==="height"||L==="width")){F.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY];if(Ak.css(this,"display")==="inline"&&Ak.css(this,"float")==="none"){if(Ak.support.inlineBlockNeedsLayout){var G=AL(this.nodeName);G==="inline"?this.style.display="inline-block":(this.style.display="inline",this.style.zoom=1);}else{this.style.display="inline-block";}}}Ak.isArray(B[L])&&((F.specialEasing=F.specialEasing||{})[L]=B[L][1],B[L]=B[L][0]);}F.overflow!=null&&(this.style.overflow="hidden"),F.curAnim=Ak.extend({},B),Ak.each(B,function(S,R){var Q=new Ak.fx(I,F,S);if(AU.test(R)){Q[R==="toggle"?J?"show":"hide":R](B);}else{var P=AS.exec(R),O=Q.cur();if(P){var N=parseFloat(P[2]),M=P[3]||(Ak.cssNumber[S]?"":"px");M!=="px"&&(Ak.style(I,S,(N||1)+M),O=(N||1)/Q.cur()*O,Ak.style(I,S,O+M)),P[1]&&(N=(P[1]==="-="?-1:1)*N+O),Q.custom(O,N,M);}else{Q.custom(O,R,"");}}});return !0;});},stop:function(B,A){var C=Ak.timers;B&&this.queue([]),this.each(function(){for(var D=C.length-1;D>=0;D--){C[D].elem===this&&(A&&C[D](!0),C.splice(D,1));}}),A||this.dequeue();return this;}}),Ak.each({slideDown:AN("show",1),slideUp:AN("hide",1),slideToggle:AN("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(B,A){Ak.fn[B]=function(C,E,D){return this.animate(A,C,E,D);};}),Ak.extend({speed:function(B,A,D){var C=B&&typeof B==="object"?Ak.extend({},B):{complete:D||!D&&A||Ak.isFunction(B)&&B,duration:B,easing:D&&A||A&&!Ak.isFunction(A)&&A};C.duration=Ak.fx.off?0:typeof C.duration==="number"?C.duration:C.duration in Ak.fx.speeds?Ak.fx.speeds[C.duration]:Ak.fx.speeds._default,C.old=C.complete,C.complete=function(){C.queue!==!1&&Ak(this).dequeue(),Ak.isFunction(C.old)&&C.old.call(this);};return C;},easing:{linear:function(B,A,D,C){return D+C*B;},swing:function(B,A,D,C){return(-Math.cos(B*Math.PI)/2+0.5)*C+D;}},timers:[],fx:function(B,A,C){this.options=A,this.elem=B,this.prop=C,A.orig||(A.orig={});}}),Ak.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(Ak.fx.step[this.prop]||Ak.fx.step._default)(this);},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop];}var B,A=Ak.css(this.elem,this.prop);return isNaN(B=parseFloat(A))?!A||A==="auto"?0:A:B;},custom:function(B,A,F){function C(G){return E.step(G);}var E=this,D=Ak.fx;this.startTime=Ak.now(),this.start=B,this.end=A,this.unit=F||this.unit||(Ak.cssNumber[this.prop]?"":"px"),this.now=this.start,this.pos=this.state=0,C.elem=this.elem,C()&&Ak.timers.push(C)&&!AQ&&(AQ=setInterval(D.tick,D.interval));},show:function(){this.options.orig[this.prop]=Ak.style(this.elem,this.prop),this.options.show=!0,this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),Ak(this.elem).show();},hide:function(){this.options.orig[this.prop]=Ak.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0);},step:function(J){var I=Ak.now(),H=!0;if(J||I>=this.options.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),this.options.curAnim[this.prop]=!0;for(var G in this.options.curAnim){this.options.curAnim[G]!==!0&&(H=!1);}if(H){if(this.options.overflow!=null&&!Ak.support.shrinkWrapBlocks){var F=this.elem,E=this.options;Ak.each(["","X","Y"],function(L,K){F.style["overflow"+K]=E.overflow[L];});}this.options.hide&&Ak(this.elem).hide();if(this.options.hide||this.options.show){for(var D in this.options.curAnim){Ak.style(this.elem,D,this.options.orig[D]);
}}this.options.complete.call(this.elem);}return !1;}var C=I-this.startTime;this.state=C/this.options.duration;var B=this.options.specialEasing&&this.options.specialEasing[this.prop],A=this.options.easing||(Ak.easing.swing?"swing":"linear");this.pos=Ak.easing[B||A](this.state,C,0,1,this.options.duration),this.now=this.start+(this.end-this.start)*this.pos,this.update();return !0;}},Ak.extend(Ak.fx,{tick:function(){var B=Ak.timers;for(var A=0;A<B.length;A++){B[A]()||B.splice(A--,1);}B.length||Ak.fx.stop();},interval:13,stop:function(){clearInterval(AQ),AQ=null;},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(A){Ak.style(A.elem,"opacity",A.now);},_default:function(A){A.elem.style&&A.elem.style[A.prop]!=null?A.elem.style[A.prop]=(A.prop==="width"||A.prop==="height"?Math.max(0,A.now):A.now)+A.unit:A.elem[A.prop]=A.now;}}}),Ak.expr&&Ak.expr.filters&&(Ak.expr.filters.animated=function(A){return Ak.grep(Ak.timers,function(B){return A===B.elem;}).length;});var AI=/^t(?:able|d|h)$/i,AG=/^(?:body|html)$/i;"getBoundingClientRect" in Am.documentElement?Ak.fn.offset=function(N){var M=this[0],L;if(N){return this.each(function(O){Ak.offset.setOffset(this,N,O);});}if(!M||!M.ownerDocument){return null;}if(M===M.ownerDocument.body){return Ak.offset.bodyOffset(M);}try{L=M.getBoundingClientRect();}catch(K){}var J=M.ownerDocument,I=J.documentElement;if(!L||!Ak.contains(I,M)){return L?{top:L.top,left:L.left}:{top:0,left:0};}var H=J.body,G=AF(J),F=I.clientTop||H.clientTop||0,E=I.clientLeft||H.clientLeft||0,D=G.pageYOffset||Ak.support.boxModel&&I.scrollTop||H.scrollTop,C=G.pageXOffset||Ak.support.boxModel&&I.scrollLeft||H.scrollLeft,B=L.top+D-F,A=L.left+C-E;return{top:B,left:A};}:Ak.fn.offset=function(L){var K=this[0];if(L){return this.each(function(M){Ak.offset.setOffset(this,L,M);});}if(!K||!K.ownerDocument){return null;}if(K===K.ownerDocument.body){return Ak.offset.bodyOffset(K);}Ak.offset.initialize();var J,I=K.offsetParent,H=K,G=K.ownerDocument,F=G.documentElement,E=G.body,D=G.defaultView,C=D?D.getComputedStyle(K,null):K.currentStyle,B=K.offsetTop,A=K.offsetLeft;while((K=K.parentNode)&&K!==E&&K!==F){if(Ak.offset.supportsFixedPosition&&C.position==="fixed"){break;}J=D?D.getComputedStyle(K,null):K.currentStyle,B-=K.scrollTop,A-=K.scrollLeft,K===I&&(B+=K.offsetTop,A+=K.offsetLeft,Ak.offset.doesNotAddBorder&&(!Ak.offset.doesAddBorderForTableAndCells||!AI.test(K.nodeName))&&(B+=parseFloat(J.borderTopWidth)||0,A+=parseFloat(J.borderLeftWidth)||0),H=I,I=K.offsetParent),Ak.offset.subtractsBorderForOverflowNotVisible&&J.overflow!=="visible"&&(B+=parseFloat(J.borderTopWidth)||0,A+=parseFloat(J.borderLeftWidth)||0),C=J;}if(C.position==="relative"||C.position==="static"){B+=E.offsetTop,A+=E.offsetLeft;}Ak.offset.supportsFixedPosition&&C.position==="fixed"&&(B+=Math.max(F.scrollTop,E.scrollTop),A+=Math.max(F.scrollLeft,E.scrollLeft));return{top:B,left:A};},Ak.offset={initialize:function(){var B=Am.body,A=Am.createElement("div"),H,G,F,E,D=parseFloat(Ak.css(B,"marginTop"))||0,C="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";Ak.extend(A.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),A.innerHTML=C,B.insertBefore(A,B.firstChild),H=A.firstChild,G=H.firstChild,E=H.nextSibling.firstChild.firstChild,this.doesNotAddBorder=G.offsetTop!==5,this.doesAddBorderForTableAndCells=E.offsetTop===5,G.style.position="fixed",G.style.top="20px",this.supportsFixedPosition=G.offsetTop===20||G.offsetTop===15,G.style.position=G.style.top="",H.style.overflow="hidden",H.style.position="relative",this.subtractsBorderForOverflowNotVisible=G.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=B.offsetTop!==D,B.removeChild(A),Ak.offset.initialize=Ak.noop;},bodyOffset:function(B){var A=B.offsetTop,C=B.offsetLeft;
Ak.offset.initialize(),Ak.offset.doesNotIncludeMarginInBodyOffset&&(A+=parseFloat(Ak.css(B,"marginTop"))||0,C+=parseFloat(Ak.css(B,"marginLeft"))||0);return{top:A,left:C};},setOffset:function(M,L,K){var J=Ak.css(M,"position");J==="static"&&(M.style.position="relative");var I=Ak(M),H=I.offset(),G=Ak.css(M,"top"),F=Ak.css(M,"left"),E=(J==="absolute"||J==="fixed")&&Ak.inArray("auto",[G,F])>-1,D={},C={},B,A;E&&(C=I.position()),B=E?C.top:parseInt(G,10)||0,A=E?C.left:parseInt(F,10)||0,Ak.isFunction(L)&&(L=L.call(M,K,H)),L.top!=null&&(D.top=L.top-H.top+B),L.left!=null&&(D.left=L.left-H.left+A),"using" in L?L.using.call(M,D):I.css(D);}},Ak.fn.extend({position:function(){if(!this[0]){return null;}var B=this[0],A=this.offsetParent(),D=this.offset(),C=AG.test(A[0].nodeName)?{top:0,left:0}:A.offset();D.top-=parseFloat(Ak.css(B,"marginTop"))||0,D.left-=parseFloat(Ak.css(B,"marginLeft"))||0,C.top+=parseFloat(Ak.css(A[0],"borderTopWidth"))||0,C.left+=parseFloat(Ak.css(A[0],"borderLeftWidth"))||0;return{top:D.top-C.top,left:D.left-C.left};},offsetParent:function(){return this.map(function(){var A=this.offsetParent||Am.body;while(A&&(!AG.test(A.nodeName)&&Ak.css(A,"position")==="static")){A=A.offsetParent;}return A;});}}),Ak.each(["Left","Top"],function(A,C){var B="scroll"+C;Ak.fn[B]=function(F){var E=this[0],D;if(!E){return null;}if(F!==Ao){return this.each(function(){D=AF(this),D?D.scrollTo(A?Ak(D).scrollLeft():F,A?F:Ak(D).scrollTop()):this[B]=F;});}D=AF(E);return D?"pageXOffset" in D?D[A?"pageYOffset":"pageXOffset"]:Ak.support.boxModel&&D.document.documentElement[B]||D.document.body[B]:E[B];};}),Ak.each(["Height","Width"],function(A,C){var B=C.toLowerCase();Ak.fn["inner"+C]=function(){return this[0]?parseFloat(Ak.css(this[0],B,"padding")):null;},Ak.fn["outer"+C]=function(D){return this[0]?parseFloat(Ak.css(this[0],B,D?"margin":"border")):null;},Ak.fn[B]=function(D){var H=this[0];if(!H){return D==null?null:this;}if(Ak.isFunction(D)){return this.each(function(I){var J=Ak(this);J[B](D.call(this,I,J[B]()));});}if(Ak.isWindow(H)){var G=H.document.documentElement["client"+C];return H.document.compatMode==="CSS1Compat"&&G||H.document.body["client"+C]||G;}if(H.nodeType===9){return Math.max(H.documentElement["client"+C],H.body["scroll"+C],H.documentElement["scroll"+C],H.body["offset"+C],H.documentElement["offset"+C]);}if(D===Ao){var F=Ak.css(H,B),E=parseFloat(F);return Ak.isNaN(E)?F:E;}return this.css(B,typeof D==="string"?D:D+"px");};}),Aq.jQuery=Aq.$=Ak;})(window);Raphael=(function(){var AS=/[, ]+/,BI=/^(circle|rect|path|ellipse|text|image)$/,Bh="prototype",AW="hasOwnProperty",Ac=document,Bf=window,AJ={was:Object[Bh][AW].call(Bf,"Raphael"),is:Bf.Raphael},Au=function(){if(Au.is(arguments[0],"array")){var G=arguments[0],F=R[Bj](Au,G.splice(0,3+Au.is(G[0],A0))),A=F.set();for(var B=0,D=G[AI];B<D;B++){var C=G[B]||{};BI.test(C.type)&&A[AP](F[C.type]().attr(C));}return A;}return R[Bj](Au,arguments);},Bm=function(){},BM="appendChild",Bj="apply",Bo="concat",Bg="",Aw=" ",Av="split",Aj="click dblclick mousedown mousemove mouseout mouseover mouseup"[Av](Aw),BZ="join",AI="length",Ab=String[Bh].toLowerCase,BB=Math,AN=BB.max,BP=BB.min,A0="number",BX="toString",Bc=Object[Bh][BX],E={},BL=BB.pow,AP="push",Bl=/^(?=[\da-f]$)/,AQ=/^url\(['"]?([^\)]+?)['"]?\)$/i,Ay=/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgb\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|rgb\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\)|hs[bl]\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|hs[bl]\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\))\s*$/i,AY=BB.round,S="setAttribute",BG=parseFloat,Ai=parseInt,BJ=String[Bh].toUpperCase,AL={blur:0,"clip-rect":"0 0 1e9 1e9",cursor:"default",cx:0,cy:0,fill:"#fff","fill-opacity":1,font:'10px "Arial"',"font-family":'"Arial"',"font-size":"10","font-style":"normal","font-weight":400,gradient:0,height:0,href:"http://raphaeljs.com/",opacity:1,path:"M0,0",r:0,rotation:0,rx:0,ry:0,scale:"1 1",src:"",stroke:"#000","stroke-dasharray":"","stroke-linecap":"butt","stroke-linejoin":"butt","stroke-miterlimit":0,"stroke-opacity":1,"stroke-width":1,target:"_blank","text-anchor":"middle",title:"Raphael",translation:"0 0",width:0,x:0,y:0},BD={along:"along",blur:A0,"clip-rect":"csv",cx:A0,cy:A0,fill:"colour","fill-opacity":A0,"font-size":A0,height:A0,opacity:A0,path:"path",r:A0,rotation:"csv",rx:A0,ry:A0,scale:"csv",stroke:"colour","stroke-opacity":A0,"stroke-width":A0,translation:"csv",width:A0,x:A0,y:A0},BH="replace";
Au.version="1.3.2";Au.type=(Bf.SVGAngle||Ac.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")?"SVG":"VML");if(Au.type=="VML"){var A6=Ac.createElement("div");A6.innerHTML="<!--[if vml]><br><br><![endif]-->";if(A6.childNodes[AI]!=2){return Au.type=null;}A6=null;}Au.svg=!(Au.vml=Au.type=="VML");Bm[Bh]=Au[Bh];Au._id=0;Au._oid=0;Au.fn={};Au.is=function(A,B){B=Ab.call(B);return((B=="object"||B=="undefined")&&typeof A==B)||(A==null&&B=="null")||Ab.call(Bc.call(A).slice(8,-1))==B;};Au.setWindow=function(A){Bf=A;Ac=Bf.document;};var BU=function(B){if(Au.vml){var C=/^\s+|\s+$/g;BU=A3(function(G){var F;G=(G+Bg)[BH](C,Bg);try{var J=new Bf.ActiveXObject("htmlfile");J.write("<body>");J.close();F=J.body;}catch(H){F=Bf.createPopup().document.body;}var D=F.createTextRange();try{F.style.color=G;var I=D.queryCommandValue("ForeColor");I=((I&255)<<16)|(I&65280)|((I&16711680)>>>16);return"#"+("000000"+I[BX](16)).slice(-6);}catch(H){return"none";}});}else{var A=Ac.createElement("i");A.title="Rapha\xebl Colour Picker";A.style.display="none";Ac.body[BM](A);BU=A3(function(D){A.style.color=D;return Ac.defaultView.getComputedStyle(A,Bg).getPropertyValue("color");});}return BU(B);};var A2=function(){return"hsb("+[this.h,this.s,this.b]+")";},e=function(){return this.hex;};Au.hsb2rgb=A3(function(J,L,C){if(Au.is(J,"object")&&"h" in J&&"s" in J&&"b" in J){C=J.b;L=J.s;J=J.h;}var H,G,B;if(C==0){return{r:0,g:0,b:0,hex:"#000"};}if(J>1||L>1||C>1){J/=255;L/=255;C/=255;}var N=~~(J*6),I=(J*6)-N,P=C*(1-L),M=C*(1-(L*I)),A=C*(1-(L*(1-I)));H=[C,M,P,P,A,C,C][N];G=[A,C,C,M,P,P,A][N];B=[P,P,A,C,C,M,P][N];H*=255;G*=255;B*=255;var F={r:H,g:G,b:B,toString:e},O=(~~H)[BX](16),K=(~~G)[BX](16),D=(~~B)[BX](16);O=O[BH](Bl,"0");K=K[BH](Bl,"0");D=D[BH](Bl,"0");F.hex="#"+O+K+D;return F;},Au);Au.rgb2hsb=A3(function(J,H,G){if(Au.is(J,"object")&&"r" in J&&"g" in J&&"b" in J){G=J.b;H=J.g;J=J.r;}if(Au.is(J,"string")){var D=Au.getRGB(J);J=D.r;H=D.g;G=D.b;}if(J>1||H>1||G>1){J/=255;H/=255;G/=255;}var I=AN(J,H,G),C=BP(J,H,G),B,K,A=I;if(C==I){return{h:0,s:0,b:I};}else{var F=(I-C);K=F/I;if(J==I){B=(H-G)/F;}else{if(H==I){B=2+((G-J)/F);}else{B=4+((J-H)/F);}}B/=6;B<0&&B++;B>1&&B--;}return{h:B,s:K,b:A,toString:A2};},Au);var BT=/,?([achlmqrstvxz]),?/gi;Au._path2string=function(){return this.join(",")[BH](BT,"$1");};function A3(B,C,D){function A(){var G=Array[Bh].slice.call(arguments,0),I=G[BZ]("\u25ba"),F=A.cache=A.cache||{},H=A.count=A.count||[];if(F[AW](I)){return D?D(F[I]):F[I];}H[AI]>=1000&&delete F[H.shift()];H[AP](I);F[I]=B[Bj](C,G);return D?D(F[I]):F[I];}return A;}Au.getRGB=A3(function(J){if(!J||!!((J=J+Bg).indexOf("-")+1)){return{r:-1,g:-1,b:-1,hex:"none",error:1};}if(J=="none"){return{r:-1,g:-1,b:-1,hex:"none"};}!(({hs:1,rg:1})[AW](J.substring(0,2))||J.charAt()=="#")&&(J=BU(J));var A,C,K,F,D,H=J.match(Ay);if(H){if(H[2]){F=Ai(H[2].substring(5),16);K=Ai(H[2].substring(3,5),16);C=Ai(H[2].substring(1,3),16);}if(H[3]){F=Ai((D=H[3].charAt(3))+D,16);K=Ai((D=H[3].charAt(2))+D,16);C=Ai((D=H[3].charAt(1))+D,16);}if(H[4]){H=H[4][Av](/\s*,\s*/);C=BG(H[0]);K=BG(H[1]);F=BG(H[2]);}if(H[5]){H=H[5][Av](/\s*,\s*/);C=BG(H[0])*2.55;K=BG(H[1])*2.55;F=BG(H[2])*2.55;}if(H[6]){H=H[6][Av](/\s*,\s*/);C=BG(H[0]);K=BG(H[1]);F=BG(H[2]);return Au.hsb2rgb(C,K,F);}if(H[7]){H=H[7][Av](/\s*,\s*/);C=BG(H[0])*2.55;K=BG(H[1])*2.55;F=BG(H[2])*2.55;return Au.hsb2rgb(C,K,F);}H={r:C,g:K,b:F};var I=(~~C)[BX](16),B=(~~K)[BX](16),G=(~~F)[BX](16);I=I[BH](Bl,"0");B=B[BH](Bl,"0");G=G[BH](Bl,"0");H.hex="#"+I+B+G;return H;}return{r:-1,g:-1,b:-1,hex:"none",error:1};},Au);Au.getColor=function(B){var A=this.getColor.start=this.getColor.start||{h:0,s:1,b:B||0.75},C=this.hsb2rgb(A.h,A.s,A.b);A.h+=0.075;if(A.h>1){A.h=0;A.s-=0.2;A.s<=0&&(this.getColor.start={h:0,s:1,b:A.b});}return C.hex;};Au.getColor.reset=function(){delete this.start;};var Be=/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig,Az=/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig;Au.parsePathString=A3(function(C){if(!C){return null;}var A={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},B=[];
if(Au.is(C,"array")&&Au.is(C[0],"array")){B=Bd(C);}if(!B[AI]){(C+Bg)[BH](Be,function(F,H,G){var I=[],D=Ab.call(H);G[BH](Az,function(J,K){K&&I[AP](+K);});if(D=="m"&&I[AI]>2){B[AP]([H][Bo](I.splice(0,2)));D="l";H=H=="m"?"l":"L";}while(I[AI]>=A[D]){B[AP]([H][Bo](I.splice(0,A[D])));if(!A[D]){break;}}});}B[BX]=Au._path2string;return B;});Au.findDotsAtSegment=function(T,U,V,X,N,O,K,M,D){var G=1-D,H=BL(G,3)*T+BL(G,2)*3*D*V+G*3*D*D*N+BL(D,3)*K,J=BL(G,3)*U+BL(G,2)*3*D*X+G*3*D*D*O+BL(D,3)*M,B=T+2*D*(V-T)+D*D*(N-2*V+T),C=U+2*D*(X-U)+D*D*(O-2*X+U),W=V+2*D*(N-V)+D*D*(K-2*N+V),A=X+2*D*(O-X)+D*D*(M-2*O+X),F=(1-D)*T+D*V,I=(1-D)*U+D*X,P=(1-D)*N+D*K,Q=(1-D)*O+D*M,L=(90-BB.atan((B-W)/(C-A))*180/BB.PI);(B>W||C<A)&&(L+=180);return{x:H,y:J,m:{x:B,y:C},n:{x:W,y:A},start:{x:F,y:I},end:{x:P,y:Q},alpha:L};};var AU=A3(function(B){if(!B){return{x:0,y:0,width:0,height:0};}B=Ah(B);var G=0,H=0,C=[],J=[],L;for(var A=0,D=B[AI];A<D;A++){L=B[A];if(L[0]=="M"){G=L[1];H=L[2];C[AP](G);J[AP](H);}else{var I=BV(G,H,L[1],L[2],L[3],L[4],L[5],L[6]);C=C[Bo](I.min.x,I.max.x);J=J[Bo](I.min.y,I.max.y);G=L[5];H=L[6];}}var K=BP[Bj](0,C),F=BP[Bj](0,J);return{x:K,y:F,width:AN[Bj](0,C)-K,height:AN[Bj](0,J)-F};}),Bd=function(F){var C=[];if(!Au.is(F,"array")||!Au.is(F&&F[0],"array")){F=Au.parsePathString(F);}for(var D=0,B=F[AI];D<B;D++){C[D]=[];for(var G=0,A=F[D][AI];G<A;G++){C[D][G]=F[D][G];}}C[BX]=Au._path2string;return C;},A9=A3(function(I){if(!Au.is(I,"array")||!Au.is(I&&I[0],"array")){I=Au.parsePathString(I);}var J=[],F=0,H=0,B=0,C=0,Q=0;if(I[0][0]=="M"){F=I[0][1];H=I[0][2];B=F;C=H;Q++;J[AP](["M",F,H]);}for(var M=Q,A=I[AI];M<A;M++){var P=J[M]=[],D=I[M];if(D[0]!=Ab.call(D[0])){P[0]=Ab.call(D[0]);switch(P[0]){case"a":P[1]=D[1];P[2]=D[2];P[3]=D[3];P[4]=D[4];P[5]=D[5];P[6]=+(D[6]-F).toFixed(3);P[7]=+(D[7]-H).toFixed(3);break;case"v":P[1]=+(D[1]-H).toFixed(3);break;case"m":B=D[1];C=D[2];default:for(var O=1,L=D[AI];O<L;O++){P[O]=+(D[O]-((O%2)?F:H)).toFixed(3);}}}else{P=J[M]=[];if(D[0]=="m"){B=D[1]+F;C=D[2]+H;}for(var G=0,N=D[AI];G<N;G++){J[M][G]=D[G];}}var K=J[M][AI];switch(J[M][0]){case"z":F=B;H=C;break;case"h":F+=+J[M][K-1];break;case"v":H+=+J[M][K-1];break;default:F+=+J[M][K-2];H+=+J[M][K-1];}}J[BX]=Au._path2string;return J;},0,Bd),AC=A3(function(H){if(!Au.is(H,"array")||!Au.is(H&&H[0],"array")){H=Au.parsePathString(H);}var J=[],G=0,I=0,B=0,C=0,P=0;if(H[0][0]=="M"){G=+H[0][1];I=+H[0][2];B=G;C=I;P++;J[0]=["M",G,I];}for(var L=P,A=H[AI];L<A;L++){var O=J[L]=[],D=H[L];if(D[0]!=BJ.call(D[0])){O[0]=BJ.call(D[0]);switch(O[0]){case"A":O[1]=D[1];O[2]=D[2];O[3]=D[3];O[4]=D[4];O[5]=D[5];O[6]=+(D[6]+G);O[7]=+(D[7]+I);break;case"V":O[1]=+D[1]+I;break;case"H":O[1]=+D[1]+G;break;case"M":B=+D[1]+G;C=+D[2]+I;default:for(var N=1,K=D[AI];N<K;N++){O[N]=+D[N]+((N%2)?G:I);}}}else{for(var F=0,M=D[AI];F<M;F++){J[L][F]=D[F];}}switch(O[0]){case"Z":G=B;I=C;break;case"H":G=O[1];break;case"V":I=O[1];break;default:G=J[L][J[L][AI]-2];I=J[L][J[L][AI]-1];}}J[BX]=Au._path2string;return J;},null,Bd),Bi=function(C,B,D,A){return[C,B,D,A,D,A];},BN=function(H,F,G,C,I,B){var A=1/3,D=2/3;return[A*H+D*G,A*F+D*C,A*I+D*G,A*B+D*C,I,B];},Ae=function(p,C,f,h,o,v,A,q,D,n){var B=BB.PI,j=B*120/180,w=B/180*(+o||0),Y=[],b,H=A3(function(Bw,Bt,Bx){var Bu=Bw*BB.cos(Bx)-Bt*BB.sin(Bx),Bv=Bw*BB.sin(Bx)+Bt*BB.cos(Bx);return{x:Bu,y:Bv};});if(!n){b=H(p,C,-w);p=b.x;C=b.y;b=H(q,D,-w);q=b.x;D=b.y;var u=BB.cos(B/180*o),s=BB.sin(B/180*o),W=(p-q)/2,X=(C-D)/2;var J=(W*W)/(f*f)+(X*X)/(h*h);if(J>1){J=BB.sqrt(J);f=J*f;h=J*h;}var O=f*f,T=h*h,P=(v==A?-1:1)*BB.sqrt(BB.abs((O*T-O*X*X-T*W*W)/(O*X*X+T*W*W))),l=P*f*X/h+(p+q)/2,m=P*-h*W/f+(C+D)/2,z=BB.asin(((C-m)/h).toFixed(7)),Bq=BB.asin(((D-m)/h).toFixed(7));z=p<l?B-z:z;Bq=q<l?B-Bq:Bq;z<0&&(z=B*2+z);Bq<0&&(Bq=B*2+Bq);if(A&&z>Bq){z=z-B*2;}if(!A&&Bq>z){Bq=Bq-B*2;}}else{z=n[0];Bq=n[1];l=n[2];m=n[3];}var r=Bq-z;if(BB.abs(r)>j){var k=Bq,g=q,t=D;Bq=z+j*(A&&Bq>z?1:-1);q=l+f*BB.cos(Bq);D=m+h*BB.sin(Bq);Y=Ae(q,D,f,h,o,0,A,g,t,[Bq,k,l,m]);}r=Bq-z;var Br=BB.cos(z),F=BB.sin(z),Bs=BB.cos(Bq),G=BB.sin(Bq),V=BB.tan(r/4),Q=4/3*f*V,U=4/3*h*V,I=[p,C],K=[p+Q*F,C-U*Br],L=[q+Q*G,D-U*Bs],N=[q,D];
K[0]=2*I[0]-K[0];K[1]=2*I[1]-K[1];if(n){return[K,L,N][Bo](Y);}else{Y=[K,L,N][Bo](Y)[BZ]()[Av](",");var a=[];for(var M=0,Z=Y[AI];M<Z;M++){a[M]=M%2?H(Y[M-1],Y[M],w).y:H(Y[M],Y[M+1],w).x;}return a;}},AZ=function(H,J,K,C,F,G,I,A,D){var B=1-D;return{x:BL(B,3)*H+BL(B,2)*3*D*K+B*3*D*D*F+BL(D,3)*I,y:BL(B,3)*J+BL(B,2)*3*D*C+B*3*D*D*G+BL(D,3)*A};},BV=A3(function(J,P,I,Q,A,B,G,L){var C=(A-2*I+J)-(G-2*A+I),H=2*(I-J)-2*(A-I),M=J-I,O=(-H+BB.sqrt(H*H-4*C*M))/2/C,F=(-H-BB.sqrt(H*H-4*C*M))/2/C,K=[P,L],D=[J,G],N;BB.abs(O)>1000000000000&&(O=0.5);BB.abs(F)>1000000000000&&(F=0.5);if(O>0&&O<1){N=AZ(J,P,I,Q,A,B,G,L,O);D[AP](N.x);K[AP](N.y);}if(F>0&&F<1){N=AZ(J,P,I,Q,A,B,G,L,F);D[AP](N.x);K[AP](N.y);}C=(B-2*Q+P)-(L-2*B+Q);H=2*(Q-P)-2*(B-Q);M=P-Q;O=(-H+BB.sqrt(H*H-4*C*M))/2/C;F=(-H-BB.sqrt(H*H-4*C*M))/2/C;BB.abs(O)>1000000000000&&(O=0.5);BB.abs(F)>1000000000000&&(F=0.5);if(O>0&&O<1){N=AZ(J,P,I,Q,A,B,G,L,O);D[AP](N.x);K[AP](N.y);}if(F>0&&F<1){N=AZ(J,P,I,Q,A,B,G,L,F);D[AP](N.x);K[AP](N.y);}return{min:{x:BP[Bj](0,D),y:BP[Bj](0,K)},max:{x:AN[Bj](0,D),y:AN[Bj](0,K)}};}),Ah=A3(function(A,I){var H=AC(A),G=I&&AC(I),D={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},O={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},M=function(V,U){var Q,T;if(!V){return["C",U.x,U.y,U.x,U.y,U.x,U.y];}!(V[0] in {T:1,Q:1})&&(U.qx=U.qy=null);switch(V[0]){case"M":U.X=V[1];U.Y=V[2];break;case"A":V=["C"][Bo](Ae[Bj](0,[U.x,U.y][Bo](V.slice(1))));break;case"S":Q=U.x+(U.x-(U.bx||U.x));T=U.y+(U.y-(U.by||U.y));V=["C",Q,T][Bo](V.slice(1));break;case"T":U.qx=U.x+(U.x-(U.qx||U.x));U.qy=U.y+(U.y-(U.qy||U.y));V=["C"][Bo](BN(U.x,U.y,U.qx,U.qy,V[1],V[2]));break;case"Q":U.qx=V[1];U.qy=V[2];V=["C"][Bo](BN(U.x,U.y,V[1],V[2],V[3],V[4]));break;case"L":V=["C"][Bo](Bi(U.x,U.y,V[1],V[2]));break;case"H":V=["C"][Bo](Bi(U.x,U.y,V[1],U.y));break;case"V":V=["C"][Bo](Bi(U.x,U.y,U.x,V[1]));break;case"Z":V=["C"][Bo](Bi(U.x,U.y,U.X,U.Y));break;}return V;},N=function(U,T){if(U[T][AI]>7){U[T].shift();var Q=U[T];while(Q[AI]){U.splice(T++,0,["C"][Bo](Q.splice(0,6)));}U.splice(T,1);C=AN(H[AI],G&&G[AI]||0);}},P=function(Q,T,V,W,U){if(Q&&T&&Q[U][0]=="M"&&T[U][0]!="M"){T.splice(U,0,["M",W.x,W.y]);V.bx=0;V.by=0;V.x=Q[U][1];V.y=Q[U][2];C=AN(H[AI],G&&G[AI]||0);}};for(var K=0,C=AN(H[AI],G&&G[AI]||0);K<C;K++){H[K]=M(H[K],D);N(H,K);G&&(G[K]=M(G[K],O));G&&N(G,K);P(H,G,D,O,K);P(G,H,O,D,K);var L=H[K],B=G&&G[K],F=L[AI],J=G&&B[AI];D.x=L[F-2];D.y=L[F-1];D.bx=BG(L[F-4])||D.x;D.by=BG(L[F-3])||D.y;O.bx=G&&(BG(B[J-4])||O.x);O.by=G&&(BG(B[J-3])||O.y);O.x=G&&B[J-2];O.y=G&&B[J-1];}return G?[H,G]:H;},null,Bd),AE=A3(function(D){var F=[];for(var I=0,B=D[AI];I<B;I++){var J={},G=D[I].match(/^([^:]*):?([\d\.]*)/);J.color=Au.getRGB(G[1]);if(J.color.error){return null;}J.color=J.color.hex;G[2]&&(J.offset=G[2]+"%");F[AP](J);}for(I=1,B=F[AI]-1;I<B;I++){if(!F[I].offset){var K=BG(F[I-1].offset||0),C=0;for(var A=I+1;A<B;A++){if(F[A].offset){C=F[A].offset;break;}}if(!C){C=100;A=B;}C=BG(C);var H=(C-K)/(A-I+1);for(;I<A;I++){K+=H;F[I].offset=K+"%";}}}return F;}),As=function(F,B,A,C){var D;if(Au.is(F,"string")||Au.is(F,"object")){D=Au.is(F,"string")?Ac.getElementById(F):F;if(D.tagName){if(B==null){return{container:D,width:D.style.pixelWidth||D.offsetWidth,height:D.style.pixelHeight||D.offsetHeight};}else{return{container:D,width:B,height:A};}}}else{if(Au.is(F,A0)&&C!=null){return{container:1,x:F,y:B,width:A,height:C};}}},BR=function(D,A){var C=this;for(var B in A){if(A[AW](B)&&!(B in D)){switch(typeof A[B]){case"function":(function(F){D[B]=D===C?F:function(){return F[Bj](C,arguments);};})(A[B]);break;case"object":D[B]=D[B]||{};BR.call(this,D[B],A[B]);break;default:D[B]=A[B];break;}}}},A1=function(B,A){B==A.top&&(A.top=B.prev);B==A.bottom&&(A.bottom=B.next);B.next&&(B.next.prev=B.prev);B.prev&&(B.prev.next=B.next);},BE=function(B,A){if(A.top===B){return ;}A1(B,A);B.next=null;B.prev=A.top;A.top.next=B;A.top=B;},AK=function(B,A){if(A.bottom===B){return ;}A1(B,A);B.next=A.bottom;B.prev=null;A.bottom.prev=B;A.bottom=B;},At=function(B,C,A){A1(B,A);C==A.top&&(A.top=B);C.next&&(C.next.prev=B);
B.next=C.next;B.prev=C;C.next=B;},Ap=function(B,C,A){A1(B,A);C==A.bottom&&(A.bottom=B);C.prev&&(C.prev.next=B);B.prev=C.prev;C.prev=B;B.next=C;},AB=function(A){return function(){throw new Error("Rapha\xebl: you are calling to method \u201c"+A+"\u201d of removed object");};},Al=/^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/;if(Au.svg){Bm[Bh].svgns="http://www.w3.org/2000/svg";Bm[Bh].xlink="http://www.w3.org/1999/xlink";AY=function(A){return +A+(~~A===A)*0.5;};var AT=function(A){for(var D=0,C=A[AI];D<C;D++){if(Ab.call(A[D][0])!="a"){for(var F=1,B=A[D][AI];F<B;F++){A[D][F]=AY(A[D][F]);}}else{A[D][6]=AY(A[D][6]);A[D][7]=AY(A[D][7]);}}return A;},BO=function(A,C){if(C){for(var B in C){if(C[AW](B)){A[S](B,C[B]+Bg);}}}else{return Ac.createElementNS(Bm[Bh].svgns,A);}};Au[BX]=function(){return"Your browser supports SVG.\nYou are running Rapha\xebl "+this.version;};var AD=function(D,B){var C=BO("path");B.canvas&&B.canvas[BM](C);var A=new Bb(C,B);A.type="path";BC(A,{fill:"none",stroke:"#000",path:D});return A;};var AR=function(J,C,P){var H="linear",L=0.5,O=0.5,A=J.style;C=(C+Bg)[BH](Al,function(V,T,U){H="radial";if(T&&U){L=BG(T);O=BG(U);var W=((O>0.5)*2-1);BL(L-0.5,2)+BL(O-0.5,2)>0.25&&(O=BB.sqrt(0.25-BL(L-0.5,2))*W+0.5)&&O!=0.5&&(O=O.toFixed(5)-0.00001*W);}return Bg;});C=C[Av](/\s*\-\s*/);if(H=="linear"){var M=C.shift();M=-BG(M);if(isNaN(M)){return null;}var G=[0,0,BB.cos(M*BB.PI/180),BB.sin(M*BB.PI/180)],D=1/(AN(BB.abs(G[2]),BB.abs(G[3]))||1);G[2]*=D;G[3]*=D;if(G[2]<0){G[0]=-G[2];G[2]=0;}if(G[3]<0){G[1]=-G[3];G[3]=0;}}var I=AE(C);if(!I){return null;}var N=J.getAttribute("fill");N=N.match(/^url\(#(.*)\)$/);N&&P.defs.removeChild(Ac.getElementById(N[1]));var Q=BO(H+"Gradient");Q.id="r"+(Au._id++)[BX](36);BO(Q,H=="radial"?{fx:L,fy:O}:{x1:G[0],y1:G[1],x2:G[2],y2:G[3]});P.defs[BM](Q);for(var K=0,B=I[AI];K<B;K++){var F=BO("stop");BO(F,{offset:I[K].offset?I[K].offset:!K?"0%":"100%","stop-color":I[K].color||"#fff"});Q[BM](F);}BO(J,{fill:"url(#"+Q.id+")",opacity:1,"fill-opacity":1});A.fill=Bg;A.opacity=1;A.fillOpacity=1;return 1;};var Aa=function(A){var B=A.getBBox();BO(A.pattern,{patternTransform:Au.format("translate({0},{1})",B.x,B.y)});};var BC=function(G,W){var C={"":[0],none:[0],"-":[3,1],".":[1,1],"-.":[3,1,1,1],"-..":[3,1,1,1,1,1],". ":[1,3],"- ":[4,3],"--":[8,3],"- .":[4,3,1,3],"--.":[8,3,1,3],"--..":[8,3,1,3,1,3]},A=G.node,F=G.attrs,J=G.rotate(),M=function(g,h){h=C[Ab.call(h)];if(h){var a=g.attrs["stroke-width"]||"1",f={round:a,square:a,butt:0}[g.attrs["stroke-linecap"]||W["stroke-linecap"]]||0,j=[];var b=h[AI];while(b--){j[b]=h[b]*a+((b%2)?1:-1)*f;}BO(A,{"stroke-dasharray":j[BZ](",")});}};W[AW]("rotation")&&(J=W.rotation);var K=(J+Bg)[Av](AS);if(!(K.length-1)){K=null;}else{K[1]=+K[1];K[2]=+K[2];}BG(J)&&G.rotate(0,true);for(var B in W){if(W[AW](B)){if(!AL[AW](B)){continue;}var D=W[B];F[B]=D;switch(B){case"blur":G.blur(D);break;case"rotation":G.rotate(D,true);break;case"href":case"title":case"target":var Y=A.parentNode;if(Ab.call(Y.tagName)!="a"){var P=BO("a");Y.insertBefore(P,A);P[BM](A);Y=P;}Y.setAttributeNS(G.paper.xlink,B,D);break;case"cursor":A.style.cursor=D;break;case"clip-rect":var T=(D+Bg)[Av](AS);if(T[AI]==4){G.clip&&G.clip.parentNode.parentNode.removeChild(G.clip.parentNode);var Q=BO("clipPath"),Z=BO("rect");Q.id="r"+(Au._id++)[BX](36);BO(Z,{x:T[0],y:T[1],width:T[2],height:T[3]});Q[BM](Z);G.paper.defs[BM](Q);BO(A,{"clip-path":"url(#"+Q.id+")"});G.clip=Z;}if(!D){var X=Ac.getElementById(A.getAttribute("clip-path")[BH](/(^url\(#|\)$)/g,Bg));X&&X.parentNode.removeChild(X);BO(A,{"clip-path":Bg});delete G.clip;}break;case"path":if(G.type=="path"){BO(A,{d:D?F.path=AT(AC(D)):"M0,0"});}break;case"width":A[S](B,D);if(F.fx){B="x";D=F.x;}else{break;}case"x":if(F.fx){D=-F.x-(F.width||0);}case"rx":if(B=="rx"&&G.type=="rect"){break;}case"cx":K&&(B=="x"||B=="cx")&&(K[1]+=D-F[B]);A[S](B,AY(D));G.pattern&&Aa(G);break;case"height":A[S](B,D);if(F.fy){B="y";D=F.y;}else{break;}case"y":if(F.fy){D=-F.y-(F.height||0);}case"ry":if(B=="ry"&&G.type=="rect"){break;}case"cy":K&&(B=="y"||B=="cy")&&(K[2]+=D-F[B]);
A[S](B,AY(D));G.pattern&&Aa(G);break;case"r":if(G.type=="rect"){BO(A,{rx:D,ry:D});}else{A[S](B,D);}break;case"src":if(G.type=="image"){A.setAttributeNS(G.paper.xlink,"href",D);}break;case"stroke-width":A.style.strokeWidth=D;A[S](B,D);if(F["stroke-dasharray"]){M(G,F["stroke-dasharray"]);}break;case"stroke-dasharray":M(G,D);break;case"translation":var O=(D+Bg)[Av](AS);O[0]=+O[0]||0;O[1]=+O[1]||0;if(K){K[1]+=O[0];K[2]+=O[1];}AA.call(G,O[0],O[1]);break;case"scale":O=(D+Bg)[Av](AS);G.scale(+O[0]||1,+O[1]||+O[0]||1,isNaN(BG(O[2]))?null:+O[2],isNaN(BG(O[3]))?null:+O[3]);break;case"fill":var N=(D+Bg).match(AQ);if(N){Q=BO("pattern");var H=BO("image");Q.id="r"+(Au._id++)[BX](36);BO(Q,{x:0,y:0,patternUnits:"userSpaceOnUse",height:1,width:1});BO(H,{x:0,y:0});H.setAttributeNS(G.paper.xlink,"href",N[1]);Q[BM](H);var V=Ac.createElement("img");V.style.cssText="position:absolute;left:-9999em;top-9999em";V.onload=function(){BO(Q,{width:this.offsetWidth,height:this.offsetHeight});BO(H,{width:this.offsetWidth,height:this.offsetHeight});Ac.body.removeChild(this);G.paper.safari();};Ac.body[BM](V);V.src=N[1];G.paper.defs[BM](Q);A.style.fill="url(#"+Q.id+")";BO(A,{fill:"url(#"+Q.id+")"});G.pattern=Q;G.pattern&&Aa(G);break;}if(!Au.getRGB(D).error){delete W.gradient;delete F.gradient;!Au.is(F.opacity,"undefined")&&Au.is(W.opacity,"undefined")&&BO(A,{opacity:F.opacity});!Au.is(F["fill-opacity"],"undefined")&&Au.is(W["fill-opacity"],"undefined")&&BO(A,{"fill-opacity":F["fill-opacity"]});}else{if((({circle:1,ellipse:1})[AW](G.type)||(D+Bg).charAt()!="r")&&AR(A,D,G.paper)){F.gradient=D;F.fill="none";break;}}case"stroke":A[S](B,Au.getRGB(D).hex);break;case"gradient":(({circle:1,ellipse:1})[AW](G.type)||(D+Bg).charAt()!="r")&&AR(A,D,G.paper);break;case"opacity":case"fill-opacity":if(F.gradient){var U=Ac.getElementById(A.getAttribute("fill")[BH](/^url\(#|\)$/g,Bg));if(U){var L=U.getElementsByTagName("stop");L[L[AI]-1][S]("stop-opacity",D);}break;}default:B=="font-size"&&(D=Ai(D,10)+"px");var I=B[BH](/(\-.)/g,function(a){return BJ.call(a.substring(1));});A.style[I]=D;A[S](B,D);break;}}}Ak(G,W);if(K){G.rotate(K.join(Aw));}else{BG(J)&&G.rotate(J,true);}};var AM=1.2,Ak=function(K,C){if(K.type!="text"||!(C[AW]("text")||C[AW]("font")||C[AW]("font-size")||C[AW]("x")||C[AW]("y"))){return ;}var F=K.attrs,J=K.node,B=J.firstChild?Ai(Ac.defaultView.getComputedStyle(J.firstChild,Bg).getPropertyValue("font-size"),10):10;if(C[AW]("text")){F.text=C.text;while(J.firstChild){J.removeChild(J.firstChild);}var L=(C.text+Bg)[Av]("\n");for(var A=0,D=L[AI];A<D;A++){if(L[A]){var H=BO("tspan");A&&BO(H,{dy:B*AM,x:F.x});H[BM](Ac.createTextNode(L[A]));J[BM](H);}}}else{L=J.getElementsByTagName("tspan");for(A=0,D=L[AI];A<D;A++){A&&BO(L[A],{dy:B*AM,x:F.x});}}BO(J,{y:F.y});var I=K.getBBox(),G=F.y-(I.y+I.height/2);G&&isFinite(G)&&BO(J,{y:F.y+G});},Bb=function(C,D){var B=0,A=0;this[0]=C;this.id=Au._oid++;this.node=C;C.raphael=this;this.paper=D;this.attrs=this.attrs||{};this.transformations=[];this._={tx:0,ty:0,rt:{deg:0,cx:0,cy:0},sx:1,sy:1};!D.bottom&&(D.bottom=this);this.prev=D.top;D.top&&(D.top.next=this);D.top=this;this.next=null;};Bb[Bh].rotate=function(C,D,B){if(this.removed){return this;}if(C==null){if(this._.rt.cx){return[this._.rt.deg,this._.rt.cx,this._.rt.cy][BZ](Aw);}return this._.rt.deg;}var A=this.getBBox();C=(C+Bg)[Av](AS);if(C[AI]-1){D=BG(C[1]);B=BG(C[2]);}C=BG(C[0]);if(D!=null){this._.rt.deg=C;}else{this._.rt.deg+=C;}(B==null)&&(D=null);this._.rt.cx=D;this._.rt.cy=B;D=D==null?A.x+A.width/2:D;B=B==null?A.y+A.height/2:B;if(this._.rt.deg){this.transformations[0]=Au.format("rotate({0} {1} {2})",this._.rt.deg,D,B);this.clip&&BO(this.clip,{transform:Au.format("rotate({0} {1} {2})",-this._.rt.deg,D,B)});}else{this.transformations[0]=Bg;this.clip&&BO(this.clip,{transform:Bg});}BO(this.node,{transform:this.transformations[BZ](Aw)});return this;};Bb[Bh].hide=function(){!this.removed&&(this.node.style.display="none");return this;};Bb[Bh].show=function(){!this.removed&&(this.node.style.display="");
return this;};Bb[Bh].remove=function(){if(this.removed){return ;}A1(this,this.paper);this.node.parentNode.removeChild(this.node);for(var A in this){delete this[A];}this.removed=true;};Bb[Bh].getBBox=function(){if(this.removed){return this;}if(this.type=="path"){return AU(this.attrs.path);}if(this.node.style.display=="none"){this.show();var D=true;}var C={};try{C=this.node.getBBox();}catch(A){}finally{C=C||{};}if(this.type=="text"){C={x:C.x,y:Infinity,width:0,height:0};for(var G=0,B=this.node.getNumberOfChars();G<B;G++){var F=this.node.getExtentOfChar(G);(F.y<C.y)&&(C.y=F.y);(F.y+F.height-C.y>C.height)&&(C.height=F.y+F.height-C.y);(F.x+F.width-C.x>C.width)&&(C.width=F.x+F.width-C.x);}}D&&this.hide();return C;};Bb[Bh].attr=function(F,D){if(this.removed){return this;}if(F==null){var A={};for(var B in this.attrs){if(this.attrs[AW](B)){A[B]=this.attrs[B];}}this._.rt.deg&&(A.rotation=this.rotate());(this._.sx!=1||this._.sy!=1)&&(A.scale=this.scale());A.gradient&&A.fill=="none"&&(A.fill=A.gradient)&&delete A.gradient;return A;}if(D==null&&Au.is(F,"string")){if(F=="translation"){return AA.call(this);}if(F=="rotation"){return this.rotate();}if(F=="scale"){return this.scale();}if(F=="fill"&&this.attrs.fill=="none"&&this.attrs.gradient){return this.attrs.gradient;}return this.attrs[F];}if(D==null&&Au.is(F,"array")){var I={};for(var H=0,G=F.length;H<G;H++){I[F[H]]=this.attr(F[H]);}return I;}if(D!=null){var C={};C[F]=D;BC(this,C);}else{if(F!=null&&Au.is(F,"object")){BC(this,F);}}return this;};Bb[Bh].toFront=function(){if(this.removed){return this;}this.node.parentNode[BM](this.node);var A=this.paper;A.top!=this&&BE(this,A);return this;};Bb[Bh].toBack=function(){if(this.removed){return this;}if(this.node.parentNode.firstChild!=this.node){this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild);AK(this,this.paper);var A=this.paper;}return this;};Bb[Bh].insertAfter=function(B){if(this.removed){return this;}var A=B.node;if(A.nextSibling){A.parentNode.insertBefore(this.node,A.nextSibling);}else{A.parentNode[BM](this.node);}At(this,B,this.paper);return this;};Bb[Bh].insertBefore=function(B){if(this.removed){return this;}var A=B.node;A.parentNode.insertBefore(this.node,A);Ap(this,B,this.paper);return this;};Bb[Bh].blur=function(C){var D=this;if(+C!==0){var A=BO("filter"),B=BO("feGaussianBlur");D.attrs.blur=C;A.id="r"+(Au._id++)[BX](36);BO(B,{stdDeviation:+C||1.5});A.appendChild(B);D.paper.defs.appendChild(A);D._blur=A;BO(D.node,{filter:"url(#"+A.id+")"});}else{if(D._blur){D._blur.parentNode.removeChild(D._blur);delete D._blur;delete D.attrs.blur;}D.node.removeAttribute("filter");}};var AX=function(F,G,B,C){G=AY(G);B=AY(B);var D=BO("circle");F.canvas&&F.canvas[BM](D);var A=new Bb(D,F);A.attrs={cx:G,cy:B,r:C,fill:"none",stroke:"#000"};A.type="circle";BO(D,A.attrs);return A;};var BS=function(B,I,F,H,A,G){I=AY(I);F=AY(F);var C=BO("rect");B.canvas&&B.canvas[BM](C);var D=new Bb(C,B);D.attrs={x:I,y:F,width:H,height:A,r:G||0,rx:G||0,ry:G||0,fill:"none",stroke:"#000"};D.type="rect";BO(C,D.attrs);return D;};var A4=function(G,H,F,B,C){H=AY(H);F=AY(F);var D=BO("ellipse");G.canvas&&G.canvas[BM](D);var A=new Bb(D,G);A.attrs={cx:H,cy:F,rx:B,ry:C,fill:"none",stroke:"#000"};A.type="ellipse";BO(D,A.attrs);return A;};var AF=function(B,H,I,F,G,A){var C=BO("image");BO(C,{x:I,y:F,width:G,height:A,preserveAspectRatio:"none"});C.setAttributeNS(B.xlink,"href",H);B.canvas&&B.canvas[BM](C);var D=new Bb(C,B);D.attrs={x:I,y:F,width:G,height:A,src:H};D.type="image";return D;};var BF=function(F,G,B,C){var D=BO("text");BO(D,{x:G,y:B,"text-anchor":"middle"});F.canvas&&F.canvas[BM](D);var A=new Bb(D,F);A.attrs={x:G,y:B,"text-anchor":"middle",text:C,font:AL.font,stroke:"none",fill:"#000"};A.type="text";BC(A,A.attrs);return A;};var Bk=function(A,B){this.width=A||this.width;this.height=B||this.height;this.canvas[S]("width",this.width);this.canvas[S]("height",this.height);return this;};var R=function(){var D=As[Bj](0,arguments),B=D&&D.container,G=D.x,F=D.y,C=D.width,H=D.height;
if(!B){throw new Error("SVG container not found.");}var A=BO("svg");C=C||512;H=H||342;BO(A,{xmlns:"http://www.w3.org/2000/svg",version:1.1,width:C,height:H});if(B==1){A.style.cssText="position:absolute;left:"+G+"px;top:"+F+"px";Ac.body[BM](A);}else{if(B.firstChild){B.insertBefore(A,B.firstChild);}else{B[BM](A);}}B=new Bm;B.width=C;B.height=H;B.canvas=A;BR.call(B,B,Au.fn);B.clear();return B;};Bm[Bh].clear=function(){var A=this.canvas;while(A.firstChild){A.removeChild(A.firstChild);}this.bottom=this.top=null;(this.desc=BO("desc"))[BM](Ac.createTextNode("Created with Rapha\xebl"));A[BM](this.desc);A[BM](this.defs=BO("defs"));};Bm[Bh].remove=function(){this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas);for(var A in this){this[A]=AB(A);}};}if(Au.vml){var An={M:"m",L:"l",C:"c",Z:"x",m:"t",l:"r",c:"v",z:"x"},Am=/([clmz]),?([^clmz]*)/gi,Ad=/-?[^,\s-]+/g,BY=1000+Aw+1000,AG=10,BQ=function(B){var G=/[ahqstv]/ig,L=AC;(B+Bg).match(G)&&(L=Ah);G=/[clmz]/g;if(L==AC&&!(B+Bg).match(G)){var H=(B+Bg)[BH](Am,function(M,Q,O){var T=[],P=Ab.call(Q)=="m",N=An[Q];O[BH](Ad,function(U){if(P&&T[AI]==2){N+=T+An[Q=="m"?"l":"L"];T=[];}T[AP](AY(U*AG));});return N+T;});return H;}var F=L(B),J,K;H=[];for(var A=0,D=F[AI];A<D;A++){J=F[A];K=Ab.call(F[A][0]);K=="z"&&(K="x");for(var C=1,I=J[AI];C<I;C++){K+=AY(J[C]*AG)+(C!=I-1?",":Bg);}H[AP](K);}return H[BZ](Aw);};Au[BX]=function(){return"Your browser doesn\u2019t support SVG. Falling down to VML.\nYou are running Rapha\xebl "+this.version;};AD=function(B,G){var A=A5("group");A.style.cssText="position:absolute;left:0;top:0;width:"+G.width+"px;height:"+G.height+"px";A.coordsize=G.coordsize;A.coordorigin=G.coordorigin;var C=A5("shape"),D=C.style;D.width=G.width+"px";D.height=G.height+"px";C.coordsize=BY;C.coordorigin=G.coordorigin;A[BM](C);var F=new Bb(C,A,G),H={fill:"none",stroke:"#000"};B&&(H.path=B);F.isAbsolute=true;F.type="path";F.path=[];F.Path=Bg;BC(F,H);G.canvas[BM](A);return F;};BC=function(J,D){J.attrs=J.attrs||{};var G=J.node,C=J.attrs,N=G.style,P,V=J;for(var L in D){if(D[AW](L)){C[L]=D[L];}}D.href&&(G.href=D.href);D.title&&(G.title=D.title);D.target&&(G.target=D.target);D.cursor&&(N.cursor=D.cursor);"blur" in D&&J.blur(D.blur);if(D.path&&J.type=="path"){C.path=D.path;G.path=BQ(C.path);}if(D.rotation!=null){J.rotate(D.rotation,true);}if(D.translation){P=(D.translation+Bg)[Av](AS);AA.call(J,P[0],P[1]);if(J._.rt.cx!=null){J._.rt.cx+=+P[0];J._.rt.cy+=+P[1];J.setBox(J.attrs,P[0],P[1]);}}if(D.scale){P=(D.scale+Bg)[Av](AS);J.scale(+P[0]||1,+P[1]||+P[0]||1,+P[2]||null,+P[3]||null);}if("clip-rect" in D){var U=(D["clip-rect"]+Bg)[Av](AS);if(U[AI]==4){U[2]=+U[2]+(+U[0]);U[3]=+U[3]+(+U[1]);var K=G.clipRect||Ac.createElement("div"),W=K.style,M=G.parentNode;W.clip=Au.format("rect({1}px {2}px {3}px {0}px)",U);if(!G.clipRect){W.position="absolute";W.top=0;W.left=0;W.width=J.paper.width+"px";W.height=J.paper.height+"px";M.parentNode.insertBefore(K,M);K[BM](M);G.clipRect=K;}}if(!D["clip-rect"]){G.clipRect&&(G.clipRect.style.clip=Bg);}}if(J.type=="image"&&D.src){G.src=D.src;}if(J.type=="image"&&D.opacity){G.filterOpacity=" progid:DXImageTransform.Microsoft.Alpha(opacity="+(D.opacity*100)+")";N.filter=(G.filterMatrix||Bg)+(G.filterOpacity||Bg);}D.font&&(N.font=D.font);D["font-family"]&&(N.fontFamily='"'+D["font-family"][Av](",")[0][BH](/^['"]+|['"]+$/g,Bg)+'"');D["font-size"]&&(N.fontSize=D["font-size"]);D["font-weight"]&&(N.fontWeight=D["font-weight"]);D["font-style"]&&(N.fontStyle=D["font-style"]);if(D.opacity!=null||D["stroke-width"]!=null||D.fill!=null||D.stroke!=null||D["stroke-width"]!=null||D["stroke-opacity"]!=null||D["fill-opacity"]!=null||D["stroke-dasharray"]!=null||D["stroke-miterlimit"]!=null||D["stroke-linejoin"]!=null||D["stroke-linecap"]!=null){G=J.shape||G;var F=(G.getElementsByTagName("fill")&&G.getElementsByTagName("fill")[0]),B=false;!F&&(B=F=A5("fill"));if("fill-opacity" in D||"opacity" in D){var T=((+C["fill-opacity"]+1||2)-1)*((+C.opacity+1||2)-1);T<0&&(T=0);T>1&&(T=1);F.opacity=T;}D.fill&&(F.on=true);
if(F.on==null||D.fill=="none"){F.on=false;}if(F.on&&D.fill){var Q=D.fill.match(AQ);if(Q){F.src=Q[1];F.type="tile";}else{F.color=Au.getRGB(D.fill).hex;F.src=Bg;F.type="solid";if(Au.getRGB(D.fill).error&&(V.type in {circle:1,ellipse:1}||(D.fill+Bg).charAt()!="r")&&AR(V,D.fill)){C.fill="none";C.gradient=D.fill;}}}B&&G[BM](F);var O=(G.getElementsByTagName("stroke")&&G.getElementsByTagName("stroke")[0]),A=false;!O&&(A=O=A5("stroke"));if((D.stroke&&D.stroke!="none")||D["stroke-width"]||D["stroke-opacity"]!=null||D["stroke-dasharray"]||D["stroke-miterlimit"]||D["stroke-linejoin"]||D["stroke-linecap"]){O.on=true;}(D.stroke=="none"||O.on==null||D.stroke==0||D["stroke-width"]==0)&&(O.on=false);O.on&&D.stroke&&(O.color=Au.getRGB(D.stroke).hex);T=((+C["stroke-opacity"]+1||2)-1)*((+C.opacity+1||2)-1);var I=(BG(D["stroke-width"])||1)*0.75;T<0&&(T=0);T>1&&(T=1);D["stroke-width"]==null&&(I=C["stroke-width"]);D["stroke-width"]&&(O.weight=I);I&&I<1&&(T*=I)&&(O.weight=1);O.opacity=T;D["stroke-linejoin"]&&(O.joinstyle=D["stroke-linejoin"]||"miter");O.miterlimit=D["stroke-miterlimit"]||8;D["stroke-linecap"]&&(O.endcap=D["stroke-linecap"]=="butt"?"flat":D["stroke-linecap"]=="square"?"square":"round");if(D["stroke-dasharray"]){var H={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};O.dashstyle=H[AW](D["stroke-dasharray"])?H[D["stroke-dasharray"]]:Bg;}A&&G[BM](O);}if(V.type=="text"){N=V.paper.span.style;C.font&&(N.font=C.font);C["font-family"]&&(N.fontFamily=C["font-family"]);C["font-size"]&&(N.fontSize=C["font-size"]);C["font-weight"]&&(N.fontWeight=C["font-weight"]);C["font-style"]&&(N.fontStyle=C["font-style"]);V.node.string&&(V.paper.span.innerHTML=(V.node.string+Bg)[BH](/</g,"&#60;")[BH](/&/g,"&#38;")[BH](/\n/g,"<br>"));V.W=C.w=V.paper.span.offsetWidth;V.H=C.h=V.paper.span.offsetHeight;V.X=C.x;V.Y=C.y+AY(V.H/2);switch(C["text-anchor"]){case"start":V.node.style["v-text-align"]="left";V.bbx=AY(V.W/2);break;case"end":V.node.style["v-text-align"]="right";V.bbx=-AY(V.W/2);break;default:V.node.style["v-text-align"]="center";break;}}};AR=function(K,H){K.attrs=K.attrs||{};var G=K.attrs,D=K.node.getElementsByTagName("fill"),B="linear",I=".5 .5";K.attrs.gradient=H;H=(H+Bg)[BH](Al,function(N,M,O){B="radial";if(M&&O){M=BG(M);O=BG(O);BL(M-0.5,2)+BL(O-0.5,2)>0.25&&(O=BB.sqrt(0.25-BL(M-0.5,2))*((O>0.5)*2-1)+0.5);I=M+Aw+O;}return Bg;});H=H[Av](/\s*\-\s*/);if(B=="linear"){var J=H.shift();J=-BG(J);if(isNaN(J)){return null;}}var C=AE(H);if(!C){return null;}K=K.shape||K.node;D=D[0]||A5("fill");if(C[AI]){D.on=true;D.method="none";D.type=(B=="radial")?"gradientradial":"gradient";D.color=C[0].color;D.color2=C[C[AI]-1].color;var A=[];for(var L=0,F=C[AI];L<F;L++){C[L].offset&&A[AP](C[L].offset+Aw+C[L].color);}D.colors&&(D.colors.value=A[AI]?A[BZ](","):"0% "+D.color);if(B=="radial"){D.focus="100%";D.focussize=I;D.focusposition=I;}else{D.angle=(270-J)%360;}}return 1;};Bb=function(C,G,H){var B=0,A=0,F=0,D=1;this[0]=C;this.id=Au._oid++;this.node=C;C.raphael=this;this.X=0;this.Y=0;this.attrs={};this.Group=G;this.paper=H;this._={tx:0,ty:0,rt:{deg:0},sx:1,sy:1};!H.bottom&&(H.bottom=this);this.prev=H.top;H.top&&(H.top.next=this);H.top=this;this.next=null;};Bb[Bh].rotate=function(B,C,A){if(this.removed){return this;}if(B==null){if(this._.rt.cx){return[this._.rt.deg,this._.rt.cx,this._.rt.cy][BZ](Aw);}return this._.rt.deg;}B=(B+Bg)[Av](AS);if(B[AI]-1){C=BG(B[1]);A=BG(B[2]);}B=BG(B[0]);if(C!=null){this._.rt.deg=B;}else{this._.rt.deg+=B;}A==null&&(C=null);this._.rt.cx=C;this._.rt.cy=A;this.setBox(this.attrs,C,A);this.Group.style.rotation=this._.rt.deg;return this;};Bb[Bh].setBox=function(V,Q,T){if(this.removed){return this;}var G=this.Group.style,O=(this.shape&&this.shape.style)||this.node.style;V=V||{};for(var B in V){if(V[AW](B)){this.attrs[B]=V[B];}}Q=Q||this._.rt.cx;T=T||this._.rt.cy;var D=this.attrs,L,N,K,A;switch(this.type){case"circle":L=D.cx-D.r;N=D.cy-D.r;
K=A=D.r*2;break;case"ellipse":L=D.cx-D.rx;N=D.cy-D.ry;K=D.rx*2;A=D.ry*2;break;case"rect":case"image":L=+D.x;N=+D.y;K=D.width||0;A=D.height||0;break;case"text":this.textpath.v=["m",AY(D.x),", ",AY(D.y-2),"l",AY(D.x)+1,", ",AY(D.y-2)][BZ](Bg);L=D.x-AY(this.W/2);N=D.y-this.H/2;K=this.W;A=this.H;break;case"path":if(!this.attrs.path){L=0;N=0;K=this.paper.width;A=this.paper.height;}else{var C=AU(this.attrs.path);L=C.x;N=C.y;K=C.width;A=C.height;}break;default:L=0;N=0;K=this.paper.width;A=this.paper.height;break;}Q=(Q==null)?L+K/2:Q;T=(T==null)?N+A/2:T;var P=Q-this.paper.width/2,H=T-this.paper.height/2,I;G.left!=(I=P+"px")&&(G.left=I);G.top!=(I=H+"px")&&(G.top=I);this.X=this.type=="path"?-P:L;this.Y=this.type=="path"?-H:N;this.W=K;this.H=A;if(this.type=="path"){O.left!=(I=-P*AG+"px")&&(O.left=I);O.top!=(I=-H*AG+"px")&&(O.top=I);}else{if(this.type=="text"){O.left!=(I=-P+"px")&&(O.left=I);O.top!=(I=-H+"px")&&(O.top=I);}else{G.width!=(I=this.paper.width+"px")&&(G.width=I);G.height!=(I=this.paper.height+"px")&&(G.height=I);O.left!=(I=L-P+"px")&&(O.left=I);O.top!=(I=N-H+"px")&&(O.top=I);O.width!=(I=K+"px")&&(O.width=I);O.height!=(I=A+"px")&&(O.height=I);var M=(+V.r||0)/BP(K,A);if(this.type=="rect"&&this.arcsize.toFixed(4)!=M.toFixed(4)&&(M||this.arcsize)){var F=A5("roundrect"),U={},J=this.events&&this.events[AI];B=0;F.arcsize=M;F.raphael=this;this.Group[BM](F);this.Group.removeChild(this.node);this[0]=this.node=F;this.arcsize=M;for(B in D){U[B]=D[B];}delete U.scale;this.attr(U);if(this.events){for(;B<J;B++){this.events[B].unbind=A8(this.node,this.events[B].name,this.events[B].f,this);}}}}}};Bb[Bh].hide=function(){!this.removed&&(this.Group.style.display="none");return this;};Bb[Bh].show=function(){!this.removed&&(this.Group.style.display="block");return this;};Bb[Bh].getBBox=function(){if(this.removed){return this;}if(this.type=="path"){return AU(this.attrs.path);}return{x:this.X+(this.bbx||0),y:this.Y,width:this.W,height:this.H};};Bb[Bh].remove=function(){if(this.removed){return ;}A1(this,this.paper);this.node.parentNode.removeChild(this.node);this.Group.parentNode.removeChild(this.Group);this.shape&&this.shape.parentNode.removeChild(this.shape);for(var A in this){delete this[A];}this.removed=true;};Bb[Bh].attr=function(G,F){if(this.removed){return this;}if(G==null){var B={};for(var D in this.attrs){if(this.attrs[AW](D)){B[D]=this.attrs[D];}}this._.rt.deg&&(B.rotation=this.rotate());(this._.sx!=1||this._.sy!=1)&&(B.scale=this.scale());B.gradient&&B.fill=="none"&&(B.fill=B.gradient)&&delete B.gradient;return B;}if(F==null&&Au.is(G,"string")){if(G=="translation"){return AA.call(this);}if(G=="rotation"){return this.rotate();}if(G=="scale"){return this.scale();}if(G=="fill"&&this.attrs.fill=="none"&&this.attrs.gradient){return this.attrs.gradient;}return this.attrs[G];}if(this.attrs&&F==null&&Au.is(G,"array")){var A,H={};for(D=0,A=G[AI];D<A;D++){H[G[D]]=this.attr(G[D]);}return H;}var C;if(F!=null){C={};C[G]=F;}F==null&&Au.is(G,"object")&&(C=G);if(C){if(C.text&&this.type=="text"){this.node.string=C.text;}BC(this,C);if(C.gradient&&(({circle:1,ellipse:1})[AW](this.type)||(C.gradient+Bg).charAt()!="r")){AR(this,C.gradient);}(this.type!="path"||this._.rt.deg)&&this.setBox(this.attrs);}return this;};Bb[Bh].toFront=function(){!this.removed&&this.Group.parentNode[BM](this.Group);this.paper.top!=this&&BE(this,this.paper);return this;};Bb[Bh].toBack=function(){if(this.removed){return this;}if(this.Group.parentNode.firstChild!=this.Group){this.Group.parentNode.insertBefore(this.Group,this.Group.parentNode.firstChild);AK(this,this.paper);}return this;};Bb[Bh].insertAfter=function(A){if(this.removed){return this;}if(A.Group.nextSibling){A.Group.parentNode.insertBefore(this.Group,A.Group.nextSibling);}else{A.Group.parentNode[BM](this.Group);}At(this,A,this.paper);return this;};Bb[Bh].insertBefore=function(A){if(this.removed){return this;}A.Group.parentNode.insertBefore(this.Group,A.Group);Ap(this,A,this.paper);return this;};var Bn=/ progid:\S+Blur\([^\)]+\)/g;
Bb[Bh].blur=function(C){var B=this.node.style,A=B.filter;A=A.replace(Bn,"");if(+C!==0){this.attrs.blur=C;B.filter=A+" progid:DXImageTransform.Microsoft.Blur(pixelradius="+(+C||1.5)+")";B.margin=Raphael.format("-{0}px 0 0 -{0}px",Math.round(+C||1.5));}else{B.filter=A;B.margin=0;delete this.attrs.blur;}};AX=function(H,I,F,B){var C=A5("group"),G=A5("oval"),A=G.style;C.style.cssText="position:absolute;left:0;top:0;width:"+H.width+"px;height:"+H.height+"px";C.coordsize=BY;C.coordorigin=H.coordorigin;C[BM](G);var D=new Bb(G,C,H);D.type="circle";BC(D,{stroke:"#000",fill:"none"});D.attrs.cx=I;D.attrs.cy=F;D.attrs.r=B;D.setBox({x:I-B,y:F-B,width:B*2,height:B*2});H.canvas[BM](C);return D;};BS=function(H,G,I,F,K,J){var B=A5("group"),C=A5("roundrect"),D=(+J||0)/(BP(F,K));B.style.cssText="position:absolute;left:0;top:0;width:"+H.width+"px;height:"+H.height+"px";B.coordsize=BY;B.coordorigin=H.coordorigin;B[BM](C);C.arcsize=D;var A=new Bb(C,B,H);A.type="rect";BC(A,{stroke:"#000"});A.arcsize=D;A.setBox({x:G,y:I,width:F,height:K,r:J});H.canvas[BM](B);return A;};A4=function(I,D,F,C,G){var B=A5("group"),J=A5("oval"),H=J.style;B.style.cssText="position:absolute;left:0;top:0;width:"+I.width+"px;height:"+I.height+"px";B.coordsize=BY;B.coordorigin=I.coordorigin;B[BM](J);var A=new Bb(J,B,I);A.type="ellipse";BC(A,{stroke:"#000"});A.attrs.cx=D;A.attrs.cy=F;A.attrs.rx=C;A.attrs.ry=G;A.setBox({x:D-C,y:F-G,width:C*2,height:G*2});I.canvas[BM](B);return A;};AF=function(I,J,F,G,D,K){var B=A5("group"),C=A5("image"),H=C.style;B.style.cssText="position:absolute;left:0;top:0;width:"+I.width+"px;height:"+I.height+"px";B.coordsize=BY;B.coordorigin=I.coordorigin;C.src=J;B[BM](C);var A=new Bb(C,B,I);A.type="image";A.attrs.src=J;A.attrs.x=F;A.attrs.y=G;A.attrs.w=D;A.attrs.h=K;A.setBox({x:F,y:G,width:D,height:K});I.canvas[BM](B);return A;};BF=function(I,G,H,F){var C=A5("group"),L=A5("shape"),J=L.style,D=A5("path"),K=D.style,B=A5("textpath");C.style.cssText="position:absolute;left:0;top:0;width:"+I.width+"px;height:"+I.height+"px";C.coordsize=BY;C.coordorigin=I.coordorigin;D.v=Au.format("m{0},{1}l{2},{1}",AY(G*10),AY(H*10),AY(G*10)+1);D.textpathok=true;J.width=I.width;J.height=I.height;B.string=F+Bg;B.on=true;L[BM](B);L[BM](D);C[BM](L);var A=new Bb(B,C,I);A.shape=L;A.textpath=D;A.type="text";A.attrs.text=F;A.attrs.x=G;A.attrs.y=H;A.attrs.w=1;A.attrs.h=1;BC(A,{font:AL.font,stroke:"none",fill:"#000"});A.setBox();I.canvas[BM](C);return A;};Bk=function(A,C){var B=this.canvas.style;A==+A&&(A+="px");C==+C&&(C+="px");B.width=A;B.height=C;B.clip="rect(0 "+A+" "+C+" 0)";return this;};var A5;Ac.createStyleSheet().addRule(".rvml","behavior:url(#default#VML)");try{!Ac.namespaces.rvml&&Ac.namespaces.add("rvml","urn:schemas-microsoft-com:vml");A5=function(A){return Ac.createElement("<rvml:"+A+' class="rvml">');};}catch(A7){A5=function(A){return Ac.createElement("<"+A+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">');};}R=function(){var C=As[Bj](0,arguments),J=C.container,F=C.height,D,H=C.width,G=C.x,I=C.y;if(!J){throw new Error("VML container not found.");}var B=new Bm,A=B.canvas=Ac.createElement("div"),K=A.style;H=H||512;F=F||342;H==+H&&(H+="px");F==+F&&(F+="px");B.width=1000;B.height=1000;B.coordsize=AG*1000+Aw+AG*1000;B.coordorigin="0 0";B.span=Ac.createElement("span");B.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";A[BM](B.span);K.cssText=Au.format("width:{0};height:{1};position:absolute;clip:rect(0 {0} {1} 0);overflow:hidden",H,F);if(J==1){Ac.body[BM](A);K.left=G+"px";K.top=I+"px";}else{J.style.width=H;J.style.height=F;if(J.firstChild){J.insertBefore(A,J.firstChild);}else{J[BM](A);}}BR.call(B,B,Au.fn);return B;};Bm[Bh].clear=function(){this.canvas.innerHTML=Bg;this.span=Ac.createElement("span");this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";this.canvas[BM](this.span);this.bottom=this.top=null;};Bm[Bh].remove=function(){this.canvas.parentNode.removeChild(this.canvas);
for(var A in this){this[A]=AB(A);}return true;};}if((/^Apple|^Google/).test(Bf.navigator.vendor)&&!(Bf.navigator.userAgent.indexOf("Version/4.0")+1)){Bm[Bh].safari=function(){var A=this.rect(-99,-99,this.width+99,this.height+99);Bf.setTimeout(function(){A.remove();});};}else{Bm[Bh].safari=function(){};}var A8=(function(){if(Ac.addEventListener){return function(B,A,D,F){var C=function(G){return D.call(F,G);};B.addEventListener(A,C,false);return function(){B.removeEventListener(A,C,false);return true;};};}else{if(Ac.attachEvent){return function(B,D,A,F){var C=function(H){return A.call(F,H||Bf.event);};B.attachEvent("on"+D,C);var G=function(){B.detachEvent("on"+D,C);return true;};return G;};}}})();for(var BA=Aj[AI];BA--;){(function(A){Bb[Bh][A]=function(B){if(Au.is(B,"function")){this.events=this.events||[];this.events.push({name:A,f:B,unbind:A8(this.shape||this.node,A,B,this)});}return this;};Bb[Bh]["un"+A]=function(C){var B=this.events,D=B[AI];while(D--){if(B[D].name==A&&B[D].f==C){B[D].unbind();B.splice(D,1);!B.length&&delete this.events;return this;}}return this;};})(Aj[BA]);}Bb[Bh].hover=function(A,B){return this.mouseover(A).mouseout(B);};Bb[Bh].unhover=function(A,B){return this.unmouseover(A).unmouseout(B);};Bm[Bh].circle=function(C,A,B){return AX(this,C||0,A||0,B||0);};Bm[Bh].rect=function(F,B,D,A,C){return BS(this,F||0,B||0,D||0,A||0,C||0);};Bm[Bh].ellipse=function(D,B,A,C){return A4(this,D||0,B||0,A||0,C||0);};Bm[Bh].path=function(A){A&&!Au.is(A,"string")&&!Au.is(A[0],"array")&&(A+=Bg);return AD(Au.format[Bj](Au,arguments),this);};Bm[Bh].image=function(C,F,B,D,A){return AF(this,C||"about:blank",F||0,B||0,D||0,A||0);};Bm[Bh].text=function(C,A,B){return BF(this,C||0,A||0,B||Bg);};Bm[Bh].set=function(A){arguments[AI]>1&&(A=Array[Bh].splice.call(arguments,0,arguments[AI]));return new AV(A);};Bm[Bh].setSize=Bk;Bm[Bh].top=Bm[Bh].bottom=null;Bm[Bh].raphael=Au;function d(){return this.x+Aw+this.y;}Bb[Bh].scale=function(G,H,P,X){if(G==null&&H==null){return{x:this._.sx,y:this._.sy,toString:d};}H=H||G;!+H&&(H=G);var B,D,C,F,T=this.attrs;if(G!=0){var I=this.getBBox(),M=I.x+I.width/2,O=I.y+I.height/2,U=G/this._.sx,V=H/this._.sy;P=(+P||P==0)?P:M;X=(+X||X==0)?X:O;var J=~~(G/BB.abs(G)),N=~~(H/BB.abs(H)),j=this.node.style,h=P+(M-P)*U,Q=X+(O-X)*V;switch(this.type){case"rect":case"image":var K=T.width*J*U,k=T.height*N*V;this.attr({height:k,r:T.r*BP(J*U,N*V),width:K,x:h-K/2,y:Q-k/2});break;case"circle":case"ellipse":this.attr({rx:T.rx*J*U,ry:T.ry*N*V,r:T.r*BP(J*U,N*V),cx:h,cy:Q});break;case"path":var f=A9(T.path),b=true;for(var Z=0,A=f[AI];Z<A;Z++){var g=f[Z],L=BJ.call(g[0]);if(L=="M"&&b){continue;}else{b=false;}if(L=="A"){g[f[Z][AI]-2]*=U;g[f[Z][AI]-1]*=V;g[1]*=J*U;g[2]*=N*V;g[5]=+!(J+N?!+g[5]:+g[5]);}else{if(L=="H"){for(var a=1,W=g[AI];a<W;a++){g[a]*=U;}}else{if(L=="V"){for(a=1,W=g[AI];a<W;a++){g[a]*=V;}}else{for(a=1,W=g[AI];a<W;a++){g[a]*=(a%2)?U:V;}}}}}var Y=AU(f);B=h-Y.x-Y.width/2;D=Q-Y.y-Y.height/2;f[0][1]+=B;f[0][2]+=D;this.attr({path:f});break;}if(this.type in {text:1,image:1}&&(J!=1||N!=1)){if(this.transformations){this.transformations[2]="scale("[Bo](J,",",N,")");this.node[S]("transform",this.transformations[BZ](Aw));B=(J==-1)?-T.x-(K||0):T.x;D=(N==-1)?-T.y-(k||0):T.y;this.attr({x:B,y:D});T.fx=J-1;T.fy=N-1;}else{this.node.filterMatrix=" progid:DXImageTransform.Microsoft.Matrix(M11="[Bo](J,", M12=0, M21=0, M22=",N,", Dx=0, Dy=0, sizingmethod='auto expand', filtertype='bilinear')");j.filter=(this.node.filterMatrix||Bg)+(this.node.filterOpacity||Bg);}}else{if(this.transformations){this.transformations[2]=Bg;this.node[S]("transform",this.transformations[BZ](Aw));T.fx=0;T.fy=0;}else{this.node.filterMatrix=Bg;j.filter=(this.node.filterMatrix||Bg)+(this.node.filterOpacity||Bg);}}T.scale=[G,H,P,X][BZ](Aw);this._.sx=G;this._.sy=H;}return this;};Bb[Bh].clone=function(){var A=this.attr();delete A.scale;delete A.translation;return this.paper[this.type]().attr(A);};var AO=A3(function(N,M,J,L,A,B,D,G,F){var H=0,C;for(var I=0;I<1.001;I+=0.001){var K=Au.findDotsAtSegment(N,M,J,L,A,B,D,G,I);
I&&(H+=BL(BL(C.x-K.x,2)+BL(C.y-K.y,2),0.5));if(H>=F){return K;}C=K;}}),BW=function(B,A){return function(C,H,O){C=Ah(C);var I,K,P,N,J="",D={},G,L=0;for(var M=0,F=C.length;M<F;M++){P=C[M];if(P[0]=="M"){I=+P[1];K=+P[2];}else{N=AH(I,K,P[1],P[2],P[3],P[4],P[5],P[6]);if(L+N>H){if(A&&!D.start){G=AO(I,K,P[1],P[2],P[3],P[4],P[5],P[6],H-L);J+=["C",G.start.x,G.start.y,G.m.x,G.m.y,G.x,G.y];if(O){return J;}D.start=J;J=["M",G.x,G.y+"C",G.n.x,G.n.y,G.end.x,G.end.y,P[5],P[6]][BZ]();L+=N;I=+P[5];K=+P[6];continue;}if(!B&&!A){G=AO(I,K,P[1],P[2],P[3],P[4],P[5],P[6],H-L);return{x:G.x,y:G.y,alpha:G.alpha};}}L+=N;I=+P[5];K=+P[6];}J+=P;}D.end=J;G=B?L:A?D:Au.findDotsAtSegment(I,K,P[1],P[2],P[3],P[4],P[5],P[6],1);G.alpha&&(G={x:G.x,y:G.y,alpha:G.alpha});return G;};},AH=A3(function(M,L,K,B,A,C,F,G){var D={x:0,y:0},H=0;for(var I=0;I<1.01;I+=0.01){var J=AZ(M,L,K,B,A,C,F,G,I);I&&(H+=BL(BL(D.x-J.x,2)+BL(D.y-J.y,2),0.5));D=J;}return H;});var Ar=BW(1),Ao=BW(),Af=BW(0,1);Bb[Bh].getTotalLength=function(){if(this.type!="path"){return ;}return Ar(this.attrs.path);};Bb[Bh].getPointAtLength=function(A){if(this.type!="path"){return ;}return Ao(this.attrs.path,A);};Bb[Bh].getSubpath=function(A,B){if(this.type!="path"){return ;}if(BB.abs(this.getTotalLength()-B)<0.000001){return Af(this.attrs.path,A).end;}var C=Af(this.attrs.path,B,1);return A?Af(C,A).end:C;};Au.easing_formulas={linear:function(A){return A;},"<":function(A){return BL(A,3);},">":function(A){return BL(A-1,3)+1;},"<>":function(A){A=A*2;if(A<1){return BL(A,3)/2;}A-=2;return(BL(A,3)+2)/2;},backIn:function(A){var B=1.70158;return A*A*((B+1)*A-B);},backOut:function(A){A=A-1;var B=1.70158;return A*A*((B+1)*A+B)+1;},elastic:function(A){if(A==0||A==1){return A;}var B=0.3,C=B/4;return BL(2,-10*A)*BB.sin((A-C)*(2*BB.PI)/B)+1;},bounce:function(B){var C=7.5625,A=2.75,D;if(B<(1/A)){D=C*B*B;}else{if(B<(2/A)){B-=(1.5/A);D=C*B*B+0.75;}else{if(B<(2.5/A)){B-=(2.25/A);D=C*B*B+0.9375;}else{B-=(2.625/A);D=C*B*B+0.984375;}}}return D;}};var Ag={length:0},Bp=function(){var K=+new Date;for(var Y in Ag){if(Y!="length"&&Ag[AW](Y)){var Q=Ag[Y];if(Q.stop||Q.el.removed){delete Ag[Y];Ag[AI]--;continue;}var N=K-Q.start,A=Q.ms,B=Q.easing,X=Q.from,F=Q.diff,P=Q.to,G=Q.t,C=Q.prev||0,L=Q.el,O=Q.callback,D={},U;if(N<A){var M=Au.easing_formulas[B]?Au.easing_formulas[B](N/A):N/A;for(var a in X){if(X[AW](a)){switch(BD[a]){case"along":U=M*A*F[a];P.back&&(U=P.len-U);var Z=Ao(P[a],U);L.translate(F.sx-F.x||0,F.sy-F.y||0);F.x=Z.x;F.y=Z.y;L.translate(Z.x-F.sx,Z.y-F.sy);P.rot&&L.rotate(F.r+Z.alpha,Z.x,Z.y);break;case"number":U=+X[a]+M*A*F[a];break;case"colour":U="rgb("+[Aq(AY(X[a].r+M*A*F[a].r)),Aq(AY(X[a].g+M*A*F[a].g)),Aq(AY(X[a].b+M*A*F[a].b))][BZ](",")+")";break;case"path":U=[];for(var V=0,H=X[a][AI];V<H;V++){U[V]=[X[a][V][0]];for(var W=1,T=X[a][V][AI];W<T;W++){U[V][W]=+X[a][V][W]+M*A*F[a][V][W];}U[V]=U[V][BZ](Aw);}U=U[BZ](Aw);break;case"csv":switch(a){case"translation":var I=F[a][0]*(N-C),J=F[a][1]*(N-C);G.x+=I;G.y+=J;U=I+Aw+J;break;case"rotation":U=+X[a][0]+M*A*F[a][0];X[a][1]&&(U+=","+X[a][1]+","+X[a][2]);break;case"scale":U=[+X[a][0]+M*A*F[a][0],+X[a][1]+M*A*F[a][1],(2 in P[a]?P[a][2]:Bg),(3 in P[a]?P[a][3]:Bg)][BZ](Aw);break;case"clip-rect":U=[];V=4;while(V--){U[V]=+X[a][V]+M*A*F[a][V];}break;}break;}D[a]=U;}}L.attr(D);L._run&&L._run.call(L);}else{if(P.along){Z=Ao(P.along,P.len*!P.back);L.translate(F.sx-(F.x||0)+Z.x-F.sx,F.sy-(F.y||0)+Z.y-F.sy);P.rot&&L.rotate(F.r+Z.alpha,Z.x,Z.y);}(G.x||G.y)&&L.translate(-G.x,-G.y);P.scale&&(P.scale=P.scale+Bg);L.attr(P);delete Ag[Y];Ag[AI]--;L.in_animation=null;Au.is(O,"function")&&O.call(L);}Q.prev=N;}}Au.svg&&L&&L.paper.safari();Ag[AI]&&Bf.setTimeout(Bp);},Aq=function(A){return A>255?255:(A<0?0:A);},AA=function(C,A){if(C==null){return{x:this._.tx,y:this._.ty,toString:d};}this._.tx+=+C;this._.ty+=+A;switch(this.type){case"circle":case"ellipse":this.attr({cx:+C+this.attrs.cx,cy:+A+this.attrs.cy});break;case"rect":case"image":case"text":this.attr({x:+C+this.attrs.x,y:+A+this.attrs.y});break;case"path":var B=A9(this.attrs.path);
B[0][1]+=+C;B[0][2]+=+A;this.attr({path:B});break;}return this;};Bb[Bh].animateWith=function(D,A,F,B,C){Ag[D.id]&&(A.start=Ag[D.id].start);return this.animate(A,F,B,C);};Bb[Bh].animateAlong=Ba();Bb[Bh].animateAlongBack=Ba(1);function Ba(A){return function(F,C,G,B){var D={back:A};Au.is(G,"function")?(B=G):(D.rot=G);F&&F.constructor==Bb&&(F=F.attrs.path);F&&(D.along=F);return this.animate(D,C,B);};}Bb[Bh].onAnimation=function(A){this._run=A||0;return this;};Bb[Bh].animate=function(U,H,I,P){if(Au.is(I,"function")||!I){P=I||null;}var C={},Q={},K={};for(var G in U){if(U[AW](G)){if(BD[AW](G)){C[G]=this.attr(G);(C[G]==null)&&(C[G]=AL[G]);Q[G]=U[G];switch(BD[G]){case"along":var W=Ar(U[G]),F=Ao(U[G],W*!!U.back),O=this.getBBox();K[G]=W/H;K.tx=O.x;K.ty=O.y;K.sx=F.x;K.sy=F.y;Q.rot=U.rot;Q.back=U.back;Q.len=W;U.rot&&(K.r=BG(this.rotate())||0);break;case"number":K[G]=(Q[G]-C[G])/H;break;case"colour":C[G]=Au.getRGB(C[G]);var D=Au.getRGB(Q[G]);K[G]={r:(D.r-C[G].r)/H,g:(D.g-C[G].g)/H,b:(D.b-C[G].b)/H};break;case"path":var M=Ah(C[G],Q[G]);C[G]=M[0];var J=M[1];K[G]=[];for(var A=0,L=C[G][AI];A<L;A++){K[G][A]=[0];for(var B=1,V=C[G][A][AI];B<V;B++){K[G][A][B]=(J[A][B]-C[G][A][B])/H;}}break;case"csv":var T=(U[G]+Bg)[Av](AS),N=(C[G]+Bg)[Av](AS);switch(G){case"translation":C[G]=[0,0];K[G]=[T[0]/H,T[1]/H];break;case"rotation":C[G]=(N[1]==T[1]&&N[2]==T[2])?N:[0,T[1],T[2]];K[G]=[(T[0]-C[G][0])/H,0,0];break;case"scale":U[G]=T;C[G]=(C[G]+Bg)[Av](AS);K[G]=[(T[0]-C[G][0])/H,(T[1]-C[G][1])/H,0,0];break;case"clip-rect":C[G]=(C[G]+Bg)[Av](AS);K[G]=[];A=4;while(A--){K[G][A]=(T[A]-C[G][A])/H;}break;}Q[G]=T;}}}}this.stop();this.in_animation=1;Ag[this.id]={start:U.start||+new Date,ms:H,easing:I,from:C,diff:K,to:Q,el:this,callback:P,t:{x:0,y:0}};++Ag[AI]==1&&Bp();return this;};Bb[Bh].stop=function(){Ag[this.id]&&Ag[AI]--;delete Ag[this.id];return this;};Bb[Bh].translate=function(B,A){return this.attr({translation:B+" "+A});};Bb[Bh][BX]=function(){return"Rapha\xebl\u2019s object";};Au.ae=Ag;var AV=function(C){this.items=[];this[AI]=0;if(C){for(var B=0,A=C[AI];B<A;B++){if(C[B]&&(C[B].constructor==Bb||C[B].constructor==AV)){this[this.items[AI]]=this.items[this.items[AI]]=C[B];this[AI]++;}}}};AV[Bh][AP]=function(){var A,D;for(var C=0,B=arguments[AI];C<B;C++){A=arguments[C];if(A&&(A.constructor==Bb||A.constructor==AV)){D=this.items[AI];this[D]=this.items[D]=A;this[AI]++;}}return this;};AV[Bh].pop=function(){delete this[this[AI]--];return this.items.pop();};for(var Ax in Bb[Bh]){if(Bb[Bh][AW](Ax)){AV[Bh][Ax]=(function(A){return function(){for(var C=0,B=this.items[AI];C<B;C++){this.items[C][A][Bj](this.items[C],arguments);}return this;};})(Ax);}}AV[Bh].attr=function(F,D){if(F&&Au.is(F,"array")&&Au.is(F[0],"object")){for(var G=0,A=F[AI];G<A;G++){this.items[G].attr(F[G]);}}else{for(var C=0,B=this.items[AI];C<B;C++){this.items[C].attr(F,D);}}return this;};AV[Bh].animate=function(A,H,C,F){(Au.is(C,"function")||!C)&&(F=C||null);var I=this.items[AI],D=I,G=this,B;F&&(B=function(){!--I&&F.call(G);});this.items[--D].animate(A,H,C||B,B);while(D--){this.items[D].animateWith(this.items[I-1],A,H,C||B,B);}return this;};AV[Bh].insertAfter=function(A){var B=this.items[AI];while(B--){this.items[B].insertAfter(A);}return this;};AV[Bh].getBBox=function(){var G=[],F=[],D=[],B=[];for(var C=this.items[AI];C--;){var A=this.items[C].getBBox();G[AP](A.x);F[AP](A.y);D[AP](A.x+A.width);B[AP](A.y+A.height);}G=BP[Bj](0,G);F=BP[Bj](0,F);return{x:G,y:F,width:AN[Bj](0,D)-G,height:AN[Bj](0,B)-F};};AV[Bh].clone=function(A){A=new AV;for(var C=0,B=this.items[AI];C<B;C++){A[AP](this.items[C].clone());}return A;};Au.registerFont=function(G){if(!G.face){return G;}this.fonts=this.fonts||{};var D={w:G.w,face:{},glyphs:{}},B=G.face["font-family"];for(var F in G.face){if(G.face[AW](F)){D.face[F]=G.face[F];}}if(this.fonts[B]){this.fonts[B][AP](D);}else{this.fonts[B]=[D];}if(!G.svg){D.face["units-per-em"]=Ai(G.face["units-per-em"],10);for(var C in G.glyphs){if(G.glyphs[AW](C)){var A=G.glyphs[C];D.glyphs[C]={w:A.w,k:{},d:A.d&&"M"+A.d[BH](/[mlcxtrv]/g,function(I){return{l:"L",c:"C",x:"z",t:"m",r:"l",v:"c"}[I]||"M";
})+"z"};if(A.k){for(var H in A.k){if(A[AW](H)){D.glyphs[C].k[H]=A.k[H];}}}}}}return G;};Bm[Bh].getFont=function(F,D,H,C){C=C||"normal";H=H||"normal";D=+D||{normal:400,bold:700,lighter:300,bolder:800}[D]||400;var A=Au.fonts[F];if(!A){var K=new RegExp("(^|\\s)"+F[BH](/[^\w\d\s+!~.:_-]/g,Bg)+"(\\s|$)","i");for(var J in Au.fonts){if(Au.fonts[AW](J)){if(K.test(J)){A=Au.fonts[J];break;}}}}var I;if(A){for(var G=0,B=A[AI];G<B;G++){I=A[G];if(I.face["font-weight"]==D&&(I.face["font-style"]==H||!I.face["font-style"])&&I.face["font-stretch"]==C){break;}}}return I;};Bm[Bh].print=function(O,P,T,L,K,A){A=A||"middle";var F=this.set(),B=(T+Bg)[Av](Bg),D=0,I=Bg,U;Au.is(L,"string")&&(L=this.getFont(L));if(L){U=(K||16)/L.face["units-per-em"];var Q=L.face.bbox.split(AS),N=+Q[0],J=+Q[1]+(A=="baseline"?Q[3]-Q[1]+(+L.face.descent):(Q[3]-Q[1])/2);for(var G=0,M=B[AI];G<M;G++){var H=G&&L.glyphs[B[G-1]]||{},C=L.glyphs[B[G]];D+=G?(H.w||L.w)+(H.k&&H.k[B[G]]||0):0;C&&C.d&&F[AP](this.path(C.d).attr({fill:"#000",stroke:"none",translation:[D,0]}));}F.scale(U,U,N,J).translate(O-N,P-J);}return F;};var BK=/\{(\d+)\}/g;Au.format=function(B,A){var C=Au.is(A,"array")?[0][Bo](A):arguments;B&&Au.is(B,"string")&&C[AI]-1&&(B=B[BH](BK,function(D,F){return C[++F]==null?Bg:C[F];}));return B||Bg;};Au.ninja=function(){AJ.was?(Raphael=AJ.is):delete Raphael;return Au;};Au.el=Bb[Bh];return Au;})();(function(D){var B=[],A=[],C={zIndex:1000,over:false};$(window).bind("resize.multiModal",function(){for(var K=0;K<B.length;K++){var N=B[K],J=$("#multiModalOverlay-"+N.modalId),F=$("#multiModalContainer-"+N.modalId),G=$(window),M=F.width(),L=F.height(),E=G.height(),I=Math.round(G.width()/2)-Math.round(M/2),H=Math.round(E/2)-Math.round(L/2);J.height(G.height());J.width(G.width());F.css({left:I+"px"});}});$.fn.setDefaultModalOptions=function(E){$.extend(C,E);};$.fn.modal=function(E){if(B.length>0&&E&&E.alone){A.push($(this));return ;}var F=$.extend({},C);F=$.extend(F,E);return this.each(function(){var R=$(this);if(R.data("modalData")==null){var V=Math.random().toString().replace(".",""),K=1000;for(var O=0;O<B.length;O++){if(B[O].over==false){if(B[O].modalZ>K){K=B[O].modalZ;}}}var J=K+10;if(F.over){J+=1000;}var R=$(this),U=R.parent(),I=$(window),G=I.height()>768?768:I.height(),H=$('<div id="multiModalContainer-'+V+'" class="multiModalContainer"></div>');if($(".multiModalOverlay").length==0){var N=$('<div class="multiModalOverlay" id="multiModalOverlay-'+V+'"></div>');N.css({position:"absolute",top:"0",left:"0",position:"fixed","z-index":J});$(document.body).append(N);N.css({height:I.height(),width:I.width()});}H.css({position:"absolute","z-index":J+1});$(document.body).append(H);$(H).append(R);var S=R.css("display");R.show();var Q=H.width(),P=H.height(),M=Math.round(I.width()/2)-Math.round(Q/2),L=Math.round(G/2)-Math.round(P/2);if(F.fixed){L=F.fixed;}if(L<0){L=0;}H.css({left:M+"px",top:L+"px"});var T={modalId:V,modalZ:J,parent:U,hideStatus:S,over:F.over};R.data("modalData",T);B.push(T);$("body > .tooltip").each(function(){if(this.className.indexOf("toolTipActiveClass")>=0){$(this).remove();}});}else{var T=R.data("modalData"),N=$("#multiModalOverlay-"+T.modalId),H=$("#multiModalContainer-"+T.modalId),K=0;for(var O=0;O<B.length;O++){if(B[O].over==false){if(B[O].modalZ>K){K=B[O].modalZ;}}}T.modalZ=K+10;N.css("z-index",T.modalZ);H.css("z-index",T.modalZ+1);}});};$.fn.modalClose=function(){return this.each(function(){var G=$(this),I=G.data("modalData");if(I!=null){var F=$("#multiModalOverlay-"+I.modalId),E=$("#multiModalContainer-"+I.modalId);I.parent.append(G);G.css("display",I.hideStatus);F.remove();E.remove();for(var H=0;H<B.length;H++){if(B[H].modalId==I.modalId){B.splice(H,1);break;}}delete I;G.data("modalData",null);}if(B.length==0&&A.length>0){(A.pop()).modal();}});};$.fn.modalResize=function(){return this.each(function(){var M=$(this),N=M.data("modalData"),J=$("#multiModalOverlay-"+N.modalId),F=$("#multiModalContainer-"+N.modalId),G=$(window),L=F.width(),K=F.height(),E=G.height(),I=Math.round(G.width()/2)-Math.round(L/2),H=Math.round(E/2)-Math.round(K/2);
J.height(G.height());J.width(G.width());F.css({left:I+"px",top:H+"px"});});};$.modal={};$.modal.close=function(){var K=-1,J={modalZ:0};for(var I=0;I<B.length;I++){if(B[I].modalZ>J.modalZ){J=B[I];K=I;}}var G=$("#multiModalOverlay-"+J.modalId),E=$("#multiModalContainer-"+J.modalId),H=E.children();if(H.length>0){var F=$(H[0]);F.css("display",J.hideStatus);J.parent.append(F);G.remove();E.remove();B.splice(K,1);delete J;F.data("modalData",null);}};})(jQuery);$.fn.numberAnimator=function(H,D,E){var C=this;var G=D!="slow"?3:20;var E=E==null?{}:E;var A=E.isFloat==null?false:E.isFloat;var B=E.decimals==null?1:E.decimals;var F=E.decimalSeparator==null?".":E.decimalSeparator;return this.each(function(){var J=$(this);var K=J.attr("jnacurrentvalue");if(K+""=="undefined"){K=parseFloat($(this).html());if(K+""!="NaN"){J.attr("jnacurrentvalue",K);}}else{K=parseFloat(J.attr("jnacurrentvalue"));}if(K+""!="NaN"){if(H-K!=0){var M=Math.abs(H-K)/G<0.02?H-K:(H-K)/G;K+=M;J.attr("jnacurrentvalue",K);if(A){var I=Math.round(K*B*10)/(B*10);I=Math.round(I)/I==1?I+F+"0":I;$(this).html(I);}else{$(this).html(Math.round(K));}clearTimeout($(this).data("timeoutRef"));var L=setTimeout(function(){J.numberAnimator(H,D,E);},32);$(this).data("timeoutRef",L);}else{J.removeAttr("jnacurrentvalue");if(E.callback+""!="undefined"){E.callback(this);}}}});};(function(C){C.tools=C.tools||{version:{}};C.tools.version.tooltip="1.0.2";var A={toggle:[function(){this.getTip().show();},function(){this.getTip().hide();}],fade:[function(){this.getTip().fadeIn(this.getConf().fadeInSpeed);},function(){this.getTip().fadeOut(this.getConf().fadeOutSpeed);}]};C.tools.addTipEffect=function(F,D,E){A[F]=[D,E];};C.tools.addTipEffect("slideup",function(){var E=this.getConf();var D=E.slideOffset||10;this.getTip().css({opacity:0}).animate({top:"-="+D,opacity:E.opacity},E.slideInSpeed||200).show();},function(){var E=this.getConf();var D=E.slideOffset||10;this.getTip().animate({top:"-="+D,opacity:0},E.slideOutSpeed||200,function(){C(this).hide().animate({top:"+="+(D*2)},0);});});function B(H,I){var J=this;var F=H.next();if(I.tip){if(I.tip.indexOf("#")!=-1){F=C(I.tip);}else{F=H.nextAll(I.tip).eq(0);if(!F.length){F=H.parent().nextAll(I.tip).eq(0);}}}function D(L,K){C(J).bind(L,function(N,M){if(K&&K.call(this)===false&&M){M.proceed=false;}});return J;}C.each(I,function(L,K){if(C.isFunction(K)){D(L,K);}});var G=H.is("input, textarea");H.bind(G?"focus":"mouseover",function(K){K.target=this;J.show(K);F.hover(function(){J.show();},function(){J.hide();});});H.bind(G?"blur":"mouseout",function(){J.hide();});F.css("opacity",I.opacity);var E=0;C.extend(J,{show:function(O){if(O){H=C(O.target);}clearTimeout(E);if(F.is(":animated")||F.is(":visible")){return J;}var P={proceed:true};C(J).trigger("onBeforeShow",P);if(!P.proceed){return J;}var Q=H.position().top-F.outerHeight();var M=F.outerHeight()+H.outerHeight();var N=I.position[0];if(N=="center"){Q+=M/2;}if(N=="bottom"){Q+=M;}var L=H.outerWidth()+F.outerWidth();var K=H.position().left+H.outerWidth();N=I.position[1];if(N=="center"){K-=L/2;}if(N=="left"){K-=L;}Q+=I.offset[0];K+=I.offset[1];F.css({position:"absolute",top:Q,left:K});A[I.effect][0].call(J);C(J).trigger("onShow");return J;},hide:function(){clearTimeout(E);E=setTimeout(function(){if(!F.is(":visible")){return J;}var K={proceed:true};C(J).trigger("onBeforeHide",K);if(!K.proceed){return J;}A[I.effect][1].call(J);C(J).trigger("onHide");},I.delay||1);return J;},isShown:function(){return F.is(":visible, :animated");},getConf:function(){return I;},getTip:function(){return F;},getTrigger:function(){return H;},onBeforeShow:function(K){return D("onBeforeShow",K);},onShow:function(K){return D("onShow",K);},onBeforeHide:function(K){return D("onBeforeHide",K);},onHide:function(K){return D("onHide",K);}});}C.prototype.tooltip=function(F){var E=this.eq(typeof F=="number"?F:0).data("tooltip");if(E){return E;}var D={tip:null,effect:"slideup",delay:30,opacity:1,position:["top","center"],offset:[0,0],api:false};if(C.isFunction(F)){F={onBeforeShow:F};
}C.extend(D,F);this.each(function(){E=new B(C(this),D);C(this).data("tooltip",E);});return D.api?E:this;};})(jQuery);(function(D){$.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(F,E){$.fx.step[E]=function(G){if(G.state==0){G.start=C(G.elem,E);G.end=B(G.end);}G.elem.style[E]="rgb("+[Math.max(Math.min(parseInt((G.pos*(G.end[0]-G.start[0]))+G.start[0]),255),0),Math.max(Math.min(parseInt((G.pos*(G.end[1]-G.start[1]))+G.start[1]),255),0),Math.max(Math.min(parseInt((G.pos*(G.end[2]-G.start[2]))+G.start[2]),255),0)].join(",")+")";};});function B(F){var E;if(F&&F.constructor==Array&&F.length==3){return F;}if(E=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(F)){return[parseInt(E[1]),parseInt(E[2]),parseInt(E[3])];}if(E=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(F)){return[parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55];}if(E=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(F)){return[parseInt(E[1],16),parseInt(E[2],16),parseInt(E[3],16)];}if(E=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(F)){return[parseInt(E[1]+E[1],16),parseInt(E[2]+E[2],16),parseInt(E[3]+E[3],16)];}return A[$.trim(F).toLowerCase()];}function C(G,E){var F;do{F=$.curCSS(G,E);if(F!=""&&F!="transparent"||$.nodeName(G,"body")){break;}E="backgroundColor";}while(G=G.parentNode);return B(F);}var A={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]};})(jQuery);(function(A){A.tinysort={id:"TinySort",version:"1.0.4",defaults:{order:"asc",attr:"",place:"start",returns:false}};A.fn.extend({tinysort:function(M,L){if(M&&typeof (M)!="string"){L=M;M=null;}var P=A.extend({},A.tinysort.defaults,L);var F={};this.each(function(T){var R=(!M||M=="")?A(this):A(this).find(M);var S=P.order=="rand"?""+Math.random():(P.attr==""?R.text():R.attr(P.attr));var U=A(this).parent();if(!F[U]){F[U]={s:[],n:[]};}if(R.length>0){F[U].s.push({s:S,e:A(this),n:T});}else{F[U].n.push({e:A(this),n:T});}});for(var N in F){var Q=F[N];Q.s.sort(function K(T,U){var S=T.s.toLowerCase?T.s.toLowerCase():T.s;var R=U.s.toLowerCase?U.s.toLowerCase():U.s;if(C(T.s)&&C(U.s)){S=parseFloat(T.s);R=parseFloat(U.s);}return(P.order=="asc"?1:-1)*(S<R?-1:(S>R?1:0));});}var I=[];for(var N in F){var Q=F[N];var H=[];var O=A(this).length;switch(P.place){case"first":A.each(Q.s,function(S,R){O=Math.min(O,R.n);});break;case"org":A.each(Q.s,function(S,R){H.push(R.n);});break;case"end":O=Q.n.length;break;default:O=0;}var E=[0,0];for(var J=0;J<A(this).length;J++){var G=J>=O&&J<O+Q.s.length;if(B(H,J)){G=true;}var D=(G?Q.s:Q.n)[E[G?0:1]].e;D.parent().append(D);if(G||!P.returns){I.push(D.get(0));}E[G?0:1]++;}}return this.pushStack(I);}});function C(D){var E=/^\s*?[\+-]?(\d*\.?\d*?)\s*?$/.exec(D);return E&&E.length>0?E[1]:false;}function B(E,D){var F=false;A.each(E,function(G,H){if(!F){F=H==D;}});return F;}A.fn.TinySort=A.fn.Tinysort=A.fn.tsort=A.fn.tinysort;})(jQuery);(function(E){var D={offsetX:10,offsetY:20,marginX:14,marginY:14,tooltipObject:"next",tooltipSelector:"tooltip",tooltipClassPrefix:"toolTipActiveClass-"};$.fn.toolTiper=function(F){$.extend(D,F);
return this.each(function(){var J=$.extend({},D),I=$(this),N;if(J.tooltipObject=="next"){N=I.next();}if(J.tooltipObject=="element"){N=I.find(tooltipSelector);}var H=N.attr("class"),M=new RegExp("("+J.tooltipClassPrefix+"\\d*)(?=s|$)"),L=M.exec(H),K=M.exec(H);if(L==null){var G=J.tooltipClassPrefix+Math.random().toString().replace(/\./g,"");J.tooltipRef=G;N.addClass(G);}else{J.tooltipRef=L[0];}I.data("options",J);I.unbind("mouseenter.tooltiper",C).bind("mouseenter.tooltiper",C);I.unbind("mouseleave.tooltiper",A).bind("mouseleave.tooltiper",A);I.unbind("mousedown.tooltiper",A).bind("mousedown.tooltiper",A);});};$.fn.unToolTiper=function(F){$.extend(D,F);return this.each(function(){var G=$(this);G.unbind("mouseenter.tooltiper",C);G.unbind("mouseleave.tooltiper",A);G.unbind("mousedown.tooltiper",A);});};$.fn._toolTiperIntervalReference={};function C(J){var G=$(this),F=G.data("options"),L=G.attr("id");if(L==""){L="TEMP_TOOLTIPER_ID_"+Math.random().toString().replace(/\./g,"");G.attr("id",L);}clearInterval(F.intervalRef);if(!G.parent().hasClass("draggingItem")){var K="if($('#"+L+"').length == 0){var data = $.fn._toolTiperIntervalReference['"+L+"'];clearInterval(data.intervalRef);$('body > .' + data.tooltipRef).remove();}",I=setInterval(K,500);F.intervalRef=I;$.fn._toolTiperIntervalReference[L]={intervalRef:I,tooltipRef:F.tooltipRef};G.data("options",F);if(F.tooltipObject=="next"){tooltip=G.next();}if(F.tooltipObject=="element"){tooltip=G.find(tooltipSelector);}if(F.beforeDisplay){F.beforeDisplay(G.parent());}var H=tooltip.clone();$(document.body).append(H.fadeIn("fast").css({display:"block","z-index":10000}).data("intervalRef",F.intervalRef));if(H.find(".comparedItem .tooltipText").length>0){H.find(".tooltipText").css({height:(H.height()-59)+"px"});}B.call(this,J);G.unbind("mousemove.tooltiper").bind("mousemove.tooltiper",B);}}function B(J){var K=$(this),O=K.data("options"),N=$("body > ."+O.tooltipRef),I=$(window).width(),H=$(window).height(),G=0,F=0;N.removeClass("tooltipRight tooltipTop");if(J.pageX+O.offsetX+N.width()+O.marginX>I){G=(N.width()+O.offsetX*2)*-1;N.addClass("tooltipRight");}if(J.pageY+O.offsetY+N.height()+O.marginY>H){F=(N.height()+O.offsetY*2)*-1;N.addClass("tooltipTop");}var M=J.pageX+O.offsetX+G,L=J.pageY+O.offsetY+F;N.css({left:M+"px",top:L+"px"});}function A(){var G=$(this),F=G.data("options"),H=$("body > ."+F.tooltipRef);if($.fn._toolTiperIntervalReference[G.attr("id")]!=null){clearInterval($.fn._toolTiperIntervalReference[G.attr("id")].intervalRef);}G.unbind("mousemove.tooltiper",B);H.remove();}})(jQuery);(function(C){var A=C.scrollTo=function(D,E,F){C(window).scrollTo(D,E,F);};A.defaults={axis:"xy",duration:parseFloat(C.fn.jquery)>=1.3?0:1};A.window=function(D){return C(window)._scrollable();};C.fn._scrollable=function(){return this.map(function(){var D=this,E=!D.nodeName||C.inArray(D.nodeName.toLowerCase(),["iframe","#document","html","body"])!=-1;if(!E){return D;}var F=(D.contentWindow||D).document||D.ownerDocument||D;return C.browser.safari||F.compatMode=="BackCompat"?F.body:F.documentElement;});};C.fn.scrollTo=function(F,E,D){if(typeof E=="object"){D=E;E=0;}if(typeof D=="function"){D={onAfter:D};}if(F=="max"){F=9000000000;}D=C.extend({},A.defaults,D);E=E||D.speed||D.duration;D.queue=D.queue&&D.axis.length>1;if(D.queue){E/=2;}D.offset=B(D.offset);D.over=B(D.over);return this._scrollable().each(function(){var M=this,K=C(M),L=F,I,J={},G=K.is("html,body");switch(typeof L){case"number":case"string":if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(L)){L=B(L);break;}L=C(L,this);case"object":if(L.is||L.style){I=(L=C(L)).offset();}}C.each(D.axis.split(""),function(P,Q){var S=Q=="x"?"Left":"Top",R=S.toLowerCase(),U="scroll"+S,O=M[U],N=A.max(M,Q);if(I){J[U]=I[R]+(G?0:O-K.offset()[R]);if(D.margin){J[U]-=parseInt(L.css("margin"+S))||0;J[U]-=parseInt(L.css("border"+S+"Width"))||0;}J[U]+=D.offset[R]||0;if(D.over[R]){J[U]+=L[Q=="x"?"width":"height"]()*D.over[R];}}else{var T=L[R];J[U]=T.slice&&T.slice(-1)=="%"?parseFloat(T)/100*N:T;}if(/^\d+$/.test(J[U])){J[U]=J[U]<=0?0:Math.min(J[U],N);
}if(!P&&D.queue){if(O!=J[U]){H(D.onAfterFirst);}delete J[U];}});H(D.onAfter);function H(N){K.animate(J,E,D.easing,N&&function(){N.call(this,F,D);});}}).end();};A.max=function(F,G){var I=G=="x"?"Width":"Height",H="scroll"+I;if(!C(F).is("html,body")){return F[H]-C(F)[I.toLowerCase()]();}var J="client"+I,E=F.ownerDocument.documentElement,D=F.ownerDocument.body;return Math.max(E[H],D[H])-Math.min(E[J],D[J]);};function B(D){return typeof D=="object"?D:{top:D,left:D};}})(jQuery);jQuery.fn.outerHtml=function(){try{return $("<div></div>").append(this.clone()).html();}catch(A){console.warn(A,arguments.callee.caller,this);}};(function(A){A.fn.blink=function(B){var C={delay:800},B=A.extend(C,B);return this.each(function(){var D=A(this);setInterval(function(){A(D).css("visibility",(A(D).css("visibility")=="visible"?"hidden":"visible"));},B.delay);});};}(jQuery));(function(A){A.fn.orbit=function(B){B=A.extend({animation:"horizontal-push",animationSpeed:600,timer:!0,advanceSpeed:4000,pauseOnHover:!1,startClockOnMouseOut:!1,startClockOnMouseOutAfter:1000,directionalNav:!0,captions:!0,captionAnimation:"fade",captionAnimationSpeed:600,bullets:!1,bulletThumbs:!1,bulletThumbLocation:"",afterSlideChange:function(){}},B);return this.each(function(){function P(){if(!B.timer||B.timer=="false"){return !1;}else{N.is(":hidden")?L=setInterval(function(){V("next");},B.advanceSpeed):(S=!0,F.removeClass("active"),L=setInterval(function(){var C="rotate("+U+"deg)";U+=2;J.css({"-webkit-transform":C,"-moz-transform":C,"-o-transform":C});U>180&&(J.addClass("move"),E.addClass("move"));U>360&&(J.removeClass("move"),E.removeClass("move"),U=0,V("next"));},B.advanceSpeed/180));}}function T(){if(!B.timer||B.timer=="false"){return !1;}else{S=!1,clearInterval(L),F.addClass("active");}}function Q(){if(!B.captions||B.captions=="false"){return !1;}else{var C=a.eq(g).data("caption");(_captionHTML=A(C).html())?(X.attr("id",C).html(_captionHTML),B.captionAnimation=="none"&&X.show(),B.captionAnimation=="fade"&&X.fadeIn(B.captionAnimationSpeed),B.captionAnimation=="slideOpen"&&X.slideDown(B.captionAnimationSpeed)):(B.captionAnimation=="none"&&X.hide(),B.captionAnimation=="fade"&&X.fadeOut(B.captionAnimationSpeed),B.captionAnimation=="slideOpen"&&X.slideUp(B.captionAnimationSpeed));}}function O(){if(B.bullets){K.children("li").removeClass("active").eq(g).addClass("active");}else{return !1;}}function V(b){function e(){a.eq(D).css({"z-index":1});I=!1;B.afterSlideChange.call(this);}var D=g,C=b;if(D==C){return !1;}if(a.length=="1"){return !1;}I||(I=!0,b=="next"?(g++,g==R&&(g=0)):b=="prev"?(g--,g<0&&(g=R-1)):(g=b,D<g?C="next":D>g&&(C="prev")),O(),a.eq(D).css({"z-index":2}),B.animation=="fade"&&a.eq(g).css({opacity:0,"z-index":3}).animate({opacity:1},B.animationSpeed,e),B.animation=="horizontal-slide"&&(C=="next"&&a.eq(g).css({left:Y,"z-index":3}).animate({left:0},B.animationSpeed,e),C=="prev"&&a.eq(g).css({left:-Y,"z-index":3}).animate({left:0},B.animationSpeed,e)),B.animation=="vertical-slide"&&(C=="prev"&&a.eq(g).css({top:H,"z-index":3}).animate({top:0},B.animationSpeed,e),C=="next"&&a.eq(g).css({top:-H,"z-index":3}).animate({top:0},B.animationSpeed,e)),B.animation=="horizontal-push"&&(C=="next"&&(a.eq(g).css({left:Y,"z-index":3}).animate({left:0},B.animationSpeed,e),a.eq(D).animate({left:-Y},B.animationSpeed)),C=="prev"&&(a.eq(g).css({left:-Y,"z-index":3}).animate({left:0},B.animationSpeed,e),a.eq(D).animate({left:Y},B.animationSpeed))),Q());}var g=0,R=0,Y,H,I,Z=A(this).addClass("orbit"),d=Z.wrap('<div class="orbit-wrapper" />').parent();Z.add(Y).width("1px").height("1px");var a=Z.children("img, a, div");a.each(function(){var D=A(this),C=D.width(),D=D.height();C>Z.width()&&(Z.add(d).width(C),Y=Z.width());D>Z.height()&&(Z.add(d).height(D),H=Z.height());R++;});if(a.length==1){B.directionalNav=!1,B.timer=!1,B.bullets=!1;}a.eq(g).css({"z-index":3}).fadeIn(function(){a.css({display:"block"});});if(B.timer){d.append('<div class="timer"><span class="mask"><span class="rotator"></span></span><span class="pause"></span></div>');
var N=A("div.timer"),S;if(N.length!=0){var J=A("div.timer span.rotator"),E=A("div.timer span.mask"),F=A("div.timer span.pause"),U=0,L;P();N.click(function(){S?T():P();});if(B.startClockOnMouseOut){var M;d.mouseleave(function(){M=setTimeout(function(){S||P();},B.startClockOnMouseOutAfter);});d.mouseenter(function(){clearTimeout(M);});}}}B.pauseOnHover&&d.mouseenter(function(){T();});if(B.captions){d.append('<div class="orbit-caption"></div>');var X=d.children(".orbit-caption");Q();}if(B.directionalNav){if(B.directionalNav=="false"){return !1;}d.append('<div class="slider-nav"><span class="right">Right</span><span class="left">Left</span></div>');var W=d.children("div.slider-nav").children("span.left"),G=d.children("div.slider-nav").children("span.right");W.click(function(){T();V("prev");});G.click(function(){T();V("next");});}if(B.bullets){d.append('<ul class="orbit-bullets"></ul>');var K=A("ul.orbit-bullets");for(i=0;i<R;i++){W=A("<li>"+(i+1)+"</li>");if(B.bulletThumbs&&(G=a.eq(i).data("thumb"))){W=A('<li class="has-thumb">'+i+"</li>"),W.css({background:"url("+B.bulletThumbLocation+G+") no-repeat"});}A("ul.orbit-bullets").append(W);W.data("index",i);W.click(function(){T();V(A(this).data("index"));});}O();}});};})(jQuery);(function(A){A.color={};A.color.make=function(F,E,C,D){var G={};G.r=F||0;G.g=E||0;G.b=C||0;G.a=D!=null?D:1;G.add=function(J,I){for(var H=0;H<J.length;++H){G[J.charAt(H)]+=I;}return G.normalize();};G.scale=function(J,I){for(var H=0;H<J.length;++H){G[J.charAt(H)]*=I;}return G.normalize();};G.toString=function(){if(G.a>=1){return"rgb("+[G.r,G.g,G.b].join(",")+")";}else{return"rgba("+[G.r,G.g,G.b,G.a].join(",")+")";}};G.normalize=function(){function H(J,K,I){return K<J?J:(K>I?I:K);}G.r=H(0,parseInt(G.r),255);G.g=H(0,parseInt(G.g),255);G.b=H(0,parseInt(G.b),255);G.a=H(0,G.a,1);return G;};G.clone=function(){return A.color.make(G.r,G.b,G.g,G.a);};return G.normalize();};A.color.extract=function(D,C){var E;do{E=D.css(C).toLowerCase();if(E!=""&&E!="transparent"){break;}D=D.parent();}while(!A.nodeName(D.get(0),"body"));if(E=="rgba(0, 0, 0, 0)"){E="transparent";}return A.color.parse(E);};A.color.parse=function(F){var E,C=A.color.make;if(E=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(F)){return C(parseInt(E[1],10),parseInt(E[2],10),parseInt(E[3],10));}if(E=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(F)){return C(parseInt(E[1],10),parseInt(E[2],10),parseInt(E[3],10),parseFloat(E[4]));}if(E=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(F)){return C(parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55);}if(E=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(F)){return C(parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55,parseFloat(E[4]));}if(E=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(F)){return C(parseInt(E[1],16),parseInt(E[2],16),parseInt(E[3],16));}if(E=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(F)){return C(parseInt(E[1]+E[1],16),parseInt(E[2]+E[2],16),parseInt(E[3]+E[3],16));}var D=A.trim(F).toLowerCase();if(D=="transparent"){return C(255,255,255,0);}else{E=B[D]||[0,0,0];return C(E[0],E[1],E[2]);}};var B={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]};
})(jQuery);(function(C){function A(Au,BA,Ak,BD){var Ad=[],Af={colors:["#edc240","#afd8f8","#cb4b4b","#4da74d","#9440ed"],legend:{show:true,noColumns:1,labelFormatter:null,labelBoxBorderColor:"#ccc",container:null,position:"ne",margin:5,backgroundColor:null,backgroundOpacity:0.85},xaxis:{show:null,position:"bottom",mode:null,color:null,tickColor:null,transform:null,inverseTransform:null,min:null,max:null,autoscaleMargin:null,ticks:null,tickFormatter:null,labelWidth:null,labelHeight:null,reserveSpace:null,tickLength:null,alignTicksWithAxis:null,tickDecimals:null,tickSize:null,minTickSize:null,monthNames:null,timeformat:null,twelveHourClock:false},yaxis:{autoscaleMargin:0.02,position:"left"},xaxes:[],yaxes:[],series:{points:{show:false,radius:3,lineWidth:2,fill:true,fillColor:"#ffffff",symbol:"circle"},lines:{lineWidth:2,fill:false,fillColor:null,steps:false},bars:{show:false,lineWidth:2,barWidth:1,fill:true,fillColor:null,align:"left",horizontal:false},shadowSize:3},grid:{show:true,aboveData:false,color:"#545454",backgroundColor:null,borderColor:null,tickColor:null,labelMargin:5,axisMargin:8,borderWidth:2,minBorderMargin:null,markings:null,markingsColor:"#f4f4f4",markingsLineWidth:2,clickable:false,hoverable:false,autoHighlight:true,mouseActiveRadius:10},hooks:{}},Am=null,BF=null,b=null,Ao=null,A0=null,AI=[],As=[],AH={left:0,right:0,top:0,bottom:0},Ap=0,Al=0,AP=0,AB=0,A8={processOptions:[],processRawData:[],processDatapoints:[],drawSeries:[],draw:[],bindEvents:[],drawOverlay:[],shutdown:[]},A2=this;A2.setData=A9;A2.setupGrid=AE;A2.draw=AX;A2.getPlaceholder=function(){return Au;};A2.getCanvas=function(){return Am;};A2.getPlotOffset=function(){return AH;};A2.width=function(){return AP;};A2.height=function(){return AB;};A2.offset=function(){var D=b.offset();D.left+=AH.left;D.top+=AH.top;return D;};A2.getData=function(){return Ad;};A2.getAxes=function(){var D={},E;C.each(AI.concat(As),function(G,F){if(F){D[F.direction+(F.n!=1?F.n:"")+"axis"]=F;}});return D;};A2.getXAxes=function(){return AI;};A2.getYAxes=function(){return As;};A2.c2p=Ax;A2.p2c=A1;A2.getOptions=function(){return Af;};A2.highlight=AA;A2.unhighlight=Aa;A2.triggerRedrawOverlay=AR;A2.pointOffset=function(D){return{left:parseInt(AI[BJ(D,"x")-1].p2c(+D.x)+AH.left),top:parseInt(As[BJ(D,"y")-1].p2c(+D.y)+AH.top)};};A2.shutdown=BC;A2.resize=function(){Az();AQ(Am);AQ(BF);};A2.hooks=A8;Ar(A2);AU(Ak);AW();A9(BA);AE();AX();BB();function A5(D,F){F=[A2].concat(F);for(var E=0;E<D.length;++E){D[E].apply(this,F);}}function Ar(){for(var E=0;E<BD.length;++E){var D=BD[E];D.init(A2);if(D.options){C.extend(true,Af,D.options);}}}function AU(E){var F;C.extend(true,Af,E);if(Af.xaxis.color==null){Af.xaxis.color=Af.grid.color;}if(Af.yaxis.color==null){Af.yaxis.color=Af.grid.color;}if(Af.xaxis.tickColor==null){Af.xaxis.tickColor=Af.grid.tickColor;}if(Af.yaxis.tickColor==null){Af.yaxis.tickColor=Af.grid.tickColor;}if(Af.grid.borderColor==null){Af.grid.borderColor=Af.grid.color;}if(Af.grid.tickColor==null){Af.grid.tickColor=C.color.parse(Af.grid.color).scale("a",0.22).toString();}for(F=0;F<Math.max(1,Af.xaxes.length);++F){Af.xaxes[F]=C.extend(true,{},Af.xaxis,Af.xaxes[F]);}for(F=0;F<Math.max(1,Af.yaxes.length);++F){Af.yaxes[F]=C.extend(true,{},Af.yaxis,Af.yaxes[F]);}if(Af.xaxis.noTicks&&Af.xaxis.ticks==null){Af.xaxis.ticks=Af.xaxis.noTicks;}if(Af.yaxis.noTicks&&Af.yaxis.ticks==null){Af.yaxis.ticks=Af.yaxis.noTicks;}if(Af.x2axis){Af.xaxes[1]=C.extend(true,{},Af.xaxis,Af.x2axis);Af.xaxes[1].position="top";}if(Af.y2axis){Af.yaxes[1]=C.extend(true,{},Af.yaxis,Af.y2axis);Af.yaxes[1].position="right";}if(Af.grid.coloredAreas){Af.grid.markings=Af.grid.coloredAreas;}if(Af.grid.coloredAreasColor){Af.grid.markingsColor=Af.grid.coloredAreasColor;}if(Af.lines){C.extend(true,Af.series.lines,Af.lines);}if(Af.points){C.extend(true,Af.series.points,Af.points);}if(Af.bars){C.extend(true,Af.series.bars,Af.bars);}if(Af.shadowSize!=null){Af.series.shadowSize=Af.shadowSize;}for(F=0;F<Af.xaxes.length;++F){AY(AI,F+1).options=Af.xaxes[F];
}for(F=0;F<Af.yaxes.length;++F){AY(As,F+1).options=Af.yaxes[F];}for(var D in A8){if(Af.hooks[D]&&Af.hooks[D].length){A8[D]=A8[D].concat(Af.hooks[D]);}}A5(A8.processOptions,[Af]);}function A9(D){Ad=AV(D);Aq();a();}function AV(D){var F=[];for(var G=0;G<D.length;++G){var E=C.extend(true,{},Af.series);if(D[G].data!=null){E.data=D[G].data;delete D[G].data;C.extend(true,E,D[G]);D[G].data=E.data;}else{E.data=D[G];}F.push(E);}return F;}function BJ(E,D){var F=E[D+"axis"];if(typeof F=="object"){F=F.n;}if(typeof F!="number"){F=1;}return F;}function AL(){return C.grep(AI.concat(As),function(D){return D;});}function Ax(D){var F={},G,E;for(G=0;G<AI.length;++G){E=AI[G];if(E&&E.used){F["x"+E.n]=E.c2p(D.left);}}for(G=0;G<As.length;++G){E=As[G];if(E&&E.used){F["y"+E.n]=E.c2p(D.top);}}if(F.x1!==undefined){F.x=F.x1;}if(F.y1!==undefined){F.y=F.y1;}return F;}function A1(D){var F={},G,E,H;for(G=0;G<AI.length;++G){E=AI[G];if(E&&E.used){H="x"+E.n;if(D[H]==null&&E.n==1){H="x";}if(D[H]!=null){F.left=E.p2c(D[H]);break;}}}for(G=0;G<As.length;++G){E=As[G];if(E&&E.used){H="y"+E.n;if(D[H]==null&&E.n==1){H="y";}if(D[H]!=null){F.top=E.p2c(D[H]);break;}}}return F;}function AY(D,E){if(!D[E-1]){D[E-1]={n:E,direction:D==AI?"x":"y",options:C.extend(true,{},D==AI?Af.xaxis:Af.yaxis)};}return D[E-1];}function Aq(){var G;var N=Ad.length,L=[],I=[];for(G=0;G<Ad.length;++G){var D=Ad[G].color;if(D!=null){--N;if(typeof D=="number"){I.push(D);}else{L.push(C.color.parse(Ad[G].color));}}}for(G=0;G<I.length;++G){N=Math.max(N,I[G]+1);}var K=[],H=0;G=0;while(K.length<N){var E;if(Af.colors.length==G){E=C.color.make(100,100,100);}else{E=C.color.parse(Af.colors[G]);}var J=H%2==1?-1:1;E.scale("rgb",1+J*Math.ceil(H/2)*0.2);K.push(E);++G;if(G>=Af.colors.length){G=0;++H;}}var F=0,M;for(G=0;G<Ad.length;++G){M=Ad[G];if(M.color==null){M.color=K[F].toString();++F;}else{if(typeof M.color=="number"){M.color=K[M.color].toString();}}if(M.lines.show==null){var O,P=true;for(O in M){if(M[O]&&M[O].show){P=false;break;}}if(P){M.lines.show=true;}}M.xaxis=AY(AI,BJ(M,"x"));M.yaxis=AY(As,BJ(M,"y"));}}function a(){var O=Number.POSITIVE_INFINITY,U=Number.NEGATIVE_INFINITY,e=Number.MAX_VALUE,I,K,L,P,Z,T,J,N,V,W,d,f,F,R;function X(j,g,h){if(g<j.datamin&&g!=-e){j.datamin=g;}if(h>j.datamax&&h!=e){j.datamax=h;}}C.each(AL(),function(h,g){g.datamin=O;g.datamax=U;g.used=false;});for(I=0;I<Ad.length;++I){T=Ad[I];T.datapoints={points:[]};A5(A8.processRawData,[T,T.data,T.datapoints]);}for(I=0;I<Ad.length;++I){T=Ad[I];var D=T.data,G=T.datapoints.format;if(!G){G=[];G.push({x:true,number:true,required:true});G.push({y:true,number:true,required:true});if(T.bars.show||(T.lines.show&&T.lines.fill)){G.push({y:true,number:true,required:false,defaultValue:0});if(T.bars.horizontal){delete G[G.length-1].y;G[G.length-1].x=true;}}T.datapoints.format=G;}if(T.datapoints.pointsize!=null){continue;}T.datapoints.pointsize=G.length;N=T.datapoints.pointsize;J=T.datapoints.points;insertSteps=T.lines.show&&T.lines.steps;T.xaxis.used=T.yaxis.used=true;for(K=L=0;K<D.length;++K,L+=N){R=D[K];var Y=R==null;if(!Y){for(P=0;P<N;++P){f=R[P];F=G[P];if(F){if(F.number&&f!=null){f=+f;if(isNaN(f)){f=null;}else{if(f==Infinity){f=e;}else{if(f==-Infinity){f=-e;}}}}if(f==null){if(F.required){Y=true;}if(F.defaultValue!=null){f=F.defaultValue;}}}J[L+P]=f;}}if(Y){for(P=0;P<N;++P){f=J[L+P];if(f!=null){F=G[P];if(F.x){X(T.xaxis,f,f);}if(F.y){X(T.yaxis,f,f);}}J[L+P]=null;}}else{if(insertSteps&&L>0&&J[L-N]!=null&&J[L-N]!=J[L]&&J[L-N+1]!=J[L+1]){for(P=0;P<N;++P){J[L+N+P]=J[L+P];}J[L+1]=J[L-N+1];L+=N;}}}}for(I=0;I<Ad.length;++I){T=Ad[I];A5(A8.processDatapoints,[T,T.datapoints]);}for(I=0;I<Ad.length;++I){T=Ad[I];J=T.datapoints.points,N=T.datapoints.pointsize;var S=O,M=O,Q=U,H=U;for(K=0;K<J.length;K+=N){if(J[K]==null){continue;}for(P=0;P<N;++P){f=J[K+P];F=G[P];if(!F||f==e||f==-e){continue;}if(F.x){if(f<S){S=f;}if(f>Q){Q=f;}}if(F.y){if(f<M){M=f;}if(f>H){H=f;}}}}if(T.bars.show){var E=T.bars.align=="left"?0:-T.bars.barWidth/2;if(T.bars.horizontal){M+=E;H+=E+T.bars.barWidth;
}else{S+=E;Q+=E+T.bars.barWidth;}}X(T.xaxis,S,Q);X(T.yaxis,M,H);}C.each(AL(),function(h,g){if(g.datamin==O){g.datamin=null;}if(g.datamax==U){g.datamax=null;}});}function AO(F,E){var D=document.createElement("canvas");D.className=E;D.width=Ap;D.height=Al;if(!F){C(D).css({position:"absolute",left:0,top:0});}C(D).appendTo(Au);if(!D.getContext){D=window.G_vmlCanvasManager.initElement(D);}D.getContext("2d").save();return D;}function Az(){Ap=Au.width();Al=Au.height();if(Ap<=0||Al<=0){throw"Invalid dimensions for plot, width = "+Ap+", height = "+Al;}}function AQ(D){if(D.width!=Ap){D.width=Ap;}if(D.height!=Al){D.height=Al;}var E=D.getContext("2d");E.restore();E.save();}function AW(){var E,F=Au.children("canvas.base"),D=Au.children("canvas.overlay");if(F.length==0||D==0){Au.html("");Au.css({padding:0});if(Au.css("position")=="static"){Au.css("position","relative");}Az();Am=AO(true,"base");BF=AO(false,"overlay");E=false;}else{Am=F.get(0);BF=D.get(0);E=true;}Ao=Am.getContext("2d");A0=BF.getContext("2d");b=C([BF,Am]);if(E){Au.data("plot").shutdown();A2.resize();A0.clearRect(0,0,Ap,Al);b.unbind();Au.children().not([Am,BF]).remove();}Au.data("plot",A2);}function BB(){if(Af.grid.hoverable){b.mousemove(BI);b.mouseleave(AM);}if(Af.grid.clickable){b.click(Ac);}A5(A8.bindEvents,[b]);}function BC(){if(Ah){clearTimeout(Ah);}b.unbind("mousemove",BI);b.unbind("mouseleave",AM);b.unbind("click",Ac);A5(A8.shutdown,[b]);}function AG(D){function H(J){return J;}var E,I,G=D.options.transform||H,F=D.options.inverseTransform;if(D.direction=="x"){E=D.scale=AP/Math.abs(G(D.max)-G(D.min));I=Math.min(G(D.max),G(D.min));}else{E=D.scale=AB/Math.abs(G(D.max)-G(D.min));E=-E;I=Math.max(G(D.max),G(D.min));}if(G==H){D.p2c=function(J){return(J-I)*E;};}else{D.p2c=function(J){return(G(J)-I)*E;};}if(!F){D.c2p=function(J){return I+J/E;};}else{D.c2p=function(J){return F(I+J/E);};}}function Ai(J){var L=J.options,H,D=J.ticks||[],E=[],I,M=L.labelWidth,G=L.labelHeight,K;function F(N,O){return C('<div style="position:absolute;top:-10000px;'+O+'font-size:smaller"><div class="'+J.direction+"Axis "+J.direction+J.n+'Axis">'+N.join("")+"</div></div>").appendTo(Au);}if(J.direction=="x"){if(M==null){M=Math.floor(Ap/(D.length>0?D.length:1));}if(G==null){E=[];for(H=0;H<D.length;++H){I=D[H].label;if(I){E.push('<div class="tickLabel" style="float:left;width:'+M+'px">'+I+"</div>");}}if(E.length>0){E.push('<div style="clear:left"></div>');K=F(E,"width:10000px;");G=K.height();K.remove();}}}else{if(M==null||G==null){for(H=0;H<D.length;++H){I=D[H].label;if(I){E.push('<div class="tickLabel">'+I+"</div>");}}if(E.length>0){K=F(E,"");if(M==null){M=K.children().width();}if(G==null){G=K.find("div.tickLabel").height();}K.remove();}}}if(M==null){M=0;}if(G==null){G=0;}J.labelWidth=M;J.labelHeight=G;}function Aw(J){var K=J.labelWidth,N=J.labelHeight,F=J.options.position,H=J.options.tickLength,G=Af.grid.axisMargin,D=Af.grid.labelMargin,O=J.direction=="x"?AI:As,I;var L=C.grep(O,function(P){return P&&P.options.position==F&&P.reserveSpace;});if(C.inArray(J,L)==L.length-1){G=0;}if(H==null){H="full";}var E=C.grep(O,function(P){return P&&P.reserveSpace;});var M=C.inArray(J,E)==0;if(!M&&H=="full"){H=5;}if(!isNaN(+H)){D+=+H;}if(J.direction=="x"){N+=D;if(F=="bottom"){AH.bottom+=N+G;J.box={top:Al-AH.bottom,height:N};}else{J.box={top:AH.top+G,height:N};AH.top+=N+G;}}else{K+=D;if(F=="left"){J.box={left:AH.left+G,width:K};AH.left+=K+G;}else{AH.right+=K+G;J.box={left:Ap-AH.right,width:K};}}J.position=F;J.tickLength=H;J.box.padding=D;J.innermost=M;}function AZ(D){if(D.direction=="x"){D.box.left=AH.left;D.box.width=AP;}else{D.box.top=AH.top;D.box.height=AB;}}function AE(){var F,D=AL();C.each(D,function(I,H){H.show=H.options.show;if(H.show==null){H.show=H.used;}H.reserveSpace=H.show||H.options.reserveSpace;AK(H);});allocatedAxes=C.grep(D,function(H){return H.reserveSpace;});AH.left=AH.right=AH.top=AH.bottom=0;if(Af.grid.show){C.each(allocatedAxes,function(I,H){Ab(H);Ae(H);A3(H,H.ticks);Ai(H);});for(F=allocatedAxes.length-1;
F>=0;--F){Aw(allocatedAxes[F]);}var E=Af.grid.minBorderMargin;if(E==null){E=0;for(F=0;F<Ad.length;++F){E=Math.max(E,Ad[F].points.radius+Ad[F].points.lineWidth/2);}}for(var G in AH){AH[G]+=Af.grid.borderWidth;AH[G]=Math.max(E,AH[G]);}}AP=Ap-AH.left-AH.right;AB=Al-AH.bottom-AH.top;C.each(D,function(I,H){AG(H);});if(Af.grid.show){C.each(allocatedAxes,function(I,H){AZ(H);});AN();}AJ();}function AK(G){var F=G.options,H=+(F.min!=null?F.min:G.datamin),J=+(F.max!=null?F.max:G.datamax),D=J-H;if(D==0){var I=J==0?1:0.01;if(F.min==null){H-=I;}if(F.max==null||F.min!=null){J+=I;}}else{var E=F.autoscaleMargin;if(E!=null){if(F.min==null){H-=D*E;if(H<0&&G.datamin!=null&&G.datamin>=0){H=0;}}if(F.max==null){J+=D*E;if(J>0&&G.datamax!=null&&G.datamax<=0){J=0;}}}}G.min=H;G.max=J;}function Ab(R){var L=R.options;var Q;if(typeof L.ticks=="number"&&L.ticks>0){Q=L.ticks;}else{Q=0.3*Math.sqrt(R.direction=="x"?Ap:Al);}var E=(R.max-R.min)/Q,J,W,K,G,F,H,P;if(L.mode=="time"){var O={second:1000,minute:60*1000,hour:60*60*1000,day:24*60*60*1000,month:30*24*60*60*1000,year:365.2425*24*60*60*1000};var N=[[1,"second"],[2,"second"],[5,"second"],[10,"second"],[30,"second"],[1,"minute"],[2,"minute"],[5,"minute"],[10,"minute"],[30,"minute"],[1,"hour"],[2,"hour"],[4,"hour"],[8,"hour"],[12,"hour"],[1,"day"],[2,"day"],[3,"day"],[0.25,"month"],[0.5,"month"],[1,"month"],[2,"month"],[3,"month"],[6,"month"],[1,"year"]];var V=0;if(L.minTickSize!=null){if(typeof L.tickSize=="number"){V=L.tickSize;}else{V=L.minTickSize[0]*O[L.minTickSize[1]];}}for(var F=0;F<N.length-1;++F){if(E<(N[F][0]*O[N[F][1]]+N[F+1][0]*O[N[F+1][1]])/2&&N[F][0]*O[N[F][1]]>=V){break;}}J=N[F][0];K=N[F][1];if(K=="year"){H=Math.pow(10,Math.floor(Math.log(E/O.year)/Math.LN10));P=(E/O.year)/H;if(P<1.5){J=1;}else{if(P<3){J=2;}else{if(P<7.5){J=5;}else{J=10;}}}J*=H;}R.tickSize=L.tickSize||[J,K];W=function(g){var Y=[],d=g.tickSize[0],X=g.tickSize[1],Z=new Date(g.min);var h=d*O[X];if(X=="second"){Z.setUTCSeconds(B(Z.getUTCSeconds(),d));}if(X=="minute"){Z.setUTCMinutes(B(Z.getUTCMinutes(),d));}if(X=="hour"){Z.setUTCHours(B(Z.getUTCHours(),d));}if(X=="month"){Z.setUTCMonth(B(Z.getUTCMonth(),d));}if(X=="year"){Z.setUTCFullYear(B(Z.getUTCFullYear(),d));}Z.setUTCMilliseconds(0);if(h>=O.minute){Z.setUTCSeconds(0);}if(h>=O.hour){Z.setUTCMinutes(0);}if(h>=O.day){Z.setUTCHours(0);}if(h>=O.day*4){Z.setUTCDate(1);}if(h>=O.year){Z.setUTCMonth(0);}var k=0,l=Number.NaN,f;do{f=l;l=Z.getTime();Y.push(l);if(X=="month"){if(d<1){Z.setUTCDate(1);var j=Z.getTime();Z.setUTCMonth(Z.getUTCMonth()+1);var e=Z.getTime();Z.setTime(l+k*O.hour+(e-j)*d);k=Z.getUTCHours();Z.setUTCHours(0);}else{Z.setUTCMonth(Z.getUTCMonth()+d);}}else{if(X=="year"){Z.setUTCFullYear(Z.getUTCFullYear()+d);}else{Z.setTime(l+h);}}}while(l<g.max&&l!=f);return Y;};G=function(f,Z){var X=new Date(f);if(L.timeformat!=null){return C.plot.formatDate(X,L.timeformat,L.monthNames);}var e=Z.tickSize[0]*O[Z.tickSize[1]];var d=Z.max-Z.min;var Y=(L.twelveHourClock)?" %p":"";if(e<O.minute){fmt="%h:%M:%S"+Y;}else{if(e<O.day){if(d<2*O.day){fmt="%h:%M"+Y;}else{fmt="%b %d %h:%M"+Y;}}else{if(e<O.month){fmt="%b %d";}else{if(e<O.year){if(d<O.year){fmt="%b";}else{fmt="%b %y";}}else{fmt="%y";}}}}return C.plot.formatDate(X,fmt,L.monthNames);};}else{var D=L.tickDecimals;var I=-Math.floor(Math.log(E)/Math.LN10);if(D!=null&&I>D){I=D;}H=Math.pow(10,-I);P=E/H;if(P<1.5){J=1;}else{if(P<3){J=2;if(P>2.25&&(D==null||I+1<=D)){J=2.5;++I;}}else{if(P<7.5){J=5;}else{J=10;}}}J*=H;if(L.minTickSize!=null&&J<L.minTickSize){J=L.minTickSize;}R.tickDecimals=Math.max(0,D!=null?D:I);R.tickSize=L.tickSize||J;W=function(d){var Y=[];var X=B(d.min,d.tickSize),e=0,f=Number.NaN,Z;do{Z=f;f=X+e*d.tickSize;Y.push(f);++e;}while(f<d.max&&f!=Z);return Y;};G=function(Y,X){return Y.toFixed(X.tickDecimals);};}if(L.alignTicksWithAxis!=null){var S=(R.direction=="x"?AI:As)[L.alignTicksWithAxis-1];if(S&&S.used&&S!=R){var M=W(R);if(M.length>0){if(L.min==null){R.min=Math.min(R.min,M[0]);}if(L.max==null&&M.length>1){R.max=Math.max(R.max,M[M.length-1]);
}}W=function(Y){var X=[],d,Z;for(Z=0;Z<S.ticks.length;++Z){d=(S.ticks[Z].v-S.min)/(S.max-S.min);d=Y.min+d*(Y.max-Y.min);X.push(d);}return X;};if(R.mode!="time"&&L.tickDecimals==null){var T=Math.max(0,-Math.floor(Math.log(E)/Math.LN10)+1),U=W(R);if(!(U.length>1&&/\..*0$/.test((U[1]-U[0]).toFixed(T)))){R.tickDecimals=T;}}}}R.tickGenerator=W;if(C.isFunction(L.tickFormatter)){R.tickFormatter=function(Y,X){return""+L.tickFormatter(Y,X);};}else{R.tickFormatter=G;}}function Ae(F){var D=F.options.ticks,E=[];if(D==null||(typeof D=="number"&&D>0)){E=F.tickGenerator(F);}else{if(D){if(C.isFunction(D)){E=D({min:F.min,max:F.max});}else{E=D;}}}var G,J;F.ticks=[];for(G=0;G<E.length;++G){var I=null;var H=E[G];if(typeof H=="object"){J=+H[0];if(H.length>1){I=H[1];}}else{J=+H;}if(I==null){I=F.tickFormatter(J,F);}if(!isNaN(J)){F.ticks.push({v:J,label:I});}}}function A3(E,D){if(E.options.autoscaleMargin&&D.length>0){if(E.options.min==null){E.min=Math.min(E.min,D[0].v);}if(E.options.max==null&&D.length>1){E.max=Math.max(E.max,D[D.length-1].v);}}}function AX(){Ao.clearRect(0,0,Ap,Al);var D=Af.grid;if(D.show&&D.backgroundColor){Ag();}if(D.show&&!D.aboveData){BG();}for(var E=0;E<Ad.length;++E){A5(A8.drawSeries,[Ao,Ad[E]]);AT(Ad[E]);}A5(A8.draw,[Ao]);if(D.show&&D.aboveData){BG();}}function Av(J,K){var G,D,E,H,F=AL();for(i=0;i<F.length;++i){G=F[i];if(G.direction==K){H=K+G.n+"axis";if(!J[H]&&G.n==1){H=K+"axis";}if(J[H]){D=J[H].from;E=J[H].to;break;}}}if(!J[H]){G=K=="x"?AI[0]:As[0];D=J[K+"1"];E=J[K+"2"];}if(D!=null&&E!=null&&D>E){var I=D;D=E;E=I;}return{from:D,to:E,axis:G};}function Ag(){Ao.save();Ao.translate(AH.left,AH.top);Ao.fillStyle=A6(Af.grid.backgroundColor,AB,0,"rgba(255, 255, 255, 0)");Ao.fillRect(0,0,AP,AB);Ao.restore();}function BG(){var H;Ao.save();Ao.translate(AH.left,AH.top);var F=Af.grid.markings;if(F){if(C.isFunction(F)){var S=A2.getAxes();S.xmin=S.xaxis.min;S.xmax=S.xaxis.max;S.ymin=S.yaxis.min;S.ymax=S.yaxis.max;F=F(S);}for(H=0;H<F.length;++H){var J=F[H],K=Av(J,"x"),E=Av(J,"y");if(K.from==null){K.from=K.axis.min;}if(K.to==null){K.to=K.axis.max;}if(E.from==null){E.from=E.axis.min;}if(E.to==null){E.to=E.axis.max;}if(K.to<K.axis.min||K.from>K.axis.max||E.to<E.axis.min||E.from>E.axis.max){continue;}K.from=Math.max(K.from,K.axis.min);K.to=Math.min(K.to,K.axis.max);E.from=Math.max(E.from,E.axis.min);E.to=Math.min(E.to,E.axis.max);if(K.from==K.to&&E.from==E.to){continue;}K.from=K.axis.p2c(K.from);K.to=K.axis.p2c(K.to);E.from=E.axis.p2c(E.from);E.to=E.axis.p2c(E.to);if(K.from==K.to||E.from==E.to){Ao.beginPath();Ao.strokeStyle=J.color||Af.grid.markingsColor;Ao.lineWidth=J.lineWidth||Af.grid.markingsLineWidth;Ao.moveTo(K.from,E.from);Ao.lineTo(K.to,E.to);Ao.stroke();}else{Ao.fillStyle=J.color||Af.grid.markingsColor;Ao.fillRect(K.from,E.to,K.to-K.from,E.from-E.to);}}}var S=AL(),Q=Af.grid.borderWidth;for(var I=0;I<S.length;++I){var L=S[I],G=L.box,M=L.tickLength,P,R,N,D;if(!L.show||L.ticks.length==0){continue;}Ao.strokeStyle=L.options.tickColor||C.color.parse(L.options.color).scale("a",0.22).toString();Ao.lineWidth=1;if(L.direction=="x"){P=0;if(M=="full"){R=(L.position=="top"?0:AB);}else{R=G.top-AH.top+(L.position=="top"?G.height:0);}}else{R=0;if(M=="full"){P=(L.position=="left"?0:AP);}else{P=G.left-AH.left+(L.position=="left"?G.width:0);}}if(!L.innermost){Ao.beginPath();N=D=0;if(L.direction=="x"){N=AP;}else{D=AB;}if(Ao.lineWidth==1){P=Math.floor(P)+0.5;R=Math.floor(R)+0.5;}Ao.moveTo(P,R);Ao.lineTo(P+N,R+D);Ao.stroke();}Ao.beginPath();for(H=0;H<L.ticks.length;++H){var O=L.ticks[H].v;N=D=0;if(O<L.min||O>L.max||(M=="full"&&Q>0&&(O==L.min||O==L.max))){continue;}if(L.direction=="x"){P=L.p2c(O);D=M=="full"?-AB:M;if(L.position=="top"){D=-D;}}else{R=L.p2c(O);N=M=="full"?-AP:M;if(L.position=="left"){N=-N;}}if(Ao.lineWidth==1){if(L.direction=="x"){P=Math.floor(P)+0.5;}else{R=Math.floor(R)+0.5;}}Ao.moveTo(P,R);Ao.lineTo(P+N,R+D);}Ao.stroke();}if(Q){Ao.lineWidth=Q;Ao.strokeStyle=Af.grid.borderColor;Ao.strokeRect(-Q/2,-Q/2,AP+Q,AB+Q);}Ao.restore();}function AN(){Au.find(".tickLabels").remove();
var G=['<div class="tickLabels" style="font-size:smaller">'];var D=AL();for(var J=0;J<D.length;++J){var K=D[J],H=K.box;if(!K.show){continue;}G.push('<div class="'+K.direction+"Axis "+K.direction+K.n+'Axis" style="color:'+K.options.color+'">');for(var I=0;I<K.ticks.length;++I){var F=K.ticks[I];if(!F.label||F.v<K.min||F.v>K.max){continue;}var N={},E;if(K.direction=="x"){E="center";N.left=Math.round(AH.left+K.p2c(F.v)-K.labelWidth/2);if(K.position=="bottom"){N.top=H.top+H.padding;}else{N.bottom=Al-(H.top+H.height-H.padding);}}else{N.top=Math.round(AH.top+K.p2c(F.v)-K.labelHeight/2);if(K.position=="left"){N.right=Ap-(H.left+H.width-H.padding);E="right";}else{N.left=H.left+H.padding;E="left";}}N.width=K.labelWidth;var L=["position:absolute","text-align:"+E];for(var M in N){L.push(M+":"+N[M]+"px");}G.push('<div class="tickLabel" style="'+L.join(";")+'">'+F.label+"</div>");}G.push("</div>");}G.push("</div>");Au.append(G.join(""));}function AT(D){if(D.lines.show){Ay(D);}if(D.bars.show){AS(D);}if(D.points.show){A4(D);}}function Ay(G){function H(S,R,L,N,O){var M=S.points,K=S.pointsize,U=null,V=null;Ao.beginPath();for(var T=K;T<M.length;T+=K){var W=M[T-K],P=M[T-K+1],X=M[T],Q=M[T+1];if(W==null||X==null){continue;}if(P<=Q&&P<O.min){if(Q<O.min){continue;}W=(O.min-P)/(Q-P)*(X-W)+W;P=O.min;}else{if(Q<=P&&Q<O.min){if(P<O.min){continue;}X=(O.min-P)/(Q-P)*(X-W)+W;Q=O.min;}}if(P>=Q&&P>O.max){if(Q>O.max){continue;}W=(O.max-P)/(Q-P)*(X-W)+W;P=O.max;}else{if(Q>=P&&Q>O.max){if(P>O.max){continue;}X=(O.max-P)/(Q-P)*(X-W)+W;Q=O.max;}}if(W<=X&&W<N.min){if(X<N.min){continue;}P=(N.min-W)/(X-W)*(Q-P)+P;W=N.min;}else{if(X<=W&&X<N.min){if(W<N.min){continue;}Q=(N.min-W)/(X-W)*(Q-P)+P;X=N.min;}}if(W>=X&&W>N.max){if(X>N.max){continue;}P=(N.max-W)/(X-W)*(Q-P)+P;W=N.max;}else{if(X>=W&&X>N.max){if(W>N.max){continue;}Q=(N.max-W)/(X-W)*(Q-P)+P;X=N.max;}}if(W!=U||P!=V){Ao.moveTo(N.p2c(W)+R,O.p2c(P)+L);}U=X;V=Q;Ao.lineTo(N.p2c(X)+R,O.p2c(Q)+L);}Ao.stroke();}function F(e,T,U){var N=e.points,O=e.pointsize,W=Math.min(Math.max(0,U.min),U.max),M=0,P,Q=false,X=1,Y=0,S=0;while(true){if(O>0&&M>N.length+O){break;}M+=O;var K=N[M-O],Z=N[M-O+X],L=N[M],d=N[M+X];if(Q){if(O>0&&K!=null&&L==null){S=M;O=-O;X=2;continue;}if(O<0&&M==Y+O){Ao.fill();Q=false;O=-O;X=1;M=Y=S+O;continue;}}if(K==null||L==null){continue;}if(K<=L&&K<T.min){if(L<T.min){continue;}Z=(T.min-K)/(L-K)*(d-Z)+Z;K=T.min;}else{if(L<=K&&L<T.min){if(K<T.min){continue;}d=(T.min-K)/(L-K)*(d-Z)+Z;L=T.min;}}if(K>=L&&K>T.max){if(L>T.max){continue;}Z=(T.max-K)/(L-K)*(d-Z)+Z;K=T.max;}else{if(L>=K&&L>T.max){if(K>T.max){continue;}d=(T.max-K)/(L-K)*(d-Z)+Z;L=T.max;}}if(!Q){Ao.beginPath();Ao.moveTo(T.p2c(K),U.p2c(W));Q=true;}if(Z>=U.max&&d>=U.max){Ao.lineTo(T.p2c(K),U.p2c(U.max));Ao.lineTo(T.p2c(L),U.p2c(U.max));continue;}else{if(Z<=U.min&&d<=U.min){Ao.lineTo(T.p2c(K),U.p2c(U.min));Ao.lineTo(T.p2c(L),U.p2c(U.min));continue;}}var V=K,R=L;if(Z<=d&&Z<U.min&&d>=U.min){K=(U.min-Z)/(d-Z)*(L-K)+K;Z=U.min;}else{if(d<=Z&&d<U.min&&Z>=U.min){L=(U.min-Z)/(d-Z)*(L-K)+K;d=U.min;}}if(Z>=d&&Z>U.max&&d<=U.max){K=(U.max-Z)/(d-Z)*(L-K)+K;Z=U.max;}else{if(d>=Z&&d>U.max&&Z<=U.max){L=(U.max-Z)/(d-Z)*(L-K)+K;d=U.max;}}if(K!=V){Ao.lineTo(T.p2c(V),U.p2c(Z));}Ao.lineTo(T.p2c(K),U.p2c(Z));Ao.lineTo(T.p2c(L),U.p2c(d));if(L!=R){Ao.lineTo(T.p2c(L),U.p2c(d));Ao.lineTo(T.p2c(R),U.p2c(d));}}}Ao.save();Ao.translate(AH.left,AH.top);Ao.lineJoin="round";var E=G.lines.lineWidth,J=G.shadowSize;if(E>0&&J>0){Ao.lineWidth=J;Ao.strokeStyle="rgba(0,0,0,0.1)";var D=Math.PI/18;H(G.datapoints,Math.sin(D)*(E/2+J/2),Math.cos(D)*(E/2+J/2),G.xaxis,G.yaxis);Ao.lineWidth=J/2;H(G.datapoints,Math.sin(D)*(E/2+J/4),Math.cos(D)*(E/2+J/4),G.xaxis,G.yaxis);}Ao.lineWidth=E;Ao.strokeStyle=G.color;var I=BE(G.lines,G.color,0,AB);if(I){Ao.fillStyle=I;F(G.datapoints,G.xaxis,G.yaxis);}if(E>0){H(G.datapoints,0,0,G.xaxis,G.yaxis);}Ao.restore();}function A4(G){function D(T,U,M,W,O,N,Q,K){var P=T.points,L=T.pointsize;for(var V=0;V<P.length;V+=L){var R=P[V],S=P[V+1];if(R==null||R<N.min||R>N.max||S<Q.min||S>Q.max){continue;
}Ao.beginPath();R=N.p2c(R);S=Q.p2c(S)+W;if(K=="circle"){Ao.arc(R,S,U,0,O?Math.PI:Math.PI*2,false);}else{K(Ao,R,S,U,O);}Ao.closePath();if(M){Ao.fillStyle=M;Ao.fill();}Ao.stroke();}}Ao.save();Ao.translate(AH.left,AH.top);var E=G.points.lineWidth,I=G.shadowSize,J=G.points.radius,F=G.points.symbol;if(E>0&&I>0){var H=I/2;Ao.lineWidth=H;Ao.strokeStyle="rgba(0,0,0,0.1)";D(G.datapoints,J,null,H+H/2,true,G.xaxis,G.yaxis,F);Ao.strokeStyle="rgba(0,0,0,0.2)";D(G.datapoints,J,null,H/2,true,G.xaxis,G.yaxis,F);}Ao.lineWidth=E;Ao.strokeStyle=G.color;D(G.datapoints,J,BE(G.points,G.color),0,false,G.xaxis,G.yaxis,F);Ao.restore();}function At(L,M,D,Q,I,T,V,N,O,E,H,W){var U,F,P,J,S,X,K,R,G;if(H){R=X=K=true;S=false;U=D;F=L;J=M+Q;P=M+I;if(F<U){G=F;F=U;U=G;S=true;X=false;}}else{S=X=K=true;R=false;U=L+Q;F=L+I;P=D;J=M;if(J<P){G=J;J=P;P=G;R=true;K=false;}}if(F<N.min||U>N.max||J<O.min||P>O.max){return ;}if(U<N.min){U=N.min;S=false;}if(F>N.max){F=N.max;X=false;}if(P<O.min){P=O.min;R=false;}if(J>O.max){J=O.max;K=false;}U=N.p2c(U);P=O.p2c(P);F=N.p2c(F);J=O.p2c(J);if(V){E.beginPath();E.moveTo(U,P);E.lineTo(U,J);E.lineTo(F,J);E.lineTo(F,P);E.fillStyle=V(P,J);E.fill();}if(W>0&&(S||X||K||R)){E.beginPath();E.moveTo(U,P+T);if(S){E.lineTo(U,J+T);}else{E.moveTo(U,J+T);}if(K){E.lineTo(F,J+T);}else{E.moveTo(F,J+T);}if(X){E.lineTo(F,P+T);}else{E.moveTo(F,P+T);}if(R){E.lineTo(U,P+T);}else{E.moveTo(U,P+T);}E.stroke();}}function AS(E){function F(H,I,P,K,Q,N,O){var M=H.points,L=H.pointsize;for(var J=0;J<M.length;J+=L){if(M[J]==null){continue;}At(M[J],M[J+1],M[J+2],I,P,K,Q,N,O,Ao,E.bars.horizontal,E.bars.lineWidth);}}Ao.save();Ao.translate(AH.left,AH.top);Ao.lineWidth=E.bars.lineWidth;Ao.strokeStyle=E.color;var G=E.bars.align=="left"?0:-E.bars.barWidth/2;var D=E.bars.fill?function(I,H){return BE(E.bars,E.color,I,H);}:null;F(E.datapoints,G,G+E.bars.barWidth,0,D,E.xaxis,E.yaxis);Ao.restore();}function BE(G,I,H,E){var F=G.fill;if(!F){return null;}if(G.fillColor){return A6(G.fillColor,H,E,I);}var D=C.color.parse(I);D.a=typeof F=="number"?F:0.4;D.normalize();return D.toString();}function AJ(){Au.find(".legend").remove();if(!Af.legend.show){return ;}var F=[],H=false,M=Af.legend.labelFormatter,N,D;for(var I=0;I<Ad.length;++I){N=Ad[I];D=N.label;if(!D){continue;}if(I%Af.legend.noColumns==0){if(H){F.push("</tr>");}F.push("<tr>");H=true;}if(M){D=M(D,N);}F.push('<td class="legendColorBox"><div style="border:1px solid '+Af.legend.labelBoxBorderColor+';padding:1px"><div style="width:4px;height:0;border:5px solid '+N.color+';overflow:hidden"></div></div></td><td class="legendLabel">'+D+"</td>");}if(H){F.push("</tr>");}if(F.length==0){return ;}var O='<table style="font-size:smaller;color:'+Af.grid.color+'">'+F.join("")+"</table>";if(Af.legend.container!=null){C(Af.legend.container).html(O);}else{var E="",K=Af.legend.position,J=Af.legend.margin;if(J[0]==null){J=[J,J];}if(K.charAt(0)=="n"){E+="top:"+(J[1]+AH.top)+"px;";}else{if(K.charAt(0)=="s"){E+="bottom:"+(J[1]+AH.bottom)+"px;";}}if(K.charAt(1)=="e"){E+="right:"+(J[0]+AH.right)+"px;";}else{if(K.charAt(1)=="w"){E+="left:"+(J[0]+AH.left)+"px;";}}var P=C('<div class="legend">'+O.replace('style="','style="position:absolute;'+E+";")+"</div>").appendTo(Au);if(Af.legend.backgroundOpacity!=0){var G=Af.legend.backgroundColor;if(G==null){G=Af.grid.backgroundColor;if(G&&typeof G=="string"){G=C.color.parse(G);}else{G=C.color.extract(P,"background-color");}G.a=1;G=G.toString();}var L=P.children();C('<div style="position:absolute;width:'+L.width()+"px;height:"+L.height()+"px;"+E+"background-color:"+G+';"> </div>').prependTo(P).css("opacity",Af.legend.backgroundOpacity);}}}var BH=[],Ah=null;function Aj(U,W,Z){var O=Af.grid.mouseActiveRadius,f=O*O+1,E=null,L=false,G,I;for(G=Ad.length-1;G>=0;--G){if(!Z(Ad[G])){continue;}var N=Ad[G],V=N.xaxis,X=N.yaxis,H=N.datapoints.points,J=N.datapoints.pointsize,M=V.c2p(U),P=X.c2p(W),d=O/V.scale,e=O/X.scale;if(V.options.inverseTransform){d=Number.MAX_VALUE;}if(X.options.inverseTransform){e=Number.MAX_VALUE;}if(N.lines.show||N.points.show){for(I=0;
I<H.length;I+=J){var S=H[I],T=H[I+1];if(S==null){continue;}if(S-M>d||S-M<-d||T-P>e||T-P<-e){continue;}var Q=Math.abs(V.p2c(S)-U),R=Math.abs(X.p2c(T)-W),K=Q*Q+R*R;if(K<f){f=K;E=[G,I/J];}}}if(N.bars.show&&!E){var Y=N.bars.align=="left"?0:-N.bars.barWidth/2,F=Y+N.bars.barWidth;for(I=0;I<H.length;I+=J){var S=H[I],T=H[I+1],D=H[I+2];if(S==null){continue;}if(Ad[G].bars.horizontal?(M<=Math.max(D,S)&&M>=Math.min(D,S)&&P>=T+Y&&P<=T+F):(M>=S+Y&&M<=S+F&&P>=Math.min(D,T)&&P<=Math.max(D,T))){E=[G,I/J];}}}}if(E){G=E[0];I=E[1];J=Ad[G].datapoints.pointsize;return{datapoint:Ad[G].datapoints.points.slice(I*J,(I+1)*J),dataIndex:I,series:Ad[G],seriesIndex:G};}return null;}function BI(D){if(Af.grid.hoverable){AD("plothover",D,function(E){return E.hoverable!=false;});}}function AM(D){if(Af.grid.hoverable){AD("plothover",D,function(E){return false;});}}function Ac(D){AD("plotclick",D,function(E){return E.clickable!=false;});}function AD(K,L,J){var I=b.offset(),F=L.pageX-I.left-AH.left,H=L.pageY-I.top-AH.top,D=Ax({left:F,top:H});D.pageX=L.pageX;D.pageY=L.pageY;var M=Aj(F,H,J);if(M){M.pageX=parseInt(M.series.xaxis.p2c(M.datapoint[0])+I.left+AH.left);M.pageY=parseInt(M.series.yaxis.p2c(M.datapoint[1])+I.top+AH.top);}if(Af.grid.autoHighlight){for(var G=0;G<BH.length;++G){var E=BH[G];if(E.auto==K&&!(M&&E.series==M.series&&E.point[0]==M.datapoint[0]&&E.point[1]==M.datapoint[1])){Aa(E.series,E.point);}}if(M){AA(M.series,M.datapoint,K);}}Au.trigger(K,[D,M]);}function AR(){if(!Ah){Ah=setTimeout(AF,30);}}function AF(){Ah=null;A0.save();A0.clearRect(0,0,Ap,Al);A0.translate(AH.left,AH.top);var D,E;for(D=0;D<BH.length;++D){E=BH[D];if(E.series.bars.show){AC(E.series,E.point);}else{An(E.series,E.point);}}A0.restore();A5(A8.drawOverlay,[A0]);}function AA(F,H,D){if(typeof F=="number"){F=Ad[F];}if(typeof H=="number"){var E=F.datapoints.pointsize;H=F.datapoints.points.slice(E*H,E*(H+1));}var G=A7(F,H);if(G==-1){BH.push({series:F,point:H,auto:D});AR();}else{if(!D){BH[G].auto=false;}}}function Aa(D,F){if(D==null&&F==null){BH=[];AR();}if(typeof D=="number"){D=Ad[D];}if(typeof F=="number"){F=D.data[F];}var E=A7(D,F);if(E!=-1){BH.splice(E,1);AR();}}function A7(E,D){for(var G=0;G<BH.length;++G){var F=BH[G];if(F.series==E&&F.point[0]==D[0]&&F.point[1]==D[1]){return G;}}return -1;}function An(G,H){var I=H[0],K=H[1],D=G.xaxis,E=G.yaxis;if(I<D.min||I>D.max||K<E.min||K>E.max){return ;}var F=G.points.radius+G.points.lineWidth/2;A0.lineWidth=F;A0.strokeStyle=C.color.parse(G.color).scale("a",0.5).toString();var J=1.5*F,I=D.p2c(I),K=E.p2c(K);A0.beginPath();if(G.points.symbol=="circle"){A0.arc(I,K,J,0,2*Math.PI,false);}else{G.points.symbol(A0,I,K,J,false);}A0.closePath();A0.stroke();}function AC(D,G){A0.lineWidth=D.bars.lineWidth;A0.strokeStyle=C.color.parse(D.color).scale("a",0.5).toString();var E=C.color.parse(D.color).scale("a",0.5).toString();var F=D.bars.align=="left"?0:-D.bars.barWidth/2;At(G[0],G[1],G[2]||0,F,F+D.bars.barWidth,0,function(){return E;},D.xaxis,D.yaxis,A0,D.bars.horizontal,D.bars.lineWidth);}function A6(D,L,F,K){if(typeof D=="string"){return D;}else{var E=Ao.createLinearGradient(0,F,0,L);for(var I=0,J=D.colors.length;I<J;++I){var H=D.colors[I];if(typeof H!="string"){var G=C.color.parse(K);if(H.brightness!=null){G=G.scale("rgb",H.brightness);}if(H.opacity!=null){G.a*=H.opacity;}H=G.toString();}E.addColorStop(I/(J-1),H);}return E;}}}C.plot=function(D,F,G){var E=new A(C(D),F,G,C.plot.plugins);return E;};C.plot.version="0.7";C.plot.plugins=[];C.plot.formatDate=function(H,M,K){var E=function(O){O=""+O;return O.length==1?"0"+O:O;};var N=[];var D=false,J=false;var F=H.getUTCHours();var I=F<12;if(K==null){K=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];}if(M.search(/%p|%P/)!=-1){if(F>12){F=F-12;}else{if(F==0){F=12;}}}for(var L=0;L<M.length;++L){var G=M.charAt(L);if(D){switch(G){case"h":G=""+F;break;case"H":G=E(F);break;case"M":G=E(H.getUTCMinutes());break;case"S":G=E(H.getUTCSeconds());break;case"d":G=""+H.getUTCDate();break;case"m":G=""+(H.getUTCMonth()+1);
break;case"y":G=""+H.getUTCFullYear();break;case"b":G=""+K[H.getUTCMonth()];break;case"p":G=(I)?("am"):("pm");break;case"P":G=(I)?("AM"):("PM");break;case"0":G="";J=true;break;}if(G&&J){G=E(G);J=false;}N.push(G);if(!J){D=false;}}else{if(G=="%"){D=true;}else{N.push(G);}}}return N.join("");};function B(D,E){return E*Math.floor(D/E);}})(jQuery);(function(A){function C(AA){var AN=null;var O=null;var AI=null;var AE=null;var AG=null;var N=0;var Y=true;var AH=10;var U=0.95;var AF=0;var AR=false;var Q=false;var AM=[];AA.hooks.processOptions.push(AO);AA.hooks.bindEvents.push(AQ);function AO(D,E){if(E.series.pie.show){E.grid.show=false;if(E.series.pie.label.show=="auto"){if(E.legend.show){E.series.pie.label.show=false;}else{E.series.pie.label.show=true;}}if(E.series.pie.radius=="auto"){if(E.series.pie.label.show){E.series.pie.radius=3/4;}else{E.series.pie.radius=1;}}if(E.series.pie.tilt>1){E.series.pie.tilt=1;}if(E.series.pie.tilt<0){E.series.pie.tilt=0;}D.hooks.processDatapoints.push(a);D.hooks.drawOverlay.push(T);D.hooks.draw.push(AC);}}function AQ(D,F){var E=D.getOptions();if(E.series.pie.show&&E.grid.hoverable){F.unbind("mousemove").mousemove(Z);}if(E.series.pie.show&&E.grid.clickable){F.unbind("click").click(AK);}}function W(E){var D="";function F(H,G){if(!G){G=0;}for(var I=0;I<H.length;++I){for(var J=0;J<G;J++){D+="\t";}if(typeof H[I]=="object"){D+=""+I+":\n";F(H[I],G+1);}else{D+=""+I+": "+H[I]+"\n";}}}F(E);alert(D);}function AD(D){for(var F=0;F<D.length;++F){var E=parseFloat(D[F].data[0][1]);if(E){N+=E;}}}function a(D,G,F,E){if(!AR){AR=true;AN=D.getCanvas();O=A(AN).parent();B=D.getOptions();D.setData(P(D.getData()));}}function S(){AF=O.children().filter(".legend").children().width();AI=Math.min(AN.width,(AN.height/B.series.pie.tilt))/2;AG=(AN.height/2)+B.series.pie.offset.top;AE=(AN.width/2);if(B.series.pie.offset.left=="auto"){if(B.legend.position.match("w")){AE+=AF/2;}else{AE-=AF/2;}}else{AE+=B.series.pie.offset.left;}if(AE<AI){AE=AI;}else{if(AE>AN.width-AI){AE=AN.width-AI;}}}function V(D){for(var E=0;E<D.length;++E){if(typeof (D[E].data)=="number"){D[E].data=[[1,D[E].data]];}else{if(typeof (D[E].data)=="undefined"||typeof (D[E].data[0])=="undefined"){if(typeof (D[E].data)!="undefined"&&typeof (D[E].data.label)!="undefined"){D[E].label=D[E].data.label;}D[E].data=[[1,0]];}}}return D;}function P(F){F=V(F);AD(F);var G=0;var D=0;var I=B.series.pie.combine.color;var E=[];for(var H=0;H<F.length;++H){F[H].data[0][1]=parseFloat(F[H].data[0][1]);if(!F[H].data[0][1]){F[H].data[0][1]=0;}if(F[H].data[0][1]/N<=B.series.pie.combine.threshold){G+=F[H].data[0][1];D++;if(!I){I=F[H].color;}}else{E.push({data:[[1,F[H].data[0][1]]],color:F[H].color,label:F[H].label,angle:(F[H].data[0][1]*(Math.PI*2))/N,percent:(F[H].data[0][1]/N*100)});}}if(D>0){E.push({data:[[1,G]],color:I,label:B.series.pie.combine.label,angle:(G*(Math.PI*2))/N,percent:(G/N*100)});}return E;}function AC(E,G){if(!O){return ;}ctx=G;S();var D=E.getData();var H=0;while(Y&&H<AH){Y=false;if(H>0){AI*=U;}H+=1;J();if(B.series.pie.tilt<=0.8){I();}F();}if(H>=AH){J();O.prepend('<div class="error">Could not draw pie with labels contained inside canvas</div>');}if(E.setSeries&&E.insertLegend){E.setSeries(D);E.insertLegend();}function J(){ctx.clearRect(0,0,AN.width,AN.height);O.children().filter(".pieLabel, .pieLabelBackground").remove();}function I(){var d=5;var e=15;var K=10;var f=0.02;if(B.series.pie.radius>1){var M=B.series.pie.radius;}else{var M=AI*B.series.pie.radius;}if(M>=(AN.width/2)-d||M*B.series.pie.tilt>=(AN.height/2)-e||M<=K){return ;}ctx.save();ctx.translate(d,e);ctx.globalAlpha=f;ctx.fillStyle="#000";ctx.translate(AE,AG);ctx.scale(1,B.series.pie.tilt);for(var L=1;L<=K;L++){ctx.beginPath();ctx.arc(0,0,M,0,Math.PI*2,false);ctx.fill();M-=L;}ctx.restore();}function F(){startAngle=Math.PI*B.series.pie.startAngle;if(B.series.pie.radius>1){var M=B.series.pie.radius;}else{var M=AI*B.series.pie.radius;}ctx.save();ctx.translate(AE,AG);ctx.scale(1,B.series.pie.tilt);ctx.save();var d=startAngle;
for(var K=0;K<D.length;++K){D[K].startAngle=d;e(D[K].angle,D[K].color,true);}ctx.restore();ctx.save();ctx.lineWidth=B.series.pie.stroke.width;d=startAngle;for(var K=0;K<D.length;++K){e(D[K].angle,B.series.pie.stroke.color,false);}ctx.restore();R(ctx);if(B.series.pie.label.show){L();}ctx.restore();function e(f,h,g){if(f<=0){return ;}if(g){ctx.fillStyle=h;}else{ctx.strokeStyle=h;ctx.lineJoin="round";}ctx.beginPath();if(Math.abs(f-Math.PI*2)>1e-9){ctx.moveTo(0,0);}else{if(A.browser.msie){f-=0.0001;}}ctx.arc(0,0,M,d,d+f,false);ctx.closePath();d+=f;if(g){ctx.fill();}else{ctx.stroke();}}function L(){var f=startAngle;if(B.series.pie.label.radius>1){var j=B.series.pie.label.radius;}else{var j=AI*B.series.pie.label.radius;}for(var g=0;g<D.length;++g){if(D[g].percent>=B.series.pie.label.threshold*100){h(D[g],f,g);}f+=D[g].angle;}function h(m,t,v){if(m.data[0][1]==0){return ;}var k=B.legend.labelFormatter,l,z=B.series.pie.label.formatter;if(k){l=k(m.label,m);}else{l=m.label;}if(z){l=z(l,m);}var s=((t+m.angle)+t)/2;var n=AE+Math.round(Math.cos(s)*j);var p=AG+Math.round(Math.sin(s)*j)*B.series.pie.tilt;var w='<span class="pieLabel" id="pieLabel'+v+'" style="position:absolute;top:'+p+"px;left:"+n+'px;">'+l+"</span>";O.append(w);var o=O.children("#pieLabel"+v);var AS=(p-o.height()/2);var u=(n-o.width()/2);o.css("top",AS);o.css("left",u);if(0-AS>0||0-u>0||AN.height-(AS+o.height())<0||AN.width-(u+o.width())<0){Y=true;}if(B.series.pie.label.background.opacity!=0){var r=B.series.pie.label.background.color;if(r==null){r=m.color;}var q="top:"+AS+"px;left:"+u+"px;";A('<div class="pieLabelBackground" style="position:absolute;width:'+o.width()+"px;height:"+o.height()+"px;"+q+"background-color:"+r+';"> </div>').insertBefore(o).css("opacity",B.series.pie.label.background.opacity);}}}}}function R(D){if(B.series.pie.innerRadius>0){D.save();innerRadius=B.series.pie.innerRadius>1?B.series.pie.innerRadius:AI*B.series.pie.innerRadius;D.globalCompositeOperation="destination-out";D.beginPath();D.fillStyle=B.series.pie.stroke.color;D.arc(0,0,innerRadius,0,Math.PI*2,false);D.fill();D.closePath();D.restore();D.save();D.beginPath();D.strokeStyle=B.series.pie.stroke.color;D.arc(0,0,innerRadius,0,Math.PI*2,false);D.stroke();D.closePath();D.restore();}}function b(F,E){for(var D=false,G=-1,I=F.length,H=I-1;++G<I;H=G){((F[G][1]<=E[1]&&E[1]<F[H][1])||(F[H][1]<=E[1]&&E[1]<F[G][1]))&&(E[0]<(F[H][0]-F[G][0])*(E[1]-F[G][1])/(F[H][1]-F[G][1])+F[G][0])&&(D=!D);}return D;}function X(F,H){var D=AA.getData(),I=AA.getOptions(),J=I.series.pie.radius>1?I.series.pie.radius:AI*I.series.pie.radius;for(var G=0;G<D.length;++G){var E=D[G];if(E.pie.show){ctx.save();ctx.beginPath();ctx.moveTo(0,0);ctx.arc(0,0,J,E.startAngle,E.startAngle+E.angle,false);ctx.closePath();x=F-AE;y=H-AG;if(ctx.isPointInPath){if(ctx.isPointInPath(F-AE,H-AG)){ctx.restore();return{datapoint:[E.percent,E.data],dataIndex:0,series:E,seriesIndex:G};}}else{p1X=(J*Math.cos(E.startAngle));p1Y=(J*Math.sin(E.startAngle));p2X=(J*Math.cos(E.startAngle+(E.angle/4)));p2Y=(J*Math.sin(E.startAngle+(E.angle/4)));p3X=(J*Math.cos(E.startAngle+(E.angle/2)));p3Y=(J*Math.sin(E.startAngle+(E.angle/2)));p4X=(J*Math.cos(E.startAngle+(E.angle/1.5)));p4Y=(J*Math.sin(E.startAngle+(E.angle/1.5)));p5X=(J*Math.cos(E.startAngle+E.angle));p5Y=(J*Math.sin(E.startAngle+E.angle));arrPoly=[[0,0],[p1X,p1Y],[p2X,p2Y],[p3X,p3Y],[p4X,p4Y],[p5X,p5Y]];arrPoint=[x,y];if(b(arrPoly,arrPoint)){ctx.restore();return{datapoint:[E.percent,E.data],dataIndex:0,series:E,seriesIndex:G};}}ctx.restore();}}return null;}function Z(D){AJ("plothover",D);}function AK(D){AJ("plotclick",D);}function AJ(L,F){var K=AA.offset(),H=parseInt(F.pageX-K.left),J=parseInt(F.pageY-K.top),D=X(H,J);if(B.grid.autoHighlight){for(var I=0;I<AM.length;++I){var G=AM[I];if(G.auto==L&&!(D&&G.series==D.series)){AP(G.series);}}}if(D){AL(D.series,L);}var E={pageX:F.pageX,pageY:F.pageY};O.trigger(L,[E,D]);}function AL(E,D){if(typeof E=="number"){E=series[E];}var F=AB(E);if(F==-1){AM.push({series:E,auto:D});
AA.triggerRedrawOverlay();}else{if(!D){AM[F].auto=false;}}}function AP(D){if(D==null){AM=[];AA.triggerRedrawOverlay();}if(typeof D=="number"){D=series[D];}var E=AB(D);if(E!=-1){AM.splice(E,1);AA.triggerRedrawOverlay();}}function AB(D){for(var F=0;F<AM.length;++F){var E=AM[F];if(E.series==D){return F;}}return -1;}function T(E,D){var F=E.getOptions();var H=F.series.pie.radius>1?F.series.pie.radius:AI*F.series.pie.radius;D.save();D.translate(AE,AG);D.scale(1,F.series.pie.tilt);for(i=0;i<AM.length;++i){G(AM[i].series);}R(D);D.restore();function G(I){if(I.angle<0){return ;}D.fillStyle="rgba(255, 255, 255, "+F.series.pie.highlight.opacity+")";D.beginPath();if(Math.abs(I.angle-Math.PI*2)>1e-9){D.moveTo(0,0);}D.arc(0,0,H,I.startAngle,I.startAngle+I.angle,false);D.closePath();D.fill();}}}var B={series:{pie:{show:false,radius:"auto",innerRadius:0,startAngle:3/2,tilt:1,offset:{top:0,left:"auto"},stroke:{color:"#FFF",width:1},label:{show:"auto",formatter:function(E,D){return'<div style="font-size:x-small;text-align:center;padding:2px;color:'+D.color+';">'+E+"<br/>"+Math.round(D.percent)+"%</div>";},radius:1,background:{color:null,opacity:0},threshold:0},combine:{threshold:-1,color:null,label:"Other"},highlight:{opacity:0.5}}}};A.plot.plugins.push({init:C,options:B,name:"pie",version:"1.0"});})(jQuery);if(typeof dojo!=="undefined"){dojo.provide("org.cometd");}else{this.org=this.org||{};org.cometd={};}org.cometd.JSON={};org.cometd.JSON.toJSON=org.cometd.JSON.fromJSON=function(A){throw"Abstract";};org.cometd.TransportRegistry=function(){var B=[];var A={};this.getTransportTypes=function(){return B.slice(0);};this.findTransportTypes=function(D,G){var C=[];for(var E=0;E<B.length;++E){var F=B[E];if(A[F].accept(D,G)){C.push(F);}}return C;};this.negotiateTransport=function(F,C,H){for(var E=0;E<B.length;++E){var G=B[E];for(var D=0;D<F.length;++D){if(G==F[D]){var I=A[G];if(I.accept(C,H)===true){return I;}}}}return null;};this.add=function(E,G,C){var F=false;for(var D=0;D<B.length;++D){if(B[D]==E){F=true;break;}}if(!F){if(typeof C!=="number"){B.push(E);}else{B.splice(C,0,E);}A[E]=G;}return !F;};this.remove=function(D){for(var C=0;C<B.length;++C){if(B[C]==D){B.splice(C,1);var E=A[D];delete A[D];return E;}}return null;};this.reset=function(){for(var C=0;C<B.length;++C){A[B[C]].reset();}};};org.cometd.Cometd=function(AB){var Ad=this;var AM=AB||"default";var Ab;var AO;var j;var AK;var t;var AG;var K;var AN;var V;var J=false;var AJ=new org.cometd.TransportRegistry();var X;var h="disconnected";var AR=0;var AH=null;var AD=0;var AL=[];var R=false;var A={};var AA=0;var AF=null;var s=[];var n={};var F;var g=false;var Ac=true;function AE(Ak,Ap,Ao){var Aj=Ap||{};for(var Am=2;Am<arguments.length;++Am){var Al=arguments[Am];if(Al===undefined||Al===null){continue;}for(var An in Al){var Aq=Al[An];if(Aq===Ap){continue;}if(Aq===undefined){continue;}if(Ak&&typeof Aq==="object"&&Aq!==null){if(Aq instanceof Array){Aj[An]=AE(Ak,[],Aq);}else{Aj[An]=AE(Ak,{},Aq);}}else{Aj[An]=Aq;}}}return Aj;}this._mixin=AE;function u(Ak,Al){for(var Aj=0;Aj<Al.length;++Aj){if(Ak==Al[Aj]){return Aj;}}return -1;}function e(Aj){if(Aj===undefined||Aj===null){return false;}return typeof Aj==="string"||Aj instanceof String;}function Q(Aj){if(Aj===undefined||Aj===null){return false;}return Aj instanceof Array;}function Z(Aj){if(Aj===undefined||Aj===null){return false;}return typeof Aj==="function";}function o(Al,Ak){if(window.console){var Aj=window.console[Al];if(Z(Aj)){Aj.apply(window.console,Ak);}}}function C(){o("warn",arguments);}this._warn=C;function N(){if(Ab!="warn"){o("info",arguments);}}this._info=N;function Ai(){if(Ab=="debug"){o("debug",arguments);}}this._debug=Ai;function Ag(Am){Ai("Configuring cometd object with",Am);if(e(Am)){Am={url:Am};}if(!Am){Am={};}AO=Am.url;if(!AO){throw"Missing required configuration parameter 'url' specifying the Bayeux server URL";}j=Am.maxConnections||2;AK=Am.backoffIncrement||1000;t=Am.maxBackoff||60000;Ab=Am.logLevel||"info";AG=Am.reverseIncomingExtensions!==false;
K=Am.maxNetworkDelay||10000;AN=Am.requestHeaders||{};V=Am.appendMessageTypeToURL!==false;var Al=/(^https?:)?(\/\/(([^:\/\?#]+)(:(\d+))?))?([^\?#]*)(.*)?/.exec(AO);J=Al[3]&&Al[3]!=window.location.host;if(V){if(Al[8]!==undefined){N("Appending message type to URI "+Al[7]+Al[8]+" is not supported, disabling 'appendMessageTypeToURL' configuration");V=false;}else{var Ak=Al[7].split("/");var Aj=Ak.length-1;if(Al[7].match(/\/$/)){Aj-=1;}if(Ak[Aj].indexOf(".")>=0){N("Appending message type to URI "+Al[7]+" is not supported, disabling 'appendMessageTypeToURL' configuration");V=false;}}}}function W(){for(var Al in A){var Am=A[Al];for(var Aj=0;Aj<Am.length;++Aj){var Ak=Am[Aj];if(Ak&&!Ak.listener){delete Am[Aj];Ai("Removed subscription",Ak,"for channel",Al);}}}}function Ah(Aj){Ai("Status",h,"->",Aj);h=Aj;}function AT(){return h=="disconnecting"||h=="disconnected";}function E(){return ++AR;}function AZ(An,Aq,Al,Ao,Ak){try{return Aq.call(An,Ao);}catch(Aj){Ai("Exception during execution of extension",Al,Aj);var Am=Ad.onExtensionException;if(Z(Am)){Ai("Invoking extension exception callback",Al,Aj);try{Am.call(Ad,Aj,Al,Ak,Ao);}catch(Ap){N("Exception during execution of exception callback in extension",Al,Ap);}}return Ao;}}function d(Am){for(var Al=0;Al<s.length;++Al){if(Am===undefined||Am===null){break;}var Ak=AG?s.length-1-Al:Al;var Ao=s[Ak];var An=Ao.extension.incoming;if(Z(An)){var Aj=AZ(Ao.extension,An,Ao.name,Am,false);Am=Aj===undefined?Am:Aj;}}return Am;}function B(Al){for(var Ak=0;Ak<s.length;++Ak){if(Al===undefined||Al===null){break;}var An=s[Ak];var Am=An.extension.outgoing;if(Z(Am)){var Aj=AZ(An.extension,Am,An.name,Al,true);Al=Aj===undefined?Al:Aj;}}return Al;}function v(Ak){if(e(Ak)){try{return org.cometd.JSON.fromJSON(Ak);}catch(Aj){Ai("Could not convert to JSON the following string",'"'+Ak+'"');throw Aj;}}if(Q(Ak)){return Ak;}if(Ak===undefined||Ak===null){return[];}if(Ak instanceof Object){return[Ak];}throw"Conversion Error "+Ak+", typeof "+(typeof Ak);}function AX(An,Am){var Aq=A[An];if(Aq&&Aq.length>0){for(var Ak=0;Ak<Aq.length;++Ak){var Al=Aq[Ak];if(Al){try{Al.callback.call(Al.scope,Am);}catch(Aj){Ai("Exception during notification",Al,Am,Aj);var Ao=Ad.onListenerException;if(Z(Ao)){Ai("Invoking listener exception callback",Al,Aj);try{Ao.call(Ad,Aj,Al.handle,Al.listener,Am);}catch(Ap){N("Exception during execution of listener callback",Al,Ap);}}}}}}}function Aa(An,Am){AX(An,Am);var Ao=An.split("/");var Al=Ao.length-1;for(var Ak=Al;Ak>0;--Ak){var Aj=Ao.slice(0,Ak).join("/")+"/*";if(Ak==Al){AX(Aj,Am);}Aj+="*";AX(Aj,Am);}}function I(Ak,Aj){return setTimeout(function(){try{Ak();}catch(Al){Ai("Exception invoking timed function",Ak,Al);}},Aj);}function U(){if(AF!==null){clearTimeout(AF);}AF=null;}function Y(Aj){U();var Ak=AA;if(n.interval&&n.interval>0){Ak+=n.interval;}AF=I(Aj,Ak);}var AW;var b;function p(Ap,Ao,Aj,An){for(var Al=0;Al<Ao.length;++Al){var Am=Ao[Al];Am.id=E();if(AH){Am.clientId=AH;}Am=B(Am);if(Am!==undefined&&Am!==null){Ao[Al]=Am;}else{Ao.splice(Al--,1);}}if(Ao.length===0){return ;}var Ak=AO;if(V){if(!Ak.match(/\/$/)){Ak=Ak+"/";}if(An){Ak=Ak+An;}}var Aq={url:Ak,sync:Ap,messages:Ao,onSuccess:function(At,As){try{AW.call(Ad,At,As,Aj);}catch(Ar){Ai("Exception during handling of response",Ar);}},onFailure:function(At,Au,As){try{b.call(Ad,At,Ao,Au,As,Aj);}catch(Ar){Ai("Exception during handling of failure",Ar);}}};Ai("Send, sync="+Ap,Aq);X.send(Aq,Aj);}function AC(Aj){if(AD>0||R===true){AL.push(Aj);}else{p(false,[Aj],false);}}this.send=AC;function AI(){AA=0;}function AP(){if(AA<t){AA+=AK;}}function r(){++AD;}function H(){var Aj=AL;AL=[];if(Aj.length>0){p(false,Aj,false);}}function m(){--AD;if(AD<0){throw"Calls to startBatch() and endBatch() are not paired";}if(AD===0&&!AT()&&!R){H();}}function S(){if(!AT()){var Aj={channel:"/meta/connect",connectionType:X.getType()};if(!Ac){Ac=true;Aj.advice={};Aj.advice.timeout=0;}Ah("connecting");Ai("Connect sent",Aj);p(false,[Aj],true,"connect");Ah("connected");}}function a(){Ah("connecting");
Y(function(){S();});}function T(Am){AH=null;W();if(AT()){AJ.reset();}AD=0;R=true;F=Am;var Aj="1.0";var An=AJ.findTransportTypes(Aj,J);var Ak={version:Aj,minimumVersion:"0.9",channel:"/meta/handshake",supportedConnectionTypes:An};var Al=AE(false,{},F,Ak);X=AJ.negotiateTransport(An,Aj,J);Ai("Initial transport is",X);Ah("handshaking");Ai("Handshake sent",Al);p(false,[Al],false,"handshake");}function Ae(){Ah("handshaking");R=true;Y(function(){T(F);});}function z(Ak){if(Ak.successful){AH=Ak.clientId;var Aj=AJ.negotiateTransport(Ak.supportedConnectionTypes,Ak.version,J);if(Aj===null){throw"Could not negotiate transport with server; client "+AJ.findTransportTypes(Ak.version,J)+", server "+Ak.supportedConnectionTypes;}else{Ai("Transport",X,"->",Aj);X=Aj;}R=false;H();Ak.reestablish=g;g=true;Aa("/meta/handshake",Ak);if(!AT()){if(n.reconnect!="none"){a();}else{AI();Ah("disconnected");}}}else{Aa("/meta/handshake",Ak);Aa("/meta/unsuccessful",Ak);if(!AT()){if(n.reconnect!="none"){AP();Ae();}else{AI();Ah("disconnected");}}}}function f(Al,Ak){var Aj={successful:false,failure:true,channel:"/meta/handshake",request:Ak,xhr:Al,advice:{action:"retry",interval:AA}};Aa("/meta/handshake",Aj);Aa("/meta/unsuccessful",Aj);if(!AT()){if(n.reconnect!="none"){AP();Ae();}else{AI();Ah("disconnected");}}}function AU(Aj){Ac=Aj.successful;if(Ac){Aa("/meta/connect",Aj);if(!AT()){if(!n.reconnect||n.reconnect=="retry"){AI();a();}else{AI();Ah("disconnected");}}}else{Aa("/meta/connect",Aj);Aa("/meta/unsuccessful",Aj);if(!AT()){var Ak=n.reconnect?n.reconnect:"retry";switch(Ak){case"retry":AP();a();break;case"handshake":AI();Ae();break;case"none":AI();Ah("disconnected");break;default:N("Unrecognized advice action",Ak);break;}}}}function q(Am,Ak){Ac=false;var Aj={successful:false,failure:true,channel:"/meta/connect",request:Ak,xhr:Am,advice:{action:"retry",interval:AA}};Aa("/meta/connect",Aj);Aa("/meta/unsuccessful",Aj);if(!AT()){var Al=n.reconnect?n.reconnect:"retry";switch(Al){case"retry":AP();a();break;case"handshake":AI();Ae();break;case"none":AI();Ah("disconnected");break;default:N("Unrecognized advice action",Al);break;}}}function O(Aj){U();if(Aj){X.abort();}AH=null;Ah("disconnected");AD=0;AL=[];AI();}function AY(Aj){if(Aj.successful){O(false);Aa("/meta/disconnect",Aj);}else{O(true);Aa("/meta/disconnect",Aj);Aa("/meta/unsuccessful",Aj);}}function L(Al,Ak){O(true);var Aj={successful:false,failure:true,channel:"/meta/disconnect",request:Ak,xhr:Al,advice:{action:"none",interval:0}};Aa("/meta/disconnect",Aj);Aa("/meta/unsuccessful",Aj);}function Af(Aj){if(Aj.successful){Aa("/meta/subscribe",Aj);}else{Aa("/meta/subscribe",Aj);Aa("/meta/unsuccessful",Aj);}}function P(Al,Ak){var Aj={successful:false,failure:true,channel:"/meta/subscribe",request:Ak,xhr:Al,advice:{action:"none",interval:0}};Aa("/meta/subscribe",Aj);Aa("/meta/unsuccessful",Aj);}function D(Aj){if(Aj.successful){Aa("/meta/unsubscribe",Aj);}else{Aa("/meta/unsubscribe",Aj);Aa("/meta/unsuccessful",Aj);}}function M(Al,Ak){var Aj={successful:false,failure:true,channel:"/meta/unsubscribe",request:Ak,xhr:Al,advice:{action:"none",interval:0}};Aa("/meta/unsubscribe",Aj);Aa("/meta/unsuccessful",Aj);}function l(Aj){if(Aj.successful===undefined){if(Aj.data){Aa(Aj.channel,Aj);}else{Ai("Unknown message",Aj);}}else{if(Aj.successful){Aa("/meta/publish",Aj);}else{Aa("/meta/publish",Aj);Aa("/meta/unsuccessful",Aj);}}}function w(Al,Ak){var Aj={successful:false,failure:true,channel:Ak.channel,request:Ak,xhr:Al,advice:{action:"none",interval:0}};Aa("/meta/publish",Aj);Aa("/meta/unsuccessful",Aj);}function AS(Ak){Ak=d(Ak);if(Ak===undefined||Ak===null){return ;}if(Ak.advice){n=Ak.advice;}var Aj=Ak.channel;switch(Aj){case"/meta/handshake":z(Ak);break;case"/meta/connect":AU(Ak);break;case"/meta/disconnect":AY(Ak);break;case"/meta/subscribe":Af(Ak);break;case"/meta/unsubscribe":D(Ak);break;default:l(Ak);break;}}this.receive=AS;AW=function AW(Ao,Ak,Aj){var An=v(Ak);Ai("Received",Ak,"converted to",An);X.complete(Ao,true,Aj);for(var Al=0;
Al<An.length;++Al){var Am=An[Al];AS(Am);}};b=function b(Ak,Al,Ao,Aj,Am){var Aq=Ak.xhr;Ai("Failed",Al,Ao,Aj);X.complete(Ak,false,Am);for(var An=0;An<Al.length;++An){var Ar=Al[An];var Ap=Ar.channel;switch(Ap){case"/meta/handshake":f(Aq,Ar);break;case"/meta/connect":q(Aq,Ar);break;case"/meta/disconnect":L(Aq,Ar);break;case"/meta/subscribe":P(Aq,Ar);break;case"/meta/unsubscribe":M(Aq,Ar);break;default:w(Aq,Ar);break;}}};function G(Ak){var Al=A[Ak];if(Al){for(var Aj=0;Aj<Al.length;++Aj){if(Al[Aj]){return true;}}}return false;}function k(Ak,Al){var Aj={scope:Ak,method:Al};if(Z(Ak)){Aj.scope=undefined;Aj.method=Ak;}else{if(e(Al)){if(!Ak){throw"Invalid scope "+Ak;}Aj.method=Ak[Al];if(!Z(Aj.method)){throw"Invalid callback "+Al+" for scope "+Ak;}}else{if(!Z(Al)){throw"Invalid callback "+Al;}}}return Aj;}function AV(Ao,Am,Aq,Al){var Ak=k(Am,Aq);Ai("Listener scope",Ak.scope,"and callback",Ak.method);var An={channel:Ao,scope:Ak.scope,callback:Ak.method,listener:Al};var Ap=A[Ao];if(!Ap){Ap=[];A[Ao]=Ap;}var Aj=Ap.push(An)-1;An.id=Aj;An.handle=[Ao,Aj];Ai("Added listener",An,"for channel",Ao,"having id =",Aj);return An.handle;}function AQ(Aj){var Ak=A[Aj[0]];if(Ak){delete Ak[Aj[1]];Ai("Removed listener",Aj);}}this.registerTransport=function(Al,Am,Ak){var Aj=AJ.add(Al,Am,Ak);if(Aj){Ai("Registered transport",Al);if(Z(Am.registered)){Am.registered(Al,this);}}return Aj;};this.getTransportTypes=function(){return AJ.getTransportTypes();};this.unregisterTransport=function(Aj){var Ak=AJ.remove(Aj);if(Ak!==null){Ai("Unregistered transport",Aj);if(Z(Ak.unregistered)){Ak.unregistered();}}return Ak;};this.configure=function(Aj){Ag.call(this,Aj);};this.init=function(Ak,Aj){this.configure(Ak);this.handshake(Aj);};this.handshake=function(Aj){Ah("disconnected");g=false;T(Aj);};this.disconnect=function(Al,Am){if(AT()){return ;}if(Am===undefined){if(typeof Al!=="boolean"){Am=Al;Al=false;}}var Aj={channel:"/meta/disconnect"};var Ak=AE(false,{},Am,Aj);Ah("disconnecting");p(Al===true,[Ak],false,"disconnect");};this.startBatch=function(){r();};this.endBatch=function(){m();};this.batch=function(Al,Am){var Ak=k(Al,Am);this.startBatch();try{Ak.method.call(Ak.scope);this.endBatch();}catch(Aj){Ai("Exception during execution of batch",Aj);this.endBatch();throw Aj;}};this.addListener=function(Ak,Aj,Al){if(arguments.length<2){throw"Illegal arguments number: required 2, got "+arguments.length;}if(!e(Ak)){throw"Illegal argument type: channel must be a string";}return AV(Ak,Aj,Al,true);};this.removeListener=function(Aj){if(!Q(Aj)){throw"Invalid argument: expected subscription, not "+Aj;}AQ(Aj);};this.clearListeners=function(){A={};};this.subscribe=function(An,Ak,Aq,Ap){if(arguments.length<2){throw"Illegal arguments number: required 2, got "+arguments.length;}if(!e(An)){throw"Illegal argument type: channel must be a string";}if(AT()){}if(Z(Ak)){Ap=Aq;Aq=Ak;Ak=undefined;}var Ao=!G(An);var Am=AV(An,Ak,Aq,false);if(Ao){var Aj={channel:"/meta/subscribe",subscription:An};var Al=AE(false,{},Ap,Aj);AC(Al);}return Am;};this.unsubscribe=function(An,Ak){if(arguments.length<1){throw"Illegal arguments number: required 1, got "+arguments.length;}if(AT()){}this.removeListener(An);var Am=An[0];if(!G(Am)){var Aj={channel:"/meta/unsubscribe",subscription:Am};var Al=AE(false,{},Ak,Aj);AC(Al);}};this.clearSubscriptions=function(){W();};this.publish=function(Am,Al,An){if(arguments.length<1){throw"Illegal arguments number: required 1, got "+arguments.length;}if(!e(Am)){throw"Illegal argument type: channel must be a string";}if(AT()){}var Aj={channel:Am,data:Al};var Ak=AE(false,{},An,Aj);AC(Ak);};this.getStatus=function(){return h;};this.setBackoffIncrement=function(Aj){AK=Aj;};this.getBackoffIncrement=function(){return AK;};this.getBackoffPeriod=function(){return AA;};this.setLogLevel=function(Aj){Ab=Aj;};this.registerExtension=function(Aj,An){if(arguments.length<2){throw"Illegal arguments number: required 2, got "+arguments.length;}if(!e(Aj)){throw"Illegal argument type: extension name must be a string";
}var Al=false;for(var Ak=0;Ak<s.length;++Ak){var Am=s[Ak];if(Am.name==Aj){Al=true;break;}}if(!Al){s.push({name:Aj,extension:An});Ai("Registered extension",Aj);if(Z(An.registered)){An.registered(Aj,this);}return true;}else{N("Could not register extension with name",Aj,"since another extension with the same name already exists");return false;}};this.unregisterExtension=function(Ak){if(!e(Ak)){throw"Illegal argument type: extension name must be a string";}var Aj=false;for(var Al=0;Al<s.length;++Al){var An=s[Al];if(An.name==Ak){s.splice(Al,1);Aj=true;Ai("Unregistered extension",Ak);var Am=An.extension;if(Z(Am.unregistered)){Am.unregistered();}break;}}return Aj;};this.getExtension=function(Aj){for(var Ak=0;Ak<s.length;++Ak){var Al=s[Ak];if(Al.name==Aj){return Al.extension;}}return null;};this.getName=function(){return AM;};this.getClientId=function(){return AH;};this.getURL=function(){return AO;};this.getTransport=function(){return X;};org.cometd.Transport=function(){var As=this;var Am;var Ao=0;var Ap=null;var Aj=[];var Aq=[];this.registered=function(Av,Au){Am=Av;};this.unregistered=function(){Am=null;};this.accept=function(Au,Av){throw"Abstract";};this.transportSend=function(Av,Au){throw"Abstract";};this.transportSuccess=function(Aw,Av,Au){if(!Av.expired){clearTimeout(Av.timeout);if(Au&&Au.length>0){Aw.onSuccess(Av,Au);}else{Aw.onFailure(Av,"Empty HTTP response");}}};this.transportFailure=function(Ax,Av,Aw,Au){if(!Av.expired){clearTimeout(Av.timeout);Ax.onFailure(Av,Aw,Au);}};function Ar(Aw,Av){Av.expired=false;this.transportSend(Aw,Av);if(!Aw.sync){var Au=K;if(Av.longpoll===true){Au+=n&&typeof n.timeout==="number"?n.timeout:0;}Av.timeout=I(function(){Av.expired=true;if(Av.xhr){Av.xhr.abort();}var Ax="Transport "+As.getType()+" exceeded "+Au+" ms max network delay for request "+Av.id;Ai(Ax);Aw.onFailure(Av,"timeout",Ax);},Au);}}function At(Aw){if(Ap!==null){throw"Concurrent longpoll requests not allowed, request "+Ap.id+" not yet completed";}var Av=++Ao;var Au={id:Av,longpoll:true};Ar.call(this,Aw,Au);Ap=Au;}function An(Aw){var Av=++Ao;var Au={id:Av,longpoll:false};if(Aj.length<j-1){Ai("Transport sending request",Av,Aw);Ar.call(this,Aw,Au);Aj.push(Au);}else{Ai("Transport queueing request",Av,Aw);Aq.push([Aw,Au]);}}function Al(Au){var Av=Au.id;if(Ap!==null&&Ap!==Au){throw"Longpoll request mismatch, completing request "+Av;}Ap=null;}function Ak(Av,Ax){var Au=u(Av,Aj);if(Au>=0){Aj.splice(Au,1);}if(Aq.length>0){var Aw=Aq.shift();if(Ax){An.call(this,Aw[0]);Ai("Transport completed request",Av.id,Aw[0]);}else{setTimeout(function(){Aw[0].onFailure(Aw[1],"error");},0);}}}this.getType=function(){return Am;};this.send=function(Av,Au){if(Au){At.call(this,Av);}else{An.call(this,Av);}};this.complete=function(Av,Aw,Au){if(Au){Al.call(this,Av);}else{Ak.call(this,Av,Aw);}};this.abort=function(){for(var Au=0;Au<Aj.length;++Au){var Av=Aj[Au];Ai("Aborting request",Av);if(Av.xhr){Av.xhr.abort();}}if(Ap){Ai("Aborting longpoll request",Ap);if(Ap.xhr){Ap.xhr.abort();}}this.reset();};this.reset=function(){Ap=null;Aj=[];Aq=[];};this.toString=function(){return this.getType();};};org.cometd.LongPollingTransport=function(){var Aj=this;var Ak=true;this.accept=function(Al,Am){return Ak||!Am;};this.xhrSend=function(Al){throw"Abstract";};this.transportSend=function(Ao,An){try{var Am=true;An.xhr=this.xhrSend({transport:this,url:Ao.url,sync:Ao.sync,headers:AN,body:org.cometd.JSON.toJSON(Ao.messages),onSuccess:function(Ap){if(!Ap||Ap.length===0){Ak=false;}Aj.transportSuccess(Ao,An,Ap);},onError:function(Aq,Ap){Ak=false;if(Am){I(function(){Aj.transportFailure(Ao,An,Aq,Ap);},0);}else{Aj.transportFailure(Ao,An,Aq,Ap);}}});Am=false;}catch(Al){Ak=false;I(function(){Aj.transportFailure(Ao,An,"error",Al);},0);}};this.reset=function(){org.cometd.LongPollingTransport.prototype.reset();Ak=true;};};org.cometd.LongPollingTransport.prototype=new org.cometd.Transport();org.cometd.LongPollingTransport.prototype.constructor=org.cometd.LongPollingTransport;org.cometd.CallbackPollingTransport=function(){var Ak=this;
var Aj=2000;this.accept=function(Al,Am){return true;};this.jsonpSend=function(Al){throw"Abstract";};this.transportSend=function(Ap,Ao){var An=org.cometd.JSON.toJSON(Ap.messages);var Ar=Ap.url.length+encodeURI(An).length;if(Ar>Aj){var Al=Ap.messages.length>1?"Too many bayeux messages in the same batch resulting in message too big ("+Ar+" bytes, max is "+Aj+") for transport "+this.getType():"Bayeux message too big ("+Ar+" bytes, max is "+Aj+") for transport "+this.getType();I(function(){Ak.transportFailure(Ap,Ao,"error",Al);},0);}else{try{var Am=true;this.jsonpSend({transport:this,url:Ap.url,sync:Ap.sync,headers:AN,body:An,onSuccess:function(As){Ak.transportSuccess(Ap,Ao,As);},onError:function(At,As){if(Am){I(function(){Ak.transportFailure(Ap,Ao,At,As);},0);}else{Ak.transportFailure(Ap,Ao,At,As);}}});Am=false;}catch(Aq){I(function(){Ak.transportFailure(Ap,Ao,"error",Aq);},0);}}};};org.cometd.CallbackPollingTransport.prototype=new org.cometd.Transport();org.cometd.CallbackPollingTransport.prototype.constructor=org.cometd.CallbackPollingTransport;};var PlanetoSocket={};PlanetoSocket.Native=function(){var D,C,F,B,A="";myWs=this;this.dispatching=false;this.socketType="Native WebSocket";this.connected=false;this.outgoingChunks=[];var E="",H=false;this.connect=function(I){D=new WebSocket(I+"/proxy");D.onmessage=function(J){clearTimeout(E);G(J);};D.onopen=function(J){if(H==false){C(J);}};D.onclose=F;D.onerror=function(J){console.error("--- Error: ",J);};E=setTimeout(function(){H=true;facade.sendEvent(PlanetoService.CONNECT,{nativesocket:false});},3000);};var G=function(L){var M=0,K=L.data.length,J;for(J=0;J<K;J++){if(PlanetoSocket._addChar(L.data.charAt(J))){A=A+L.data.substring(M,J+1);M=J+1;var I=A;A="";B(I);}}if(M<K){A=A+L.data.substring(M);}};this.setOnMessageCallback=function(I){B=I;};this.setConnectCallback=function(I){C=I;};this.setDisconnectCallback=function(I){F=I;};this.dispatch=function(J){var I=J.length;maxPartLength=366;for(var L=0;L<I;L+=maxPartLength){var K=L+Math.min(maxPartLength,I-L);D.send(J.substring(L,K));}};this.disconnect=function(){D.close();};this.localScope=function(K){var I=this,J=arguments;return function(){K.apply(I,J);};delete I;};return this;};WEB_SOCKET_DEBUG=false;PlanetoSocket.Flash=function(){var D,C,E,B,A="";this.socketType="Flash WebSocket";this.connected=false;this.connect=function(G){D=new FlashSocket(G+"/proxy");D.onmessage=F;D.onopen=C;D.onclose=E;};var F=function(J){var K=0,I=J.data.length,H;for(H=0;H<I;H++){if(PlanetoSocket._addChar(J.data.charAt(H))){A=A+J.data.substring(K,H+1);K=H+1;var G=A;A="";B(G);}}if(K<I){A=A+J.data.substring(K);}};this.setOnMessageCallback=function(G){B=G;};this.setConnectCallback=function(G){C=G;};this.setDisconnectCallback=function(G){E=G;};this.dispatch=function(G){D.send(G);};this.disconnect=function(){D.close();};return this;};PlanetoSocket.CometD=function(){if(window.$==null){throw"$ not defined";}else{if(window.$.cometd==null){throw"$.cometd not defined";}}var B=$.cometd,I=false;this.socketType="CometD WebSocket";this.connected=false;var J=null;var C=null;var A=null;var G=null;var D=null,E="";var H=null;var F=function(O){var N=I;I=O.successful===true;if(!N&&I){A=B.subscribe("/proxy/response",M);L();}else{if(N&&!I){B.unsubscribe(A);B.disconnect();}}};var M=function(Q){if(G!=null){var R=0,P=Q.data.length,O;for(O=0;O<P;O++){if(PlanetoSocket._addChar(Q.data.charAt(O))){E=E+Q.data.substring(R,O+1);R=O+1;var N=E;E="";G(N);}}if(R<P){E=E+Q.data.substring(R);}}};var L=function(){if(D!=null){D();}};var K=function(P){var O=P.length,N=366;for(var R=0;R<O;R+=N){var Q=R+Math.min(N,O-R);B.publish("/proxy/request",{data:P.substring(R,Q)});}};this.connect=function(N){B.configure({url:N.replace("ws://","http://").replace("wss://","https://")+"/cometd"});J=B.addListener("/meta/connect",F);C=B.addListener("/meta/disconnect",H);B.handshake();};this.dispatch=function(N){K(N);};this.disconnect=function(){B.unsubscribe(A);B.removeListener(J);B.disconnect();};this.setOnMessageCallback=function(N){G=N;
};this.setConnectCallback=function(N){D=N;};this.setDisconnectCallback=function(N){H=N;};return this;};PlanetoSocket.inString=false;PlanetoSocket.insEscapeSeq=false;PlanetoSocket.bracketsCount=0;PlanetoSocket._addChar=function(B){var A=PlanetoSocket.inString;if(PlanetoSocket.inString){if(B=="\\"&&!PlanetoSocket.inEscapeSeq){PlanetoSocket.inEscapeSeq=true;}else{if(B=='"'&&!PlanetoSocket.inEscapeSeq){PlanetoSocket.inString=false;}PlanetoSocket.inEscapeSeq=false;}}else{if(B=='"'){PlanetoSocket.inString=true;}else{if(B=="{"){PlanetoSocket.bracketsCount++;}else{if(B=="}"){PlanetoSocket.bracketsCount--;}}}}if(PlanetoSocket.bracketsCount==0){PlanetoSocket.bracketsCount=0;return true;}return false;};if(typeof (Planeto)=="undefined"){Planeto={};}Planeto.Globals={appMode:"",currentGameType:"",autoStartGameType:"",gamePaused:false};var user_id="",playerModel=null;ignoreUserList=new Array();fb_status="",fb_friends=[];totalQuestions=0,connectedAsGuest=false,connectedToFB=false,connectedToGoogle=false;gamePaused=false,ignoreTutorial=false,qsOrSqPlayed=false,currentSelfQuiz={},tutorial_done=0,question_set_summary="",creator_content={},duelRoundIndex=0,chatBodyRest=610,playerIdle=false,show_mastery_points_after_load=false,href_match_uref="",href_match_lb="",href_match_wm="",href_match_gt="",href_match_kn=false,webServiceHost="",requiresReloadAfterConvertAccount=false,kn_url="http://local.planeto.net/",facebookAppID=decideFbAppId();if(location.href.indexOf("local")==-1){kn_url="http://www."+location.href.match("(widget|beta|create|play).([^/?]*)")[2]+"/";}var selector_templates_friend=$("#templates div.friend"),selector_templates_planetoItem=$("#templates > div.planetoItem"),selector_statusContainer=$("#statusContainer");$("textarea.restrict_maxlength").live("keyup",function(){var C=$(this).attr("maxlength"),B=$(this).val(),A=B.length;if(A>C){$(this).val(B.substr(0,C));}});$("input:text[placeholder!=''], textarea[placeholder!='']").live("focusin",function(){var B=$(this).attr("placeholder"),A=$(this).val();$(this).removeClass("grey");if(A==B){$(this).val("");}}).live("focusout",function(){var B=$(this).attr("placeholder"),A=$(this).val();if(A==""){$(this).addClass("grey").val(B);}});CallbackProxy=function(B,C,A){return function(){var E=[];for(var D=0;D<arguments.length;D++){E.push(arguments[D]);}if(A!=null){E.push(A);}C.apply(B,E);};};CallbackProxyTimeouts=function(B,C,A){return function(){C.apply(B,[A]);};};function ignoredByUser(A){return $.inArray(A,ignoreUserList)>=0;}function decideFbAppId(){var C="165427943513068",B="199015894516",A=location.href.toString().match(/^http\:\/\/(.*?)planeto.com((\:\d+\/)|(\/))/gi);return A!=null&&A.length>0?C:B;}function update_doc_title(A){if(playerIdle==true&&A+""!="undefined"){document.title=A+" - Planeto.com";}else{document.title="Planeto.com";}}function number_suffix(A){if(A%10==1){A+="st";}else{if(A%10==2){A+="nd";}else{if(A%10==3){A+="rd";}else{A+="th";}}}return A;}function get_quiz_info(F,B){var E="",A=B.questionSets?B.questionSets.length:0,D=B.selfQuizes?B.selfQuizes.length:0;if(A>0){for(var C=0;C<A;C++){if(B.questionSets[C].id==F){E=B.questionSets[C];break;}}}if(D>0&&E==""){for(var C=0;C<D;C++){if(B.selfQuizes[C].id==F){E=B.selfQuizes[C];break;}}}return E;}function format_time(E,D,A){if(!A&&A!=0){A=1;}if(D){var B=Math.floor(E/60),C=(E-B*60),F=C.toFixed(0)<10?"0":"";E=B+":"+F+C.toFixed(0);}else{if(E>=60){var B=Math.floor(E/60);E=B+" m "+(E-B*60).toFixed(A)+" s";}else{E=E.toFixed(A)+" s";}}return E;}function planetoItemTooltip(B,R,S){var H=R.type=="questionSet"?true:false,F=H?"question_set":R.type,K=12,I=14;if(R.description!=null){B.find("p.planetoItemToolTipDesc").html(R.description).show();}else{B.find("p.planetoItemToolTipDesc").hide();}if(R.nbrOfFriendsWhoHavePlayedIt>-1){B.find("p.planetoItemToolTipQsetFriendsPlayed").html(R.nbrOfFriendsWhoHavePlayedIt+" friend"+(R.nbrOfFriendsWhoHavePlayedIt==1?"":"s")+" have played this").show();}else{B.find("p.planetoItemToolTipQsetFriendsPlayed").hide();}if(R.name.length>45){K=9;
I=11;}else{if(R.name.length>40){K=10;I=12;}else{if(R.name.length>35){K=11;I=13;}}}B.find("h3.planetoItemTooltipName").css({"font-size":K+"px","line-height":I+"px"}).html(R.name);if(R.rarity!=""){var T=R.rarity.toLowerCase();if(!H){B.find(".planetoItemRarity").addClass(R.type+" "+R.type+"_rarity_"+T);}B.find("div.tooltipRarity img").addClass("color_rarity_"+T);B.find("div.tooltipRarity span").html(R.rarity);B.find("h3.planetoItemTooltipName").addClass("color_rarity_"+T+"_color");}else{B.find("div.tooltipRarity").hide();}if(R.category!=null){var Q=R.category.id;B.find(".planetoItemCategory").addClass(F+" "+F+"_category_"+Q);B.find("div.category").show();}if(R.itemLevel>0){B.find("div.tooltipItemLevel span").html(R.itemLevel);}else{B.find("div.tooltipItemLevel").hide();}if(R.goldCost==0){B.find("div.tooltipCost").hide();}else{B.find("div.tooltipCost p span").html(R.goldCost);B.find("div.tooltipCost").show();}if(R.traitDescriptionDTO!=null){B.find(".tooltipTraitHeader").html(R.traitDescriptionDTO.name);for(var P=0;P<R.traitDescriptionDTO.effectDescriptions.length;P++){var A=R.traitDescriptionDTO.effectDescriptions[P],G,N="";G=P==0?B.find("div.tooltipEffect"):$("#templates .tooltipEffect").clone();G.find(".tooltipEffectDescColumn").html(A.description);if(A.value!=null){var J="",M="";if(A.operator=="ADD"){J="+";}else{if(A.operator=="MUL"){J="x";}}if(A.unit!=null){if(A.unit=="SEC"){M="s";}else{if(A.unit=="GOLD"){M="g";}}}var L=A.value;if(L.indexOf(".")!=-1){L=parseFloat(L).toFixed(2);}N=J+" "+L+" "+M;}if(A.category!=null){var O=A.category.name,Q=A.category.id;G.find("div.tooltipEffectCat").addClass("color_category_"+Q).html(O);}if(A.value==null&&A.category==null){G.find("div.tooltipEffectValColumn").hide();G.find("div.tooltipEffectDescColumn").addClass("tooltipEffectDescColumnWide");}G.find("div.tooltipEffectVal").html(N);if(P>0){B.find("div.tooltipTrait").append(G);}if((P+1)==R.traitDescriptionDTO.effectDescriptions.length){G.find("div.tooltipEffectDivider").remove();}}}else{B.find("div.tooltipTrait").hide();}if(R.ttl!=null){var C=$("#templates .tooltipTrait").clone();C.find(".tooltipEffectDescColumn").html(R.ttl.description);C.find(".tooltipTraitHeader").html("Duration");if(R.ttl.value!=null){C.find("div.tooltipEffectVal").html(R.ttl.value);var E="";if(R.ttl.unit=="Q"){E="questions";}else{if(R.ttl.unit=="CORRECT"){E="correct answers";}}C.find("div.tooltipEffectCat").html(E);}else{C.find("div.tooltipEffectValColumn").css({width:"0"});C.find("div.tooltipEffectDescColumn").css({width:"210px"});}B.find("div.tooltipText").append(C);C.find("div.tooltipEffectDivider").remove();}B.find("div.tooltipRequiredLevel img").css({"background-position":"0 "+(R.requiredLevel*-27-1)+"px"});var D=B.find("div.tooltipRequiredLevel");if(parseInt(R.requiredLevel)>parseInt(S)&&S!=null){D.addClass("red").siblings(".tooltipWrongLevel").show();}else{D.removeClass("red").siblings(".tooltipWrongLevel").hide();}if(R.type){if(R.type=="questionSet"){B.find("img.planetoItemImage").attr("src",getImageUrl("QS",R.iconId,42));}else{B.find("img.planetoItemImage").addClass("spr_"+R.type+"s spr_"+R.type+"_"+R.iconId);}}}function initWearableTooltipComparison(E,C,B){var A=B.attr("rel");if(A!=""){var D=$("#attireSlot_"+A+" div.tooltipcontent").html();if(D){B.find(".comparedItem").html(D);B.find(".tooltipcomparecontent").show();}else{B.find(".comparedItem").empty();B.find(".tooltipcomparecontent").hide();}}}function getImageUrl(D,C,B){var A=resource_null_gif;if(C==""){if(D=="SQ"){switch(B){case 42:A=resource_sq_default_42;break;case 90:A=resource_sq_default_90;break;case"plain":A=resource_sq_default_plain;break;}}else{switch(B){case 42:A=resource_qs_default_42;break;case 90:A=resource_qs_default_90;break;case"plain":A=resource_qs_default_plain;break;}}}else{switch(B){case 42:A="/img/42x42/"+C;break;case 90:A="/img/90x90/"+C;break;case"plain":A="/img/plain/"+C;break;}}return A;}function htmlEncode(A){if(A&&A.replace){return A.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
}}function shortenString(H,E,G,B){var A=[],F=[];if(B){F=H.split(" ");}else{F.push(H);}for(var D=0;D<F.length;D++){var C=F[D];if(C.length>E){C=C.substr(0,E)+G;}A.push(C);}return A.join(" ");}function workAroundLoginToFacebook(F){$("#facebook_account").val("");var B=null;var A=null;var E=function(){var H=$("#facebook_account").val();if(H!=""){$("#facebook_account").val("");clearTimeout(B);var I=null;var G=/.*#.*access_token=([^&]+)/.exec(H);if(G.length>0){I=G[1];}var K=null;var J=/.*#.*signed_request=([^&]+)/.exec(H);if(J.length>0){K=J[1];}this.facade.getInstanceByName("Planeto.Facebook.Control").session={accessToken:I,signedRequest:K,};F(I);}if(window!=null&&window.closed){clearTimeout(B);}};var B=setInterval(E,500);var D="http://"+(location.hostname=="local.planeto.net"?"local.planeto.net:8020":location.hostname);var C="https://www.facebook.com/connect/uiserver.php?app_id="+facebookAppID+"&method=permissions.request&display=page&next="+encodeURIComponent(D+facebook_login_callback_url)+"&response_type=token,signed_request&fbconnect=1&perms=email,publish_stream";var A=window.open(C,"FacebookLogin","toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=1000,height=600");}$.fn.extend({check:function(){return this.each(function(){this.checked=true;});},uncheck:function(){return this.each(function(){this.checked=false;});}});$.fn.encodeHtml=function(A){return this.each(function(){$(this).html(htmlEncode(A));});};String.prototype.startsWith=function(A){return(this.match("^"+A)==A);};String.prototype.endsWith=function(A){return(this.match(A+"$")==A);};var BasicMVC={};(function(){var A=false,B=/xyz/.test(function(){xyz;})?/\b_super\b/:/.*/;this.BasicMVC.Class=function(){};BasicMVC.Class.extend=function(G){var E=this.prototype;A=true;var D=new this();A=false;var F=false;for(var C in G){D[C]=typeof G[C]=="function"&&typeof E[C]=="function"&&B.test(G[C])?(function(H,I){return function(){var K=this._super;this._super=E[H];var J=I.apply(this,arguments);this._super=K;return J;};})(C,G[C]):G[C];if(C=="constructor"){F=true;}}if(!F){D.constructor=G.constructor;}D.localScope=function(J){var H=this,I=arguments;return function(){J.apply(H,I);};delete H;};D.localScopeFull=function(J){var H=this;var I=arguments;return function(){var L=[];for(var K=0;K<arguments.length;K++){L.push(arguments[K]);}if(I!=null){for(var K=0;K<I.length;K++){L.push(I[K]);}}J.apply(H,L);};delete H;};BasicMVC.Class=function(){if(!A&&this.constructor){this.constructor.apply(this,arguments);}};BasicMVC.Class.prototype=D;BasicMVC.Class.constructor=BasicMVC.Class;BasicMVC.Class.extend=arguments.callee;return BasicMVC.Class;};})();BasicMVC.Facade=function(){this.objects=[];this.objectsRef=[];this.objectsFriendlyName={};this.debug=false;this.referencesThroughEventName={};};BasicMVC.Facade.facade;BasicMVC.Facade.getInstance=function(){if(BasicMVC.Facade.facade==null){BasicMVC.Facade.facade=new BasicMVC.Facade();}return BasicMVC.Facade.facade;};BasicMVC.Facade.prototype.register=function(C){if(this.debug){if(C.name==null){console.error("This class doesnt have the name properity set: ",C);throw"doesnt have a name attribute. this is needed in BasicMVC.";}}var A=C.name+"-"+Math.random().toString().replace(/\./,"");C.uniqueName=A;this.objectsRef[A]=C;if(this.objectsFriendlyName[C.name]==null){this.objectsFriendlyName[C.name]=[];}this.objectsFriendlyName[C.name].push(C);var E=C.eventListeners(),B=E.length;for(var D=0;D<B;D++){if(E[D]+""=="undefined"){console.error("ERROR: event name (pos:"+(D+1)+") not defined in object '"+C.name+"' when registering to facade.");}else{if(this.referencesThroughEventName[E[D]]+""=="undefined"){this.referencesThroughEventName[E[D]]=[];}this.referencesThroughEventName[E[D]].push(C);}}this.objects.push(C);return A;};BasicMVC.Facade.prototype.getInstanceByName=function(B){var A=null;if(typeof this.objectsFriendlyName[B]=="object"){if(this.objectsFriendlyName[B].length>1){A=this.objectsFriendlyName[B];}else{A=this.objectsFriendlyName[B][0];}}if(A===null){throw"Class not declared in facade: "+B;
}return A;},BasicMVC.Facade.prototype.hasInstance=function(A){return(typeof this.objectsFriendlyName[A]=="object")?true:false;},BasicMVC.Facade.prototype.unregister=function(A){var C=this.objectsRef[A];if(C){this._unregisterObject(C);}else{var B=this.objectsFriendlyName[A];if(B){for(var D=0;D<=B.length-1;D++){this._unregisterObject(B[D]);}}}},BasicMVC.Facade.prototype._unregisterObject=function(B){var D=B.eventListeners();for(var C=0;C<=D.length-1;C++){for(var A in this.referencesThroughEventName[D[C]]){if(this.referencesThroughEventName[D[C]][A]==B){this.referencesThroughEventName[D[C]].splice(A,1);}}if(this.referencesThroughEventName[D[C]].length==0){delete this.referencesThroughEventName[D[C]];}}this.objectsRef[B.uniqueName]=null;this.objectsFriendlyName[B.name]=null;delete this.objectsFriendlyName[B.name];delete this.objectsRef[B.uniqueName];B.dispose();B=null;delete B;};BasicMVC.Facade.prototype.sendEvent=function(B){var F={name:B};if(arguments.length==2){F.data=arguments[1];}else{if(arguments.length>2){var A=[];for(var C=1;C<arguments.length;C++){A.push(arguments[C]);}F.data=A;}}if(this.debug){if(B+""=="undefined"){console.warn("ERROR: event name not defined when dispatched from '"+this.name+"'");}var G=new Date(),D=G.getHours()+":"+(G.getMinutes()<10?"0"+G.getMinutes():G.getMinutes())+":"+(G.getSeconds()<10?"0"+G.getSeconds():G.getSeconds())+" "+(G.getTime()-(new Date(G.toString())).getTime());if(typeof F.data!="undefined"){console.info("["+D+"] "+B+" - ",F.data);}else{console.info("["+D+"] "+B);}}var H=this.referencesThroughEventName[B];if(H!=null){for(var C=0;C<H.length;C++){try{H[C].eventHandlers(F);}catch(E){console.warn("--",H[C].name,E,B);}}}};BasicMVC.Base=BasicMVC.Class.extend({constructor:function(){},facade:BasicMVC.Facade.getInstance(),sendEvent:function(A){this.facade.sendEvent.apply(this.facade,arguments);},register:function(B){var A;A=this.facade.register(B);if(!this.components){this.components=[];}this.components.push(A);},unregister:function(A){this.facade.unregister(A);this.components[A]=null;delete this.components[A];},unregisterAll:function(){for(var A=0;A<=this.components.length-1;A++){this.facade.unregister(this.components[A]);}this.components=[];},eventListeners:function(){return[];},eventHandlers:function(A,B){throw new TypeError("Cannot be called, must be overriden");},dispose:function(){}});Math.uuid=(function(){var A="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");return function(B,F){var H=A,E=[],D=Math.random;F=F||H.length;if(B){for(var C=0;C<B;C++){E[C]=H[0|D()*F];}}else{var G;E[8]=E[13]=E[18]=E[23]="-";E[14]="4";for(var C=0;C<36;C++){if(!E[C]){G=0|D()*16;E[C]=H[(C==19)?(G&3)|8:G&15];}}}return E.join("");};})();var randomUUID=Math.uuid;Planeto.Application=Planeto.Application||{};Planeto.Application.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Application.Control";this.debug=false;var A=this;this.registerOnStartup=null;this.facade.debug=location.href.indexOf("debug")!=-1;},eventListeners:function(){return[Planeto.Application.Control.INIT];},eventHandlers:function(A){switch(A.name){case Planeto.Application.Control.INIT:this.init(A.data);break;}},init:function(A){this.registerOnStartup=A;this.checkCompability();},checkCompability:function(){if($.browser.msie&&$.browser.version>=8||$.browser.webkit||$.browser.safari||$.browser.mozilla||location.href.indexOf("nobrowsercheck")!=-1){if((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPod/i))||(navigator.userAgent.match(/iPad/i))){var A=this.getIphoneOSVersion(navigator.userAgent);if(A<3.2){this.sendEvent(Planeto.Application.Control.UPGRADE_MOBILE_SAFARI);}else{this.initApp();}}else{this.initApp();}}else{this.sendEvent(Planeto.Application.Control.BROWSER_NOT_SUPPORTED);}},getIphoneOSVersion:function(D){var C=navigator.userAgent.split(" "),A=0;for(var B=0;B<C.length;B++){if(C[B]=="OS"){A=C[B+1];break;}}A=parseFloat(A.replace("_","."));return A;},initApp:function(){this.sendEvent(Planeto.Application.Control.LOAD_FINISHED);
}});Planeto.Application.Control.INIT="Planeto.Application.Control.INIT";Planeto.Application.Control.LOAD_FINISHED="Planeto.Application.Control.LOAD_FINISHED";Planeto.Application.Control.BROWSER_NOT_SUPPORTED="Planeto.Application.Control.BROWSER_NOT_SUPPORTED";Planeto.Application.Control.UPGRADE_MOBILE_SAFARI="Planeto.Application.Control.UPGRADE_MOBILE_SAFARI";if(typeof (Planeto)=="undefined"){Planeto={};}if(typeof (Planeto.SoundFX)=="undefined"){Planeto.SoundFX={};}Planeto.SoundFX.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.SoundFX.Control";this.html5_audio=this.checkHtml5AudioSupport();this.resources=this.getSoundResources();this.activeSounds=[];this.defaultContext="en";this.context=this.defaultContext;this.muted=false;this.disabled=false;this.baseVolume=1;if(!this.html5_audio){this.sendEvent(Planeto.SoundFX.NO_AUDIO_SUPPORT);}this.disabled=!this.html5_audio;sfx=this;},eventListeners:function(){return[Planeto.SoundFX.PLAY,Planeto.SoundFX.STOP,Planeto.SoundFX.MUTE,Planeto.SoundFX.DISABLE,Planeto.SoundFX.FADE_IN,Planeto.SoundFX.FADE_OUT,Planeto.SoundFX.SET_CONTEXT];},eventHandlers:function(A){switch(A.name){case Planeto.SoundFX.PLAY:if(!this.disabled){this.play(A.data.name,A.data.loop,A.data.fadeInTime,A.data.fadeOutTime);}break;case Planeto.SoundFX.STOP:if(!this.disabled){this.stop(A.data.name,A.data.fadeOutTime);}break;case Planeto.SoundFX.DISABLE:this.disabled=A.data;if(this.disabled){this.stopAll();}break;case Planeto.SoundFX.MUTE:if(!this.disabled){this.muted=A.data;this.muteAll(A.data);}break;case Planeto.SoundFX.FADE_IN:if(!this.disabled){this.fadeIn(A.data.name,A.data.time);}break;case Planeto.SoundFX.FADE_OUT:if(!this.disabled){this.fadeOut(A.data.name,A.data.time);}break;case Planeto.SoundFX.SET_CONTEXT:this.setContext(A.data);break;}},setContext:function(A){if(this.resources[A]){this.context=A;}else{console.log("No sound context found with name: "+A);}},getResource:function(A){var B=this.resources[this.context][A];if(!B){B=this.resources[this.defaultContext][A];}if(!B){throw"No sound resource found with name: "+A;}return B;},play:function(B,A,F,E){var D;try{D=this.getResource(B);}catch(C){console.warn(C);}if(D){this.playMedia(B,D.url,A,F,E);}},playMedia:function(A,B,F,K,E){var C=this,H=A+"_"+this.guid(),I="soundfx-"+H,D;D=$("<audio>");D.attr("id",H);D.attr("src",B);if(F){D.attr("loop","loop");}$("body").append(D);D=document.getElementById(H);var J={identity:H,name:A,audio:D};this.addActiveSound(J);if(!F&&E){D.addEventListener("timeupdate",function(N){var M=D.duration*1000,L=M-E;currentTime=D.currentTime*1000;if(currentTime>=L&&!D.fadeActive){D.fadeActive=true;C.fadeOut(A,E);}},false);}D.addEventListener("ended",function(L){if(F){D.currentTime=0;}else{C.removeActiveSound(A,H);}},false);if(K){try{D.volume=0;}catch(G){console.warn("fadeInTime error: ",G);}this.fadeIn(A,K);}if(this.muted){D.muted=true;}D.play();},addActiveSound:function(A){if(!this.activeSounds[A.name]){this.activeSounds[A.name]=[];}this.activeSounds[A.name][A.identity]=A;},removeActiveSounds:function(C){var B=this.activeSounds[C];for(var A in B){this.removeActiveSound(C,A);}delete this.activeSounds[C];},removeActiveSound:function(B,A){var D;try{if(this.activeSounds[B]&&this.activeSounds[B][A]){D=this.activeSounds[B][A];this.removeDOMElements(D);delete this.activeSounds[B][A];if(this.itemCount(this.activeSounds[B])==0){this.removeActiveSounds(B);}}}catch(C){console.warn(C);}},removeDOMElements:function(A){$("#"+A.identity).remove();},stop:function(C,F){var B=this.activeSounds[C],D=this;if(!B){return ;}for(var A in B){var E=B[A];if(F){this.fadeOut(C,F);setTimeout(function(){D.removeActiveSounds(C);},F+1000);}else{E.audio.currentTime=0;E.audio.pause();}}if(!F){this.removeActiveSounds(C);}},fadeOut:function(C,E){var B=this.activeSounds[C];if(!B){return ;}if(!E){E=1000;}for(var A in B){var D=B[A];this.fader(D,E,true);}},fadeIn:function(C,E){var B=this.activeSounds[C];if(!B){return ;}if(!E){E=1000;}for(var A in B){var D=B[A];this.fader(D,E,false);
}},muteAll:function(D){var C,E;for(var B in this.activeSounds){C=this.activeSounds[B];for(var A in C){E=C[A];E.audio.muted=D;}}},stopAll:function(){for(var C in this.activeSounds){var B=this.activeSounds[C];if(!B){return ;}for(var A in B){var D=B[A];D.audio.currentTime=0;D.audio.pause();}this.removeActiveSounds(C);}},checkHtml5AudioSupport:function(){return !!(document.createElement("audio").canPlayType);},fader:function(E,D,B){var A=D/100,F=1/A,C=null;C=setInterval(function(){var G;if(B){G=E.audio.volume-F;}if(!B){G=E.audio.volume+F;}if(G>1){G=1;}if(G<0){G=0;}try{E.audio.volume=G;}catch(H){console.warn("fader error: ",H,"\n",E.audio);}A--;if(A==0){E.fadeActive=false;clearInterval(C);}},100);},getSoundResources:function(){var D=[],A;if(typeof (RuntimeObject)=="undefined"){A=window;}else{A=RuntimeObject();}for(var E in A){if(E.match(/resource_sfx/)){var C={},B=E.split("_");if(B.length>=4){C.context=B[2];C.name=B.slice(3).join("_");C.url=window[E];if(!D[C.context]){D[C.context]=[];}D[C.context][C.name]=C;}}}return D;},guid:function(){var A=function(){return(((1+Math.random())*65536)|0).toString(16).substring(1);};return(A()+A()+"-"+A()+"-"+A()+"-"+A()+"-"+A()+A()+A());},itemCount:function(C){var B=0;for(var A in C){if(C.propertyIsEnumerable(A)){B++;}}return B;}});Planeto.SoundFX.PLAY="Planeto.SoundFX.PLAY";Planeto.SoundFX.STOP="Planeto.SoundFX.STOP";Planeto.SoundFX.MUTE="Planeto.SoundFX.MUTE";Planeto.SoundFX.DISABLE="Planeto.SoundFX.DISABLE";Planeto.SoundFX.FADE_IN="Planeto.SoundFX.FADE_IN";Planeto.SoundFX.FADE_OUT="Planeto.SoundFX.FADE_OUT";Planeto.SoundFX.SET_CONTEXT="Planeto.SoundFX.SET_CONTEXT";Planeto.SoundFX.NO_AUDIO_SUPPORT="Planeto.SoundFX.NO_AUDIO_SUPPORT";BasicMVC.Facade.getInstance().register(new Planeto.SoundFX.Control());BrowserErrorView=BasicMVC.Base.extend({constructor:function(){this.name="BrowserErrorView";},eventListeners:function(){return[Planeto.Application.Control.BROWSER_NOT_SUPPORTED,Planeto.Application.Control.UPGRADE_MOBILE_SAFARI];},eventHandlers:function(A){switch(A.name){case Planeto.Application.Control.BROWSER_NOT_SUPPORTED:this.showDialog();break;case Planeto.Application.Control.UPGRADE_MOBILE_SAFARI:this.showUpgradeMobileSafariDialog();break;}},showDialog:function(){$("#dialogWrongBrowser").modal();},showUpgradeMobileSafariDialog:function(){var A=$("#dialogUpgradeMobileSafari");if(navigator.userAgent.match(/iPod/i)){A.find(".iphone").remove();}else{if(navigator.userAgent.match(/iPhone/i)){A.find(".ipod").remove();}else{A.find(".ipod").remove();}}A.modal();}});BasicMVC.Facade.getInstance().register(new BrowserErrorView());(function($){$.toJSON=function(o){if(typeof (JSON)=="object"&&JSON.stringify){return JSON.stringify(o);}var type=typeof (o);if(o===null){return"null";}if(type=="undefined"){return undefined;}if(type=="number"||type=="boolean"){return o+"";}if(type=="string"){return $.quoteString(o);}if(type=="object"){if(typeof o.toJSON=="function"){return $.toJSON(o.toJSON());}if(o.constructor===Date){var month=o.getUTCMonth()+1;if(month<10){month="0"+month;}var day=o.getUTCDate();if(day<10){day="0"+day;}var year=o.getUTCFullYear();var hours=o.getUTCHours();if(hours<10){hours="0"+hours;}var minutes=o.getUTCMinutes();if(minutes<10){minutes="0"+minutes;}var seconds=o.getUTCSeconds();if(seconds<10){seconds="0"+seconds;}var milli=o.getUTCMilliseconds();if(milli<100){milli="0"+milli;}if(milli<10){milli="0"+milli;}return'"'+year+"-"+month+"-"+day+"T"+hours+":"+minutes+":"+seconds+"."+milli+'Z"';}if(o.constructor===Array){var ret=[];for(var i=0;i<o.length;i++){ret.push($.toJSON(o[i])||"null");}return"["+ret.join(",")+"]";}var pairs=[];for(var k in o){var name;var type=typeof k;if(type=="number"){name='"'+k+'"';}else{if(type=="string"){name=$.quoteString(k);}else{continue;}}if(typeof o[k]=="function"){continue;}var val=$.toJSON(o[k]);pairs.push(name+":"+val);}return"{"+pairs.join(", ")+"}";}};$.evalJSON=function(src){if(typeof (JSON)=="object"&&JSON.parse){return JSON.parse(src);}return eval("("+src+")");};
$.secureEvalJSON=function(src){if(typeof (JSON)=="object"&&JSON.parse){return JSON.parse(src);}var filtered=src;filtered=filtered.replace(/\\["\\\/bfnrtu]/g,"@");filtered=filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]");filtered=filtered.replace(/(?:^|:|,)(?:\s*\[)+/g,"");if(/^[\],:{}\s]*$/.test(filtered)){return eval("("+src+")");}else{throw new SyntaxError("Error parsing JSON, source is not valid.");}};$.quoteString=function(string){if(string.match(_escapeable)){return'"'+string.replace(_escapeable,function(a){var c=_meta[a];if(typeof c==="string"){return c;}c=a.charCodeAt();return"\\u00"+Math.floor(c/16).toString(16)+(c%16).toString(16);})+'"';}return'"'+string+'"';};var _escapeable=/["\\\x00-\x1f\x7f-\x9f]/g;var _meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};})(jQuery);(function(B){org.cometd.JSON.toJSON=B.toJSON;org.cometd.JSON.fromJSON=B.secureEvalJSON;function A(D,C){if(C){for(var E in C){if(E.toLowerCase()==="content-type"){continue;}D.setRequestHeader(E,C[E]);}}}B.cometd=new org.cometd.Cometd();B.cometd.LongPollingTransport=function(){this.xhrSend=function(C){return B.ajax({url:C.url,async:C.sync!==true,type:"POST",contentType:"application/json;charset=UTF-8",data:C.body,beforeSend:function(D){A(D,C.headers);return true;},success:C.onSuccess,error:function(F,E,D){C.onError(E,D);}});};};B.cometd.LongPollingTransport.prototype=new org.cometd.LongPollingTransport();B.cometd.LongPollingTransport.prototype.constructor=B.cometd.LongPollingTransport;B.cometd.CallbackPollingTransport=function(){this.jsonpSend=function(C){B.ajax({url:C.url,async:C.sync!==true,type:"GET",dataType:"jsonp",jsonp:"jsonp",data:{message:C.body},beforeSend:function(D){A(D,C.headers);return true;},success:C.onSuccess,error:function(F,E,D){C.onError(E,D);}});};};B.cometd.CallbackPollingTransport.prototype=new org.cometd.CallbackPollingTransport();B.cometd.CallbackPollingTransport.prototype.constructor=B.cometd.CallbackPollingTransport;B.cometd.registerTransport("long-polling",new B.cometd.LongPollingTransport());B.cometd.registerTransport("callback-polling",new B.cometd.CallbackPollingTransport());})(jQuery);MessageStackBaseView=BasicMVC.Base.extend({config:function(A){this.messageStackId=A.messageStackId;this.messageItemId=A.messageItemId;this.dataId=A.dataId;this.messageTemplate=$(A.messageTemplate);},addToView:function(A){this.list.push(A);this.renderCurrentList();},renderCurrentList:function(){var C=$(this.messageStackId),G={},B=$(this.messageStackId+" > div");for(var F=0;F<this.list.length;F++){G[this.list[F][this.dataId]]="exists";var I=this.list[F],E=$(this.messageItemId+I[this.dataId]),D=E.data("timeoutRef")==null?-1:parseInt(E.data("timeoutRef")),H;clearTimeout(D);if(F>0){H=this.lastMessage+this.messageHeight;}else{H=9;}this.lastMessage=H;this.messageHeight=I.type=="item"?42:46;if(E.length==0){E=this.createMessageDom(I);C.append(E);var D=setTimeout(CallbackProxy(this,function(){$(this.messageItemId+I[this.dataId]).css({position:"absolute",bottom:"238px"}).animate({bottom:H+"px"},500);}),F*300);E.data("timeoutRef",D);}else{this.updateMessageDom(I,E);E.animate({bottom:H+"px"});}}for(var F=0;F<B.length;F++){var A=$(B[F]);if(G[A.data("id")]!=="exists"){A.remove();}}delete G;},opacity:function(A){return A.active?1:0.4;}});var PlanetoEvents={};PlanetoEvents.KICK_PLAYER_FROM_TEAM_RESPONSE="team.KickPlayerFromTeamResponse";PlanetoEvents.TEAM_INVITATION_RESPONSE="team.TeamInvitationResponse";PlanetoEvents.LEFT_TEAM_RESPONSE="team.LeftTeamResponse";PlanetoEvents.TEAM_MEMBER_LEFT_EVENT="team.TeamMemberLeftEvent";PlanetoEvents.TEAM_DISBANDED_EVENT="team.TeamDisbandedEvent";PlanetoEvents.GET_TEAM_MEMBERS_RESPONSE="team.GetTeamMembersResponse";PlanetoEvents.IS_TEAM_NAME_AVAILABLE_RESPONSE="team.IsTeamNameAvailableResponse";PlanetoEvents.PLAYER_JOINED_TEAM_EVENT="team.PlayerJoinedTeamEvent";PlanetoEvents.INVITE_TO_TEAM_RESPONSE="team.InviteToTeamResponse";PlanetoEvents.DISBAND_TEAM_RESPONSE="team.DisbandTeamResponse";
PlanetoEvents.GET_TEAMS_LIST_RESPONSE="team.GetTeamsListResponse";PlanetoEvents.INITIATE_CREATE_TEAM_RESPONSE="team.InitiateCreateTeamResponse";PlanetoEvents.KICKED_FROM_TEAM_EVENT="team.KickedFromTeamEvent";PlanetoEvents.CREATE_TEAM_RESPONSE="team.CreateTeamResponse";PlanetoEvents.GET_TEAM_INFO_RESPONSE="team.GetTeamInfoResponse";PlanetoEvents.ACCEPT_TEAM_INVITATION_RESULT_RESPONSE="team.AcceptTeamInvitationResultResponse";PlanetoEvents.TEAM_MEMBER_JOINED_EVENT="team.TeamMemberJoinedEvent";PlanetoEvents.FRIEND_ONLINE_STATUS_CHANGED_EVENT="user.FriendOnlineStatusChangedEvent";PlanetoEvents.META_DATA_CHANGED_EVENT="metadata.MetaDataChangedEvent";PlanetoEvents.INITIATE_SOCIAL_GOLD_PURCHASE_RESPONSE="payment.InitiateSocialGoldPurchaseResponse";PlanetoEvents.LIST_CITIES_RESPONSE="common.location.ListCitiesResponse";PlanetoEvents.LOCATION_SELECTION_RESPONSE="common.location.LocationSelectionResponse";PlanetoEvents.LEFT_CHAT_ROOM_EVENT="chat.LeftChatRoomEvent";PlanetoEvents.CHAT_ROOM_STATE_EVENT="chat.ChatRoomStateEvent";PlanetoEvents.MESSAGE_RECEIVED_EVENT="chat.MessageReceivedEvent";PlanetoEvents.CHAT_ROOMS_AVAILABLE_EVENT="chat.ChatRoomsAvailableEvent";PlanetoEvents.INVITE_STATE_EVENT="account.invite.InviteStateEvent";PlanetoEvents.INVITE_BY_EMAIL_RESPONSE="account.invite.InviteByEmailResponse";PlanetoEvents.IS_INVITED_BY_EMAIL_RESPONSE="account.invite.IsInvitedByEmailResponse";PlanetoEvents.LOGIN_RESPONSE="account.LoginResponse";PlanetoEvents.IGNORE_USER_LIST_CHANGED_EVENT="account.IgnoreUserListChangedEvent";PlanetoEvents.CONVERT_LOGIN_RESULT_RESPONSE="account.ConvertLoginResultResponse";PlanetoEvents.AWARD_ROLE_FROM_INVITATION_RESPONSE="account.AwardRoleFromInvitationResponse";PlanetoEvents.GET_MATCHING_CITIES_RESPONSE="account.simpleusersettings.GetMatchingCitiesResponse";PlanetoEvents.GET_USER_SETTINGS_RESPONSE="account.simpleusersettings.GetUserSettingsResponse";PlanetoEvents.FORCED_LOGOUT_EVENT="account.ForcedLogoutEvent";PlanetoEvents.LOGOUT_RESPONSE="account.LogoutResponse";PlanetoEvents.VERIFY_BETA_ACCOUNT_RESPONSE="account.VerifyBetaAccountResponse";PlanetoEvents.GENERATE_ACCOUNT_ROLE_INVITATION_RESPONSE="account.GenerateAccountRoleInvitationResponse";PlanetoEvents.OPEN_ID_REDIRECT_EVENT="account.openid.OpenIdRedirectEvent";PlanetoEvents.USER_LOCATION_UPDATED_EVENT="account.UserLocationUpdatedEvent";PlanetoEvents.QUESTION_LANGUAGES_EVENT="account.QuestionLanguagesEvent";PlanetoEvents.GET_FACEBOOK_ID_FOR_FRIEND_RESPONSE="account.GetFacebookIdForFriendResponse";PlanetoEvents.ACCOUNT_ROLE_RESPONSE="account.AccountRoleResponse";PlanetoEvents.RPC_EXCEPTION_RESPONSE="rpc.RpcExceptionResponse";PlanetoEvents.HEARTBEAT_EVENT="site.HeartbeatEvent";PlanetoEvents.TOP_PLAYERS_RESPONSE="site.homepage.TopPlayersResponse";PlanetoEvents.IDLE_EVENT="site.IdleEvent";PlanetoEvents.CONNECT_RESPONSE="site.ConnectResponse";PlanetoEvents.PING_RESPONSE="site.PingResponse";PlanetoEvents.GETTING_USER_ID_FROM_FACEBOOK_FAILED_EVENT="site.GettingUserIdFromFacebookFailedEvent";PlanetoEvents.NOTIFICATION_EVENT="site.notification.NotificationEvent";PlanetoEvents.NOTIFICATION_TYPE_DTO="site.notification.NotificationTypeDTO";PlanetoEvents.GET_ALL_QUESTION_LANGUAGES_RESPONSE="ucq.create.GetAllQuestionLanguagesResponse";PlanetoEvents.GET_AVAILABLE_STAR_HUNT_TYPES_RESPONSE="ucq.create.starhunt.GetAvailableStarHuntTypesResponse";PlanetoEvents.STAR_HUNT_USER_CREATED_CONTENT_CHANGED="ucq.create.starhunt.StarHuntUserCreatedContentChanged";PlanetoEvents.GET_USER_CREATED_CONTENT_RESPONSE="ucq.create.GetUserCreatedContentResponse";PlanetoEvents.UCQSAVE_FAILED_EVENT="ucq.create.UCQSaveFailedEvent";PlanetoEvents.USER_CREATED_CONTENT_REMOVED_EVENT="ucq.create.UserCreatedContentRemovedEvent";PlanetoEvents.USER_CREATED_CONTENT_IS_PENDING_EVENT="ucq.create.UserCreatedContentIsPendingEvent";PlanetoEvents.USER_CREATED_CONTENT_CHANGED_EVENT="ucq.create.UserCreatedContentChangedEvent";PlanetoEvents.USER_CREATED_CONTENT_ADDED_EVENT="ucq.create.UserCreatedContentAddedEvent";PlanetoEvents.USER_CREATED_CONTENT_REFRESHED_EVENT="ucq.create.UserCreatedContentRefreshedEvent";
PlanetoEvents.PUBLISH_FAILED_EVENT="ucq.create.PublishFailedEvent";PlanetoEvents.NEW_UCQSESSION_RESPONSE="ucq.application.NewUCQSessionResponse";PlanetoEvents.RECEIVE_BONUS_FOR_WAVE_RESPONSE="wave.ReceiveBonusForWaveResponse";PlanetoEvents.WAVE_DTO="wave.WaveDTO";PlanetoEvents.WAVE_PARTICIPANT_DTO="wave.WaveParticipantDTO";PlanetoEvents.PASS_WAVE_RESPONSE="wave.PassWaveResponse";PlanetoEvents.GET_WAVES_RESPONSE="wave.GetWavesResponse";PlanetoEvents.WAVE_ENDED_EVENT="wave.WaveEndedEvent";PlanetoEvents.SEARCH_QUESTION_SET_FOR_WAVE_RESPONSE="wave.SearchQuestionSetForWaveResponse";PlanetoEvents.CREATE_WAVE_RESPONSE="wave.CreateWaveResponse";PlanetoEvents.WAVE_MESSAGE_RECEIVED_EVENT="wave.WaveMessageReceivedEvent";PlanetoEvents.WAVE_STATISTICS_DTO="wave.WaveStatisticsDTO";PlanetoEvents.BULLETIN_LIST_RESPONSE="quiz.bulletin.BulletinListResponse";PlanetoEvents.NEXT_TIPS_AND_TRICKS_RESPONSE="quiz.tips.NextTipsAndTricksResponse";PlanetoEvents.TEAM_LEADER_BOARD_DATA_RESPONSE="quiz.leaderboard.team.TeamLeaderBoardDataResponse";PlanetoEvents.LEADER_BOARD_DATA_RESPONSE="quiz.leaderboard.LeaderBoardDataResponse";PlanetoEvents.ITEM_FROM_LINK_BONUS_EVENT="quiz.item.ItemFromLinkBonusEvent";PlanetoEvents.QUIZ_APPLICATION_STOPPED_EVENT="quiz.QuizApplicationStoppedEvent";PlanetoEvents.MEDAL_RECEIVED_EVENT="quiz.medal.MedalReceivedEvent";PlanetoEvents.SET_MEDALS_AND_PROGRESS_EVENT="quiz.medal.SetMedalsAndProgressEvent";PlanetoEvents.SELF_QUIZ_STARTED_EVENT="quiz.selfquiz.SelfQuizStartedEvent";PlanetoEvents.GET_SOME_SELF_QUIZES_RESPONSE="quiz.selfquiz.GetSomeSelfQuizesResponse";PlanetoEvents.SUBMIT_SELF_QUIZ_ANSWERS_RESPONSE="quiz.selfquiz.SubmitSelfQuizAnswersResponse";PlanetoEvents.GET_AVAILABLE_SELF_QUIZES_RESPONSE="quiz.selfquiz.GetAvailableSelfQuizesResponse";PlanetoEvents.GET_LOGOUT_SESSION_SUMMARY_RESPONSE="quiz.GetLogoutSessionSummaryResponse";PlanetoEvents.BUY_MORE_INVENTORY_SPACE_RESPONSE="quiz.inventory.BuyMoreInventorySpaceResponse";PlanetoEvents.ALL_QUESTIONS_ANSWERED_IN_DOMAIN_EVENT="quiz.knowledgedomain.AllQuestionsAnsweredInDomainEvent";PlanetoEvents.NEW_KNOWLEDGE_DOMAINS_ACTIVATED_FOR_TESTING_EVENT="quiz.knowledgedomain.NewKnowledgeDomainsActivatedForTestingEvent";PlanetoEvents.CERTIFIED_AS_EXPERT_EVENT="quiz.knowledgedomain.CertifiedAsExpertEvent";PlanetoEvents.QUEST_FAILED_EVENT="quiz.quest.QuestFailedEvent";PlanetoEvents.GET_QUESTS_RESPONSE="quiz.quest.GetQuestsResponse";PlanetoEvents.ACTIVATE_QUEST_EVENT="quiz.quest.ActivateQuestEvent";PlanetoEvents.NO_QUEST_AVAILABLE_EVENT="quiz.quest.NoQuestAvailableEvent";PlanetoEvents.QUEST_SLOT_CLEARED_EVENT="quiz.quest.QuestSlotClearedEvent";PlanetoEvents.QUEST_ASSIGNED_EVENT="quiz.quest.QuestAssignedEvent";PlanetoEvents.QUEST_FULFILLED_EVENT="quiz.quest.QuestFulfilledEvent";PlanetoEvents.QUEST_PROGRESS_UPDATED_EVENT="quiz.quest.QuestProgressUpdatedEvent";PlanetoEvents.GET_COMPLETED_QUESTS_RESPONSE="quiz.quest.GetCompletedQuestsResponse";PlanetoEvents.CLIENT_WON_DUEL_EVENT="quiz.duel.ClientWonDuelEvent";PlanetoEvents.DUEL_SHOW_CORRECT_ANSWER_EVENT="quiz.duel.DuelShowCorrectAnswerEvent";PlanetoEvents.DUEL_OPPONENT_SCORE_MULTIPLIER_CHANGED_EVENT="quiz.duel.DuelOpponentScoreMultiplierChangedEvent";PlanetoEvents.DUEL_STREAK_CHANGED_EVENT="quiz.duel.DuelStreakChangedEvent";PlanetoEvents.DUEL_OPPONENT_ANSWERED_QUESTION_EVENT="quiz.duel.DuelOpponentAnsweredQuestionEvent";PlanetoEvents.DUEL_OPPONENT_STREAK_CHANGED_EVENT="quiz.duel.DuelOpponentStreakChangedEvent";PlanetoEvents.CLIENT_LOST_DUEL_EVENT="quiz.duel.ClientLostDuelEvent";PlanetoEvents.DUEL_SCORE_MULTIPLIER_CHANGED_EVENT="quiz.duel.DuelScoreMultiplierChangedEvent";PlanetoEvents.DUEL_CHI_CHANGED_EVENT="quiz.duel.DuelChiChangedEvent";PlanetoEvents.START_DUEL_EVENT="quiz.duel.StartDuelEvent";PlanetoEvents.DUEL_OPPONENT_SCORE_CHANGED_EVENT="quiz.duel.DuelOpponentScoreChangedEvent";PlanetoEvents.DUEL_OPPONENT_UPDATED_EVENT="quiz.duel.DuelOpponentUpdatedEvent";PlanetoEvents.DUEL_ROUND_SUMMARY_EVENT="quiz.duel.DuelRoundSummaryEvent";PlanetoEvents.DUEL_PLAYER_UPDATED_EVENT="quiz.duel.DuelPlayerUpdatedEvent";
PlanetoEvents.CLIENT_DUEL_DRAW_EVENT="quiz.duel.ClientDuelDrawEvent";PlanetoEvents.DUEL_PLAYER_ANSWERED_QUESTION_EVENT="quiz.duel.DuelPlayerAnsweredQuestionEvent";PlanetoEvents.DUEL_SHOW_ANSWER_ALTERNATIVES_EVENT="quiz.duel.DuelShowAnswerAlternativesEvent";PlanetoEvents.DUEL_OPPONENT_CHI_CHANGED_EVENT="quiz.duel.DuelOpponentChiChangedEvent";PlanetoEvents.DUEL_SHOW_QUESTIONS_EVENT="quiz.duel.DuelShowQuestionsEvent";PlanetoEvents.DUEL_ENDED_EVENT="quiz.duel.DuelEndedEvent";PlanetoEvents.QUESTION_SET_STARTED_EVENT="quiz.questionset.QuestionSetStartedEvent";PlanetoEvents.GET_REWARD_FOR_CHALLENGING_AFRIEND_RESPONSE="quiz.questionset.GetRewardForChallengingAFriendResponse";PlanetoEvents.QUESTION_SET_STOPPED_EVENT="quiz.questionset.QuestionSetStoppedEvent";PlanetoEvents.GET_COMPLETED_QUESTION_SETS_RESPONSE="quiz.questionset.GetCompletedQuestionSetsResponse";PlanetoEvents.GET_QUESTION_SET_LEADERBOARD_RESPONSE="quiz.questionset.GetQuestionSetLeaderboardResponse";PlanetoEvents.GET_SOME_QUESTION_SETS_RESPONSE="quiz.questionset.GetSomeQuestionSetsResponse";PlanetoEvents.UPDATE_FEED_FULL_UPDATE_EVENT="quiz.updatefeed.UpdateFeedFullUpdateEvent";PlanetoEvents.UPDATE_FEED_SINGLE_UPDATE_EVENT="quiz.updatefeed.UpdateFeedSingleUpdateEvent";PlanetoEvents.FRIEND_SCORE_CHANGED_EVENT="quiz.friendslist.FriendScoreChangedEvent";PlanetoEvents.SHOW_FRIENDS_LIST_EVENT="quiz.friendslist.ShowFriendsListEvent";PlanetoEvents.GAME_STARTED_EVENT="quiz.GameStartedEvent";PlanetoEvents.GET_SESSION_STATS_RESPONSE="quiz.GetSessionStatsResponse";PlanetoEvents.LOBBY_LEFT_EVENT="quiz.lobby.LobbyLeftEvent";PlanetoEvents.LOBBY_STATE_EVENT="quiz.lobby.LobbyStateEvent";PlanetoEvents.LOBBY_CHANGED_OTHER_PLAYER_LEFT_EVENT="quiz.lobby.LobbyChangedOtherPlayerLeftEvent";PlanetoEvents.CHALLENGE_TO_DUEL_EVENT="quiz.lobby.ChallengeToDuelEvent";PlanetoEvents.CHALLENGE_WITHDRAWN_EVENT="quiz.lobby.ChallengeWithdrawnEvent";PlanetoEvents.LOBBY_CHANGED_OTHER_PLAYER_DECLINED_CHALLENGE_EVENT="quiz.lobby.LobbyChangedOtherPlayerDeclinedChallengeEvent";PlanetoEvents.NEW_QUIZ_EVENT="quiz.game.NewQuizEvent";PlanetoEvents.STAR_HUNT_FOCUS_DEPLETED_EVENT="quiz.game.starhunt.StarHuntFocusDepletedEvent";PlanetoEvents.STAR_HUNT_MAP_CHANGED_EVENT="quiz.game.starhunt.StarHuntMapChangedEvent";PlanetoEvents.GET_STAR_HUNT_MISSION_PACKS_RESPONSE="quiz.game.starhunt.GetStarHuntMissionPacksResponse";PlanetoEvents.GET_STAR_HUNT_MAP_CHAINS_RESPONSE="quiz.game.starhunt.GetStarHuntMapChainsResponse";PlanetoEvents.STAR_HUNT_MAP_STARTED_EVENT="quiz.game.starhunt.StarHuntMapStartedEvent";PlanetoEvents.STAR_HUNT_FOCUS_CHANGED_EVENT="quiz.game.starhunt.StarHuntFocusChangedEvent";PlanetoEvents.PURCHASE_STAR_HUNT_MISSION_PACK_RESPONSE="quiz.game.starhunt.PurchaseStarHuntMissionPackResponse";PlanetoEvents.STAR_HUNT_MAP_CHAIN_COMPLETED_EVENT="quiz.game.starhunt.StarHuntMapChainCompletedEvent";PlanetoEvents.NEW_STAR_HUNT_MAP_EVENT="quiz.game.starhunt.NewStarHuntMapEvent";PlanetoEvents.GET_STAR_HUNT_MAP_RESPONSE="quiz.game.starhunt.GetStarHuntMapResponse";PlanetoEvents.STAR_HUNT_PLAYER_LOCATION_CHANGED_EVENT="quiz.game.starhunt.StarHuntPlayerLocationChangedEvent";PlanetoEvents.STAR_HUNT_EFFECT_ACTIVATED_EVENT="quiz.game.starhunt.StarHuntEffectActivatedEvent";PlanetoEvents.STAR_HUNT_MAP_COMPLETED_EVENT="quiz.game.starhunt.StarHuntMapCompletedEvent";PlanetoEvents.RESPITE_EVENT="quiz.game.RespiteEvent";PlanetoEvents.SHOW_JACKPOT_EVENT="quiz.game.ShowJackpotEvent";PlanetoEvents.SHOW_QUESTION_EVENT="quiz.game.ShowQuestionEvent";PlanetoEvents.NEW_QUIZ_RESPONSE="quiz.game.NewQuizResponse";PlanetoEvents.STOP_DISPLAYING_QUESTION_EVENT="quiz.game.StopDisplayingQuestionEvent";PlanetoEvents.ANSWERS_UPDATED_EVENT="quiz.game.AnswersUpdatedEvent";PlanetoEvents.GET_DROP_RESPONSE="quiz.game.GetDropResponse";PlanetoEvents.LOST_STREAK_EVENT="quiz.game.LostStreakEvent";PlanetoEvents.TIME_CHANGED_EVENT="quiz.game.TimeChangedEvent";PlanetoEvents.FRIENDS_LIST_PASSING_EVENT="quiz.game.FriendsListPassingEvent";PlanetoEvents.PAUSE_EVENT="quiz.game.PauseEvent";
PlanetoEvents.SHOW_BANNER_EVENT="quiz.game.ShowBannerEvent";PlanetoEvents.QUESTION_SKIPPED_EVENT="quiz.game.QuestionSkippedEvent";PlanetoEvents.END_QUIZ_EVENT="quiz.game.EndQuizEvent";PlanetoEvents.GAME_ROOM_PARTICIPANT_CHANGED_EVENT="quiz.gameroom.GameRoomParticipantChangedEvent";PlanetoEvents.GET_AVAILABLE_GAME_ROOM_GAMES_RESPONSE="quiz.gameroom.GetAvailableGameRoomGamesResponse";PlanetoEvents.GAME_ROOM_JOINED_EVENT="quiz.gameroom.GameRoomJoinedEvent";PlanetoEvents.QUIZ_RACE_COUNT_DOWN_TO_START_EVENT="quiz.gameroom.quizrace.QuizRaceCountDownToStartEvent";PlanetoEvents.QUIZ_RACE_LANE_PROGRESS_CHANGED_EVENT="quiz.gameroom.quizrace.QuizRaceLaneProgressChangedEvent";PlanetoEvents.QUIZ_RACE_WON_BY_PLAYER_EVENT="quiz.gameroom.quizrace.QuizRaceWonByPlayerEvent";PlanetoEvents.RESET_QUIZ_RACE_EVENT="quiz.gameroom.quizrace.ResetQuizRaceEvent";PlanetoEvents.KICKED_FROM_GAME_ROOM_EVENT="quiz.gameroom.KickedFromGameRoomEvent";PlanetoEvents.NEW_HOT_SEAT_HOLDER_EVENT="quiz.gameroom.hotseat.NewHotSeatHolderEvent";PlanetoEvents.PLAYERS_WAITING_FOR_OTHERS_CHANGED_EVENT="quiz.gameroom.PlayersWaitingForOthersChangedEvent";PlanetoEvents.TEAM_GAME_ROOM_FULL_EVENT="quiz.gameroom.TeamGameRoomFullEvent";PlanetoEvents.SHOW_COUNT_DOWN_TO_NEXT_PICTURE_QUIZ_ROUND_EVENT="quiz.gameroom.picturequiz.ShowCountDownToNextPictureQuizRoundEvent";PlanetoEvents.UNVEIL_PICTURE_QUIZ_IMAGE_EVENT="quiz.gameroom.picturequiz.UnveilPictureQuizImageEvent";PlanetoEvents.PICTURE_GRID_CELL_SOLVED_EVENT="quiz.gameroom.picturequiz.PictureGridCellSolvedEvent";PlanetoEvents.PICTURE_GRID_CELL_SOLVER_CHANGED_EVENT="quiz.gameroom.picturequiz.PictureGridCellSolverChangedEvent";PlanetoEvents.NEW_VOTE_TO_SKIP_PICTURE_EVENT="quiz.gameroom.picturequiz.NewVoteToSkipPictureEvent";PlanetoEvents.SHOW_MOTIF_DESCRIPTION_AND_WINNER="quiz.gameroom.picturequiz.ShowMotifDescriptionAndWinner";PlanetoEvents.NEW_PICTURE_QUIZ_GRID_EVENT="quiz.gameroom.picturequiz.NewPictureQuizGridEvent";PlanetoEvents.SHOW_PICTURE_QUIZ_ROUND_SUMMARY_SCREEN_EVENT="quiz.gameroom.picturequiz.ShowPictureQuizRoundSummaryScreenEvent";PlanetoEvents.GAME_ROOM_FULL_EVENT="quiz.gameroom.GameRoomFullEvent";PlanetoEvents.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME_RESPONSE="quiz.gameroom.GetGameRoomsAndCollectionsForGameResponse";PlanetoEvents.GAME_ROOM_UPDATED_EVENT="quiz.gameroom.GameRoomUpdatedEvent";PlanetoEvents.UPDATE_STANDARD_ACTIONS_EVENT="quiz.action.UpdateStandardActionsEvent";PlanetoEvents.UPDATE_PERFORMING_ACTIONS_EVENT="quiz.action.UpdatePerformingActionsEvent";PlanetoEvents.ACTIONBAR_CHANGED_RESPONSE_EVENT="quiz.player.ActionbarChangedResponseEvent";PlanetoEvents.PLAYER_PROFILE_PIC_UPDATED_EVENT="quiz.player.PlayerProfilePicUpdatedEvent";PlanetoEvents.PLAYER_NAME_UPDATED_EVENT="quiz.player.PlayerNameUpdatedEvent";PlanetoEvents.GOLD_CHANGED_EVENT="quiz.player.GoldChangedEvent";PlanetoEvents.PLAYER_UPDATED_EVENT="quiz.player.PlayerUpdatedEvent";PlanetoEvents.JACKPOT_CHANGED_EVENT="quiz.player.JackpotChangedEvent";PlanetoEvents.ATTIRE_CHANGED_EVENT="quiz.player.AttireChangedEvent";PlanetoEvents.SCORE_CHANGED_EVENT="quiz.player.ScoreChangedEvent";PlanetoEvents.STREAK_CHANGED_EVENT="quiz.player.StreakChangedEvent";PlanetoEvents.INVENTORY_CHANGED_EVENT="quiz.player.InventoryChangedEvent";PlanetoEvents.LEVEL_UP_EVENT="quiz.player.LevelUpEvent";PlanetoEvents.ACTION_BAR_ITEM_REMOVED_EVENT="quiz.player.ActionBarItemRemovedEvent";PlanetoEvents.SCORE_MULTIPLIER_CHANGED_EVENT="quiz.player.ScoreMultiplierChangedEvent";PlanetoEvents.SKILL_VALUE_CHANGED_EVENT="quiz.player.SkillValueChangedEvent";PlanetoEvents.GET_MASTERY_POINTS_RESPONSE="quiz.GetMasteryPointsResponse";PlanetoEvents.LINK_BONUS_WILL_BE_RECEIVED_EVENT="quiz.linkbonus.LinkBonusWillBeReceivedEvent";PlanetoEvents.COMPOUND_RESPONSE="quiz.CompoundResponse";PlanetoEvents.VIEW_USER_PROFILE_RESPONSE="quiz.viewprofile.ViewUserProfileResponse";PlanetoService=BasicMVC.Base.extend({constructor:function(){this.name="PlanetoService";this.flashSocketConnectionTimeout=5000;this.flashSocketConnectionTimeoutTimer=null;
if(location.href.indexOf("socketlogger")!=-1){this.logSocketTrafic=true;this.socketLogger=window.open(socketlog_address,"socketlogger","status=1,scrollbars=1,width=400,height=800");}},eventListeners:function(){return[PlanetoService.TRACK_POST,PlanetoService.ANSWER_COMMAND,PlanetoService.DUEL_ANSWER_COMMAND,PlanetoService.PAUSE_PLAYING,PlanetoService.START_PLAYING,PlanetoService.EXECUTE_ACTION,PlanetoService.NEXT_EVENT,PlanetoService.NEW_QUIZ_SESSION,PlanetoService.LOGOUT,PlanetoService.GET_CITIES,PlanetoService.LOCATION_SELECTION,PlanetoService.VALIDATE_SIGNUP,PlanetoService.FACEBOOK_LOGIN,PlanetoService.CONTINUE_PLAYING,PlanetoService.SIGNUP,PlanetoService.RESPITE,PlanetoService.UNFREEZE,PlanetoService.CONNECT,PlanetoService.GUEST_LOGIN,PlanetoService.AWARD_ROLL_FROM_INVITATION_CODE,PlanetoService.GENERATE_ACCOUNT_ROLE_INVITATION,PlanetoService.INVITE_PLAYER_TO_CHAT,PlanetoService.LEAVE_CHAT_REQUEST,PlanetoService.SEND_MESSAGE_WITH_CHAT,PlanetoService.CHALLENGE_TO_DUEL,PlanetoService.LEAVE_LOBBY,PlanetoService.RESPONDE_TO_CHALLENGE,PlanetoService.SET_PLAYER_READY_STATE_REQUEST,PlanetoService.IS_INVITED_BY_EMAIL_REQUEST,PlanetoService.INVITE_BY_EMAIL_REQUEST,PlanetoService.SET_SITE_LANGUAGE_REQUEST,PlanetoService.PING,PlanetoService.REPORT_QUESTION,PlanetoService.GET_MORE_GOLD,PlanetoService.GOLD_PURCHASE_COMPLETE,PlanetoService.GET_DEFAULT_LEADERBOARD,PlanetoService.GET_DEFAULT_TEAMLEADERBOARD,PlanetoService.SEND_LEADERBOARD_SEARCH,PlanetoService.FILTER_TEAMLEADERBOARD,PlanetoService.DUEL_CLIENT_GIVES_UP,PlanetoService.DUEL_READY_TO_PLAY,PlanetoService.VIEW_USER_PROFILE,PlanetoService.SET_META_DATA,PlanetoService.GET_USER_SETTINGS,PlanetoService.SET_USER_SETTINGS,PlanetoService.GET_MATCHING_CITIES,PlanetoService.SESSION_STATS,PlanetoService.SET_IDLE,PlanetoService.DISCARD_DROP,PlanetoService.DISCARD_ITEM,PlanetoService.MOVE_ITEM,PlanetoService.GET_DROP,PlanetoService.HEARTBEAT_REQUEST,PlanetoService.SET_REFERENCE_REQUEST,PlanetoService.NEXT_TAT_REQUEST,PlanetoService.GET_LOGOUT_SESSION_SUMMARY,PlanetoService.BUY_MORE_INVENTORY_SPACE,PlanetoService.GET_QUESTS_REQUEST,PlanetoService.GET_COMPLETED_QUESTS_REQUEST,PlanetoService.ACCEPT_QUEST_REQUEST,PlanetoService.CLAIM_QUEST_REWARD,PlanetoService.BUY_NEW_QUEST,PlanetoService.DISMISS_REQUEST,PlanetoService.GET_TEAMS_LIST,PlanetoService.INITIATE_CREATE_TEAM,PlanetoService.CREATE_TEAM,PlanetoService.DISBAND_TEAM,PlanetoService.GET_TEAM_MEMBERS,PlanetoService.LEAVE_TEAM,PlanetoService.SET_PRIMARY_TEAM,PlanetoService.KICK_PLAYER_FROM_TEAM,PlanetoService.INVITE_TO_TEAM,PlanetoService.RESPOND_TO_TEAM_INVITE,PlanetoService.GET_TEAM_INFO,PlanetoService.IS_TEAM_NAME_AVAILABLE,PlanetoService.GET_AVAILABLE_CHAT_ROOMS,PlanetoService.OPEN_CHAT_REQUEST,PlanetoService.QUESTION_SET_PUBLISHED_REQUEST,PlanetoService.GET_COMPLETED_QUESTION_SETS_REQUEST,PlanetoService.GET_QUESTIONSET_LEADERBOARD_REQUEST,PlanetoService.GET_QUESTIONSET_LEADERBOARD_FOR_TEAM_REQUEST,PlanetoService.COOKIE_LOGIN_REQUEST,PlanetoService.FACEBOOK_CONVERT_LOGIN_REQUEST,PlanetoService.NEW_UCQ_SESSION,PlanetoService.GET_USER_CREATED_CONTENT,PlanetoService.DELETE_USER_CREATED_CONTENT,PlanetoService.SAVE_USER_CREATED_CONTENT,PlanetoService.GET_ALL_QUESTION_LANGUAGES_REQUEST,PlanetoService.GET_AVAILABLE_SELF_QUIZES,PlanetoService.START_SELF_QUIZ,PlanetoService.SUBMIT_SELF_QUIZ,PlanetoService.GET_SOME_SELF_QUIZES,PlanetoService.GET_SOME_QUESTION_SETS,PlanetoService.START_QUESTION_SET,PlanetoService.START_INFINITE_STREAM_GAME,PlanetoService.STOP_GAME,PlanetoService.GET_AVAILABLE_GAME_ROOM_GAMES,PlanetoService.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME,PlanetoService.SELECT_GAME_ROOM_COLLECTION_REQUEST,PlanetoService.JOIN_TEAM_GAME_ROOM_REQUEST,PlanetoService.RATE_QUESTION_SET_REQUEST,PlanetoService.ADD_COMMENT_TO_QUESTION_SET_REQUEST,PlanetoService.GET_FB_ID_FOR_FRIEND_REQUEST,PlanetoService.GET_REWARD_FOR_CHALLENGING_A_FRIEND_REQUEST,PlanetoService.PICK_PICTURE_GRID_CELL_REQUEST,PlanetoService.VOTE_TO_SKIP_CURRENT_PICTURE_REQUEST,PlanetoService.GET_MASTERY_POINTS,PlanetoService.SET_MASTERY_POINTS,PlanetoService.SAVE_STAR_HUNT_MAP_CHAIN_REQUEST,PlanetoService.SAVE_STAR_HUNT_MAP_REQUEST,PlanetoService.GET_STAR_HUNT_MAP_REQUEST,PlanetoService.GET_USER_CREATED_STAR_HUNT_MAP_CHAINS_REQUEST,PlanetoService.GET_AVAILABLE_STAR_HUNT_TYPES_REQUEST,PlanetoService.START_PLAYING_STAR_HUNT_REQUEST,PlanetoService.GET_STAR_HUNT_MAP_CHAINS_REQUEST,PlanetoService.GET_STAR_HUNT_MISSION_PACKS_REQUEST,PlanetoService.GET_STAR_HUNT_MISSIONS_IN_MISSION_PACK_REQUEST,PlanetoService.ATTEMPT_STAR_HUNT_MOVE_REQUEST,PlanetoService.CONTINUE_STAR_HUNT_MAP_CHAIN_REQUEST,PlanetoService.GET_USER_CREATED_MISSION_PACKS_REQUEST,PlanetoService.SAVE_STAR_HUNT_MISSION_PACK_REQUEST,PlanetoService.DELETE_STAR_HUNT_CONTENT_REQUEST,PlanetoService.UCQ_GET_MISSIONS_IN_MISSION_PACK_REQUEST,PlanetoService.BE_PART_OF_WAVE_REQUEST,PlanetoService.CREATE_WAVE_REQUEST,PlanetoService.PASS_WAVE_TO_FACEBOOK_USER_REQUEST,PlanetoService.RECEIVE_BONUS_FOR_WAVE_REQUEST,PlanetoService.REJECT_WAVE_REQUEST,PlanetoService.ACKNOWLEDGE_WAVE_REQUEST,PlanetoService.GET_QUIZ_WAVES_REQUEST,PlanetoService.SEARCH_QUESTIONSET_FOR_WAVE_REQUEST,PlanetoService.OPEN_ID_LOGIN_REQUEST,PlanetoService.OPEN_ID_VERIFICATION_REQUEST,PlanetoService.IGNORE_USER_REQUEST,PlanetoService.STOP_IGNORING_USER_REQUEST];
},eventHandlers:function(A){switch(A.name){case PlanetoService.GET_COMPLETED_QUESTION_SETS_REQUEST:this.dispatch(new GetCompletedQuestionSetsRequest(A.data));break;case PlanetoService.SET_MASTERY_POINTS:this.dispatch(new SetMasteryPointsRequest(A.data));break;case PlanetoService.OPEN_ID_VERIFICATION_REQUEST:this.dispatch(new OpenIdVerificationRequest(A.data));break;case PlanetoService.OPEN_ID_LOGIN_REQUEST:this.dispatch(new OpenIdLoginRequest(A.data.providerString,A.data.immediate));break;case PlanetoService.GET_MASTERY_POINTS:this.dispatch(new GetMasteryPointsRequest());break;case PlanetoService.GET_REWARD_FOR_CHALLENGING_A_FRIEND_REQUEST:this.dispatch(new GetRewardForChallengingAFriendRequest(A.data));break;case PlanetoService.GET_FB_ID_FOR_FRIEND_REQUEST:this.dispatch(new GetFacebookIdForFriendRequest(A.data));break;case PlanetoService.RATE_QUESTION_SET_REQUEST:this.dispatch(new RateQuestionSetRequest(A.data.mood,A.data.identity));break;case PlanetoService.ADD_COMMENT_TO_QUESTION_SET_REQUEST:this.dispatch(new AddCommentToQuestionSetRequest(A.data.identity,A.data.comment));break;case PlanetoService.GET_QUESTIONSET_LEADERBOARD_REQUEST:this.dispatch(new GetQuestionSetLeaderboardRequest(A.data.identity,A.data.nbrOfEntries,A.data.firstEntryPositionNumber,A.data.networkRange));break;case PlanetoService.GET_QUESTIONSET_LEADERBOARD_FOR_TEAM_REQUEST:this.dispatch(new GetQuestionSetLeaderboardForTeamRequest(A.data.identity,A.data.nbrOfEntries,A.data.firstEntryPositionNumber,A.data.teamIdentity));break;case PlanetoService.GET_ALL_QUESTION_LANGUAGES_REQUEST:this.dispatch(new GetAllQuestionLanguagesRequest());break;case PlanetoService.OPEN_CHAT_REQUEST:this.dispatch(new OpenChatRequest(A.data));break;case PlanetoService.GET_AVAILABLE_CHAT_ROOMS:this.dispatch(new GetAvailableChatRoomsRequest(A.data));break;case PlanetoService.IS_TEAM_NAME_AVAILABLE:this.dispatch(new IsTeamNameAvailableRequest(A.data));break;case PlanetoService.SET_PRIMARY_TEAM:this.dispatch(new SetPrimaryTeamRequest(A.data));break;case PlanetoService.GET_TEAM_INFO:this.dispatch(new GetTeamInfoRequest(A.data));break;case PlanetoService.RESPOND_TO_TEAM_INVITE:this.dispatch(new RespondToTeamInviteRequest(A.data[0],A.data[1]));break;case PlanetoService.KICK_PLAYER_FROM_TEAM:this.dispatch(new KickPlayerFromTeamRequest(A.data[0],A.data[1]));break;case PlanetoService.INVITE_TO_TEAM:this.dispatch(new InviteToTeamRequest(A.data[0],A.data[1]));break;case PlanetoService.LEAVE_TEAM:this.dispatch(new LeaveTeamRequest(A.data));break;case PlanetoService.DISBAND_TEAM:this.dispatch(new DisbandTeamRequest(A.data));break;case PlanetoService.GET_TEAM_MEMBERS:this.dispatch(new GetTeamMembersRequest(A.data));break;case PlanetoService.GET_TEAMS_LIST:this.dispatch(new GetTeamsListRequest());break;case PlanetoService.INITIATE_CREATE_TEAM:this.dispatch(new InitiateCreateTeamRequest());break;case PlanetoService.CREATE_TEAM:this.dispatch(new CreateTeamRequest(A.data.teamType,A.data.name,A.data.slogan,A.data.description));break;case PlanetoService.GET_LOGOUT_SESSION_SUMMARY:this.dispatch(new GetLogoutSessionSummaryRequest());break;case PlanetoService.SET_IDLE:this.dispatch(new SetIdleRequest(A.data));break;case PlanetoService.SESSION_STATS:this.dispatch(new GetSessionStatsRequest());break;case PlanetoService.TRACK_POST:this.dispatch(new NotifyFacebookPostChoiceRequest(A.data));break;case PlanetoService.RESPITE:this.dispatch(new RespiteRequest(A.data));break;case PlanetoService.UNFREEZE:this.dispatch(new UnfreezeRequest());break;case PlanetoService.ANSWER_COMMAND:this.dispatch(new QuestionAnsweredRequest(A.data.answerIndex));break;case PlanetoService.DUEL_ANSWER_COMMAND:this.dispatch(new DuelQuestionAnsweredRequest(A.data.question,A.data.answerIndex));break;case PlanetoService.START_PLAYING:this.dispatch(new StartPlayingRequest());break;case PlanetoService.PAUSE_PLAYING:this.dispatch(new PauseRequest(A.data));break;case PlanetoService.CONTINUE_PLAYING:this.dispatch(new PauseRequest());break;case PlanetoService.GET_DROP:this.dispatch(new GetDropRequest(A.data));
break;case PlanetoService.DISCARD_DROP:this.dispatch(new DiscardDropRequest(A.data));break;case PlanetoService.DISCARD_ITEM:this.dispatch(new DiscardItemRequest(A.data[0],A.data[1],A.data[2],A.data[3]));break;case PlanetoService.MOVE_ITEM:this.dispatch(new MoveItemRequest(A.data[0],A.data[1]));break;case PlanetoService.EXECUTE_ACTION:this.dispatch(new ExecuteActionRequest(A.data[0],A.data[1],A.data[2]));break;case PlanetoService.NEXT_EVENT:this.nextEvent();break;case PlanetoService.NEW_QUIZ_SESSION:this.dispatch(new NewQuizSessionRequest());break;case PlanetoService.LOGOUT:this.dispatch(new LogoutRequest(A.data));break;case PlanetoService.FACEBOOK_LOGIN:this.dispatch(new FacebookLoginRequest(A.data));break;case PlanetoService.COOKIE_LOGIN_REQUEST:this.dispatch(new CookieLoginRequest(A.data));break;case PlanetoService.FACEBOOK_CONVERT_LOGIN_REQUEST:this.dispatch(new FacebookConvertLoginRequest(A.data));break;case PlanetoService.GET_CITIES:this.dispatch(new ListCitiesRequest(A.data));break;case PlanetoService.LOCATION_SELECTION:this.dispatch(new LocationSelectionRequest());break;case PlanetoService.VALIDATE_SIGNUP:this.dispatch(new AccountValidationRequest(A.data[0],A.data[1],A.data[2],A.data[3]));break;case PlanetoService.SIGNUP:this.dispatch(new AccountRegistrationRequest(A.data[0],A.data[1],A.data[2],A.data[3]));break;case PlanetoService.CONNECT:this.webSocketConnect(A.data);break;case PlanetoService.GUEST_LOGIN:this.guestLogin(A.data);break;case PlanetoService.AWARD_ROLL_FROM_INVITATION_CODE:this.dispatch(new AwardRoleFromInvitationRequest(A.data[0],A.data[1]));break;case PlanetoService.GENERATE_ACCOUNT_ROLE_INVITATION:this.dispatch(new GenerateAccountRoleInvitationRequest(A.data));break;case PlanetoService.INVITE_PLAYER_TO_CHAT:this.dispatch(new InviteToChatRequest(A.data));break;case PlanetoService.LEAVE_CHAT_REQUEST:this.dispatch(new LeaveChatRequest(A.data));break;case PlanetoService.SEND_MESSAGE_WITH_CHAT:this.dispatch(new SendMessageRequest(A.data[0],A.data[1]));break;case PlanetoService.SEND_LEADERBOARD_SEARCH:this.dispatch(new GetFilteredLeaderBoardRequest(A.data.minLevel,A.data.maxLevel,A.data.networkRange,A.data.columnToSortBy,A.data.nbrOfEntries,A.data.firstEntryPositionNumber,A.data.countryISOCode,A.data.cityId,A.data.teamId,A.data.allCountriesList));break;case PlanetoService.FILTER_TEAMLEADERBOARD:this.dispatch(new GetFilteredTeamLeaderBoardRequest(A.data.nbrOfEntries,A.data.firstEntryPosition,A.data.teamType,A.data.columnToSortBy));break;case PlanetoService.CHALLENGE_TO_DUEL:this.dispatch(new ChallengeToDuelRequest(A.data));break;case PlanetoService.LEAVE_LOBBY:this.dispatch(new LeaveLobbyRequest());break;case PlanetoService.RESPONDE_TO_CHALLENGE:this.dispatch(new RespondToChallengeRequest(A.data[0],A.data[1]));break;case PlanetoService.SET_PLAYER_READY_STATE_REQUEST:this.dispatch(new SetPlayerReadyStateRequest(A.data));break;case PlanetoService.IS_INVITED_BY_EMAIL_REQUEST:this.dispatch(new IsInvitedByEmailRequest(A.data));break;case PlanetoService.INVITE_BY_EMAIL_REQUEST:this.dispatch(new InviteByEmailRequest(A.data[0],A.data[1]));break;case PlanetoService.SET_SITE_LANGUAGE_REQUEST:this.dispatch(new SetQuestionLanguageRequest(A.data));break;case PlanetoService.PING:this.dispatch(new PingRequest(A.data));break;case PlanetoService.SET_META_DATA:this.dispatch(new SetMetaDataRequest(A.data.key,A.data.value));break;case PlanetoService.REPORT_QUESTION:this.dispatch(new ReportQuestionRequest(A.data[0],A.data[1],A.data[2]));break;case PlanetoService.GET_MORE_GOLD:this.dispatch(new InitiateSocialGoldPurchaseRequest());break;case PlanetoService.GOLD_PURCHASE_COMPLETE:this.dispatch(new ReportSocialGoldPurchaseSuccessRequest(A.data.success,A.data.url));break;case PlanetoService.GET_DEFAULT_LEADERBOARD:this.dispatch(new GetDefaultLeaderBoardRequest(A.data.nbrOfEntries));break;case PlanetoService.GET_DEFAULT_TEAMLEADERBOARD:this.dispatch(new GetDefaultTeamLeaderBoardRequest(A.data.nbrOfEntries));break;case PlanetoService.GET_DEFAULT_TEAMLEADERBOARD:this.dispatch(new GetDefaultTeamLeaderBoardRequest(A.data.nbrOfEntries));
break;case PlanetoService.DUEL_CLIENT_GIVES_UP:this.dispatch(new DuelClientGivesUpRequest());break;case PlanetoService.DUEL_READY_TO_PLAY:this.dispatch(new DuelReadyToPlayRequest());break;case PlanetoService.VIEW_USER_PROFILE:this.dispatch(new ViewUserProfileRequest(A.data.id));break;case PlanetoService.GET_USER_SETTINGS:this.dispatch(new GetUserSettingsRequest());break;case PlanetoService.HEARTBEAT_REQUEST:this.dispatch(new HeartbeatRequest());break;case PlanetoService.SET_USER_SETTINGS:this.dispatch(new SetUserSettingsRequest(A.data.currentSiteLanguageId,A.data.currentQuestionLanguageId,A.data.countryId,A.data.cityId,A.data.email,A.data.wantsWeeklyNewsLetter,A.data.wantsUpdateAboutFriends,A.data.wantsGameUpdates,A.data.wantsPopularCommunityActivities,A.data.wantsQuestionSetEmail));break;case PlanetoService.GET_MATCHING_CITIES:this.dispatch(new GetMatchingCitiesRequest(A.data.countryIso,A.data.partialName));break;case PlanetoService.SET_REFERENCE_REQUEST:this.dispatch(new SetUrlParamsRequest(A.data.referenceId,A.data.linkBonus));break;case PlanetoService.NEXT_TAT_REQUEST:this.dispatch(new NextTipsAndTricksRequest());break;case PlanetoService.BUY_MORE_INVENTORY_SPACE:this.dispatch(new BuyMoreInventorySpaceRequest());break;case PlanetoService.GET_QUESTS_REQUEST:this.dispatch(new GetQuestsRequest());break;case PlanetoService.GET_COMPLETED_QUESTS_REQUEST:this.dispatch(new GetCompletedQuestsRequest());break;case PlanetoService.ACCEPT_QUEST_REQUEST:this.dispatch(new AcceptQuestRequest(A.data));break;case PlanetoService.CLAIM_QUEST_REWARD:this.dispatch(new ClaimQuestRewardRequest(A.data));break;case PlanetoService.BUY_NEW_QUEST:this.dispatch(new BuyNewQuestRequest(A.data));break;case PlanetoService.DISMISS_REQUEST:this.dispatch(new DismissQuestRequest(A.data));break;case PlanetoService.QUESTION_SET_PUBLISHED_REQUEST:this.dispatch(new QuestionSetPublishedToFacebookRequest(A.data));break;case PlanetoService.NEW_UCQ_SESSION:this.dispatch(new NewUCQSessionRequest);break;case PlanetoService.GET_USER_CREATED_CONTENT:this.dispatch(new GetUserCreatedContentRequest(A.data));break;case PlanetoService.DELETE_USER_CREATED_CONTENT:this.dispatch(new DeleteUserCreatedContentRequest(A.data));break;case PlanetoService.SAVE_USER_CREATED_CONTENT:this.dispatch(new SaveUserCreatedContentRequest(A.data.question,A.data.questionSet,A.data.selfQuiz));break;case PlanetoService.GET_AVAILABLE_SELF_QUIZES:this.dispatch(new GetAvailableSelfQuizesRequest());break;case PlanetoService.START_SELF_QUIZ:this.dispatch(new StartSelfQuizRequest(A.data));break;case PlanetoService.SUBMIT_SELF_QUIZ:this.dispatch(new SubmitSelfQuizAnswersRequest(A.data.answers,A.data.identity));break;case PlanetoService.GET_SOME_SELF_QUIZES:this.dispatch(new GetSomeSelfQuizesRequest());break;case PlanetoService.GET_SOME_QUESTION_SETS:this.dispatch(new GetSomeQuestionSetsRequest());break;case PlanetoService.START_QUESTION_SET:this.dispatch(new StartQuestionSetRequest(A.data));break;case PlanetoService.START_INFINITE_STREAM_GAME:this.dispatch(new StartPlayingRequest);break;break;case PlanetoService.STOP_GAME:this.dispatch(new StopGameRequest());break;case PlanetoService.GET_AVAILABLE_GAME_ROOM_GAMES:this.dispatch(new GetAvailableGameRoomGamesRequest());break;case PlanetoService.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME:this.dispatch(new GetGameRoomsAndCollectionsForGameRequest(A.data));break;case PlanetoService.SELECT_GAME_ROOM_COLLECTION_REQUEST:this.dispatch(new SelectGameRoomCollectionRequest(A.data));break;case PlanetoService.JOIN_TEAM_GAME_ROOM_REQUEST:this.dispatch(new JoinTeamGameRoomRequest(A.data.teamIdentity,A.data.gameRoomGame));break;case PlanetoService.PICK_PICTURE_GRID_CELL_REQUEST:this.dispatch(new PickPictureGridCellRequest(A.data.row,A.data.col));break;case PlanetoService.VOTE_TO_SKIP_CURRENT_PICTURE_REQUEST:this.dispatch(new VoteToSkipCurrentPictureRequest());break;case PlanetoService.SAVE_STAR_HUNT_MAP_REQUEST:this.dispatch(new SaveStarHuntMapRequest(A.data.map,A.data.chainIdentity));
break;case PlanetoService.SAVE_STAR_HUNT_MAP_CHAIN_REQUEST:this.dispatch(new SaveStarHuntMapChainRequest(A.data));break;case PlanetoService.GET_STAR_HUNT_MAP_REQUEST:this.dispatch(new GetStarHuntMapRequest(A.data));break;case PlanetoService.GET_USER_CREATED_STAR_HUNT_MAP_CHAINS_REQUEST:this.dispatch(new GetUserCreatedStarHuntMapChainsRequest(A.data));break;case PlanetoService.DELETE_STAR_HUNT_CONTENT_REQUEST:this.dispatch(new DeleteStarHuntContentRequest(A.data.mapIdentity,A.data.chainIdentity,A.data.packIdentity));break;case PlanetoService.GET_AVAILABLE_STAR_HUNT_TYPES_REQUEST:this.dispatch(new GetAvailableStarHuntTypesRequest());break;case PlanetoService.START_PLAYING_STAR_HUNT_REQUEST:this.dispatch(new StartPlayingStarHuntRequest(A.data));break;case PlanetoService.GET_STAR_HUNT_MISSION_PACKS_REQUEST:this.dispatch(new GetStarHuntMissionPacksRequest(A.data.offset,A.data.amount));break;case PlanetoService.GET_STAR_HUNT_MISSIONS_IN_MISSION_PACK_REQUEST:this.dispatch(new GetMissionsInMissionPackRequest(A.data));break;case PlanetoService.GET_STAR_HUNT_MAP_CHAINS_REQUEST:this.dispatch(new GetStarHuntMapChainsRequest(A.data.offset,A.data.amount));break;case PlanetoService.ATTEMPT_STAR_HUNT_MOVE_REQUEST:this.dispatch(new AttemptStarHuntMoveRequest(A.data.row,A.data.col));break;case PlanetoService.CONTINUE_STAR_HUNT_MAP_CHAIN_REQUEST:this.dispatch(new ContinueStarHuntMapChainRequest());break;case PlanetoService.GET_USER_CREATED_MISSION_PACKS_REQUEST:this.dispatch(new GetUserCreatedMissionPacksRequest());break;case PlanetoService.SAVE_STAR_HUNT_MISSION_PACK_REQUEST:this.dispatch(new SaveStarHuntMissionPackRequest(A.data));break;case PlanetoService.UCQ_GET_MISSIONS_IN_MISSION_PACK_REQUEST:this.dispatch(new UCQGetMissionsInMissionPackRequest(A.data));break;case PlanetoService.TEMP_GET_STAR_HUNT_MAP_REQUEST:this.dispatch(new TempGetStarHuntMapRequest());break;case PlanetoService.CREATE_WAVE_REQUEST:this.dispatch(new CreateWaveRequest(A.data));break;case PlanetoService.BE_PART_OF_WAVE_REQUEST:this.dispatch(new BePartOfWaveRequest(A.data));break;case PlanetoService.RECEIVE_BONUS_FOR_WAVE_REQUEST:this.dispatch(new ReceiveBonusForWaveRequest(A.data));break;case PlanetoService.PASS_WAVE_TO_FACEBOOK_USER_REQUEST:this.dispatch(new PassWaveToFacebookUserRequest(A.data.waveMessageId,A.data.facebookPostId,A.data.facebookId));break;case PlanetoService.REJECT_WAVE_REQUEST:this.dispatch(new RejectWaveRequest(A.data));break;case PlanetoService.ACKNOWLEDGE_WAVE_REQUEST:this.dispatch(new AcknowledgeWaveRequest(A.data));break;case PlanetoService.GET_QUIZ_WAVES_REQUEST:this.dispatch(new GetWavesRequest());break;case PlanetoService.SEARCH_QUESTIONSET_FOR_WAVE_REQUEST:this.dispatch(new SearchQuestionSetForWaveRequest(A.data.searchStr,A.data.itemsLimit));break;case PlanetoService.IGNORE_USER_REQUEST:this.dispatch(new IgnoreUserRequest(A.data));break;case PlanetoService.STOP_IGNORING_USER_REQUEST:this.dispatch(new StopIgnoringUserRequest(A.data));break;}},nextEvent:function(){var A=this.compoundEventList.length>0;if(A){this.onResponse(this.compoundEventList.shift());}else{this.sendEvent(PlanetoService.RESPITE,false);}return A;},webSocketConnect:function(E){var B=this,G="ws",A=80,F=E?false:true;webServiceHost=location.href.match(/\/\/(.*?)[\/:]/i)[1];if(webServiceHost=="develop.planeto.net"){A=443;G="wss";}else{var H=location.href.match(/\/\/.*:([^\/]*)/);A=H?H[1]:80;}var C=G+"://ws"+webServiceHost+":"+A;this.ws=PlanetoSocket.CometD();if(location.href.indexOf("debug")!=-1){$("#debugInterface").append("<div>"+this.ws.socketType+"</div>");}this.ws.setOnMessageCallback(this.localScopeFull(this.onResponse));this.ws.setConnectCallback(function(){B.clearFlashSocketConnectionTimeoutTimer();B.ws.connected=true;B.dispatch(new ConnectRequest(navigator.userAgent,location.href,acceptLanguageHeader));});this.ws.setDisconnectCallback(function(){if(!B.ws.connected&&B.ws.socketType=="Flash WebSocket"){B.disableFlashAndReconnect();}});try{if(this.ws.socketType=="Flash WebSocket"){this.startFlashSocketConnectionTimeout();
}this.ws.connect(C);}catch(D){console.log("ws.connect error: ",D);}$(window).unload(function(){B.dispatch(new FlagCleanDisconnect());B.ws.disconnect();});},dispatch:function(A){var B=JSON.stringify(A);this.ws.dispatch(B);this.socketLog(A,"out");},addListener:function(A,B){if(A+""=="undefined"){this.undefinedListeners++;console.log("Undefined event sent to PlanetoService.addListener (total: "+this.undefinedListeners+"):");console.log(arguments);console.log("---------------------------------------------------");}if(this.listeners[A]==null){this.listeners[A]=[];}this.listeners[A].push(B);},onResponse:function(D){var A=JSON.parse(D);this.currentEventMessageType=A.type;if(A.type==PlanetoEvents.COMPOUND_RESPONSE){for(var C=0;C<A.responses.length;C++){this.sendEvent(A.responses[C].type,A.responses[C]);this.socketLog(A.responses[C],"in");}}else{var B=new Date();this.sendEvent(A.type,A);this.socketLog(A,"in");}},socketLog:function(B,C){if(this.logSocketTrafic){try{this.socketLogger.log(B,C);}catch(A){console.log("socketLog: ",A);}}},guestLogin:function(A){this.dispatch(new GuestLoginRequest(A));},_addScore:function(A){this.dispatch(new _AddScoreRequest(A));},hasFlash:function(){if("navigator" in window&&"plugins" in navigator&&navigator.plugins["Shockwave Flash"]){return !!navigator.plugins["Shockwave Flash"].description;}if("ActiveXObject" in window){try{return !!new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version");}catch(A){}}return false;},startFlashSocketConnectionTimeout:function(){this.flashSocketConnectionTimeoutTimer=setTimeout(this.localScope(this.disableFlashAndReconnect),this.flashSocketConnectionTimeout);},clearFlashSocketConnectionTimeoutTimer:function(){if(this.flashSocketConnectionTimeoutTimer){clearTimeout(this.flashSocketConnectionTimeoutTimer);this.flashSocketConnectionTimeoutTimer=null;}},disableFlashAndReconnect:function(){this.hasFlash=function(){return false;};this.sendEvent(PlanetoService.CONNECT);}});PlanetoService.TRACK_POST="PlanetoService.TRACK_POST";PlanetoService.ANSWER_COMMAND="planetoService.planetoService.answerCommand";PlanetoService.DUEL_ANSWER_COMMAND="PlanetoService.DUEL_ANSWER_COMMAND";PlanetoService.PAUSE_PLAYING="planetoService.pausePlaying";PlanetoService.START_PLAYING="planetoService.startPlaying";PlanetoService.EXECUTE_ACTION="PlanetoService.EXECUTE_ACTION";PlanetoService.NEXT_EVENT="planetoService.nextEvent";PlanetoService.NEW_QUIZ_SESSION="planetoService.newQuizSession";PlanetoService.LOGOUT="planetoService.logout";PlanetoService.GET_CITIES="planetoService.getCities";PlanetoService.LOCATION_SELECTION="planetoService.locationSelection";PlanetoService.VALIDATE_SIGNUP="planetoService.validateSignup";PlanetoService.FACEBOOK_LOGIN="planetoService.facebookLogin";PlanetoService.CONTINUE_PLAYING="planetoService.continuePlaying";PlanetoService.SIGNUP="planetoService.signup";PlanetoService.RESPITE="PlanetoService.RESPITE";PlanetoService.UNFREEZE="PlanetoService.UNFREEZE";PlanetoService.CONNECT="planetoService.connect";PlanetoService.GUEST_LOGIN="planetoService.guestLogin";PlanetoService.DISCONNECTED="PlanetoService.DISCONNECTED";PlanetoService.AWARD_ROLL_FROM_INVITATION_CODE="PlanetoService.AWARD_ROLL_FROM_INVITATION_CODE";PlanetoService.GENERATE_ACCOUNT_ROLE_INVITATION="PlanetoService.GENERATE_ACCOUNT_ROLE_INVITATION";PlanetoService.INVITE_PLAYER_TO_CHAT="PlanetoService.INVITE_PLAYER_TO_CHAT";PlanetoService.LEAVE_CHAT_REQUEST="PlanetoService.LEAVE_CHAT_REQUEST";PlanetoService.SEND_MESSAGE_WITH_CHAT="PlanetoService.SEND_MESSAGE_WITH_CHAT";PlanetoService.CHALLENGE_TO_DUEL="PlanetoService.CHALLENGE_TO_DUEL";PlanetoService.LEAVE_LOBBY="PlanetoService.LEAVE_LOBBY";PlanetoService.RESPONDE_TO_CHALLENGE="PlanetoService.RESPONDE_TO_CHALLENGE";PlanetoService.SET_PLAYER_READY_STATE_REQUEST="PlanetoService.SET_PLAYER_READY_STATE_REQUEST";PlanetoService.IS_INVITED_BY_EMAIL_REQUEST="PlanetoService.IS_INVITED_BY_EMAIL_REQUEST";PlanetoService.INVITE_BY_EMAIL_REQUEST="PlanetoService.INVITE_BY_EMAIL_REQUEST";
PlanetoService.SET_SITE_LANGUAGE_REQUEST="PlanetoService.SET_SITE_LANGUAGE_REQUEST";PlanetoService.PING="PlanetoService.PING";PlanetoService.REPORT_QUESTION="PlanetoService.REPORT_QUESTION";PlanetoService.GET_MORE_GOLD="PlanetoService.GET_MORE_GOLD";PlanetoService.GOLD_PURCHASE_COMPLETE="PlanetoService.GOLD_PURCHASE_COMPLETE";PlanetoService.GET_DEFAULT_LEADERBOARD="PlanetoService.GET_DEFAULT_LEADERBOARD";PlanetoService.GET_DEFAULT_TEAMLEADERBOARD="PlanetoService.GET_DEFAULT_TEAMLEADERBOARD";PlanetoService.SEND_LEADERBOARD_SEARCH="PlanetoService.SEND_LEADERBOARD_SEARCH";PlanetoService.FILTER_TEAMLEADERBOARD="PlanetoService.FILTER_TEAMLEADERBOARD";PlanetoService.DUEL_CLIENT_GIVES_UP="PlanetoService.DUEL_CLIENT_GIVES_UP";PlanetoService.DUEL_READY_TO_PLAY="PlanetoService.DUEL_READY_TO_PLAY";PlanetoService.VIEW_USER_PROFILE="PlanetoService.VIEW_USER_PROFILE";PlanetoService.SET_META_DATA="PlanetoService.SET_META_DATA";PlanetoService.GET_USER_SETTINGS="PlanetoService.GET_USER_SETTINGS";PlanetoService.SET_USER_SETTINGS="PlanetoService.SET_USER_SETTINGS";PlanetoService.GET_MATCHING_CITIES="PlanetoService.GET_MATCHING_CITIES";PlanetoService.SESSION_STATS="PlanetoService.SESSION_STATS";PlanetoService.SET_IDLE="PlanetoService.SET_IDLE";PlanetoService.DISCARD_DROP="PlanetoService.DISCARD_DROP";PlanetoService.DISCARD_ITEM="PlanetoService.DISCARD_ITEM";PlanetoService.MOVE_ITEM="PlanetoService.MOVE_ITEM";PlanetoService.DISCARD_DROP="PlanetoService.DISCARD_DROP";PlanetoService.GET_DROP="PlanetoService.GET_DROP";PlanetoService.HEARTBEAT_REQUEST="PlanetoService.HEARTBEAT_REQUEST";PlanetoService.SET_REFERENCE_REQUEST="PlanetoService.SET_REFERENCE_REQUEST";PlanetoService.NEXT_TAT_REQUEST="PlanetoService.NEXT_TAT_REQUEST";PlanetoService.GET_LOGOUT_SESSION_SUMMARY="PlanetoService.GET_LOGOUT_SESSION_SUMMARY";PlanetoService.BUY_MORE_INVENTORY_SPACE="PlanetoService.BUY_MORE_INVENTORY_SPACE";PlanetoService.GET_QUESTS_REQUEST="PlanetoService.GET_QUESTS_REQUEST";PlanetoService.GET_COMPLETED_QUESTS_REQUEST="PlanetoService.GET_COMPLETED_QUESTS_REQUEST";PlanetoService.ACCEPT_QUEST_REQUEST="PlanetoService.ACCEPT_QUEST_REQUEST";PlanetoService.CLAIM_QUEST_REWARD="PlanetoService.CLAIM_QUEST_REWARD";PlanetoService.BUY_NEW_QUEST="PlanetoService.BUY_NEW_QUEST";PlanetoService.DISMISS_REQUEST="PlanetoService.DISMISS_REQUEST";PlanetoService.GET_TEAMS_LIST="PlanetoService.GET_TEAMS_LIST";PlanetoService.INITIATE_CREATE_TEAM="PlanetoService.INITIATE_CREATE_TEAM";PlanetoService.CREATE_TEAM="PlanetoService.CREATE_TEAM";PlanetoService.DISBAND_TEAM="PlanetoService.DISBAND_TEAM";PlanetoService.GET_TEAM_MEMBERS="PlanetoService.GET_TEAM_MEMBERS";PlanetoService.LEAVE_TEAM="PlanetoService.LEAVE_TEAM";PlanetoService.SET_PRIMARY_TEAM="PlanetoService.SET_PRIMARY_TEAM";PlanetoService.KICK_PLAYER_FROM_TEAM="PlanetoService.KICK_PLAYER_FROM_TEAM";PlanetoService.INVITE_TO_TEAM="PlanetoService.INVITE_TO_TEAM";PlanetoService.RESPOND_TO_TEAM_INVITE="PlanetoService.RESPOND_TO_TEAM_INVITE";PlanetoService.GET_TEAM_INFO="PlanetoService.GET_TEAM_INFO";PlanetoService.IS_TEAM_NAME_AVAILABLE="PlanetoService.IS_TEAM_NAME_AVAILABLE";PlanetoService.GET_AVAILABLE_CHAT_ROOMS="PlanetoService.GET_AVAILABLE_CHAT_ROOMS";PlanetoService.OPEN_CHAT_REQUEST="PlanetoService.OPEN_CHAT_REQUEST";PlanetoService.QUESTION_SET_PUBLISHED_REQUEST="PlanetoService.QUESTION_SET_PUBLISHED_REQUEST";PlanetoService.GET_COMPLETED_QUESTION_SETS_REQUEST="PlanetoService.GET_COMPLETED_QUESTION_SETS_REQUEST";PlanetoService.GET_QUESTIONSET_LEADERBOARD_REQUEST="PlanetoService.GET_QUESTIONSET_LEADERBOARD_REQUEST";PlanetoService.GET_QUESTIONSET_LEADERBOARD_FOR_TEAM_REQUEST="PlanetoService.GET_QUESTIONSET_LEADERBOARD_FOR_TEAM_REQUEST";PlanetoService.COOKIE_LOGIN_REQUEST="PlanetoService.COOKIE_LOGIN_REQUEST";PlanetoService.FACEBOOK_CONVERT_LOGIN_REQUEST="PlanetoService.FACEBOOK_CONVERT_LOGIN_REQUEST";PlanetoService.NEW_UCQ_SESSION="PlanetoService.NEW_UCQ_SESSION";PlanetoService.GET_USER_CREATED_CONTENT="PlanetoService.GET_USER_CREATED_CONTENT";
PlanetoService.DELETE_USER_CREATED_CONTENT="PlanetoService.DELETE_USER_CREATED_CONTENT";PlanetoService.SAVE_USER_CREATED_CONTENT="PlanetoService.SAVE_USER_CREATED_CONTENT";PlanetoService.GET_ALL_QUESTION_LANGUAGES_REQUEST="PlanetoService.GET_ALL_QUESTION_LANGUAGES_REQUEST";PlanetoService.GET_AVAILABLE_SELF_QUIZES="PlanetoService.GET_AVAILABLE_SELF_QUIZES_REQUEST";PlanetoService.START_SELF_QUIZ="PlanetoService.START_SELF_QUIZ";PlanetoService.SUBMIT_SELF_QUIZ="PlanetoService.SUBMIT_SELF_QUIZ";PlanetoService.GET_SOME_SELF_QUIZES="PlanetoService.GET_SOME_SELF_QUIZES";PlanetoService.GET_SOME_QUESTION_SETS="PlanetoService.GET_SOME_QUESTION_SETS";PlanetoService.START_QUESTION_SET="PlanetoService.START_QUESTION_SET";PlanetoService.START_INFINITE_STREAM_GAME="PlanetoService.START_INFINITE_STREAM_GAME";PlanetoService.STOP_GAME="PlanetoService.STOP_GAME";PlanetoService.GET_AVAILABLE_GAME_ROOM_GAMES="PlanetoService.GET_AVAILABLE_GAME_ROOM_GAMES";PlanetoService.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME="PlanetoService.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME";PlanetoService.SELECT_GAME_ROOM_COLLECTION_REQUEST="PlanetoService.SELECT_GAME_ROOM_COLLECTION_REQUEST";PlanetoService.JOIN_TEAM_GAME_ROOM_REQUEST="PlanetoService.JOIN_TEAM_GAME_ROOM_REQUEST";PlanetoService.RATE_QUESTION_SET_REQUEST="PlanetoService.RATE_QUESTION_SET_REQUEST";PlanetoService.ADD_COMMENT_TO_QUESTION_SET_REQUEST="PlanetoService.ADD_COMMENT_TO_QUESTION_SET_REQUEST";PlanetoService.GET_FB_ID_FOR_FRIEND_REQUEST="PlanetoService.GET_FB_ID_FOR_FRIEND_REQUEST";PlanetoService.GET_REWARD_FOR_CHALLENGING_A_FRIEND_REQUEST="PlanetoService.GET_REWARD_FOR_CHALLENGING_A_FRIEND_REQUEST";PlanetoService.PICK_PICTURE_GRID_CELL_REQUEST="PlanetoService.PICK_PICTURE_GRID_CELL_REQUEST";PlanetoService.VOTE_TO_SKIP_CURRENT_PICTURE_REQUEST="PlanetoService.VOTE_TO_SKIP_CURRENT_PICTURE_REQUEST";PlanetoService.GET_MASTERY_POINTS="PlanetoService.GET_MASTERY_POINTS";PlanetoService.SET_MASTERY_POINTS="PlanetoService.SET_MASTERY_POINTS";PlanetoService.SAVE_STAR_HUNT_MAP_REQUEST="PlanetoService.SAVE_STAR_HUNT_MAP_REQUEST";PlanetoService.SAVE_STAR_HUNT_MAP_CHAIN_REQUEST="PlanetoService.SAVE_STAR_HUNT_MAP_CHAIN_REQUEST";PlanetoService.GET_STAR_HUNT_MAP_REQUEST="PlanetoService.GET_STAR_HUNT_MAP_REQUEST";PlanetoService.GET_USER_CREATED_STAR_HUNT_MAP_CHAINS_REQUEST="PlanetoService.GET_USER_CREATED_STAR_HUNT_MAP_CHAINS_REQUEST";PlanetoService.GET_AVAILABLE_STAR_HUNT_TYPES_REQUEST="PlanetoService.GET_AVAILABLE_STAR_HUNT_TYPES_REQUEST";PlanetoService.START_PLAYING_STAR_HUNT_REQUEST="PlanetoService.START_PLAYING_STAR_HUNT_REQUEST";PlanetoService.GET_STAR_HUNT_MISSION_PACKS_REQUEST="PlanetoService.GET_STAR_HUNT_MISSION_PACKS_REQUEST";PlanetoService.GET_STAR_HUNT_MISSIONS_IN_MISSION_PACK_REQUEST="PlanetoService.GET_STAR_HUNT_MISSIONS_IN_MISSION_PACK_REQUEST";PlanetoService.GET_STAR_HUNT_MAP_CHAINS_REQUEST="PlanetoService.GET_STAR_HUNT_MAP_CHAINS_REQUEST";PlanetoService.ATTEMPT_STAR_HUNT_MOVE_REQUEST="PlanetoService.ATTEMPT_STAR_HUNT_MOVE_REQUEST";PlanetoService.CONTINUE_STAR_HUNT_MAP_CHAIN_REQUEST="PlanetoService.CONTINUE_STAR_HUNT_MAP_CHAIN_REQUEST";PlanetoService.GET_USER_CREATED_MISSION_PACKS_REQUEST="PlanetoService.GET_USER_CREATED_MISSION_PACKS_REQUEST";PlanetoService.SAVE_STAR_HUNT_MISSION_PACK_REQUEST="PlanetoService.SAVE_STAR_HUNT_MISSION_PACK_REQUEST";PlanetoService.DELETE_STAR_HUNT_CONTENT_REQUEST="PlanetoService.DELETE_STAR_HUNT_CONTENT_REQUEST";PlanetoService.UCQ_GET_MISSIONS_IN_MISSION_PACK_REQUEST="PlanetoService.UCQ_GET_MISSIONS_IN_MISSION_PACK_REQUEST";PlanetoService.CREATE_WAVE_REQUEST="PlanetoService.CREATE_WAVE_REQUEST";PlanetoService.BE_PART_OF_WAVE_REQUEST="PlanetoService.BE_PART_OF_WAVE_REQUEST";PlanetoService.PASS_WAVE_TO_FACEBOOK_USER_REQUEST="PlanetoService.PASS_WAVE_TO_FACEBOOK_USER_REQUEST";PlanetoService.RECEIVE_BONUS_FOR_WAVE_REQUEST="PlanetoService.RECEIVE_BONUS_FOR_WAVE_REQUEST";PlanetoService.REJECT_WAVE_REQUEST="PlanetoService.REJECT_WAVE_REQUEST";PlanetoService.ACKNOWLEDGE_WAVE_REQUEST="PlanetoService.ACKNOWLEDGE_WAVE_REQUEST";
PlanetoService.GET_QUIZ_WAVES_REQUEST="PlanetoService.GET_QUIZ_WAVES_REQUEST";PlanetoService.SEARCH_QUESTIONSET_FOR_WAVE_REQUEST="PlanetoService.SEARCH_QUESTIONSET_FOR_WAVE_REQUEST";PlanetoService.OPEN_ID_LOGIN_REQUEST="PlanetoService.OPEN_ID_LOGIN_REQUEST";PlanetoService.OPEN_ID_VERIFICATION_REQUEST="PlanetoService.OPEN_ID_VERIFICATION_REQUEST";PlanetoService.IGNORE_USER_REQUEST="PlanetoService.IGNORE_USER_REQUEST";PlanetoService.STOP_IGNORING_USER_REQUEST="PlanetoService.STOP_IGNORING_USER_REQUEST";BasicMVC.Facade.getInstance().register(new PlanetoService());Planeto.Facebook=Planeto.Facebook||{};Planeto.Facebook.Control=BasicMVC.Base.extend({constructor:function(){this.session=null;this.name="Planeto.Facebook.Control";this.connectedToPlaneto=false;this.connectedToFB=false;this.permissionsToCheck="email,publish_stream";this.friendsListRendered=false;},eventListeners:function(){return[Planeto.Facebook.Control.LOGOUT,Planeto.Facebook.Control.CONNECT,PlanetoEvents.LOGIN_RESPONSE];},eventHandlers:function(A){switch(A.name){case Planeto.Facebook.Control.LOGOUT:this.logout();break;case Planeto.Facebook.Control.CONNECT:this.init(A.data);break;case PlanetoEvents.LOGIN_RESPONSE:this.loginResponse(A.data);break;}},loginResponse:function(A){user_id=A.account!=null?A.account.user.id:"[no account]";},logout:function(){var A=this;if(this.connectedToFB){FB.Connect.logout(function(){});this.friendsListRendered=false;}},init:function(C){try{function B(){this.doNotUseCachedConnectState=true;}var A=location.href.match(/\/\/(.*?)[\/:]/i)[1];FB.init({appId:C,status:true,cookie:true,xfbml:true,channelUrl:"http://"+A+resource_fb_channel_page,oauth:true});if(/chrome/.test(navigator.userAgent.toLowerCase())){FB.XD._origin=window.location.protocol+"//"+document.domain+"/"+FB.guid();FB.XD.Flash.init();FB.XD._transport="flash";}FB.getLoginStatus(CallbackProxy(this,this.handleLoginStatus),true);FB.Event.subscribe("auth.authResponseChange",CallbackProxy(this,this.handleSessionChange));FB.Event.subscribe("auth.statusChange",CallbackProxy(this,this.handleStatusChange));}catch(D){console.log("Facebook.Control init error ",D);}},handleLoginStatus:function(A){if(A.authResponse&&A.status=="connected"){this.session=A.authResponse;this.facebookConnected();}else{this.facebookNotConnected();}},handleSessionChange:function(A){if(A.authResponse){this.session=A.authResponse;this.facebookConnected();}},handleStatusChange:function(A){fb_status=A.status;},facebookPromptPermission:function(B,A){FB.ui({method:"permissions.request",scope:B},A);},facebookException:function(){if(this.permissionsToCheck!=""){FB.Facebook.apiClient.users_hasAppPermission(this.permissionsToCheck,CallbackProxy(this,this.facebookPermissionChecked));}else{this.facebookPermissionGranted();}},facebookPermissionChecked:function(A){if(A==0||A==null){this.facebookPromptPermission(this.permissionsToCheck,CallbackProxy(this,this.facebookPermissionGranted));}else{this.facebookPermissionGranted();}},facebookConnected:function(){if(!this.connectedToFB&&this.session==null){this.sendEvent(Planeto.Facebook.Control.CONTACT_WITH_FB);FB.Connect.requireSession(CallbackProxy(this,this.facebookException));}else{this.facebookPermissionGranted();this.facebookGetFriends();}},facebookNotConnected:function(){this.sendEvent(Planeto.Facebook.Control.NOT_CONNECTED,this.connectedToFB);this.connectedToFB=false;setCookie("PlanetoFacebookUserKey","");},facebookPermissionGranted:function(){clearTimeout(this.FBPermissionRef);if(this.session==null){var A=this;this.FBPermissionRef=setTimeout(function(){A.facebookException();},10000);return ;}if(!this.connectedToFB){this.sendEvent(Planeto.Facebook.Control.CONNECTED,this.session.accessToken);}this.connectedToFB=true;},facebookPublishFeed:function(I,A,D,K,H,L,E,G,C){console.warn($(this));var L=L!=null?L:function(){},B="http://play.planeto.com#uref=puid-"+user_id;if(!C){C=false;}if(!A.href){if(E&&E.linkBonus){B+="&lb="+E.linkBonus.identity;A.properties={"Click the link to get a free gift":{text:E.linkBonus.description,href:B}};
}if(E&&E.waveMessageId){B+="&wm="+E.waveMessageId;A.properties={"Quiz wave":{text:"Click to play it!",href:B}};}if(E&&E.gameType){B+="&gt="+E.gameType;}A.href=B;}if(A.media&&!A.media[0].href){A.media[0].href=B;}if(D==""){D=[{text:"Play Planeto Now",href:B}];}var J={method:"stream.publish",attachment:A,action_links:D,user_message_prompt:K,};if(H!=""&&H!=undefined){J.target_id=H;}if(!C){FB.ui(J,L);}else{var F=J.attachment;J.attachment=null;J.name=F.name;J.link=F.href;J.caption=F.caption;J.picture=F.media[0].src;J.description=(F.description?F.description:" ");J.actions=[{name:J.action_links[0].text,link:J.action_links[0].href}];FB.api("/me/feed","POST",J,L);}},facebookGetFriends:function(A){if(this.connectedToFB){FB.api("/me/friends",function(B){fb_friends=B.data;if(A){A(B);}});}},facebookAddFriend:function(A){FB.ui({method:"friends.add",id:A});}});Planeto.Facebook.Control.CONTACT_WITH_FB="Planeto.Facebook.Control.CONTACT_WITH_FB";Planeto.Facebook.Control.CONNECT="Planeto.Facebook.Control.connect";Planeto.Facebook.Control.CONNECTED="Planeto.Facebook.Control.connected";Planeto.Facebook.Control.NOT_CONNECTED="Planeto.Facebook.Control.notConnected";Planeto.Facebook.Control.DISCONNECTED="Planeto.Facebook.Control.disconnected";Planeto.Facebook.Control.LOGOUT="Planeto.Facebook.Control.logout";BasicMVC.Facade.getInstance().register(new Planeto.Facebook.Control());if(!this.JSON){JSON={};}(function(){function f(n){return n<10?"0"+n:n;}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z";};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key);}if(typeof rep==="function"){value=rep.call(holder,key,value);}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null";}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null";}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v;}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v);}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v;}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" ";}}else{if(typeof space==="string"){indent=space;}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify");}return str("",{"":value});};}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;
function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}return reviver.call(holder,key,value);}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4);});}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j;}throw new SyntaxError("JSON.parse");};}})();function getCookie(A){if(document.cookie.length>0){c_start=document.cookie.indexOf(A+"=");if(c_start!=-1){c_start=c_start+A.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1){c_end=document.cookie.length;}return unescape(document.cookie.substring(c_start,c_end));}}return"";}function set_cookie(C,E,A,H,D,G){var B=new Date();B.setTime(B.getTime());if(A){A=A*1000*60*60*24;}var F=new Date(B.getTime()+(A));document.cookie=C+"="+escape(E)+((A)?";expires="+F.toGMTString():"")+((H)?";path="+H:"")+((D)?";domain="+D:"")+((G)?";secure":"");}function setCookie(D,C,A){var B=new Date();B.setDate(B.getDate()+A);document.cookie=D+"="+escape(C)+((A==null)?"":";expires="+B.toGMTString());}function checkCookie(){username=getCookie("username");if(username!=null&&username!=""){alert("Welcome again "+username+"!");}else{username=prompt("Please enter your name:","");if(username!=null&&username!=""){setCookie("username",username,365);}}}Buffer=function(A){this.listener=A;this.buf="";this.position=0;};Buffer.prototype.append=function(B){var A=B.indexOf("^");if(A==-1){this.buf=this.buf+B;this.debug("PART OF PACKAGE");}else{this.buf=this.buf+B.substring(0,A);this.debug("FOUND COMPLETE PACKAGE");var C=this.buf;this.buf="";this.listener.onPacket(C);this.debug("____> BUFFERT IS EMPTY");this.append(B.substring(A+1));}};Buffer.prototype.debug=function(B){if(location.href.indexOf("showbuffer")!=-1){console.log("****************************"+B+"*******************************");var A=new Date();console.log("WebSocket data ["+A.toLocaleTimeString()+" "+A.getMilliseconds()+"]: ");console.log(this.buf);console.log("");}};ConnectionControl=BasicMVC.Base.extend({constructor:function(){this.name="ConnectionControl";this.connectedToPlaneto=false;this.connectedAsGuest=false;this.connectedToFB=false;this.connectiontoFBIsSet=false;this.convertingToFB=false;this.loginInProgress=false;this.loggedInState="";this.idle_countdown=0;playerIdle=false;this.linkBonus="";$("body").live("click",this.localScopeFull(this.detectIdle));setInterval(CallbackProxy(this,function(){this.sendEvent(PlanetoService.HEARTBEAT_REQUEST);}),120000);connectionRef=this;if(location.href.indexOf("fkn")!=-1){href_match_kn=true;setCookie("auth-method","facebook",365);}if(location.href.indexOf("unfreeze")!=-1){$("#unfreezeButtonContainer").show();}},eventListeners:function(){return[Planeto.Application.Control.LOAD_FINISHED,ConnectionControl.NEW_GAME,PlanetoEvents.CONNECT_RESPONSE,Planeto.Facebook.Control.NOT_CONNECTED,Planeto.Facebook.Control.CONNECTED,PlanetoEvents.FORCED_LOGOUT_EVENT,PlanetoEvents.LOGIN_RESPONSE,PlanetoEvents.LOGOUT_RESPONSE,PlanetoEvents.CONVERT_LOGIN_RESULT_RESPONSE,ConnectionControl.COOKIE_LOGIN,ConnectionControl.GOOGLE_LOGIN,ConnectionControl.FACEBOOK_LOGIN,ConnectionControl.OPEN_FACEBOOK_LOGIN,PlanetoEvents.OPEN_ID_REDIRECT_EVENT];},eventHandlers:function(A){switch(A.name){case Planeto.Application.Control.LOAD_FINISHED:this.connect();break;case PlanetoEvents.CONNECT_RESPONSE:this.onConnectResponse(A.data);break;case Planeto.Facebook.Control.NOT_CONNECTED:this.facebookNotConnected(A.data);break;case Planeto.Facebook.Control.CONNECTED:this.facebookConnected(A.data);break;case PlanetoEvents.FORCED_LOGOUT_EVENT:this.forcedLogout();break;case ConnectionControl.NEW_GAME:this.newGame();break;
case PlanetoEvents.LOGIN_RESPONSE:this.loginResponse(A.data);break;case PlanetoEvents.LOGOUT_RESPONSE:this.logoutResponse(A.data);break;case PlanetoEvents.CONVERT_LOGIN_RESULT_RESPONSE:this.onConvertLoginResultResponse(A.data);break;case ConnectionControl.COOKIE_LOGIN:this.loginWithCookie();break;case ConnectionControl.GOOGLE_LOGIN:this.loginWithGoogle(false);break;case ConnectionControl.FACEBOOK_LOGIN:this.loginWithFacebook();break;case ConnectionControl.OPEN_FACEBOOK_LOGIN:this.openFacebookLoginDialog();break;case PlanetoEvents.OPEN_ID_REDIRECT_EVENT:this.openIdRedirectEvent(A.data);break;}},detectIdle:function(){if(playerIdle==true){update_doc_title();playerIdle=false;this.sendEvent(PlanetoService.SET_IDLE,false);}clearTimeout(this.idle_countdown);this.idle_countdown=setTimeout(CallbackProxy(this,function(){playerIdle=true;this.sendEvent(PlanetoService.SET_IDLE,true);}),180000);},connect:function(){href_match_uref=location.href.match(/uref=([^&]*)/);href_match_lb=location.href.match(/lb=([^&]*)/);href_match_wm=location.href.match(/wm=([^&]*)/);href_match_gt=location.href.match(/gt=([^&]*)/);if(href_match_uref&&href_match_uref[1]||href_match_lb&&href_match_lb[1]){if(location.href.indexOf("debug")==-1){location.hash="";}if(href_match_lb&&href_match_lb[1]){this.linkBonus=href_match_lb[1];$.get("api/1.0.0/linkbonuses/"+this.linkBonus,this.localScopeFull(this.onGetLinkbonusResponse),"json");}}this.sendEvent(PlanetoService.CONNECT);},onGetLinkbonusResponse:function(A){if(A.type=="QSetLB"||A.type=="SelfQLB"){$.get("api/1.0.0/questionsets/"+A.itemIdentity,this.localScopeFull(this.onGetQuestionSetResponse),"json");}},onGetQuestionSetResponse:function(A){this.sendEvent(PlanetoEvents.QUESTION_SET_LOADING_EVENT,A);},onConnectResponse:function(A){this.connectedToPlaneto=true;if(href_match_uref&&href_match_uref[1]||href_match_lb&&href_match_lb[1]){this.sendEvent(PlanetoService.SET_REFERENCE_REQUEST,{referenceId:(href_match_uref&&href_match_uref[1]?href_match_uref[1]:null),linkBonus:(href_match_lb&&href_match_lb[1]?href_match_lb[1]:null)});}if(href_match_gt&&href_match_gt[1]){Planeto.Globals.autoStartGameType=href_match_gt[1];}this.sendEvent(Planeto.Facebook.Control.CONNECT,facebookAppID);},useAlternativeLogin:function(){var A=getCookie("auth-method");switch(A){case"openid":this.loginWithGoogle(true);break;default:this.loginInProgress=false;this.showLoginScreen();}},showLoginScreen:function(){if(Planeto.Globals.appMode=="create"){$("#dialogStart").modal();}else{$("#loginScreen").show();$("#loadingArea").hide();if(href_match_kn){$("#loginScreen .google").hide();$("#loginScreen .guest").hide();$("#loginScreen p").html("Login with Facebook to test your knowledge and earn expert certificates.");}$("#screenShotSlider").orbit({animation:"horizontal-slide",animationSpeed:800,timer:true,advanceSpeed:3000,directionalNav:false,captions:true,captionAnimation:"fade",captionAnimationSpeed:800,bullets:true});}},hideLoginScreen:function(){$("#loginScreen").hide();$("#loadingArea").show();},loginWithFacebook:function(){setCookie("auth-method","facebook",365);if(!this.connectedToFB){this.sendEvent(Planeto.Facebook.Control.CONNECT,facebookAppID);}else{var B=this.facade.getInstanceByName("Planeto.Facebook.Control").session,A=B.accessToken;this.hideLoginScreen();this.facebookConnected(A);}},openFacebookLoginDialog:function(){var A=this;FB.api("/me?fields=name",function(B){if(B.error){A.sendEvent(ConnectionControl.FACEBOOK_LOGIN);}workAroundLoginToFacebook(CallbackProxy(A,A.handleFacebookLoginResponse));});},handleFacebookLoginResponse:function(A){if(A!=null){setCookie("auth-method","facebook",365);this.sendEvent(Planeto.Facebook.Control.CONNECTED,A);$("#loginScreen").hide();}},loginWithGoogle:function(B){var A=550,C=850,F=($("body").width()-C)/2,E=($("body").height()-A)/2;_ref=this;if(!B){this.gwin=window.open("","googleWin","directories=0, location=0, menubar=0, resizeable=0, scrollbars=0, status=1, toolbar=0, width="+C+", height="+A+", top="+E+", left="+F);
if(this.gwin){this.gwin.focus();}}var D={providerString:"https://www.google.com/accounts/o8/id",immediate:B};setCookie("auth-method","openid",365);this.sendEvent(PlanetoService.OPEN_ID_LOGIN_REQUEST,D);},loginWithCookie:function(){var B="planeto-cookie",A="";A=getCookie(B);if(A==""||A=="undefined"){A=Math.uuid();}setCookie(B,A,365);setCookie("auth-method","guest",365);this.connectedToFB=false;this.connectedToGoogle=false;this.sendEvent(PlanetoService.COOKIE_LOGIN_REQUEST,A);connectedAsGuest=true;},newGame:function(){if(!this.connectedToFB){this.loggedInState="GUEST";this.logout();}else{this.sendEvent(Planeto.Facebook.Control.LOGOUT);}},logout:function(){setCookie("sessionId","",365);this.sendEvent(PlanetoService.LOGOUT);},facebookNotConnected:function(){clearTimeout(this.FBTimeout);this.connectiontoFBIsSet=true;if(this.connectedToPlaneto){if(this.connectedToFB){this.loggedInState="FB";this.logout();}else{if(connectedAsGuest){}else{this.useAlternativeLogin();}}this.sendEvent(ConnectionControl.NOT_LOGGED_IN_TO_FACEBOOK);}this.connectedToFB=false;},facebookConnected:function(B){if(!this.loginInProgress){this.loginInProgress=true;clearTimeout(this.FBTimeout);this.connectiontoFBIsSet=true;this.connectedToFB=true;if(this.connectedToPlaneto){var C=this.facade.getInstanceByName("Planeto.Facebook.Control").session,A=C.signedRequest;set_cookie("fbsr_"+facebookAppID,A,false,"/",(location.hostname=="local.planeto.net"?".planeto.net":".planeto.com"));switch(Planeto.Globals.appMode){case"create":this.ucqLoginProcedure(B);break;default:this.defaultLoginProcedure(B);break;}}}},defaultLoginProcedure:function(A){var B=getCookie("auth-method");if(B=="facebook"){if(connectedAsGuest){this.facebookConvertLogin(A);}else{this.loginToPlanetoAsFB(A);}connectedAsGuest=false;setCookie("auth-method","facebook",365);this.sendEvent(ConnectionControl.LOGGED_IN_TO_FACEBOOK);}else{this.useAlternativeLogin();}},ucqLoginProcedure:function(A){this.loginToPlanetoAsFB(A);},forcedLogout:function(){if(this.loggedInState=="FB"){this.loggedInState="";this.sendEvent(ConnectionControl.NOT_LOGGED_IN_TO_FACEBOOK);}this.removeLoginCookie();window.location.href=logout_address;},loginToPlanetoAsFB:function(A){this.sendEvent(PlanetoService.FACEBOOK_LOGIN,A);},facebookConvertLogin:function(A){this.removeLoginCookie();this.convertingToFB=true;this.sendEvent(PlanetoService.FACEBOOK_CONVERT_LOGIN_REQUEST,A);},openIdRedirectEvent:function(B){$("#google_account").val("");clearTimeout(this.timerWin);this.timerWin=setInterval(this.localScopeFull(this.googleSigChanged),500);if(B.redirectUrl.indexOf("openid.mode=checkid_setup")!=-1){this.gwin.location=B.redirectUrl;if(this.gwin){this.gwin.focus();}}else{var A=$("<iframe>");A.attr("width",1);A.attr("height",1);A.attr("frameBorder",0);A.attr("src",B.redirectUrl);$("body").append(A);}},googleSigChanged:function(){var A=$("#google_account").val();if(A!=""){if(A=="failed"){this.showLoginScreen();}else{this.gwinAuthSubmitted=true;this.connectedToGoogle=true;this.sendEvent(PlanetoService.OPEN_ID_VERIFICATION_REQUEST,A);}$("#google_account").val("");clearTimeout(this.timerWin);}if(this.gwin&&this.gwin.closed){clearTimeout(this.timerWin);if(A==""){$("#google_account").val("");}}},removeLoginCookie:function(){setCookie("auth-method","",-365);setCookie("planeto-cookie","",-365);},loginToPlaneto:function(){var A=getCookie("sessionId");if(A==""||A=="undefined"){A="planeto-"+Math.random().toString().substr(2)+"";setCookie("sessionId",A,365);}connectedAsGuest=true;this.sendEvent(PlanetoService.GUEST_LOGIN,A);},loginResponse:function(A){this.loginInProgress=false;this.hideLoginScreen();A.connectedToPlaneto=this.connectedToPlaneto;A.connectedAsGuest=connectedAsGuest;A.connectedToFB=this.connectedToFB;A.connectedToGoogle=this.connectedToGoogle;connectedToFB=this.connectedToFB;connectedToGoogle=this.connectedToGoogle;if(!A.error){this.sendEvent(ConnectionControl.LOGIN_RESPONSE,A);}else{this.sendEvent(ConnectionControl.LOGIN_RESPONSE_ERROR,A);if(A.errorType=="THIRD_PARTY_ACCOUNT_ALREADY_ASSOCIATED"){this.pageReload();
}}},logoutResponse:function(A){this.removeLoginCookie();window.location.href=logout_address;},onConvertLoginResultResponse:function(A){this.loginInProgress=false;if(requiresReloadAfterConvertAccount||A.requiresReload){this.pageReload();}else{if(this.convertingToFB){connectedToFB=true;this.sendEvent(ConnectionControl.CONVERTED_TO_FACEBOOK);}}},pageReload:function(){if(this.linkBonus!=""){location.hash="lb="+this.linkBonus;}window.location.reload();}});ConnectionControl.NEW_GAME="connectionControl.newGame";ConnectionControl.LOGIN_RESPONSE="ConnectionControl.LOGIN_RESPONSE";ConnectionControl.LOGIN_RESPONSE_ERROR="connectionControl.loginResponseError";ConnectionControl.LOGGED_IN_TO_FACEBOOK="ConnectionControl.LOGGED_IN_TO_FACEBOOK";ConnectionControl.NOT_LOGGED_IN_TO_FACEBOOK="connectionControl.NOT_LOGGED_IN_TO_FACEBOOK";ConnectionControl.COOKIE_LOGIN="ConnectionControl.COOKIE_LOGIN";ConnectionControl.GOOGLE_LOGIN="ConnectionControl.GOOGLE_LOGIN";ConnectionControl.FACEBOOK_LOGIN="ConnectionControl.FACEBOOK_LOGIN";ConnectionControl.OPEN_FACEBOOK_LOGIN="ConnectionControl.OPEN_FACEBOOK_LOGIN";ConnectionControl.CONVERTED_TO_FACEBOOK="ConnectionControl.CONVERTED_TO_FACEBOOK";BasicMVC.Facade.getInstance().register(new ConnectionControl());if(location.href.indexOf("debug")!=-1){PlanetoDebug=BasicMVC.Base.extend({constructor:function(){this.startTime={};var A='<div id="debugInterface"><h2>Debug:</h2><h3 id="debugServerVersion">Wait...</h3><h3 id="debugProtocolVersion">Wait...</h3><h3 id="debugDatabaseSchemaVersion">Wait...</h3><h3 id="sessionId">Waiting for the user session id...</h3><br/><h3 id="authMode"></h3><br/><h3>URL commands</h3><div>&debug = Activate debugging<br/>&notutorial = No tutorial<br/>&resetinventory = Reset tutorial to 1st bag<br/>&resettutorial = Rest tutorial to beginning<br/>&socketlogger = Activate socket logger<br/>&FBApp = Preview of FB version<br/>&nows = Inactivate native web sockets<br/>&settings = Show user settings<br/>&nobrowsercheck = Play with any browser<br/>&showbuffer = Show buffer</div><br/><div id="debugQS"><h3>QuestionSets</h3><ul></ul></div><br/><div id="debugSQ"><h3>SelfQuizes</h3><ul></ul></div><br/><div id="questionsAnswered">Questions answered: <span></span></div><div id="userDifLevel">Difficulty level: <span>Wait...</span></div><div id="questionDif">Question difficulty: <span>Wait...</span></div><br/><div id="functionsRun"></div><div id="functionsRunReset">[reset debuglogging]</div><div id="loadMapChain">[Load MapChain]</div></div>';$("body").append(A);$("#debugCommands").append($("<div>Simulate NEW DAY</div>").bind("click",this.localScope(function(){this.sendEvent(Planeto.UpdateFeed.Control.NEW_DAY);})),$("<div>Simulate respite from server</div>").bind("click",this.localScope(function(){this.sendEvent(PlanetoEvents.RESPITE_EVENT);})),$("<div>Close the dialog</div>").bind("click",function(){$.modal.close();}));$("#functionsRunReset").bind("click",this.localScope(this.debugReset));$("#debugQS li span").live("click",this.localScopeFull(this.startQuestionSet));$("#debugSQ li span").live("click",this.localScopeFull(this.startSelfQuiz));$("#loadMapChain").live("click",this.localScopeFull(this.loadMapChain));},eventListeners:function(){return[PlanetoEvents.CONNECT_RESPONSE,PlanetoEvents.LOGIN_RESPONSE,PlanetoEvents.NEW_QUIZ_RESPONSE,PlanetoEvents.GET_SOME_QUESTION_SETS_RESPONSE,PlanetoEvents.GET_SOME_SELF_QUIZES_RESPONSE,ConnectionControl.LOGIN_RESPONSE];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.CONNECT_RESPONSE:this.connectResponse(A.data);break;case PlanetoEvents.LOGIN_RESPONSE:break;case PlanetoEvents.NEW_QUIZ_RESPONSE:this.sendEvent(PlanetoService.GET_SOME_QUESTION_SETS);this.sendEvent(PlanetoService.GET_SOME_SELF_QUIZES);break;case PlanetoEvents.GET_SOME_QUESTION_SETS_RESPONSE:this.getSomeQuestionSetsResponse(A.data);break;case PlanetoEvents.GET_SOME_SELF_QUIZES_RESPONSE:this.getSomeSelfQuizesResponse(A.data);break;case ConnectionControl.LOGIN_RESPONSE:this.loginResponse(A.data);
break;}},debugReset:function(){this.startTime={};$("#functionsRun").html("");},connectResponse:function(A){$("#debugServerVersion").html("Server: "+A.longServerVersion);$("#debugProtocolVersion").html("Protocol: "+A.protocolVersion);$("#debugDatabaseSchemaVersion").html("Database: "+A.databaseSchemaVersion);},loginResponse:function(A){if(A.account!=null){$("#sessionId").html("SessionId: "+A.account.user.id);}if(A.connectedToFB){$("#authMode").html("Connected with Facebook");}if(A.connectedToGoogle){$("#authMode").html("Connected with Google");}if(A.connectedAsGuest){$("#authMode").html("Connected as Guest");}},getSomeQuestionSetsResponse:function(C){var A=C.questionSets.length,E="";if(A>0){for(var D=0;D<A;D++){var B=C.questionSets[D];E+="<li id='"+B.identity+"'><a href='#lb="+B.identity+"'>"+htmlEncode(B.name).substring(0,30)+"</a> <span>now &raquo;</span></li>";}}else{E+="<li>Nope</li>";}$("#debugQS ul").html(E);},startQuestionSet:function(B){var A=$(B.target).parents("li");this.sendEvent(PlanetoService.START_QUESTION_SET,A.attr("id"));A.hide();},getSomeSelfQuizesResponse:function(B){var A=B.selfQuizes.length,E="";if(A>0){for(var D=0;D<A;D++){var C=B.selfQuizes[D];E+="<li id='"+C.identity+"'><a href='#lb="+C.identity+"'>"+htmlEncode(C.name).substring(0,30)+"</a> <span>now &raquo;</span></li>";}}else{E+="<li>Nope</li>";}$("#debugSQ ul").html(E);},startSelfQuiz:function(B){var A=$(B.target).parents("li");this.sendEvent(PlanetoService.START_SELF_QUIZ,A.attr("id"));A.hide();},toggleHotSeatView:function(){var A=$("#debugHotSeatView");A.toggleClass("active");if(A.hasClass("active")){this.sendEvent(Planeto.HotSeat.View.INIT);A.find("span").html("ON");}else{this.sendEvent(Planeto.HotSeat.View.RESET);A.find("span").html("OFF");}},challengeFriends:function(){this.sendEvent(Planeto.ChallengeFriends.SHOW);},generateFriends:function(){this.sendEvent(Planeto.ChallengeFriends.GENERATE_FRIENDS,$("#debugFriendsToGenerate").val());},loadMapChain:function(){this.sendEvent(Planeto.StarHunt.DISPLAY_MISSION_LOADER);}});PlanetoEvents.DEBUG_START="PlanetoEvents.DEBUG_START";PlanetoEvents.DEBUG_END="PlanetoEvents.DEBUG_END";BasicMVC.Facade.getInstance().register(new PlanetoDebug());}function IsTeamNameAvailableRequest(A){this.type="team.IsTeamNameAvailableRequest";this.name=A;}function KickPlayerFromTeamRequest(A,B){this.type="team.KickPlayerFromTeamRequest";this.playerId=A;this.teamId=B;}function GetTeamInfoRequest(A){this.type="team.GetTeamInfoRequest";this.teamId=A;}function DisbandTeamRequest(A){this.type="team.DisbandTeamRequest";this.teamId=A;}function InitiateCreateTeamRequest(){this.type="team.InitiateCreateTeamRequest";}function GetTeamsListRequest(){this.type="team.GetTeamsListRequest";}function InviteToTeamRequest(B,A){this.type="team.InviteToTeamRequest";this.teamId=B;this.playerId=A;}function GetTeamMembersRequest(A){this.type="team.GetTeamMembersRequest";this.teamId=A;}function SetPrimaryTeamRequest(A){this.type="team.SetPrimaryTeamRequest";this.teamId=A;}function CreateTeamRequest(A,B,C,D){this.type="team.CreateTeamRequest";this.teamType=A;this.name=B;this.slogan=C;this.description=D;}function RespondToTeamInviteRequest(A,B){this.type="team.RespondToTeamInviteRequest";this.teamId=A;this.accepted=B;}function LeaveTeamRequest(A){this.type="team.LeaveTeamRequest";this.teamId=A;}function GetStarHuntMapRequest(A){this.type="ucq2.create.GetStarHuntMapRequest";this.mapIdentity=A;}function SaveStarHuntMapChainRequest(A){this.type="ucq2.create.SaveStarHuntMapChainRequest";this.mapChain=A;}function DeleteUserCreatedContentRequest(A){this.type="ucq2.create.DeleteUserCreatedContentRequest";this.id=A;}function UCQGetMissionsInMissionPackRequest(A){this.type="ucq2.create.UCQGetMissionsInMissionPackRequest";this.missionPackIdentity=A;}function DeleteStarHuntContentRequest(C,A,B){this.type="ucq2.create.DeleteStarHuntContentRequest";this.mapIdentity=C;this.chainIdentity=A;this.packIdentity=B;}function GetAvailableStarHuntTypesRequest(){this.type="ucq2.create.GetAvailableStarHuntTypesRequest";
}function SaveUserCreatedContentRequest(B,A,C){this.type="ucq2.create.SaveUserCreatedContentRequest";this.question=B;this.questionSet=A;this.selfQuiz=C;}function GetAllQuestionLanguagesRequest(){this.type="ucq2.create.GetAllQuestionLanguagesRequest";}function GetUserCreatedMissionPacksRequest(){this.type="ucq2.create.GetUserCreatedMissionPacksRequest";}function SaveStarHuntMapRequest(B,A){this.type="ucq2.create.SaveStarHuntMapRequest";this.map=B;this.chainIdentity=A;}function GetUserCreatedContentRequest(A){this.type="ucq2.create.GetUserCreatedContentRequest";this.id=A;}function TempGetStarHuntMapRequest(){this.type="ucq2.create.TempGetStarHuntMapRequest";}function SaveStarHuntMissionPackRequest(A){this.type="ucq2.create.SaveStarHuntMissionPackRequest";this.missionPack=A;}function NewUCQSessionRequest(){this.type="ucq2.application.NewUCQSessionRequest";}function SetMetaDataRequest(A,B){this.type="metadata.SetMetaDataRequest";this.key=A;this.value=B;}function ReportSocialGoldPurchaseSuccessRequest(B,A){this.type="payment.ReportSocialGoldPurchaseSuccessRequest";this.success=B;this.url=A;}function InitiateSocialGoldPurchaseRequest(){this.type="payment.InitiateSocialGoldPurchaseRequest";}function ReportQuestionRequest(A,C,B){this.type="feedback.ReportQuestionRequest";this.questionId=A;this.comment=C;this.problem=B;}function LocationSelectionRequest(){this.type="common.location.LocationSelectionRequest";}function ListCitiesRequest(A){this.type="common.location.ListCitiesRequest";this.countryIsoCode=A;}function InviteToChatRequest(A){this.type="chat.InviteToChatRequest";this.invitedPlayerId=A;}function LeaveChatRequest(A){this.type="chat.LeaveChatRequest";this.chatRoomId=A;}function OpenChatRequest(A){this.type="chat.OpenChatRequest";this.chatRoomId=A;}function SendMessageRequest(B,A){this.type="chat.SendMessageRequest";this.chatRoomId=B;this.message=A;}function GetAvailableChatRoomsRequest(){this.type="chat.GetAvailableChatRoomsRequest";}function AccountRegistrationRequest(C,B,A,D){this.type="account.AccountRegistrationRequest";this.nickName=C;this.email=B;this.password=A;this.cityId=D;}function IsInvitedByEmailRequest(A){this.type="account.invite.IsInvitedByEmailRequest";this.email=A;}function InviteByEmailRequest(A,B){this.type="account.invite.InviteByEmailRequest";this.email=A;this.text=B;}function AwardRoleFromInvitationRequest(B,A){this.type="account.AwardRoleFromInvitationRequest";this.invitationCode=B;this.sessionKey=A;}function SystemLoginRequest(A,B){this.type="account.system.SystemLoginRequest";this.facebookId=A;this.accountIdentity=B;}function StopIgnoringUserRequest(A){this.type="account.StopIgnoringUserRequest";this.userIdentity=A;}function AccountRoleRequest(A){this.type="account.AccountRoleRequest";this.role=A;}function SetQuestionLanguageRequest(A){this.type="account.SetQuestionLanguageRequest";this.id=A;}function GuestLoginRequest(A){this.type="account.guest.GuestLoginRequest";this.guestUserId=A;}function GetFacebookIdForFriendRequest(A){this.type="account.GetFacebookIdForFriendRequest";this.friendIdentity=A;}function FacebookLoginRequest(A){this.type="account.facebook.FacebookLoginRequest";this.accessToken=A;}function NotifyFacebookPostChoiceRequest(A,B,C){this.type="account.facebook.NotifyFacebookPostChoiceRequest";this.userPosted=A;this.param=B;this.facebookPostType=C;}function FacebookApplicationInvitationRequest(A){this.type="account.facebook.FacebookApplicationInvitationRequest";this.facebookUserId=A;}function FacebookConvertLoginRequest(A){this.type="account.facebook.FacebookConvertLoginRequest";this.accessToken=A;}function AcceptedTermsOfServiceRequest(){this.type="account.AcceptedTermsOfServiceRequest";}function LogoutRequest(A){this.type="account.LogoutRequest";this.postedToFacebook=A;}function SetUserSettingsRequest(H,B,J,D,F,C,I,A,G,E){this.type="account.simpleusersettings.SetUserSettingsRequest";this.currentSiteLanguageId=H;this.currentQuestionLanguageId=B;this.countryId=J;this.cityId=D;this.email=F;this.wantsWeeklyNewsLetter=C;
this.wantsUpdateAboutFriends=I;this.wantsGameUpdates=A;this.wantsPopularCommunityActivities=G;this.wantsQuestionSetEmail=E;}function GetUserSettingsRequest(){this.type="account.simpleusersettings.GetUserSettingsRequest";}function GetMatchingCitiesRequest(B,A){this.type="account.simpleusersettings.GetMatchingCitiesRequest";this.countryIso=B;this.partialName=A;}function CookieLoginRequest(A){this.type="account.cookie.CookieLoginRequest";this.cookieId=A;}function VerifyBetaAccountRequest(B,A){this.type="account.VerifyBetaAccountRequest";this.host=B;this.sessionKey=A;}function AccountValidationRequest(C,B,A,D){this.type="account.AccountValidationRequest";this.nickName=C;this.email=B;this.password=A;this.cityId=D;}function SetUrlParamsRequest(A,C,B){this.type="account.SetUrlParamsRequest";this.promotionalReferenceId=A;this.linkBonusId=C;this.waveMessageId=B;}function IgnoreUserRequest(A){this.type="account.IgnoreUserRequest";this.userIdentity=A;}function OpenIdVerificationRequest(A){this.type="account.openid.OpenIdVerificationRequest";this.url=A;}function OpenIdLoginRequest(B,A){this.type="account.openid.OpenIdLoginRequest";this.providerString=B;this.immediate=A;}function GenerateAccountRoleInvitationRequest(A){this.type="account.GenerateAccountRoleInvitationRequest";this.accountRoleName=A;}function GetGameRoomsAndCollectionsForGameRequest(A){this.type="gameroom.GetGameRoomsAndCollectionsForGameRequest";this.gameRoomGame=A;}function JoinTeamGameRoomRequest(A,B){this.type="gameroom.JoinTeamGameRoomRequest";this.teamIdentity=A;this.gameRoomGame=B;}function SelectGameRoomCollectionRequest(A){this.type="gameroom.SelectGameRoomCollectionRequest";this.collectionIdentity=A;}function SkipHotSeatQuestionRequest(){this.type="gameroom.hotseat.SkipHotSeatQuestionRequest";}function GetAvailableGameRoomGamesRequest(){this.type="gameroom.GetAvailableGameRoomGamesRequest";}function PickPictureGridCellRequest(B,A){this.type="gameroom.picturequiz.PickPictureGridCellRequest";this.row=B;this.col=A;}function VoteToSkipCurrentPictureRequest(){this.type="gameroom.picturequiz.VoteToSkipCurrentPictureRequest";}function RpcRequest(A,B,C){this.type="rpc.RpcRequest";this.objectId=A;this.methodName=B;this.parameters=C;}function ParameterDTO(A,B){this.type="rpc.ParameterDTO";this.type=A;this.value=B;}function TopPlayersRequest(){this.type="site.homepage.TopPlayersRequest";}function HeartbeatRequest(){this.type="site.HeartbeatRequest";}function ConnectRequest(C,B,A){this.type="site.ConnectRequest";this.userAgent=C;this.location=B;this.acceptLanguage=A;}function PingRequest(A){this.type="site.PingRequest";this.data=A;}function DisconnectRequest(){this.type="site.DisconnectRequest";}function SetIdleRequest(A){this.type="site.SetIdleRequest";this.idle=A;}function FlagCleanDisconnect(){this.type="site.FlagCleanDisconnect";}function PassWaveToPlanetoUserRequest(A,B){this.type="wave.PassWaveToPlanetoUserRequest";this.waveMessageId=A;this.recipientId=B;}function BePartOfWaveRequest(A){this.type="wave.BePartOfWaveRequest";this.waveMessageId=A;}function AcknowledgeWaveRequest(A){this.type="wave.AcknowledgeWaveRequest";this.waveMessageId=A;}function GetWavesRequest(){this.type="wave.GetWavesRequest";}function ReceiveBonusForWaveRequest(A){this.type="wave.ReceiveBonusForWaveRequest";this.waveMessageId=A;}function CreateWaveRequest(A){this.type="wave.CreateWaveRequest";this.questionSetId=A;}function RejectWaveRequest(A){this.type="wave.RejectWaveRequest";this.waveMessageId=A;}function SearchQuestionSetForWaveRequest(A,B){this.type="wave.SearchQuestionSetForWaveRequest";this.searchStr=A;this.itemsLimit=B;}function PassWaveToFacebookUserRequest(A,B,C){this.type="wave.PassWaveToFacebookUserRequest";this.waveMessageId=A;this.facebookPostId=B;this.facebookId=C;}function SetMasteryPointsRequest(A){this.type="quiz.SetMasteryPointsRequest";this.points=A;}function GetStarHuntMissionPacksRequest(B,A){this.type="quiz.starhunt.GetStarHuntMissionPacksRequest";this.offset=B;this.amount=A;
}function PurchaseStarHuntMissionPackRequest(A){this.type="quiz.starhunt.PurchaseStarHuntMissionPackRequest";this.missionPackIdentity=A;}function AttemptStarHuntMoveRequest(B,A){this.type="quiz.starhunt.AttemptStarHuntMoveRequest";this.row=B;this.col=A;}function ContinueStarHuntMapChainRequest(){this.type="quiz.starhunt.ContinueStarHuntMapChainRequest";}function GetMissionsInMissionPackRequest(A){this.type="quiz.starhunt.GetMissionsInMissionPackRequest";this.missionPackIdentity=A;}function NextTipsAndTricksRequest(){this.type="quiz.tips.NextTipsAndTricksRequest";}function GetDefaultTeamLeaderBoardRequest(A){this.type="quiz.leaderboard.team.GetDefaultTeamLeaderBoardRequest";this.nbrOfEntries=A;}function GetFilteredTeamLeaderBoardRequest(D,B,A,C){this.type="quiz.leaderboard.team.GetFilteredTeamLeaderBoardRequest";this.nbrOfEntries=D;this.firstEntryPosition=B;this.teamType=A;this.columnToSortBy=C;}function GetFilteredLeaderBoardRequest(A,H,I,J,F,D,C,G,E,B){this.type="quiz.leaderboard.GetFilteredLeaderBoardRequest";this.minLevel=A;this.maxLevel=H;this.networkRange=I;this.columnToSortBy=J;this.nbrOfEntries=F;this.firstEntryPositionNumber=D;this.countryISOCode=C;this.cityId=G;this.teamId=E;this.allCountriesList=B;}function GetDefaultLeaderBoardRequest(A){this.type="quiz.leaderboard.GetDefaultLeaderBoardRequest";this.nbrOfEntries=A;}function GetDropRequest(A){this.type="quiz.item.GetDropRequest";this.identity=A;}function MoveItemRequest(B,A){this.type="quiz.item.MoveItemRequest";this.updatedItem=B;this.dropIdentity=A;}function BuyMoreInventorySpaceRequest(){this.type="quiz.item.BuyMoreInventorySpaceRequest";}function DiscardItemRequest(D,A,C,B){this.type="quiz.item.DiscardItemRequest";this.id=D;this.container=A;this.slot=C;this.dropIdentity=B;}function DiscardDropRequest(A){this.type="quiz.item.DiscardDropRequest";this.identity=A;}function SubmitSelfQuizAnswersRequest(B,A){this.type="quiz.selfquiz.SubmitSelfQuizAnswersRequest";this.answers=B;this.identity=A;}function StartSelfQuizRequest(A){this.type="quiz.selfquiz.StartSelfQuizRequest";this.identity=A;}function GetSomeSelfQuizesRequest(){this.type="quiz.selfquiz.GetSomeSelfQuizesRequest";}function ViewUserProfileRequest(A){this.type="quiz.viewuserprofile.ViewUserProfileRequest";this.playerId=A;}function GetSessionStatsRequest(){this.type="quiz.GetSessionStatsRequest";}function AcceptQuestRequest(A){this.type="quiz.quest.AcceptQuestRequest";this.questSlot=A;}function GetQuestsRequest(){this.type="quiz.quest.GetQuestsRequest";}function GetCompletedQuestsRequest(){this.type="quiz.quest.GetCompletedQuestsRequest";}function BuyNewQuestRequest(A){this.type="quiz.quest.BuyNewQuestRequest";this.slotIndex=A;}function ClaimQuestRewardRequest(A){this.type="quiz.quest.ClaimQuestRewardRequest";this.slotIndex=A;}function DismissQuestRequest(A){this.type="quiz.quest.DismissQuestRequest";this.slotIndex=A;}function DuelClientGivesUpRequest(){this.type="quiz.duel.DuelClientGivesUpRequest";}function DuelQuestionAnsweredRequest(A,B){this.type="quiz.duel.DuelQuestionAnsweredRequest";this.question=A;this.answerIndex=B;}function DuelReadyToPlayRequest(){this.type="quiz.duel.DuelReadyToPlayRequest";}function GetFacebookIdForFriendsWhoPlayedAQuestionSet(A){this.type="quiz.questionset.GetFacebookIdForFriendsWhoPlayedAQuestionSet";this.qsetIdentity=A;}function GetQuestionSetLeaderboardRequest(A,D,C,B){this.type="quiz.questionset.GetQuestionSetLeaderboardRequest";this.identity=A;this.nbrOfEntries=D;this.firstEntryPositionNumber=C;this.networkRange=B;}function GetRewardForChallengingAFriendRequest(A){this.type="quiz.questionset.GetRewardForChallengingAFriendRequest";this.rewardType=A;}function RateQuestionSetRequest(B,A){this.type="quiz.questionset.RateQuestionSetRequest";this.mood=B;this.identity=A;}function GetSomeQuestionSetsRequest(){this.type="quiz.questionset.GetSomeQuestionSetsRequest";}function StartQuestionSetRequest(A){this.type="quiz.questionset.StartQuestionSetRequest";this.identity=A;}function GetQuestionSetLeaderboardForTeamRequest(A,C,B,D){this.type="quiz.questionset.GetQuestionSetLeaderboardForTeamRequest";
this.identity=A;this.nbrOfEntries=C;this.firstEntryPositionNumber=B;this.teamIdentity=D;}function QuestionSetPublishedToFacebookRequest(A){this.type="quiz.questionset.QuestionSetPublishedToFacebookRequest";this.linkBonusIdentity=A;}function GetCompletedQuestionSetsRequest(A){this.type="quiz.questionset.GetCompletedQuestionSetsRequest";this.nbrOfItems=A;}function AddCommentToQuestionSetRequest(A,B){this.type="quiz.questionset.AddCommentToQuestionSetRequest";this.identity=A;this.comment=B;}function _AddScoreRequest(A){this.type="quiz.debug._AddScoreRequest";this.score=A;}function GetMasteryPointsRequest(){this.type="quiz.GetMasteryPointsRequest";}function RespondToChallengeRequest(B,A){this.type="quiz.lobby.RespondToChallengeRequest";this.challengeId=B;this.accepted=A;}function SetPlayerReadyStateRequest(A){this.type="quiz.lobby.SetPlayerReadyStateRequest";this.ready=A;}function LeaveLobbyRequest(){this.type="quiz.lobby.LeaveLobbyRequest";}function ChallengeToDuelRequest(A){this.type="quiz.lobby.ChallengeToDuelRequest";this.opponentId=A;}function QuestionAnsweredRequest(A){this.type="quiz.game.QuestionAnsweredRequest";this.answerIndex=A;}function StartPlayingStarHuntRequest(A){this.type="quiz.game.starhunt.StartPlayingStarHuntRequest";this.mapChainIdentity=A;}function StartPlayingRequest(){this.type="quiz.game.StartPlayingRequest";}function UnfreezeRequest(){this.type="quiz.game.UnfreezeRequest";}function StopGameRequest(){this.type="quiz.game.StopGameRequest";}function NewQuizSessionRequest(){this.type="quiz.game.NewQuizSessionRequest";}function PauseRequest(A){this.type="quiz.game.PauseRequest";this.pauseRequested=A;}function RespiteRequest(A){this.type="quiz.game.RespiteRequest";this.respiteRequested=A;}function ExecuteActionRequest(C,B,A){this.type="quiz.action.ExecuteActionRequest";this.slotIndex=C;this.standard=B;this.identity=A;}function GetLogoutSessionSummaryRequest(){this.type="quiz.GetLogoutSessionSummaryRequest";}RespiteControl=BasicMVC.Base.extend({constructor:function(){this.name="RespiteControl";this.eventList=[];},eventListeners:function(){return[PlanetoEvents.LOST_STREAK_EVENT,PlanetoEvents.CERTIFIED_AS_EXPERT_EVENT,PlanetoEvents.FRIENDS_LIST_PASSING_EVENT,PlanetoEvents.LEVEL_UP_EVENT,PlanetoEvents.RESPITE_EVENT,PlanetoEvents.CHALLENGE_TO_DUEL_EVENT,PlanetoEvents.ALL_QUESTIONS_ANSWERED_IN_DOMAIN_EVENT,PlanetoEvents.RESPITE_INVITE_DIALOG,PlanetoEvents.TEAM_INVITATION_RESPONSE,RespiteControl.CONTINUE,RespiteControl.REPORT_QUESTION_CLICKED,RespiteControl.GET_MORE_GOLD_CLICKED,RespiteControl.SHOW_RESPITE,RespiteControl.SINGLE_MEDAL_RECEIVED,RespiteControl.ADD_SIMPLE_RESPITE,RespiteControl.REMOVE_EVENT,RespiteControl.SHOW_USER_SETTINGS,RespiteControl.TRIGGER_SESSION_STATS,RespiteControl.DROPPED_ITEMS,RespiteControl.SHOW_JACKPOT_EVENT,RespiteControl.INITIATE_CREATE_TEAM,RespiteControl.SHOW_CLAIM_QUEST_REWARD,RespiteControl.SHOW_MULTIPLAYER];},eventHandlers:function(B){switch(B.name){case RespiteControl.INITIATE_CREATE_TEAM:this.showAdvancedRespite({type:PlanetoService.INITIATE_CREATE_TEAM,message:"#showCreateTeamAfterRound"});break;case PlanetoEvents.LOST_STREAK_EVENT:B.data.type=RespiteControl.TRIGGER_LOST_STREAK_FOR_FB;this.addSimpleRespite(B.data);break;case PlanetoEvents.CERTIFIED_AS_EXPERT_EVENT:B.data.type=RespiteControl.TRIGGER_EXPERT_CERTIFICATE_FOR_FB;this.addSimpleRespite(B.data);break;case PlanetoEvents.ALL_QUESTIONS_ANSWERED_IN_DOMAIN_EVENT:B.data.type=RespiteControl.TRIGGER_DOMAIN_QUESTIONS_STATS;this.addSimpleRespite(B.data);break;case PlanetoEvents.FRIENDS_LIST_PASSING_EVENT:B.data.type=RespiteControl.TRIGGER_FRIENDS_LIST_PASSING_FOR_FB;this.addSimpleRespite(B.data);break;case RespiteControl.SHOW_JACKPOT_EVENT:B.data.type=RespiteControl.TRIGGER_JACKPOT_FB;this.addSimpleRespite(B.data);break;case PlanetoEvents.LEVEL_UP_EVENT:this.addLevelUpRespite(B.data);break;case RespiteControl.TRIGGER_SESSION_STATS:this.addSessionStatsRespite(B.data);break;case RespiteControl.DROPPED_ITEMS:this.addDroppedItemsRespite(B.data);
break;case RespiteControl.REPORT_QUESTION_CLICKED:this.showAdvancedRespite({type:Planeto.ReportQuestion.Control.REPORT_QUESTION,message:"#showReportQuestionAfterRound"});break;case PlanetoEvents.RESPITE_INVITE_DIALOG:this.showAdvancedRespite({type:PlanetoEvents.SHOW_INVITE_DIALOG,message:"#showInviteAfterRound"});break;case RespiteControl.SHOW_USER_SETTINGS:this.showAdvancedRespite({type:Planeto.UserSettings.Control.SHOW_USER_SETTINGS,message:"#showUserSettingAfterRound"});break;case RespiteControl.GET_MORE_GOLD_CLICKED:this.sendEvent(PlanetoService.GET_MORE_GOLD);break;case RespiteControl.SHOW_RESPITE:this.showAdvancedRespite({type:RespiteControl.TRIGGER_SHOW_LEADERBOARD,message:"#showLeaderboardAfterRound",originalData:B.data});break;case PlanetoEvents.RESPITE_EVENT:this.respiteEvent();break;case RespiteControl.CONTINUE:this.continueRespite();break;case RespiteControl.SINGLE_MEDAL_RECEIVED:B.data.type=RespiteControl.TRIGGER_MEDAL_RECIEVED;this.addSimpleRespite(B.data);break;case PlanetoEvents.TEAM_INVITATION_RESPONSE:B.data.type=RespiteControl.TEAM_INVITATION_RESPONSE;this.addSimpleRespite(B.data);break;case PlanetoEvents.CHALLENGE_TO_DUEL_EVENT:B.data.type=RespiteControl.TRIGGER_CHALLENGE_TO_DUEL_EVENT;this.addSimpleRespite(B.data);break;case RespiteControl.ADD_SIMPLE_RESPITE:this.addSimpleRespite(B.data);break;case RespiteControl.REMOVE_EVENT:this.removeEventFromStack(B.data);break;case RespiteControl.SHOW_CLAIM_QUEST_REWARD:var A=B.data;this.showAdvancedRespite({type:"Planeto.Quests.View.SHOW_QUEST_COMPLETED_DIALOG",message:"#showClaimQuestRewardAfterRound",quest:A});break;case RespiteControl.SHOW_MULTIPLAYER:this.showAdvancedRespite({type:"Planeto.Multiplayer.INIT",message:"#showMultiplayerAfterRound"});break;}},addSimpleRespite:function(A){if(Planeto.Globals.currentGameType=="INFINITE_STREAM_GAME"||Planeto.Globals.currentGameType=="DUEL_GAME"){this.eventList.push(A);this.sendEvent(PlanetoService.RESPITE,true);}else{this.sendEvent(A.type,A);this.sendEvent(StatusView.HIDE_MESSAGE);}},showAdvancedRespite:function(A){if(A.message){$(A.message+" a").unbind("click").bind("click",CallbackProxy(this,function(){this.removeEventFromStack(A.type);this.sendEvent(A.type,A);this.sendEvent(StatusView.HIDE_MESSAGE);}));this.sendEvent(StatusView.SHOW_MESSAGE,A.message);}this.addSimpleRespite(A);},addLevelUpRespite:function(A){A.type=RespiteControl.TRIGGER_LEVEL_UP;this.addSimpleRespite(A);var B=$.extend(true,{},A);B.type=RespiteControl.TRIGGER_LEVEL_UP_FOR_FB;this.addSimpleRespite(B);},addSessionStatsRespite:function(A){A.type=PlanetoService.SESSION_STATS;this.addSimpleRespite(A);},addDroppedItemsRespite:function(A){if(A.drop.items.length>0){this.removeEventFromStack(RespiteControl.TRIGGER_SHOW_INVENTORY);A.type=PlanetoEvents.TRIGGER_DROPPED_ITEMS;A.message="#showTreasureBagAfterRound";this.showAdvancedRespite(A);}},respiteEvent:function(){if(this.eventList.length>0){this.sendNextEvent();}},continueRespite:function(){this.sendEvent(StatusView.HIDE_MESSAGE);if(this.eventList.length==0){this.sendEvent(PlanetoService.RESPITE,false);Planeto.Globals.gamePaused=false;}else{this.sendNextEvent();}},sendNextEvent:function(){var A=this.eventList.shift();this.sendEvent(A.type,A);this.sendEvent(StatusView.HIDE_MESSAGE);},removeEventFromStack:function(B){for(var A=0;A<this.eventList.length;A++){if(this.eventList[A].type==B){this.eventList.splice(A,1);}}}});PlanetoEvents.TRIGGER_DROPPED_ITEMS="PlanetoEvents.TRIGGER_DROPPED_ITEMS";PlanetoService.SESSION_STATS="PlanetoService.SESSION_STATS";RespiteControl.ADD_SIMPLE_RESPITE="RespiteControl.ADD_SIMPLE_RESPITE";RespiteControl.TRIGGER_LEVEL_UP="RespiteControl.TRIGGER_LEVEL_UP";RespiteControl.TRIGGER_LOST_STREAK_FOR_FB="RespiteControl.TRIGGER_LOST_STREAK_FOR_FB";RespiteControl.TRIGGER_EXPERT_CERTIFICATE_FOR_FB="RespiteControl.TRIGGER_EXPERT_CERTIFICATE_FOR_FB";RespiteControl.TRIGGER_FRIENDS_LIST_PASSING_FOR_FB="RespiteControl.TRIGGER_FRIENDS_LIST_PASSING_FOR_FB";RespiteControl.TRIGGER_DOMAIN_QUESTIONS_STATS="RespiteControl.TRIGGER_DOMAIN_QUESTIONS_STATS";
RespiteControl.TRIGGER_LEVEL_UP_FOR_FB="RespiteControl.TRIGGER_LEVEL_UP_FOR_FB";RespiteControl.SHOW_JACKPOT_EVENT="RespiteControl.SHOW_JACKPOT_EVENT";RespiteControl.TRIGGER_JACKPOT_FB="RespiteControl.TRIGGER_JACKPOT_FB";RespiteControl.TRIGGER_SHOW_INVENTORY="RespiteControl.triggerShowInventory";RespiteControl.TRIGGER_SHOW_LEADERBOARD="RespiteControl.TRIGGER_SHOW_LEADERBOARD";RespiteControl.TRIGGER_MEDAL_RECIEVED="RespiteControl.TRIGGER_MEDAL_RECIEVED";RespiteControl.CONTINUE="RespiteControl.continue";RespiteControl.TRIGGER_CHALLENGE_TO_DUEL_EVENT="RespiteControl.TRIGGER_CHALLENGE_TO_DUEL_EVENT";RespiteControl.REMOVE_EVENT="RespiteControl.REMOVE_EVENT";RespiteControl.GET_MORE_GOLD_CLICKED="RespiteControl.GET_MORE_GOLD_CLICKED";RespiteControl.TRIGGER_SESSION_STATS="RespiteControl.TRIGGER_SESSION_STATS";RespiteControl.SESSION_STATS_REQUEST="RespiteControl.SESSION_STATS_REQUEST";RespiteControl.DROPPED_ITEMS="RespiteControl.DROPPED_ITEMS";RespiteControl.INITIATE_CREATE_TEAM="RespiteControl.INITIATE_CREATE_TEAM";RespiteControl.SHOW_CLAIM_QUEST_REWARD="RespiteControl.SHOW_CLAIM_QUEST_REWARD";RespiteControl.REPORT_QUESTION_CLICKED="RespiteControl.REPORT_QUESTION_CLICKED";RespiteControl.SHOW_USER_SETTINGS="RespiteControl.SHOW_USER_SETTINGS";RespiteControl.SHOW_RESPITE="RespiteControl.SHOW_RESPITE";RespiteControl.SINGLE_MEDAL_RECEIVED="RespiteControl.SINGLE_MEDAL_RECEIVED";PlanetoEvents.RESPITE_INVITE_DIALOG="PlanetoEvents.RESPITE_INVITE_DIALOG";RespiteControl.SHOW_MULTIPLAYER="RespiteControl.SHOW_MULTIPLAYER";BasicMVC.Facade.getInstance().register(new RespiteControl());GoogleAnalyticsControl=BasicMVC.Base.extend({constructor:function(){this.name="GoogleAnalyticsControl";this.facebookUserId="";this.GAIsOk=false;try{this.pageTracker=pageTracker;this.GAIsOk=true;}catch(A){}},eventListeners:function(){return[GoogleAnalyticsControl.TRACK_EVENT,PlanetoEvents.LOGIN_RESPONSE,PlanetoEvents.FORCED_LOGOUT_EVENT,PlanetoService.PAUSE_PLAYING,PlanetoEvents.END_QUIZ_EVENT,RespiteControl.TRIGGER_MEDAL_RECIEVED];},eventHandlers:function(A){if(this.GAIsOk){switch(A.name){case GoogleAnalyticsControl.TRACK_EVENT:this.trackEvent(A.data);break;case PlanetoEvents.LOGIN_RESPONSE:this.loginResponse(A.data);break;case PlanetoEvents.FORCED_LOGOUT_EVENT:this.forcedLogout(A.data);break;case PlanetoService.PAUSE_PLAYING:this.trackEvent({category:"Player",action:A.data?"Force Pause":"Force Unpause"});break;case PlanetoEvents.END_QUIZ_EVENT:this.onEndQuiz(A.data);break;case PlanetoEvents.LEVEL_UP_EVENT:this.levelUp(A.data);break;case RespiteControl.TRIGGER_MEDAL_RECIEVED:this.trackEvent({category:"Medal Received",action:A.data.name});break;}}},levelUp:function(B){var A=0;if(typeof B.level.value=="undefined"){A=B.level;}else{A=B.level.value;}this.trackEvent({category:"Player",action:"Leveled Up = "+A});},onEndQuiz:function(A){if(!A.correct){this.trackEvent({category:"Player Answered",action:"Incorrect"});}else{this.trackEvent({category:"Player Answered",action:"Correct"});this.trackEvent({category:"Player",action:"Received Score",value:A.gainedPoints});}},loginResponse:function(B){if(!B.error){var A=this.facade.getInstanceByName("Planeto.Facebook.Control").session;if(A){this.facebookUserId=A.uid+"";}this.trackEvent({category:"Player",action:"Login"});}else{this.trackEvent({category:"Player",action:"Login Error"});}},forcedLogout:function(A){this.trackEvent({category:"Player",action:"Logout"});this.facebookUserId="";},trackEvent:function(A){if(arguments.length<3||A.value+""=="undefined"){A.value=1;}this.pageTracker._trackEvent(A.category,A.action,this.facebookUserId,A.value);if(A.category=="Facebook"){this.sendEvent(PlanetoService.TRACK_POST,A.post);}}});GoogleAnalyticsControl.TRACK_EVENT="GoogleAnalyticsControl.TRACK_EVENT";if(location.href.indexOf("debug")==-1){BasicMVC.Facade.getInstance().register(new GoogleAnalyticsControl());}Planeto.Facebook=Planeto.Facebook||{};Planeto.Facebook.QuizFeed=Planeto.Facebook.QuizFeed||{};Planeto.Facebook.QuizFeed.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Facebook.QuizFeed.Control";
this.planetoFacebook=null;this.connectedToFacebook=false;$("#dialogMedal .closeModal, #dialogLostStreak .closeModal, #dialogFriendPassing .closeModal, #dialogLevelUp2 .closeModal, #dialogDuelOutcome .closeModal, #dialogJackpot .closeModal, #dialogRespite .closeModal, #dialogExpertCertificate .closeModal").live("click",this.localScopeFull(function(){this.closeModal(false,true);}));},eventListeners:function(){return[PlanetoEvents.SHOW_JACKPOT_EVENT,PlanetoEvents.SHOW_QUESTION_EVENT,PlanetoEvents.NEW_QUIZ_EVENT,PlanetoEvents.DUEL_SHOW_ANSWER_ALTERNATIVES_EVENT,PlanetoEvents.DUEL_SHOW_QUESTIONS_EVENT,PlanetoEvents.GET_LOGOUT_SESSION_SUMMARY_RESPONSE,PlanetoEvents.POST_TO_FACEBOOK_WALL,RespiteControl.TRIGGER_LEVEL_UP,RespiteControl.TRIGGER_MEDAL_RECIEVED,RespiteControl.TRIGGER_LOST_STREAK_FOR_FB,RespiteControl.TRIGGER_EXPERT_CERTIFICATE_FOR_FB,RespiteControl.TRIGGER_FRIENDS_LIST_PASSING_FOR_FB,RespiteControl.TRIGGER_LEVEL_UP_FOR_FB,RespiteControl.TRIGGER_JACKPOT_FB,Planeto.Facebook.Control.CONNECTED,Planeto.Facebook.Control.DISCONNECTED,Planeto.Facebook.Control.NOT_CONNECTED,Planeto.Facebook.QuizFeed.Control.UPDATED,Planeto.Facebook.QuizFeed.Control.PUBLISH_TO_FACEBOOK,Planeto.Facebook.QuizFeed.Control.PUBLISH_QUEST_COMPLETED,Planeto.Facebook.QuizFeed.Control.PUBLISH_QUESTIONSET,Planeto.Facebook.QuizFeed.Control.PUBLISH_SELFQUIZ,Planeto.Facebook.QuizFeed.Control.CHALLENGE_FRIEND,Planeto.Facebook.QuizFeed.Control.SEND_WAVE_TO_FRIEND,Planeto.SHARE_QUESTIONSET,PlanetoEvents.POST_TO_FRIENDS_FACEBOOK_WALL];},eventHandlers:function(A){switch(A.name){case RespiteControl.TRIGGER_LEVEL_UP:this.currentPlayerLevel=A.data.level;break;case Planeto.Facebook.Control.CONNECTED:this.planetoFacebook=BasicMVC.Facade.getInstance().getInstanceByName("Planeto.Facebook.Control");this.connectedToFacebook=true;break;case Planeto.Facebook.Control.NOT_CONNECTED:case Planeto.Facebook.Control.DISCONNECTED:this.planetoFacebook=null;this.connectedToFacebook=false;break;case RespiteControl.TRIGGER_LOST_STREAK_FOR_FB:this.showLostStreak(A.data);break;case RespiteControl.TRIGGER_EXPERT_CERTIFICATE_FOR_FB:this.showExpertCertificate(A.data);break;case RespiteControl.TRIGGER_FRIENDS_LIST_PASSING_FOR_FB:this.showFriendsListPassing(A.data);break;case RespiteControl.TRIGGER_LEVEL_UP_FOR_FB:this.showLevelUp(A.data);break;case PlanetoEvents.SHOW_JACKPOT_EVENT:A.data.lastTopic=this.lastTopic;A.data.lastQuestion=this.lastQuestion;this.sendEvent(RespiteControl.SHOW_JACKPOT_EVENT,A.data);break;case RespiteControl.TRIGGER_JACKPOT_FB:this.showJackpot(A.data);break;case RespiteControl.TRIGGER_MEDAL_RECIEVED:this.showEarnedAward(A.data);break;case PlanetoEvents.SHOW_QUESTION_EVENT:this.setLastQuestion(A.data);break;case PlanetoEvents.NEW_QUIZ_EVENT:this.onNewQuiz(A.data);break;case PlanetoEvents.DUEL_SHOW_ANSWER_ALTERNATIVES_EVENT:this.duelShowAnswerAlternatives(A.data);break;case PlanetoEvents.DUEL_SHOW_QUESTIONS_EVENT:this.duelShowQuestions(A.data);break;case Planeto.Facebook.QuizFeed.Control.UPDATED:this.setCurrentPlayerInfo(A.data);break;case Planeto.Facebook.QuizFeed.Control.PUBLISH_TO_FACEBOOK:this.showDuelOutcome(A.data);break;case PlanetoEvents.GET_LOGOUT_SESSION_SUMMARY_RESPONSE:this.logoutSessionSummary(A.data);break;case PlanetoEvents.POST_TO_FACEBOOK_WALL:this.publishPostFacebookWall(A.data);break;case PlanetoEvents.POST_TO_FRIENDS_FACEBOOK_WALL:this.publishPostFriendsFacebookWall(A.data);break;case Planeto.Facebook.QuizFeed.Control.PUBLISH_QUEST_COMPLETED:this.publishQuestCompleted(A.data);break;case Planeto.Facebook.QuizFeed.Control.PUBLISH_QUESTIONSET:this.publishQuestionSet(A.data);break;case Planeto.Facebook.QuizFeed.Control.PUBLISH_SELFQUIZ:this.publishSelfQuiz(A.data);break;case Planeto.Facebook.QuizFeed.Control.CHALLENGE_FRIEND:this.publishChallengeFriend(A.data);break;case Planeto.Facebook.QuizFeed.Control.SEND_WAVE_TO_FRIEND:this.publishWaveToFriend(A.data);break;case Planeto.SHARE_QUESTIONSET:this.publishUserCreatedQuestionSet(A.data);break;}},standardImage:function(A){return[{src:"http://www.planeto.com/static/"+A,type:"image"}];
},closeModal:function(A,B){$.modal.close();this.sendEvent(PlanetoService.TRACK_POST,A);if(B==true){this.sendEvent(RespiteControl.CONTINUE);}},openAndTrackPublish:function(G,B,J,C,E,D,A,H,K,F){if(!F){F="";}try{if(!this.planetoFacebook){$("#dialogRespite").modal();this.sendEvent(ConnectionControl.OPEN_FACEBOOK_LOGIN);}else{this.planetoFacebook.facebookPublishFeed("",B,F,"",J,CallbackProxy(this,function(N){var M=false,L=null;if(N!="null"&&N!=null){M=true;L=N.post_id;$(".facebookPublishBonus").hide();}this.sendEvent(GoogleAnalyticsControl.TRACK_EVENT,{category:C,action:(M==true?D:E),post:M});this.sendEvent(PlanetoService.TRACK_POST,M);A(M,L);}),G,H,K);}}catch(I){console.error("--- Error: ",I);}},publishUserCreatedQuestionSet:function(B){if(!B.linkBonus){B.linkBonus={};B.linkBonus.identity=B.linkBonusIdentity;if(B.content.title){B.linkBonus.description=B.content.title;}else{B.linkBonus.description=B.content.name;}}if(B.source&&B.source=="game"){var A=B.content.description,C=B.content.imageUrl;}else{if(B.content.contentType=="QSET"){var D="Quiz",F="Want to test your skills?";}else{var D="Personality Quiz",F="Try it out!";}var C=B.content.iconUrl,A="I just created a new "+D+" called '"+B.content.title+"'. "+F;}var E={media:[{src:"http://"+location.hostname+"/img/90x90/"+C,type:"image"}],name:B.content.title,caption:A};this.openAndTrackPublish(B,E,"","Facebook","User Created "+D+" Published - Skipped Publish on Facebook","User Created "+D+" Published - Published on Facebook",CallbackProxy(this,function(){}));},publishPostFacebookWall:function(A){if(!A.name||!A.caption){A.name="Click to play Planeto";A.caption="I really enjoy playing Planeto and I think that everyone should give it a try!";}var B={media:this.standardImage(ext_resource_feed_invite_friend_jpg),name:A.name,caption:A.caption};this.openAndTrackPublish(A,B,"","Facebook","Invite - Skipped Publish on Facebook","Invite - Published on Facebook",CallbackProxy(this,function(){}),"");},publishPostFriendsFacebookWall:function(A){var B={name:"Click to start Planeto",caption:""};this.openAndTrackPublish("",B,A.friendId,"Facebook","Post to friend - Skipped Publish on Facebook","Post to friend - Published on Facebook",CallbackProxy(this,function(){}));},showEarnedAward:function(B){if(B.postToFacebook){var A=$("#dialogMedal");A.modal();A.find(".dialogText img").attr("class","").addClass("spr_medals_64 spr_medal_64_"+B.medalId);A.find(".dialogText h3 span").html(B.name);A.find(".dialogText > div > p:not(.facebookPublishBonus)").html(B.description);A.find("div.spr_button_orange").unbind("click").bind("click",this.localScopeFull(this.publishEarnedAward,B));}else{this.sendEvent(RespiteControl.CONTINUE);}},publishEarnedAward:function(B,A,C){$("#dialogMedal").modalClose();var D={media:this.standardImage("medals/90x90/"+C.medalId+".jpg"),name:C.name,caption:C.description,description:"WINNING QUESTION: ["+this.lastTopic+"] "+this.lastQuestion,properties:{A:this.lastAnswers[0],B:this.lastAnswers[1],C:this.lastAnswers[2],D:this.lastAnswers[3]}};this.openAndTrackPublish("",D,"","Facebook","Medal - Skipped Publish on Facebook","Medal - Published on Facebook",CallbackProxy(this,function(){this.sendEvent(RespiteControl.CONTINUE);}));},showLostStreak:function(B){var A=$("#dialogLostStreak");A.modal();A.find(".dialogText img").addClass("spr_medals_90 spr_medal_90_lost_streak");A.find(".dialogText h3 span").html(B.streak);A.find("div.spr_button_orange").unbind("click").bind("click",this.localScopeFull(this.publishLostStreak,B));},publishLostStreak:function(B,A,D){$("#dialogLostStreak").modalClose();var C={media:this.standardImage(ext_resource_feed_lost_streak_jpg),name:"OH NO! I just lost my streak of "+D.streak+" correct answers in a row!",caption:"LOSING QUESTION: ",description:"["+this.lastTopic+"] "+this.lastQuestion,properties:{A:this.lastAnswers[0],B:this.lastAnswers[1],C:this.lastAnswers[2],D:this.lastAnswers[3]}};this.openAndTrackPublish("",C,"","Facebook","Lost streak - Skipped Publish on Facebook","Lost streak - Published on Facebook",CallbackProxy(this,function(){this.sendEvent(RespiteControl.CONTINUE);
}));},showExpertCertificate:function(B){var A=$("#dialogExpertCertificate");A.modal();A.find(".dialogText .knowledgeDomainName").html(B.knowledgeDomain.name);A.find(".dialogText .knowledgeDomainName").attr("href",B.knowledgeDomain.url);A.find(".dialogText .knowledgeDomainNbrOfExperts span").html(B.knowledgeDomain.membersCount);var C=(B.knowledgeDomain.imageId==""?resource_default_domain_pic_png:"http://"+(location.hostname=="local.planeto.net"?"local.planeto.net:8020":location.hostname)+"/img/kd90x90/"+B.knowledgeDomain.imageId);A.find(".dialogText .knowledgeDomainDescription img").attr("src",C);A.find(".dialogText .knowledgeProfilePageLink").attr("href",B.myProfileUrl);A.find("a").attr("target","_blank");A.find("div.spr_button_orange").unbind("click").bind("click",this.localScopeFull(this.publishExpertCertificate,B));},publishExpertCertificate:function(B,A,H){$("#dialogExpertCertificate").modalClose();var G=(H.knowledgeDomain.imageId==""?this.standardImage(ext_resource_default_domain_pic_png):[{src:"http://"+location.hostname+"/img/kd90x90/"+H.knowledgeDomain.imageId,type:"image",href:H.knowledgeDomain.url}]);var E={media:G,name:"I was just certified as an expert on '"+H.knowledgeDomain.name+"'",href:"http://www.planeto.com",caption:"",description:"Play Planeto to determine your own expertise."};var D=[{text:"Join Planeto Now",href:"http://www.planeto.com"}];var F=$("#dialogExpertCertificate .facebook_post > input");var C=F.attr("checked");F.attr("checked",true);if(C){this.openAndTrackPublish("",E,"","Facebook","Expert Certificate - Skipped Publish on Facebook","Expert Certificate - Published on Facebook",CallbackProxy(this,function(){this.sendEvent(RespiteControl.CONTINUE);}),"",true,D);}else{this.sendEvent(RespiteControl.CONTINUE);}},showFriendsListPassing:function(B){if(this.currentPlayerLevel>=4){var A=$("#dialogFriendPassing");A.modal();A.find(".dialogText img").addClass("spr_medals_90 spr_medal_90_friend_passing");A.find(".dialogText h3 span").html(B.name);A.find("div.spr_button_orange").unbind("click").bind("click",this.localScopeFull(this.publishFriendsListPassing,B));}else{this.sendEvent(RespiteControl.CONTINUE);}},publishFriendsListPassing:function(B,A,D){$("#dialogFriendPassing").modalClose();var C={media:this.standardImage(ext_resource_feed_leaderboard_passing_jpg),name:"I just passed you in Planeto Quiz! I am now at level "+this.currentPlayerLevel+" with a total score of "+$("#ingameLevelPoints span").html()+".",caption:"WINNING QUESTION: ",description:"["+this.lastTopic+"] "+this.lastQuestion,properties:{A:this.lastAnswers[0],B:this.lastAnswers[1],C:this.lastAnswers[2],D:this.lastAnswers[3]}};this.openAndTrackPublish("",C,D.passeeFacebookId,"Facebook","Leaderboard passing - Skipped Publish on Facebook","Leaderboard passing - Published on Facebook",CallbackProxy(this,function(){this.sendEvent(RespiteControl.CONTINUE);}));},showLevelUp:function(B){var A=$("#dialogLevelUp2");A.modal();if(B.level==10){image="spr_medal_90_levelup_10";}else{if(B.level==30){image="spr_medal_90_levelup_30";}else{if(B.level==60){image="spr_medal_90_levelup_60";}else{image="spr_medal_90_levelup";}}}A.find(".dialogText img").addClass("spr_medals_90 "+image);A.find(".dialogText h3 span").html(B.level+"! "+(B.name!=""?"You're now just behind "+B.name+".":"You're ahead of all your friends!"));A.find("div.shareLevelUp").unbind("click").bind("click",this.localScopeFull(this.publishLevelUp,B));},publishLevelUp:function(B,A,C){$("#dialogLevelUp2").modalClose();var D={media:this.standardImage(ext_resource_feed_levelup_icon_jpg),name:"YES! I just reached level "+C.level+". "+(C.name!=""?"Now I'm just behind "+C.name+".":"I'm ahead of all my friends!"),caption:"WINNING QUESTION: ",description:"["+this.lastTopic+"] "+this.lastQuestion,properties:{A:this.lastAnswers[0],B:this.lastAnswers[1],C:this.lastAnswers[2],D:this.lastAnswers[3]}};this.openAndTrackPublish("",D,"","Facebook","Level Up - Skipped Publish on Facebook","Level Up - Published on Facebook",CallbackProxy(this,function(){this.sendEvent(RespiteControl.CONTINUE);
}));},showDuelOutcome:function(E){var B=$("#dialogDuelOutcome");B.modal();var A,C,D;if(E.outcome=="VICTORY"){A="Duel Victory!";C="You won a duel against "+E.opponent+".";description2="Do you dare to give your friend a re-match?";D="spr_medal_90_duel_won";}else{if(E.outcome=="DEFEAT"){A="Duel Defeat!";C="You lost a duel against "+E.opponent+".";description2="Can you get a re-match?";D="spr_medal_90_duel_lost";}else{A="Duel Draw!";C="Your duel against "+E.opponent+" ended in a draw.";description2="You are both good. But the ultimate winner can only be decided in a re-match.";D="spr_medal_90_duel_draw";}}B.find(".dialogText img").addClass("spr_medals_90 "+D);B.find(".dialogHeader h2").html(A);B.find(".dialogText h3").html(C);B.find(".dialogText > div > p:not(.facebookPublishBonus)").html(description2);B.find("div.spr_button_orange").unbind("click").bind("click",this.localScopeFull(this.publishDuelOutcome,E));},publishDuelOutcome:function(B,A,C){$("#dialogDuelOutcome").modalClose();var D,F;if(C.outcome=="VICTORY"){D="OH YES! I won a duel against "+C.opponent+".";F=ext_resource_feed_duel_won_jpg;}else{if(C.outcome=="DEFEAT"){D="OH NO! I lost a duel against "+C.opponent+".";F=ext_resource_feed_duel_lost_jpg;}else{D="My duel against "+C.opponent+" ended in a draw.";F=ext_resource_feed_duel_draw_jpg;}}var E={media:this.standardImage(F),name:D,caption:"MY LAST QUESTION: ",description:"["+this.lastTopic+"] "+this.lastQuestion,properties:{A:this.lastAnswers[0],B:this.lastAnswers[1],C:this.lastAnswers[2],D:this.lastAnswers[3]}};this.openAndTrackPublish("",E,"","Facebook","Duel result - Skipped Publish on Facebook","Duel result - Published on Facebook",CallbackProxy(this,function(){this.sendEvent(RespiteControl.CONTINUE);}));},logoutSessionSummary:function(F){this.sendEvent(PlanetoService.RESPITE,true);var I=F.sessionSummary.endScore-F.sessionSummary.startScore,J=F.sessionSummary.endLevel-F.sessionSummary.startLevel,D=F.sessionSummary.endLevel,G=(F.sessionSummary.sessionLength/60000).toFixed(0),E=F.sessionSummary.friendsPassed,H=F.sessionSummary.nbrOfFriendsAhead+1,A=F.cityPlacement,C=F.countryPlacement,K=F.sessionSummary.longestStreak,L=F.sessionSummary.medalsReceived;if(I>0){if(I==1){$("#logoutPoints .add_s").hide();}$("#logoutPoints span:not(.add_s)").html(I);}else{$("#logoutPoints").remove();}if(J>0){if(J==1){$("#logoutLevels .add_s").hide();}$("#logoutLevels strong span:not(.add_s)").html(J);$("#logoutLevels > span").html(D);}else{$("#logoutLevels").remove();}if(G>0){if(G==1){$("#logoutTime .add_s").hide();}$("#logoutTime span:not(.add_s)").html(G);}else{$("#logoutTime").remove();}if(E>0){if(E==1){$("#logoutPassed .add_s").hide();}$("#logoutPassed strong").html(E);}else{$("#logoutPassed").remove();}$("#logoutPosition span").html(number_suffix(H));if(A>0){$("#logoutCityPlacement span").html(number_suffix(A));}else{$("#logoutCityPlacement").remove();}if(C>0){$("#logoutCountryPlacement span").html(number_suffix(C));}else{$("#logoutCountryPlacement").remove();}if(K>0){if(K==1){$("#logoutStreak .add_s").hide();}$("#logoutStreak span:not(.add_s)").html(K);}else{$("#logoutStreak").remove();}if(L>0){if(L==1){$("#logoutMedals .add_s").hide();}$("#logoutMedals span:not(.add_s)").html(L);}else{$("#logoutMedals").remove();}$("#logoutSummary p:not(.facebookPublishBonus) span").html(Math.floor(I*0.1));var B=$("#dialogLogout");B.modal();B.find("div.spr_button_grey").unbind("click").bind("click",CallbackProxy(this,function(){this.publishCloseLogout(false);}));B.find("div.spr_button_orange").unbind("click").bind("click",this.localScopeFull(this.publishLogout,F));},publishLogout:function(B,A,C){var D={media:this.standardImage(ext_resource_feed_logout_icon_jpg),name:"I just played a Planeto Quiz session!",caption:"I'm now at level "+C.sessionSummary.endLevel+" and have answered a total of "+C.totalQuestions+" questions.",description:"I now "+(C.nbrOfFriendsAhead>0?"have "+C.nbrOfFriendsAhead+" friends ahead of me":"am first among all my friends")+". And I'm in position "+C.cityPlacement+" of my city '"+$("#userFlag span").html()+"', and position "+C.countryPlacement+" in my country '"+$("#userFlag .tooltip .tooltipText").html()+"'."};
this.openAndTrackPublish(C,D,"","Facebook","Log out - Skipped Publish on Facebook","Log out - Published on Facebook",CallbackProxy(this,function(E){this.publishCloseLogout(E);}));},publishCloseLogout:function(A){this.closeModal(A,false);this.sendEvent(PlanetoService.LOGOUT,A);},showJackpot:function(B){var A=$("#dialogJackpot");A.modal();A.find(".dialogText img").addClass("spr_medals_90 spr_medal_90_jackpot");A.find(".dialogText h3 span").html(B.score);A.find("div.spr_button_orange").unbind("click").bind("click",this.localScopeFull(this.publishJackpot,B));},publishJackpot:function(B,A,C){$("#dialogJackpot").modalClose();var D={media:this.standardImage(ext_resource_feed_jackpot_icon_jpg),name:"I just grabbed the daily jackpot, winning a total of "+C.score+" points!",caption:"WINNING QUESTION: ",description:"["+this.lastTopic+"] "+this.lastQuestion,properties:{A:this.lastAnswers[0],B:this.lastAnswers[1],C:this.lastAnswers[2],D:this.lastAnswers[3]}};this.openAndTrackPublish("",D,"","Facebook","Jackpot - Skipped Publish on Facebook","Jackpot - Published on Facebook",CallbackProxy(this,function(){this.sendEvent(RespiteControl.CONTINUE);}));},publishQuestCompleted:function(A){var B={media:this.standardImage(ext_resource_feed_quest_completed_icon_jpg),name:"I just completed the quest "+A.name,caption:A.description};this.openAndTrackPublish(A,B,"","Facebook","Quest Completed - Skipped Publish on Facebook","Quest Completed - Published on Facebook",CallbackProxy(this,function(){this.sendEvent(PlanetoService.CLAIM_QUEST_REWARD,A.slotIndex);this.sendEvent(Planeto.Quests.View.CLOSE_QUEST_COMPLETED_DIALOG);this.sendEvent(RespiteControl.CONTINUE);}));},publishQuestionSet:function(A){var B={media:[{src:"http://"+location.hostname+"/img/90x90/"+A.summary.imageUrl,type:"image"}],name:A.linkBonus.description,caption:"I answered "+A.summary.nbrOfCorrect+" of "+A.summary.totalNbrOfQuestions+" questions correctly in "+format_time(A.summary.time)+". Can you beat me?"};this.openAndTrackPublish(A,B,"","Facebook","Question Set Completed - Skipped Publish on Facebook","Question Set Completed - Published on Facebook",CallbackProxy(this,function(C){if(C){this.sendEvent(PlanetoService.QUESTION_SET_PUBLISHED_REQUEST,A.linkBonus.identity);}}),"",true);},publishSelfQuiz:function(A){if(!A.linkBonus){A.linkBonus={};A.linkBonus.identity=A.selfQuiz.identity;A.linkBonus.description=A.selfQuiz.name;}var B={media:[{src:"http://"+location.hostname+"/img/90x90/"+A.outcome.image,type:"image"}],name:A.selfQuiz.name,caption:"Result: "+A.outcome.title,description:A.outcome.description};this.openAndTrackPublish(A,B,"","Facebook","Self Quiz Completed - Skipped Publish on Facebook","Question Set Completed - Published on Facebook",CallbackProxy(this,function(C){this.sendEvent(Planeto.SelfQuiz.CLOSE_SELF_QUIZ_RESULT,A);}));},publishChallengeFriend:function(A){var B={media:[{src:"http://"+location.hostname+"/img/90x90/"+A.iconUrl,type:"image"}],name:"Play the '"+A.linkBonus.description+"' quiz!",description:A.description};this.openAndTrackPublish(A,B,A.target_id,"Facebook","Challenge Friend - Skipped Publish on Facebook","Challenge Friend - Published on Facebook",CallbackProxy(this,function(C){this.sendEvent(Planeto.ChallengeFriends.SHOW_ALL_FRIENDS);if(C){this.sendEvent(PlanetoService.GET_REWARD_FOR_CHALLENGING_A_FRIEND_REQUEST,$("#dialogChallengeFriends .rewards div.active").attr("rel"));}}),"");},publishWaveToFriend:function(A){var C="Let's spread some knowledge around the world!";C+=(A.stats.passedByTotalCount==0?"":" This quiz wave has so far passed "+A.stats.passedByTotalCount+" players (including "+A.stats.passedByFriendsCount+" of my friends) "+A.stats.formatedTimeSpan+".");C+=" How far can it go?";var B={media:[{src:"http://"+location.hostname+"/img/90x90/"+A.questionSet.imageUrl,type:"image"}],name:"Play the '"+A.questionSet.name+"' quiz wave!",description:C};this.openAndTrackPublish(A,B,A.target_id,"Facebook","Challenge Friend - Skipped Publish on Facebook","Challenge Friend - Published on Facebook",CallbackProxy(this,function(D,F){this.sendEvent(Planeto.QuizWave.SHOW_ALL_FRIENDS);
if(D){var E={waveMessageId:A.waveMessageId,facebookPostId:F,facebookId:A.target_id};this.sendEvent(PlanetoService.PASS_WAVE_TO_FACEBOOK_USER_REQUEST,E);}}),"");},setLastQuestion:function(A){this.lastQuestion=A.question;},duelShowQuestions:function(A){this.lastQuestion=A.playerQuestion.question;},onNewQuiz:function(A){this.lastTopic=A.topic;this.lastAnswers=A.answers;},duelShowAnswerAlternatives:function(A){this.lastTopic=A.playerQuestion.topic;this.lastAnswers=A.playerQuestion.answers;},setCurrentPlayerInfo:function(A){this.currentPlayerLevel=A.level.value;}});Planeto.Facebook.QuizFeed.Control.UPDATED="Planeto.Facebook.QuizFeed.Control.UPDATED";Planeto.Facebook.QuizFeed.Control.PUBLISH_TO_FACEBOOK="Planeto.Facebook.QuizFeed.Control.PUBLISH_TO_FACEBOOK";Planeto.Facebook.QuizFeed.Control.PUBLISH_QUEST_COMPLETED="Planeto.Facebook.QuizFeed.Control.PUBLISH_QUEST_COMPLETED";Planeto.Facebook.QuizFeed.Control.PUBLISH_QUESTIONSET="Planeto.Facebook.QuizFeed.Control.PUBLISH_QUESTIONSET";Planeto.Facebook.QuizFeed.Control.PUBLISH_SELFQUIZ="Planeto.Facebook.QuizFeed.Control.PUBLISH_SELFQUIZ";Planeto.Facebook.QuizFeed.Control.CHALLENGE_FRIEND="Planeto.Facebook.QuizFeed.Control.CHALLENGE_FRIEND";Planeto.Facebook.QuizFeed.Control.SEND_WAVE_TO_FRIEND="Planeto.Facebook.QuizFeed.Control.SEND_WAVE_TO_FRIEND";PlanetoEvents.POST_TO_FACEBOOK_WALL="PlanetoEvents.POST_TO_FACEBOOK_WALL";Planeto.SHARE_QUESTIONSET="Planeto.SHARE_QUESTIONSET";PlanetoEvents.POST_TO_FRIENDS_FACEBOOK_WALL="PlanetoEvents.POST_TO_FRIENDS_FACEBOOK_WALL";BasicMVC.Facade.getInstance().register(new Planeto.Facebook.QuizFeed.Control());Planeto.Quiz=Planeto.Quiz||{};Planeto.Quiz.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Quiz.Control";this.paused=true;this.roundActive=false;this.inactivityCounter=0;this.INACTIVITY_TRIGGER_VALUE=1;this.inactivityPause=false;this.x_pause=5;this.x_pause_count=0;this.x_pause_disabled=false;$("#questionClock").live("click",this.localScopeFull(this.pauseOrContinue));$("#clockPauseButton").live("click",this.localScopeFull(this.pauseGameButtonHandler));$("a.continueButton, #clockContinueButton").live("click",this.localScopeFull(this.continueGameButtonHandler));$("#quizBanner a").live("click",this.localScopeFull(this.openBanner));$("#unfreezeButtonContainer").live("click",this.localScopeFull(this.unfreeze));$(document).bind("keydown",this.localScopeFull(this.answerQuestionWithKeys));},eventListeners:function(){return[Planeto.Quiz.Control.COMMAND_PAUSE_GAME,Planeto.Quiz.Control.COMMAND_CONTINUE_GAME,PlanetoEvents.PAUSE_EVENT,PlanetoEvents.NEW_QUIZ_EVENT,PlanetoEvents.END_QUIZ_EVENT,PlanetoEvents.SHOW_QUESTION_EVENT,PlanetoEvents.ANSWERS_UPDATED_EVENT,PlanetoEvents.META_DATA_CHANGED_EVENT,PlanetoEvents.QUESTION_SET_STARTED_EVENT,PlanetoEvents.QUESTION_SET_STOPPED_EVENT,PlanetoEvents.RESET_INACTIVITY,PlanetoEvents.LOGIN_RESPONSE];},eventHandlers:function(A){switch(A.name){case Planeto.Quiz.Control.COMMAND_PAUSE_GAME:this.pauseGame();break;case Planeto.Quiz.Control.COMMAND_CONTINUE_GAME:this.continueGame();break;case PlanetoEvents.PAUSE_EVENT:this.quizPaused();break;case PlanetoEvents.NEW_QUIZ_EVENT:this.onNewQuiz();break;case PlanetoEvents.END_QUIZ_EVENT:this.onEndQuiz(A.data);break;case PlanetoEvents.SHOW_QUESTION_EVENT:this.showQuestionHandler(A.data);break;case PlanetoEvents.ANSWERS_UPDATED_EVENT:this.updateAnswers(A.data);break;case PlanetoEvents.LOGIN_RESPONSE:this.metaDataRefreshed(A.data.account.metaData);break;case PlanetoEvents.META_DATA_CHANGED_EVENT:this.metaDataChanged(A.data);break;case PlanetoEvents.QUESTION_SET_STARTED_EVENT:this.x_pause_disabled=true;break;case PlanetoEvents.QUESTION_SET_STOPPED_EVENT:this.x_pause_disabled=false;break;case PlanetoEvents.RESET_INACTIVITY:this.resetInactivity();break;}},metaDataChanged:function(A){if(A.key=="x_pause"){this.x_pause=A.value;$("#summaryInterval").val(A.value);}},metaDataRefreshed:function(A){for(var B=0;B<A.length;B++){this.metaDataChanged(A[B]);}},onNewQuiz:function(){if(Planeto.Globals.currentGameType!="INFINITE_STREAM_GAME"){return ;
}this.x_pause_count++;if(this.x_pause_count>=this.x_pause){if(!this.x_pause_disabled){this.sendEvent(RespiteControl.TRIGGER_SESSION_STATS,{type:"test"});}this.x_pause_count=0;}$("#answerContainer td").unbind();this.paused=false;this.roundActive=true;this.inactivityCounter++;if(this.inactivityCounter>this.INACTIVITY_TRIGGER_VALUE){this.sendEvent(PlanetoService.PAUSE_PLAYING,true);this.inactivityPause=true;}},updateAnswers:function(A){for(var B=0;B<4;B++){if(A.answers[B]==null){$("#answer"+(B+1)).unbind();}}},showQuestionHandler:function(A){$("#answerContainer td").unbind();$("#answerContainer td:not(.exclude)").bind("click",this.localScopeFull(this.answerQuestion));},onEndQuiz:function(A){this.roundActive=false;$("#answerContainer td").unbind();},resetInactivity:function(){this.inactivityCounter=0;if(this.inactivityPause){this.inactivityPause=false;this.sendEvent(PlanetoService.PAUSE_PLAYING,false);}},quizPaused:function(){if(this.inactivityPause){this.sendEvent(StatusView.SHOW_MESSAGE,"#playerAutoPauseContent");this.sendEvent(Planeto.Quiz.Control.SHOW_PAUSE_GAME);}else{this.sendEvent(StatusView.SHOW_PAUSE);}Planeto.Globals.gamePaused=true;this.paused=true;this.roundActive=false;},pauseGame:function(){this.sendEvent(PlanetoService.PAUSE_PLAYING,true);this.sendEvent(Planeto.Quiz.Control.SHOW_PAUSE_GAME);if(this.roundActive){this.sendEvent(StatusView.SHOW_MESSAGE,"#gameWillPauseAfterRound");}else{this.sendEvent(StatusView.SHOW_PAUSE);}},continueGame:function(){this.inactivityCounter=0;this.inactivityPause=false;this.sendEvent(PlanetoService.PAUSE_PLAYING,false);this.sendEvent(StatusView.HIDE_MESSAGE);},pauseOrContinue:function(){if($("#clockPauseButton").is(":visible")){this.pauseGameButtonHandler();}else{this.continueGameButtonHandler();}},unfreeze:function(){var A=new Date().getTime();$.post("/api2/1.0.0/log/unfreeze",{identity:user_id,userName:playerModel.nickName,timestamp:A});this.sendEvent(PlanetoService.UNFREEZE);alert("Thank you. If your game session does not unfreeze now, please write a bug report in our forum: http://forum.planeto.com. Sorry for any inconvenience.");},pauseGameButtonHandler:function(){this.sendEvent(Planeto.Quiz.Control.COMMAND_PAUSE_GAME);},continueGameButtonHandler:function(){this.sendEvent(Planeto.Quiz.Control.COMMAND_CONTINUE_GAME);},openBanner:function(){this.sendEvent(Planeto.Quiz.Control.COMMAND_PAUSE_GAME);this.sendEvent(GoogleAnalyticsControl.TRACK_EVENT,{category:"Tabs",action:"Clicked BannerButton"});},answerQuestionWithKeys:function(C){var A=C.target.tagName.toLowerCase();if(C.ctrlKey&&(A=="html"||A=="body")){var B="";switch(C.keyCode){case 49:B=1;break;case 50:B=2;break;case 51:B=3;break;case 52:B=4;break;}if(B!=""){if($("#answer"+B).hasClass("exclude")){}else{if($("#questionContent").is(":hidden")){}else{this.answerQuestion({currentTarget:{id:"answer"+B}});}}C.preventDefault();return false;}}},answerQuestion:function(A){this.resetInactivity();var B=parseInt(A.currentTarget.id.replace("answer",""))-1;this.sendEvent(Planeto.Quiz.Control.ANSWER_CLICKED,$("#"+A.currentTarget.id));this.sendEvent(PlanetoService.ANSWER_COMMAND,{answerIndex:B});}});Planeto.Quiz.Control.COMMAND_PAUSE_GAME="Planeto.Quiz.Control.COMMAND_PAUSE_GAME";Planeto.Quiz.Control.COMMAND_CONTINUE_GAME="Planeto.Quiz.Control.COMMAND_CONTINUE_GAME";Planeto.Quiz.Control.SHOW_PAUSE_GAME="Planeto.Quiz.Control.SHOW_PAUSE_GAME";Planeto.Quiz.Control.SHOW_CONTINUE_GAME="Planeto.Quiz.Control.SHOW_CONTINUE_GAME";Planeto.Quiz.Control.CHANNEL_CHOOSER_CLICK="Planeto.Quiz.Control.CHANNEL_CHOOSER_CLICK";Planeto.Quiz.Control.ANSWER_CLICKED="Planeto.Quiz.Control.ANSWER_CLICKED";PlanetoEvents.RESET_INACTIVITY="PlanetoEvents.RESET_INACTIVITY";BasicMVC.Facade.getInstance().register(new Planeto.Quiz.Control());Planeto.Quiz=Planeto.Quiz||{};Planeto.Quiz.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Quiz.View";this.timerRef=0;this.currentTime=0;this.roundTime=15000;this.currentClockStep=0;this.currentTimeLeft="";this.activatePause=true;
this.standardUsed=false;this.standardChosen=0;this.jackpotAmount=0;this.questionClockPieDomObj=$("#questionClockPie");this.questionClockNumberDomObj=$("#questionClockNumber");$("#summaryScreen div.continueButton").live("click",this.localScopeFull(this.closeSessionStats));$("#domainQuestionsSummary div.continueButton").live("click",this.localScopeFull(this.closeDomainQuestionsStats));$("#summaryScreen .facebookConnect .button").live("click",this.localScopeFull(this.openFacebookLogin));$("#quizCategory").toolTiper();$("#questionBonusMultiplier").toolTiper();$("#questionJackpot").toolTiper();$("#dialogStart .loginProviders .facebook, #dialogStart .facebookLogin .button").live("click",this.localScopeFull(this.setRequiresReload));$("#loginScreen .facebook, #ingameAvatar .facebookNotLoggedIn img, .loginProviders .facebook, .facebookConnect, #dialogStart .facebookLogin .button").live("click",this.localScopeFull(this.connectToFacebook));$("#loginScreen .google, #ingameAvatar .googleNotLoggedIn img, .loginProviders .google ").live("click",this.localScopeFull(this.connectToGoogle));$("#loginScreen .guest").live("click",this.localScopeFull(this.playAsGuest));},eventListeners:function(){return[PlanetoEvents.NEW_QUIZ_EVENT,PlanetoEvents.SHOW_BANNER_EVENT,PlanetoEvents.SHOW_QUESTION_EVENT,PlanetoEvents.END_QUIZ_EVENT,PlanetoService.NEW_QUIZ_SESSION,PlanetoEvents.ANSWERS_UPDATED_EVENT,Planeto.Quiz.Control.SHOW_PAUSE_GAME,Planeto.Quiz.Control.SHOW_CONTINUE_GAME,PlanetoEvents.PAUSE_EVENT,PlanetoEvents.TIME_CHANGED_EVENT,ConnectionControl.LOGGED_IN_TO_FACEBOOK,ConnectionControl.NOT_LOGGED_IN_TO_FACEBOOK,PlanetoService.START_PLAYING,Planeto.Quiz.Control.COMMAND_PAUSE_GAME,Planeto.Quiz.Control.COMMAND_CONTINUE_GAME,Planeto.Quiz.Control.CHANNEL_CHOOSER_CLICK,Planeto.Quiz.Control.ANSWER_CLICKED,PlanetoEvents.GET_SESSION_STATS_RESPONSE,PlanetoEvents.JACKPOT_CHANGED_EVENT,PlanetoEvents.NEW_QUIZ_RESPONSE,Planeto.Quiz.View.STOP_CLOCK,ConnectionControl.LOGIN_RESPONSE,PlanetoEvents.CONVERT_LOGIN_RESULT_RESPONSE,RespiteControl.TRIGGER_DOMAIN_QUESTIONS_STATS];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.NEW_QUIZ_EVENT:this.onNewQuiz(A.data);break;case PlanetoEvents.SHOW_BANNER_EVENT:this.onShowBannerEvent(A.data);break;case PlanetoEvents.SHOW_QUESTION_EVENT:this.onShowQuestionEvent(A.data);break;case PlanetoEvents.END_QUIZ_EVENT:this.onEndQuiz(A.data);break;case PlanetoEvents.TIME_CHANGED_EVENT:this.onTimeChangedEvent(A.data);break;case PlanetoService.NEW_QUIZ_SESSION:this.resetQuestion();break;case PlanetoEvents.ANSWERS_UPDATED_EVENT:this.updateAnswers(A.data);break;case Planeto.Quiz.Control.SHOW_PAUSE_GAME:case Planeto.Quiz.Control.COMMAND_PAUSE_GAME:this.pauseGameHandler();break;case Planeto.Quiz.Control.SHOW_CONTINUE_GAME:case Planeto.Quiz.Control.COMMAND_CONTINUE_GAME:this.continueGameHandler();break;case PlanetoEvents.PAUSE_EVENT:this.quizPaused();break;case ConnectionControl.NOT_LOGGED_IN_TO_FACEBOOK:this.stopClockInterval();break;case ConnectionControl.LOGGED_IN_TO_FACEBOOK:this.onLoggedInToFacebook();break;case PlanetoService.START_PLAYING:this.showQuizView();break;case Planeto.Quiz.Control.ANSWER_CLICKED:this.answerClicked(A.data);break;case PlanetoEvents.GET_SESSION_STATS_RESPONSE:this.sessionStats(A.data);break;case RespiteControl.TRIGGER_DOMAIN_QUESTIONS_STATS:this.showDomainQuestionsStats(A.data);break;case PlanetoEvents.JACKPOT_CHANGED_EVENT:this.jackpotAmount=A.data.current;break;case PlanetoEvents.NEW_QUIZ_RESPONSE:this.jackpotAmount=A.data.jackpot.current;break;case Planeto.Quiz.View.STOP_CLOCK:this.closeTimer();break;case ConnectionControl.LOGIN_RESPONSE:this.onLoginResponse(A.data);break;case PlanetoEvents.CONVERT_LOGIN_RESULT_RESPONSE:this.onConvertLoginResponse(A.data);break;}},onLoginResponse:function(A){if(A.connectedToFB){$("#ingameAvatar .facebookNotLoggedIn").hide();$("#ingameAvatar .googleNotLoggedIn").hide();}if(A.connectedToGoogle){$("#ingameAvatar .facebookNotLoggedIn").show();$("#ingameAvatar .googleNotLoggedIn").hide();
}if(A.connectedAsGuest){$("#ingameAvatar .facebookNotLoggedIn").show();$("#ingameAvatar .googleNotLoggedIn").show();}},onConvertLoginResponse:function(A){$("#ingameAvatar .googleNotLoggedIn, .loginProviders, .guestWarning").hide();},setRequiresReload:function(){requiresReloadAfterConvertAccount=true;},connectToFacebook:function(){var A=this;FB.api("/me?fields=name",function(B){if(B.error){A.sendEvent(ConnectionControl.FACEBOOK_LOGIN);}workAroundLoginToFacebook(CallbackProxy(A,A.handleFacebookLoginResponse));});},handleFacebookLoginResponse:function(A){if(A!=null){setCookie("auth-method","facebook",365);this.sendEvent(Planeto.Facebook.Control.CONNECTED,A);$("#loginScreen").hide();}},connectToGoogle:function(){this.sendEvent(ConnectionControl.GOOGLE_LOGIN);},playAsGuest:function(){this.sendEvent(ConnectionControl.COOKIE_LOGIN);},sessionStats:function(A){var B=$("#summaryScreen");$("#quizBanner, #questionContainer, #answerContainer").hide();B.find(".summaryCorrect").html(A.correctAnswers);B.find(".summaryIncorrect").html(A.wrongAnswers);B.find(".summaryAverage").html(A.averageAnswerTime.toFixed(2)+" s");B.find(".summaryScore").html(A.score+" p");if(connectedAsGuest||connectedToGoogle){$(".facebookNotLoggedIn").show();$(".facebookLoggedIn").hide();}else{$(".facebookNotLoggedIn").hide();$(".facebookLoggedIn").show();}B.show();},closeSessionStats:function(){this.sendEvent(PlanetoService.SET_META_DATA,{key:"x_pause",value:$("#summaryInterval").val()});$("#summaryScreen").hide();this.sendEvent(RespiteControl.CONTINUE);},showDomainQuestionsStats:function(A){if(Planeto.Globals.currentGameType=="INFINITE_STREAM_GAME"){var B=$("#domainQuestionsSummary");$("#quizBanner, #questionContainer, #answerContainer").hide();var C=(A.knowledgeDomain.imageId==""?resource_default_domain_pic_png:"http://"+(location.hostname=="local.planeto.net"?"local.planeto.net:8020":location.hostname)+"/img/kd90x90/"+A.knowledgeDomain.imageId);B.find(".knowledgeDomainDescription img").attr("src",C);B.find(".knowledgeDomainName").html(A.knowledgeDomain.name);B.find("a.knowledgeDomainName").attr("href",A.knowledgeDomain.url);B.find(".knowledgeDomainNbrOfExperts").html(A.knowledgeDomain.membersCount);B.find(".correct").html(A.correctAnswers);B.find(".total").html(A.totalQuestions);B.find("a").attr("target","_blank");$("#domainQuestionsSummary div.createDomainQuestionBtn").live("click",this.localScopeFull(function(){window.open(A.knowledgeDomain.url+"&createQuestion","createQestionWindow");}));B.show();}},closeDomainQuestionsStats:function(){$("#domainQuestionsSummary").hide();this.sendEvent(RespiteControl.CONTINUE);},quizPaused:function(){this.pauseGameHandler();if($("#droppedItems").is(":hidden")){$("#gamePausOverlay").show();}else{$("#gamePausOverlay").addClass("showAfterDrop");}$("#quizBanner, #questionContainer, #answerContainer, #answerRightButWrong").hide();},onShowBannerEvent:function(A){this.resetQuestion();$("#quizBanner a").attr("href",A.clickUrl);$("#quizBanner img").attr("src",resource_banner[A.bannerId]);$("#answerContainer").hide();$("#quizBanner").show();this.resetTimer(A);},resetQuestion:function(){$("#answerContainer td").css("opacity","").removeClass("exclude correctAnswer wrongAnswerAll wrongAnswer answerButtonSelected long longer").find("div").html("");$("#questionContent").hide().html("");$("#gamePausOverlay, #droppedItems").hide();$("#questionContainer, #answerContainer").show();},updateAnswers:function(A){for(var B=0;B<4;B++){if(A.answers[B]==null){$("#answer"+(B+1)).removeClass("answerButtonSelected selectable").addClass("exclude");}}},showQuizView:function(){$("#gameplayArea").show();},onNewQuiz:function(D){this.continueGameHandler();$("#answerRightButWrong").hide();$("#answerContainer td").removeClass("selectable exclude correctAnswer wrongAnswerAll wrongAnswer answerButtonSelected long longer");$("#questionContent").hide().html("");var G=false,A=false;for(var E=0;E<4;E++){$("#answer"+(E+1)+" > div").encodeHtml(D.answers[E]);if(D.answers[E].length>80){A=true;
}else{if(D.answers[E].length>15){G=true;}}}if(A){$("#answerContainer td").addClass("longer");}else{if(G){$("#answerContainer td").addClass("long");}}var C=$("#gameplayStatusArea"),H=$("#playerCurrentTopic"),I="";for(var E=0;E<7;E++){I+=" categoryColor"+E;}C.removeClass(I);$("#playerCurrentCategory .tooltipText").encodeHtml(D.category.name);C.addClass("categoryColor"+D.category.id);var F;switch(D.category.id){case 0:F="entertainment";break;case 1:F="geography";break;case 2:F="history";break;case 3:F="artsliterature";break;case 4:F="science";break;case 5:F="sports";break;}$("#quizCategory").attr("class",F);if(D.domainIconId!=null){var J=(D.domainIconId==""?resource_default_domain_pic_png:"http://"+(location.hostname=="local.planeto.net"?"local.planeto.net:8020":location.hostname)+"/img/kd42x42/"+D.domainIconId);$("#quizCategory img").attr("src",J).removeClass("qsSqIconBackground").show();var B="www.planeto.com";$("#quizProvider .other").html("Question from <a href='"+B+"' target='_blank'>Knowledge network</a>").show().siblings().hide();}else{$("#quizProvider .planeto").show().siblings().hide();$("#quizCategory img").addClass("qsSqIconBackground").attr("src",resource_null_gif).hide();}H.removeClass("short").encodeHtml(D.topic);if(D.topic.length>24){H.addClass("short");}this.resetTimer(D);$("#questionWaitContainer #nextTopicText").show();$("#questionWaitContainer #nextTopic").encodeHtml(D.topic).show();$("#questionContainer, #statusWrapper").show();if(tutorial_done>=4||location.href.indexOf("notutorial")!=-1||Planeto.Globals.currentGameType=="QUIZ_RACE_GAME"){$("#answerContainer").show();}else{$("#answerContainer").hide();}switch(parseInt(D.questionBonus)){case 2:case 3:this.hideJackpot();this.showBonusMultiplier(D.questionBonus);break;case 100:this.hideBonusMultiplier();this.showJackpot();break;default:this.hideBonusMultiplier();this.hideJackpot();break;}this.updateComingCategories(D.comingCategories);},resetTimer:function(A){this.currentTime=new Date();this.timeUntilNextEvent=A.timeUntilNextEvent;this.roundTime=this.timeUntilNextEvent*20;if(this.roundTime<100){this.roundTime*=3;this.plotUpdate=6;}else{this.plotUpdate=2;}this.currentTimeLeft=this.timeUntilNextEvent;this.questionClockNumberDomObj.html(this.currentTimeLeft);this.stopClockInterval();this.timerRef=setInterval(CallbackProxy(this,this.updateTimer),this.roundTime);},stopClockInterval:function(){clearInterval(this.timerRef);},addTimeToTimer:function(A){this.closeTimer();this.roundTime+=A*20;this.timerRef=setInterval(CallbackProxy(this,this.updateTimer),this.roundTime);},onTimeChangedEvent:function(A){this.addTimeToTimer(A.timeUntilNextEvent);},onShowQuestionEvent:function(B){$("#questionDif span").html(B.difficultyLevel);var A=$("#questionContent").encodeHtml(B.question).show();$("#answerContainer td:not(.exclude)").addClass("selectable");A.removeClass("questionMedium questionSmall questionMini questionTiny");if(B.question.length>=120){A.addClass("questionSmall");}else{if(B.question.length>=90){A.addClass("questionMedium");}}$("#questionWaitContainer div").hide();this.resetTimer(B);$("#answerContainer").show();},updateTimer:function(){var E=new Date(),B=this.timeUntilNextEvent;this.currentTimeLeft=Math.round(this.timeUntilNextEvent-(E.getTime()-this.currentTime.getTime())/1000);this.questionClockNumberDomObj.html((this.currentTimeLeft>0?this.currentTimeLeft:""));this.currentClockStep=Math.round((E.getTime()-this.currentTime.getTime())/this.roundTime*this.plotUpdate);if(this.currentClockStep>=100){this.closeTimer();}else{if(B>10){var A=100,C=this.currentClockStep;Raphael.fn.pieChart=function(L){var N="#857364",M="#e57d1a",K="#cf1896",O=40+0.001,G=(O-0.001)/2,F=360-(360*L/A),J=-(F+90)*Math.PI/180,I=O+G*Math.cos(J),H=O+G*Math.sin(J);if(F<=90&&B>5){color=K;}else{if(F<=180&&B>5){color=M;}else{color=N;}}return this.path(["M",O,O,"L",O,(O-G),"A",G,G,0,+(F>180),0,I,H]).attr({fill:color,stroke:color});};this.questionClockPieDomObj.empty();if(C>=0&&C<A){Raphael(this.questionClockPieDomObj.attr("id"),70,70).pieChart(C);
}if(Planeto.Globals.currentGameType=="INFINITE_STREAM_GAME"){var D=0.33;if(this.currentTimeLeft<1||this.standardUsed==true&&this.currentTimeLeft>(B*D)){this.standardUsed=false;$("#actionBarSlotSpecial"+this.standardChosen+" .standardReminder").hide();}else{if(this.currentTimeLeft<(B*D)&&this.standardUsed==false){this.standardUsed=true;if(Math.round(Math.random()*9)==1){this.standardChosen=Math.round(Math.random()*($("#actionBarSlotSpecial > div").length-1));$("#actionBarSlotSpecial"+this.standardChosen+" .standardReminder").show();}}}}}else{$("#questionClockPie").html("");}}},closeTimer:function(){this.stopClockInterval();this.currentClockStep=0;$("#questionClockPie, #questionClockNumber").html("");},onEndQuiz:function(B){if(Planeto.Globals.currentGameType!="QUIZ_RACE_GAME"){this.closeTimer();}$("#answerContainer td").removeClass("selectable");$("#answer"+(B.correctAnswerIndex+1)).addClass("correctAnswer").removeClass("exclude");if(!B.correct){if($("#answerContainer td.answerButtonSelected").length==0){$("#questionContent").html("<img class='time-up' src='"+resource_times_up+"'/><br/><span>Time's up!</span>").show();$("#answerContainer td:not(.correctAnswer, .exclude)").addClass("wrongAnswerAll");this.sendEvent(GoogleAnalyticsControl.TRACK_EVENT,{category:"Player Answered",action:"No Answer",value:1});}else{$("#answerContainer td:not(.correctAnswer)").removeClass("selectable").addClass("exclude");$("#answerContainer td.answerButtonSelected").addClass("wrongAnswer").removeClass("exclude");var D=$("#answer"+(B.correctAnswerIndex+1));if(D.hasClass("answerButtonSelected")){D.removeClass("correctAnswer");$("#answerRightButWrong").fadeIn();}}}else{$("#answerContainer td:not(.correctAnswer)").removeClass("selectable").addClass("exclude");var C=$("#templates div.correctAnswerReceivedPoints").clone(),A=C.find("div.correctAnswerReceivedPointsContent");if(B.jackpot){A.addClass("jackpot");}else{this.showJackpotNoLuck();A.removeClass("jackpot");}A.show().css("top","0").html("+"+B.gainedPoints).animate({top:"-35px"},1000,"",function(){$(this).parent().remove();}).fadeOut("slow");$("#answerContainer td.correctAnswer > div").prepend(C);}$("#answerContainer td.answerButtonSelected").removeClass("answerButtonSelected");if(Planeto.Globals.currentGameType!="HOT_SEAT_GAME"){}this.fadeBonusMultiplier();},pauseGameHandler:function(){$("#clockPauseButton").hide();$("#clockContinueButton").show();},continueGameHandler:function(){$("#clockPauseButton").show();$("#clockContinueButton, #gamePausOverlay, #tutorialWrapper, #questionSetStart, #quizBanner").hide();if(!Planeto.Globals.gamePaused){$("#questionContainer, #answerContainer").show();}},autoPauseRemove:function(){this.sendEvent(StatusView.HIDE_MESSAGE);},answerClicked:function(A){$("#answerContainer td.answerButtonSelected").removeClass("answerButtonSelected");$("#answerContainer td").addClass("selectable");A.addClass("answerButtonSelected").removeClass("selectable");},showBonusMultiplier:function(A){$("#questionBonusMultiplier").addClass("x"+A).show();},hideBonusMultiplier:function(){$("#questionBonusMultiplier").hide().attr("class","");},showJackpot:function(){$("#questionJackpot").removeClass("noluck").show().children("span").html(this.jackpotAmount);},showJackpotNoLuck:function(){$("#questionJackpot").addClass("noluck");},hideJackpot:function(){$("#questionJackpot").hide();},fadeBonusMultiplier:function(){setTimeout(function(){$("#questionBonusMultiplier").fadeOut();},400);},updateComingCategories:function(A){if(A.length>0){$("#quizComingQuestions").show();}else{$("#quizComingQuestions").hide();}for(var B=0;B<A.length;B++){var C;switch(A[B].id){case 0:C="entertainment";break;case 1:C="geography";break;case 2:C="history";break;case 3:C="artsliterature";break;case 4:C="science";break;case 5:C="sports";break;}$("#quizComingQuestion"+(B+1)).attr("class",C+(B+1));}},openFacebookLogin:function(){var A=this;FB.api("/me",function(B){if(B.error){A.sendEvent(ConnectionControl.FACEBOOK_LOGIN);}workAroundLoginToFacebook(CallbackProxy(A,A.handleFacebookLoginResponseAndShowLoadingScreen));
});},handleFacebookLoginResponseAndShowLoadingScreen:function(A){if(A!=null){$("#loadingScreen").show();$("#loadingArea").hide();}},onLoggedInToFacebook:function(){$(".facebookNotLoggedIn").hide();$(".facebookLoggedIn").show();},showClock:function(B){var A=$("#questionClockContainer");if(B){A.fadeIn(400);}else{A.fadeOut(400);}},showLoginMethods:function(){$("#dialogLogin").modal();},hideLoginMethods:function(){$("#dialogLogin").modalClose();}});Planeto.Quiz.View.STOP_CLOCK="Planeto.Quiz.View.STOP_CLOCK";Planeto.Quiz.View.SHOW_LOGIN_METHODS="Planeto.Quiz.View.SHOW_LOGIN_METHODS";Planeto.Quiz.View.HIDE_LOGIN_METHODS="Planeto.Quiz.View.HIDE_LOGIN_METHODS";BasicMVC.Facade.getInstance().register(new Planeto.Quiz.View());Planeto.Quiz=Planeto.Quiz||{};Planeto.Quiz.Channels=Planeto.Quiz.Channels||{};Planeto.Quiz.Channels.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Quiz.Channels.Control";this.popupIsVisible=false;this.initBindings();},eventListeners:function(){return[PlanetoEvents.QUESTION_LANGUAGES_EVENT];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.QUESTION_LANGUAGES_EVENT:this.setDefaultChannel(A.data);break;}},initBindings:function(){$("#quizChannelsButton").bind("click",this.localScopeFull(this.channelChooserClick)).toolTiper();$("#quizChannelsDropDown ul li.quizModeChannelItem").live("click",this.localScopeFull(this.setChannel));},channelChooserClick:function(){this.popupIsVisible=!this.popupIsVisible;this.sendEvent(Planeto.Quiz.Control.CHANNEL_CHOOSER_CLICK,this.popupIsVisible);if(this.popupIsVisible){$(document.body).unbind("click.turnOfChannelsMenu").bind("click.turnOfChannelsMenu",this.localScopeFull(this.closeChannelsMenu));}},setChannel:function(C){var A=$(C.target),B=A.hasClass("quizModeChannelItem")?A:A.parents("li");var D=B.attr("rel");this.sendEvent(Planeto.Quiz.Channels.Control.CHANNEL_SET,D);this.sendEvent(PlanetoService.SET_SITE_LANGUAGE_REQUEST,D);this.popupIsVisible=false;this.sendEvent(Planeto.Quiz.Control.CHANNEL_CHOOSER_CLICK,this.popupIsVisible);$(document.body).unbind("click.turnOfChannelsMenu");},setDefaultChannel:function(A){this.sendEvent(Planeto.Quiz.Channels.Control.CHANNEL_SET,A.currentLanguageId);},closeChannelsMenu:function(B){var A=$(B.target).parents("#quizMode");if(A.length==0){this.popupIsVisible=false;this.sendEvent(Planeto.Quiz.Control.CHANNEL_CHOOSER_CLICK,this.popupIsVisible);$(document.body).unbind("click.turnOfChannelsMenu");}}});Planeto.Quiz.Channels.Control.CHANNEL_CHOOSER_CLICK="Planeto.Quiz.Control.CHANNEL_CHOOSER_CLICK";Planeto.Quiz.Channels.Control.CHANNEL_SET="Planeto.Quiz.Channels.Control.CHANNEL_SET";BasicMVC.Facade.getInstance().register(new Planeto.Quiz.Channels.Control());Planeto.Quiz=Planeto.Quiz||{};Planeto.Quiz.Channels=Planeto.Quiz.Channels||{};Planeto.Quiz.Channels.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Quiz.Channels.View";this.channelItemTemplate=$("#templates li.quizModeChannelItem").outerHtml();},eventListeners:function(){return[Planeto.Quiz.Channels.Control.CHANNEL_CHOOSER_CLICK,Planeto.Quiz.Channels.Control.CHANNEL_SET,PlanetoEvents.QUESTION_LANGUAGES_EVENT];},eventHandlers:function(A){switch(A.name){case Planeto.Quiz.Channels.Control.CHANNEL_CHOOSER_CLICK:this.showChannels(A.data);break;case PlanetoEvents.QUESTION_LANGUAGES_EVENT:this.renderChannels(A.data);break;case Planeto.Quiz.Channels.Control.CHANNEL_SET:this.setCurrentChannel(A.data);break;}},showChannels:function(A){if(A){$("#quizChannelsDropDown").fadeIn("fast");}else{$("#quizChannelsDropDown").fadeOut("fast");}},renderChannels:function(E){var B=jQuery("<ul></ul>");for(var D=0;D<E.languages.length;D++){var A=E.languages[D],C=$(this.channelItemTemplate).attr("rel",A.id);C.find("div.quizModeChannelText").html(A.name);C.find("div.quizModeChannelIcon").addClass(A.id.replace("_",""));B.append(C);}$("#quizChannelsDropDown ul").html(B.children());},setCurrentChannel:function(A){$("#quizChannelsButton div").removeClass().addClass(A.replace("_",""));
}});BasicMVC.Facade.getInstance().register(new Planeto.Quiz.Channels.View());Planeto.Player=Planeto.Player||{};var SHOW_ACHIEVEMENTS_HIDE_DELAY=5000,SHOW_LOG_OUT_HIDE_DELAY=2000,HIDE_FRIEND_MENU_TIMEOUT=-1;Planeto.Player.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Player.View";this.achievements=new Array();this.userLevel=0;this.HIGHTLIGHT_COLOR="#e64e80";$("#dialogStats div.closeModal").live("click",this.localScopeFull(this.closeModal));this.validateTimeout=0;this.levelProgressBubbleContainer_img=$("#levelProgressBubbleContainer img");$("#avatarTabs").delegate("img","click",this.localScopeFull(this.changeAvatarTab));},eventListeners:function(){return[PlanetoEvents.LOGIN_RESPONSE,PlanetoEvents.LOCATION_SELECTION_RESPONSE,PlanetoEvents.LIST_CITIES_RESPONSE,PlanetoEvents.NEW_QUIZ_RESPONSE,PlanetoEvents.SCORE_CHANGED_EVENT,PlanetoEvents.GOLD_CHANGED_EVENT,PlanetoEvents.STREAK_CHANGED_EVENT,PlanetoEvents.SKILL_VALUE_CHANGED_EVENT,PlanetoEvents.LEVEL_UP_EVENT,PlanetoEvents.SCORE_MULTIPLIER_CHANGED_EVENT,PlanetoEvents.USER_LOCATION_UPDATED_EVENT,PlanetoEvents.PLAYER_NAME_UPDATED_EVENT,PlanetoEvents.PLAYER_PROFILE_PIC_UPDATED_EVENT,RespiteControl.TRIGGER_LEVEL_UP,Planeto.Player.View.CLOSE_MODAL,Planeto.Facebook.QuizFeed.Control.UPDATED,];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.LOGIN_RESPONSE:this.loginResponse(A.data);break;case PlanetoEvents.LOCATION_SELECTION_RESPONSE:this.setSignupLocation(A.data);break;case PlanetoEvents.LIST_CITIES_RESPONSE:this.setSignupCities(A.data);break;case RespiteControl.TRIGGER_LEVEL_UP:this.updateLevel(A.data);break;case Planeto.Player.Control.CLOSE_LEVEL_UP_CLICK:case Planeto.Player.View.CLOSE_MODAL:this.closeModal();break;case Planeto.Facebook.QuizFeed.Control.UPDATED:this.displayPlayerData(A.data);break;case PlanetoEvents.NEW_QUIZ_RESPONSE:this.onNewQuizSession(A.data);break;case PlanetoEvents.SCORE_CHANGED_EVENT:this.updateScore(A.data);break;case PlanetoEvents.GOLD_CHANGED_EVENT:this.updateGold(A.data.gold);break;case PlanetoEvents.STREAK_CHANGED_EVENT:this.updateStreak(A.data);break;case PlanetoEvents.SCORE_MULTIPLIER_CHANGED_EVENT:this.showScoreMultiplier(A.data.scoreMultiplier);break;case PlanetoEvents.USER_LOCATION_UPDATED_EVENT:this.updateLocation(A.data.location);break;case PlanetoEvents.PLAYER_NAME_UPDATED_EVENT:this.updatePlayerName(A.data.nickName);break;case PlanetoEvents.PLAYER_PROFILE_PIC_UPDATED_EVENT:this.updatePlayerProfilePicture(A.data.profilePicture);break;}},changeAvatarTab:function(B){var E=$("#avatarTabs img.active"),A=E.attr("id"),C=$(B.target),D=C.attr("id");if(A!=D){if(D=="avatarTab1"){$("#attireSlots").hide();}else{if(D=="avatarTab2"){$("#attireSlots").show();}}E.removeClass("active");C.addClass("active");}},closeModal:function(){},updateLevel:function(B){var A=0;if(typeof B.level.value=="undefined"){A=B.level;}else{A=B.level.value;}var D=A,C=false;if(typeof B.type!="undefined"){C=B.type=="player.LevelUpEvent";}if(this.userLevel!=A){$("#avatarLevelNumber").fadeOut("fast",function(){$(this).css("background-position","0 -"+(D*18)+"px").fadeIn();});$("#friendId-"+user_id).find("div.friendLevel").css("background-position","0 -"+(D*27)+"px");}this.userLevel=A;if(typeof B.earnedGold!="undefined"){$("span.addedGold").html(B.earnedGold);}if(typeof B.levelScore!="undefined"){$("#dialogLevelUp span.userGold").html(B.gold);$("#dialogLevelUp span.currentScore").html(B.levelScore);if(typeof B.scoreToAchieveNextLevel!="undefined"){$("span.xpLeft").html(B.scoreToAchieveNextLevel-B.levelScore);}}},updateStreak:function(A){$("h2.playerCurrentStreak").html(A.streak);},updateScore:function(D){var C=(parseInt(D.score)-parseInt(D.level.scoreToAchieveThisLevel))/(D.level.scoreToAchieveNextLevel-D.level.scoreToAchieveThisLevel),B=$("#levelProgressBubbleContainer div"),A=130;C=C>1?1:C;if(B.is(":hidden")){B.show();this.levelProgressBubbleContainer_img.show();}B.delay(500).animate({left:34+Math.round(C*47)});this.levelProgressBubbleContainer_img.delay(500).animate({left:39+Math.round(C*130)});
$("#levelProgress").delay(500).animate({"background-position":-(150-Math.round(C*130))+"px 0"});$("#levelProgressBubbleContainer span.xpLeft").delay(500).html((D.level.scoreToAchieveNextLevel-D.score)+"p");$("#ingameLevelPoints span").html(D.score);},updatePlayerData:function(A){this.updateScore(A);$("h2.playerCurrentStreak").html(A.streak);this.updateGold(A.gold);this.updatePlayerName(A.nickName);this.updatePlayerProfilePicture(A.profilePicture);},updatePlayerName:function(A){$("#ingameAvatarBox h3").html(A);},updatePlayerProfilePicture:function(A){if(A==null){A={bigPictureUrl:resource_guestavatar_jpg};}$("#ingameAvatarImage > img").load(function(){var F=$(this),D=F.width(),J=F.height(),C,B,I=179,H=233,K=H/J,G=I/D,E=K>G?K:G;if(D>0&&J>0){D=Math.round(D*E);J=Math.round(J*E);C=Math.round((I-D)/2);B=Math.round((H-J)/2);F.css({width:D,height:J,"margin-left":C,"margin-top":B});}}).attr("src",A.bigPictureUrl);},updateLocation:function(A){var E=A.country.name,D=A.city.name,C=A.country.isoCode,B=A.country.isoCode.toLowerCase();if(E=="Unspecified"){E="Unknown country";}if(D=="Unspecified"){D="Unknown city";}$("#userFlag .tooltip .tooltipText").html(E).attr("rel",C);$("#userFlag img").attr("class","spr_flags spr_flag_"+B).toolTiper();$("#userFlag span").html(D);},onNewQuizSession:function(A){this.showReturningPlayerState();},displayPlayerData:function(A){this.updatePlayerData(A);setTimeout(CallbackProxyTimeouts(this,this.updateLevel,A),1000);},loginResponse:function(A){user_id=A.account!=null?A.account.user.id:"[no account]";if(!A.error&&A.account){this.updateLocation(A.account.user.location);}},onLogoutResponse:function(A){if(!A.error){this.account=null;this.showFlyer("#flyerShowLoggedOut",SHOW_LOG_OUT_HIDE_DELAY);}},setSignupLocation:function(A){this.setSignupCities(A);$("#signupCitySelect").val(A.selectedLocation.city.id);var C=$("#signupCountrySelect"),D;for(var B=0;B<A.countries.length;B++){D+="<option value='"+A.countries[B].isoCode+"'>"+A.countries[B].name+"</option>";}C.html(D).val(A.selectedLocation.country.isoCode);C.change(CallbackProxy(this,function(){this.sendEvent(PlanetoService.GET_CITIES,C.val());}));},setSignupCities:function(A){var C;for(var B=0;B<A.cities.length;B++){C+="<option value='"+A.cities[B].id+"'>"+A.cities[B].name+"</option>";}$("#signupCitySelect").html(C).show();},sendSignupForServerValidation:function(){var C="John Doe",B=-1,A=$("#signupEmail").val();if(A.length>0){B=A.indexOf("@")>0?A.indexOf("@"):A.length;C=A.substr(0,B);}this.sendEvent(PlanetoService.VALIDATE_SIGNUP,A,$("#signupNickname").val(),1,$("#signupPassword").val());},signup:function(){var A=this.jsValidateSignup();if(A.accountValidation.valid){var D="John Doe",C=-1,B=$("#signupEmail").val();if(B.length>0){C=B.indexOf("@")>0?B.indexOf("@"):B.length;D=B.substr(0,C);}this.sendEvent(PlanetoService.SIGNUP,B,D,1,$("#signupPassword").val());}this.showSignupErrorMessages(A,true);},jsValidateSignup:function(){var E={accountValidation:{cityValid:true,emailValidation:{taken:false,valid:true},passwordVerification:{approoved:true,complexityLevel:1,complexityLevelOk:true,passwordLength:1,passwordLengthOk:true,requiredComplexityLevel:1,requiredPasswordLength:6,repeatedCorrect:true},valid:true},accountValidationMessages:{cityMessage:"The provided city could not be found.",emailMessage:"Does not look like an E-Mail.",passwordMessage:"Password is too short.",userNameMessage:null},type:"jsValidation"},B=false;var A=$("#signupEmail"),G=$("#signupNickname"),D=$("#signupCity"),C=$("#signupAvatar"),F=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;if(!F.test(A.val())){E.accountValidation.valid=false;E.accountValidation.emailValidation.valid=false;E.accountValidationMessages.emailMessage="Does not look like an E-Mail.";}if($("#signupPassword").val().length<6){E.accountValidation.valid=false;E.accountValidation.passwordVerification.approoved=false;E.accountValidationMessages.passwordMessage="Password is to short";}if($("#signupPassword").val()!=$("#signupPasswordAgain").val()){E.accountValidation.valid=false;
E.accountValidation.passwordVerification.repeatedCorrect=false;}return E;},showSignupErrorMessages:function(A,B){B=B==null?false:B;if(!A.accountValidation.valid){if(($("#signupEmail").val()!="email")||B){if(!A.accountValidation.emailValidation.valid){signup_email_error.fadeIn("fast").html(A.accountValidationMessages.emailMessage);}else{signup_email_error.fadeOut("fast");}}if(($("#signupPassword").val()!="password")||B){if(!A.accountValidation.passwordVerification.approoved){signup_email_error.fadeIn("fast").html(A.accountValidationMessages.passwordMessage);}else{signup_email_error.fadeOut("fast");}}if(($("#signupPasswordAgain").val()!="password once more")||B){if(typeof A.accountValidation.passwordVerification.repeatedCorrect!="undefined"){if(!A.accountValidation.passwordVerification.repeatedCorrect){signup_password_error.fadeIn("fast");}else{signup_password_error.fadeOut("fast");}}}}},showReturningPlayerState:function(){$("#playerReturningPauseContent").show();$("#playerFirstTimePauseContent").hide();},showScoreMultiplier:function(A){},updateGold:function(A){$("span.userGold").html(parseInt(A));}});Planeto.Player.View.CLOSE_MODAL="Planeto.Player.View.CLOSE_MODAL";BasicMVC.Facade.getInstance().register(new Planeto.Player.View());Planeto.Player=Planeto.Player||{};Planeto.Player.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Player.Control";this.validateTimeout=0;totalQuestions=0;this.linkBonusType=null;this.quizWaveReceived=false;var B=this;$("#getMoreGold").live("click",function(){if($("#showGetMoreGoldAfterRound").is(":hidden")){B.sendEvent(RespiteControl.GET_MORE_GOLD_CLICKED);}});$("#inviteFriends .button").live("click",this.localScopeFull(this.inviteFriends));$("#knProfileLinkAndText .facebookLogin .button").live("click",this.localScopeFull(this.facebookLogin));$("#dialogStart .create").live("click",this.localScopeFull(this.loadCreator));$("#postFacebookWall").live("click",this.localScopeFull(function(){this.sendEvent(PlanetoEvents.POST_TO_FACEBOOK_WALL,{});}));$("#dialogInvite").delegate(".spr_button_orange","click",this.localScopeFull(this.openEmailInvite));$("#dialogInvite").delegate(".spr_button_grey","click",this.localScopeFull(this.closeInviteModal));$("#dialogSendInvite").delegate(".spr_button_grey","click",this.localScopeFull(this.closeSendModal));$("#dialogSendInvite").delegate(".spr_button_orange","click",this.localScopeFull(this.sendInvitationEmail));$("#dialogStart .startPlayingButton").live("click",this.localScopeFull(this.startPlay));$("#dialogSendInvite textarea").live("keydown",function(){var D=$(this).val();if(D.length>300){$(this).val(D.substr(0,300));return false;}});var A=$("#landingScreen h2").html(),C=$("#landingScreen p").html();$("#landingScreen .clickmap div").hover(function(){$("#landingScreenSingleImg, #landingScreenMultiImg").removeClass("selected");$("#"+$(this).attr("rel")).addClass("selected");$("#landingScreen h2").html($(this).attr("h2_text"));$("#landingScreen p").html($(this).attr("p_text"));},function(){$("#landingScreenSingleImg, #landingScreenMultiImg").removeClass("selected");$("#landingScreen h2").html(A);$("#landingScreen p").html(C);});$("#landingScreen").delegate(".clickmap div","click",this.localScopeFull(this.startGameMode));},eventListeners:function(){return[PlanetoEvents.NEW_QUIZ_RESPONSE,RespiteControl.TRIGGER_LEVEL_UP,PlanetoEvents.LOGIN_RESPONSE,PlanetoEvents.LOCATION_SELECTION_RESPONSE,PlanetoEvents.LIST_CITIES_RESPONSE,PlanetoEvents.INVITE_BY_EMAIL_RESPONSE,PlanetoEvents.SHOW_INVITE_DIALOG,Planeto.Player.Control.START_PLAYING,PlanetoEvents.LINK_BONUS_WILL_BE_RECEIVED_EVENT,PlanetoEvents.SHOW_LANDING_SCREEN,Planeto.Player.Control.START_LANDING,PlanetoEvents.WAVE_MESSAGE_RECEIVED_EVENT,PlanetoEvents.IGNORE_USER_LIST_CHANGED_EVENT];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.NEW_QUIZ_RESPONSE:this.onNewQuizSession(A.data);break;case RespiteControl.TRIGGER_LEVEL_UP:this.onLevelUpEvent(A.data);break;case PlanetoEvents.LOGIN_RESPONSE:this.loginResponse(A.data);
break;case PlanetoEvents.LOCATION_SELECTION_RESPONSE:this.setSignupLocation(A.data);break;case PlanetoEvents.LIST_CITIES_RESPONSE:this.setSignupCities(A.data);break;case PlanetoEvents.INVITE_BY_EMAIL_RESPONSE:this.inviteByEmailResponse(A.data);break;case PlanetoEvents.SHOW_INVITE_DIALOG:this.inviteFriends();break;case PlanetoEvents.LINK_BONUS_WILL_BE_RECEIVED_EVENT:this.linkBonusType=A.data.linkBonusType;break;case Planeto.Player.Control.START_PLAYING:this.startPlayingInfiniteGameStream(A.data);break;case Planeto.Player.Control.START_LANDING:this.startPlay();break;case PlanetoEvents.SHOW_LANDING_SCREEN:this.showLandingScreen();break;case PlanetoEvents.WAVE_MESSAGE_RECEIVED_EVENT:this.quizWaveReceived=true;break;case PlanetoEvents.IGNORE_USER_LIST_CHANGED_EVENT:ignoreUserList=A.data.ignoreUserList;this.sendEvent(PlanetoEvents.IGNORE_USER_LIST_CHANGED);break;}},startGameMode:function(A){this.sendEvent(PlanetoEvents.START_GAME_MODE,A);},closeStatsModal:function(){$.modal.close();},closeInviteModal:function(){$("#dialogInvite").modalClose();this.sendEvent(RespiteControl.CONTINUE);},closeSendModal:function(){$("#dialogSendInvite").modalClose();$("#inviteError, #inviteSending").hide();$("#dialogInvite").modal({over:true});},inviteFriends:function(){var A=$("#dialogInvite");if(connectedToGoogle){A.find("h3").hide();$("#postFacebookWall").hide();}else{A.find("h3").show();$("#postFacebookWall").show();}A.modal({over:true});},startPlay:function(){this.sendEvent(Planeto.Player.View.CLOSE_MODAL);this.sendEvent(PlanetoEvents.SHOW_LOGO);$("#dialogStart").modalClose();switch(this.linkBonusType){case"QUESTIONSET":case"SELF_QUIZ":this.sendEvent(Planeto.Player.Control.START_PLAYING,"START_PLAYING");break;default:if(Planeto.Globals.autoStartGameType=="quizrace"||location.href.indexOf("quizrace")!=-1){this.sendEvent(PlanetoService.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME,"QUIZ_RACE");}else{if(Planeto.Globals.autoStartGameType=="picturequiz"||location.href.indexOf("picturequiz")!=-1){this.sendEvent(PlanetoService.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME,"PICTURE_QUIZ");}else{if(Planeto.Globals.autoStartGameType=="hotseat"||location.href.indexOf("hotseat")!=-1){this.sendEvent(PlanetoService.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME,"HOT_SEAT");}else{if(location.href.indexOf("iquiz")!=-1){this.sendEvent(Planeto.Player.Control.START_PLAYING,"START_PLAYING");}else{if(this.quizWaveReceived){$("#landingScreen").show();}else{if(totalQuestions==0){this.sendEvent(Planeto.Player.Control.START_PLAYING,"START_PLAYING");}else{$("#landingScreen").show();if(show_mastery_points_after_load==true){$("#dialogMastery").modal();}}}}}}}this.sendEvent(PlanetoService.GET_AVAILABLE_GAME_ROOM_GAMES);break;}},startPlayingInfiniteGameStream:function(A){this.sendEvent(StatusView.HIDE_MESSAGE);if(totalQuestions>0||location.href.indexOf("notutorial")!=-1||ignoreTutorial==true){if(A=="START_PLAYING"){this.sendEvent(PlanetoService.START_PLAYING);}else{this.sendEvent(PlanetoService.PAUSE_PLAYING,false);}if(location.href.indexOf("notutorial")!=-1){this.sendEvent(PlanetoService.SET_META_DATA,{key:"tutorial_done",value:4});}}else{this.sendEvent(Planeto.Tutorial.View.FIRST_TUTORIAL_EVENT);}},openEmailInvite:function(){$("#dialogInvite").modalClose();$("#dialogSendInvite").modal({over:true});$("#inviteFrom").html($("#ingameAvatarBox h3").html());},sendInvitationEmail:function(){$("#inviteError").hide();$("#inviteSending").html("Sending email...").show();this.sendEvent(PlanetoService.INVITE_BY_EMAIL_REQUEST,$("#dialogSendInvite input").val(),$("#dialogSendInvite textarea").val());},inviteByEmailResponse:function(A){if(A.success==true){$("#inviteError").hide();$("#dialogSendInvite input").val("");$("#inviteSending").html("Invitation sent.");}else{$("#inviteSending").hide();$("#inviteError").html("Invitation failed. Please try again.").show();}},onLevelUpEvent:function(){this.sendEvent(RespiteControl.CONTINUE);},onNewQuizSession:function(A){totalQuestions=location.href.indexOf("resettutorial")!=-1?0:A.totalQuestions;
this.sendEvent(PlanetoService.GET_TEAMS_LIST);var Q=A.chosen;var J=A.domainsToBeTestedOn;var R=A.exampleDomains;var M=false;if(knViewOn||location.href.indexOf("knbeta")!=-1||R==null||J!=null||Q){M=true;$("#dialogStart").remove();$("#dialogStart-knbeta").attr("id","dialogStart");}var O=$("#dialogBulletins ul"),S="",F="",B=0,E=0;if(A.bulletins){B=A.bulletins.length;}if(!M){console.log("KN-mode disabled");if(B>0){for(var N=0;N<B;N++){if(A.bulletins[N].important!=true){if(A.bulletins[N].type=="system"){F=A.bulletins[N].message;}else{F=htmlEncode(A.bulletins[N].message);}S+="<li"+(N%2?" class='alternate'":"")+"><img src='"+resource_null_gif+"' class='"+A.bulletins[N].type+"'/><div>"+F+"</div></li>";E++;}}}}else{console.log("KN-mode enabled");var G="",H=0;for(var N=0;N<B;N++){if(A.bulletins[N].important!=true){if(A.bulletins[N].type=="system"){F=A.bulletins[N].message;}else{F=htmlEncode(A.bulletins[N].message);}S+="<li class='chatTabs'><img src='"+resource_null_gif+"' class='"+A.bulletins[N].type+"'/><div>"+F+"</div></li>";E++;}}if(J!=null){for(var N=0;N<J.length;N++){var D=J[N],T=(D.knowledgeDomain.imageId==""?resource_default_domain_pic_png:"http://"+(location.hostname=="local.planeto.net"?"local.planeto.net:8020":location.hostname)+"/img/kd90x90/"+D.knowledgeDomain.imageId),L=D.knowledgeDomain.url,U=D.knowledgeDomain.name;G+="<li class='chatTabs"+(D.unansweredQuestions==0?" inactive_domain":"")+"'><img src='"+T+"' class='domainIcon'/><p><a href='"+L+"' target='_blank'>"+U+"</a></p><p><span class='small"+(D.unansweredQuestions==0?" red":"")+"'>"+D.unansweredQuestions+" questions</span></p>"+(D.unansweredQuestions==0?"<p><span class='small'><a href='"+L+"&createQuestion' target='_blank'>Create</a> a question</span></p>":"")+"</li>";H++;}}else{if(R!=null){for(var N=0;N<R.length;N++){var D=R[N],T=(D.imageId==""?resource_default_domain_pic_png:"http://"+(location.hostname=="local.planeto.net"?"local.planeto.net:8020":location.hostname)+"/img/kd90x90/"+D.imageId),L=D.url,U=D.name;G+="<li class='chatTabs'><img src='"+T+"' class='domainIcon'/><img class='example_domain' src='"+resource_null_gif+"'/><p><a href='"+L+"' target='_blank'>"+U+"</a></p></li>";$("#knowledgeDomainsContainer .leftArrow").hide();$("#knowledgeDomainsContainer .rightArrow").hide();$("#knProfileLinkAndText .willBeTestedOnDomains").hide();if(connectedToFB){$("#knProfileLinkAndText .editKnowledgeProfile").show();}else{$("#knProfileLinkAndText .facebookLogin").show();}H++;}}}if(H>0){$("#knowledgeDomains ul").html(G).show();var P=new Scroller($("#knowledgeDomains"),$("#knowledgeDomains > ul"),$("#knowledgeDomainsContainer .leftArrow:not(.disabled)"),$("#knowledgeDomainsContainer .rightArrow:not(.disabled)"));}}if(E==0){$("#dialogBulletins").html("No login notifications available...");}else{O.html(S).show();if(location.href.indexOf("knbeta")==-1){$("#dialogBulletins > div").remove();var P=new Scroller($("#dialogBulletins"),$("#dialogBulletins > ul"),$("#bulletinsContainer .leftArrow:not(.disabled)"),$("#bulletinsContainer .rightArrow:not(.disabled)"));}}$("#facebookLike").show().children("iframe").attr("src","http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fapps%2Fapplication.php%3Fid%3D165427943513068&send=false&layout=standard&width=600&show_faces=false&action=like&colorscheme=light&font&height=35");var K="";if(A.invite!=""){K="/?inviteid="+A.invite;}var I=$("#knProfileLinkAndText .willBeTestedOnDomains a");I.attr("href",kn_url+"knbeta"+K);I.attr("target","_blank");var C=$("#knProfileLinkAndText .editKnowledgeProfile a");C.attr("href",kn_url+"knbeta"+K);C.attr("target","_blank");},openForum:function(){this.sendEvent(Planeto.Quiz.Control.COMMAND_PAUSE_GAME);this.sendEvent(GoogleAnalyticsControl.TRACK_EVENT,{"":"Tabs",action:"Clicked ForumButton"});},cancelLoginClick:function(){this.sendEvent(Planeto.Player.View.CLOSE_MODAL);},facebookLogin:function(){var A=this;$("#dialogStart").modalClose();},loginResponse:function(A){if(!A.error){this.account=A.account;
ignoreUserList=this.account.user.ignoreUserList;}},onLogoutResponse:function(A){if(!A.error){this.account=null;this.showFlyer("#flyerShowLoggedOut",SHOW_LOG_OUT_HIDE_DELAY);}},setSignupLocation:function(A){this.setSignupCities(A);$("#signupCitySelect").val(A.selectedLocation.city.id);var C=$("#signupCountrySelect"),D;for(var B=0;B<A.countries.length;B++){D+="<option value='"+A.countries[B].isoCode+"'>"+A.countries[B].name+"</option>";}C.html(D).val(A.selectedLocation.country.isoCode);C.change(CallbackProxy(this,function(){this.sendEvent(PlanetoService.GET_CITIES,C.val());}));},setSignupCities:function(A){var C;for(var B=0;B<A.cities.length;B++){C+="<option value='"+A.cities[B].id+"'>"+A.cities[B].name+"</option>";}$("#signupCitySelect").html(C).show();},showSignupDialog:function(){this.sendEvent(QuizControl.COMMAND_PAUSE_GAME);$("#dialogSignup").modal();this.sendEvent(PlanetoService.LOCATION_SELECTION);$("#signupEmail").bind("keyup",CallbackProxy(this,function(){clearTimeout(this.validateTimeout);this.validateTimeout=setTimeout(CallbackProxy(this,function(){var A=this.jsValidateSignup();if(A.accountValidation.emailValidation.valid){this.sendSignupForServerValidation();}else{this.showSignupErrorMessages(A);}}),400);}));$("#signupPassword").bind("keyup",CallbackProxy(this,function(){clearTimeout(this.validateTimeout);this.validateTimeout=setTimeout(CallbackProxy(this,function(){var A=this.jsValidateSignup();if(A.accountValidation.passwordVerification.approoved){this.sendSignupForServerValidation();}else{this.showSignupErrorMessages(A);}}),400);}));$("#signupPasswordAgain").bind("keyup",CallbackProxy(this,function(){clearTimeout(this.validateTimeout);this.validateTimeout=setTimeout(CallbackProxy(this,function(){var A=this.jsValidateSignup();if(A.accountValidation.passwordVerification.repeatedCorrect){this.sendSignupForServerValidation();}else{this.showSignupErrorMessages(A);}}),400);}));},sendSignupForServerValidation:function(){var C="John Doe",B=-1,A=$("#signupEmail").val();if(A.length>0){B=A.indexOf("@")>0?A.indexOf("@"):A.length;C=A.substr(0,B);}this.sendEvent(PlanetoService.VALIDATE_SIGNUP,A,$("#signupNickname").val(),1,$("#signupPassword").val());},signup:function(){var A=this.jsValidateSignup();if(A.accountValidation.valid){var D="John Doe",C=-1,B=$("#signupEmail").val();if(B.length>0){C=B.indexOf("@")>0?B.indexOf("@"):B.length;D=B.substr(0,C);}this.sendEvent(PlanetoService.SIGNUP,B,D,1,$("#signupPassword").val());}this.showSignupErrorMessages(A,true);},onSignup:function(A){if(A.ok){$.modal.close();}else{this.validateSignup(A);}},onValidateSignup:function(A){$("#signupPassword").val()!=$("#signupPasswordAgain").val()?A.accountValidation.valid=false:false;A.accountValidation.passwordVerification.repeatedCorrect=$("#signupPassword").val()==$("#signupPasswordAgain").val();this.showSignupErrorMessages(A,true);},jsValidateSignup:function(){var E={accountValidation:{cityValid:true,emailValidation:{taken:false,valid:true},passwordVerification:{approoved:true,complexityLevel:1,complexityLevelOk:true,passwordLength:1,passwordLengthOk:true,requiredComplexityLevel:1,requiredPasswordLength:6,repeatedCorrect:true},valid:true},accountValidationMessages:{cityMessage:"The provided city could not be found.",emailMessage:"Does not look like an E-Mail.",passwordMessage:"Password is too short.",userNameMessage:null},type:"jsValidation"},B=false;var A=$("#signupEmail"),G=$("#signupNickname"),D=$("#signupCity"),C=$("#signupAvatar"),F=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;if(!F.test(A.val())){E.accountValidation.valid=false;E.accountValidation.emailValidation.valid=false;E.accountValidationMessages.emailMessage="Does not look like an E-Mail.";}if($("#signupPassword").val().length<6){E.accountValidation.valid=false;E.accountValidation.passwordVerification.approoved=false;E.accountValidationMessages.passwordMessage="Password is to short";}if($("#signupPassword").val()!=$("#signupPasswordAgain").val()){E.accountValidation.valid=false;E.accountValidation.passwordVerification.repeatedCorrect=false;
}return E;},showSignupErrorMessages:function(A,B){B=B==null?false:B;if(!A.accountValidation.valid){if(($("#signupEmail").val()!="email")||B){if(!A.accountValidation.emailValidation.valid){signup_email_error.fadeIn("fast").html(A.accountValidationMessages.emailMessage);}else{signup_email_error.fadeOut("fast");}}if(($("#signupPassword").val()!="password")||B){if(!A.accountValidation.passwordVerification.approoved){signup_email_error.fadeIn("fast").html(A.accountValidationMessages.passwordMessage);}else{signup_email_error.fadeOut("fast");}}if(($("#signupPasswordAgain").val()!="password once more")||B){if(typeof A.accountValidation.passwordVerification.repeatedCorrect!="undefined"){if(!A.accountValidation.passwordVerification.repeatedCorrect){signup_password_error.fadeIn("fast");}else{signup_password_error.fadeOut("fast");}}}}},loadCreator:function(){location.href="http://create.planeto.com";},showLandingScreen:function(){$("#topMenuSingle > div, #topMenuTravel > div").removeClass("active");$("#landingScreen").show();}});Planeto.Player.Control.OPEN_LOGIN_DIALOG_CLICK="Planeto.Player.Control.OPEN_LOGIN_DIALOG_CLICK";PlanetoEvents.SHOW_INVITE_DIALOG="PlanetoEvents.SHOW_INVITE_DIALOG";Planeto.Player.Control.START_PLAYING="Planeto.Player.Control.START_PLAYING";PlanetoEvents.SHOW_LANDING_SCREEN="PlanetoEvents.SHOW_LANDING_SCREEN";Planeto.Player.Control.START_LANDING="Planeto.Player.Control.START_LANDING";PlanetoEvents.IGNORE_USER_LIST_CHANGED="PlanetoEvents.IGNORE_USER_LIST_CHANGED";BasicMVC.Facade.getInstance().register(new Planeto.Player.Control());Planeto.Game=Planeto.Game||{};Planeto.Game.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Game.View";this.loadingScreenVisible=true;this.showingWaitingForFB=false;this.connectedToFB=false;this.reconnectTimerPause=1000;this.reconnectTimeoutRef=null;this.connected=false;this.reconnectTry=false;this.facebookIframe=false;if(location.href.indexOf("FBApp")!=-1){this.facebookIframe=true;$("body, #column1, #column2, #column3").addClass("facebooked");$("#column1").live("mouseover",this.localScopeFull(this.slideInColumn1)).live("mouseleave",this.localScopeFull(this.slideOutColumn1));$("#column3").live("mouseover",this.localScopeFull(this.slideInColumn3)).live("mouseleave",this.localScopeFull(this.slideOutColumn3));}this.rootContainer=$("#rootContainer");},eventListeners:function(){return[PlanetoEvents.NOTIFICATION_EVENT,Planeto.Game.View.SHOW_SERVER_NOTIFICATION,PlanetoEvents.NEW_QUIZ_RESPONSE,PlanetoService.DISCONNECTED,ConnectionControl.NOT_LOGGED_IN_TO_FACEBOOK,Planeto.Facebook.Control.CONNECTED,PlanetoEvents.CONNECT_RESPONSE];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.NOTIFICATION_EVENT:if(A.data.notificationType=="INFO"||A.data.notificationType=="CUSTOM"){A.data.type=Planeto.Game.View.SHOW_SERVER_NOTIFICATION;A.data.respite=true;this.sendEvent(RespiteControl.ADD_SIMPLE_RESPITE,A.data);}else{this.showServerNotification(A.data);}break;case Planeto.Game.View.SHOW_SERVER_NOTIFICATION:this.showServerNotification(A.data);break;case PlanetoService.DISCONNECTED:this.showServerNotification({kind:"SHUTDOWN",message:"Sorry but the connection to the server has been lost. Please reload or wait a while."});break;case ConnectionControl.NOT_LOGGED_IN_TO_FACEBOOK:this.connectedToFB=false;break;case Planeto.Facebook.Control.CONNECTED:this.connectedToFB=true;break;case PlanetoEvents.NEW_QUIZ_RESPONSE:this.newQuizResponse(A.data);break;case PlanetoEvents.CONNECT_RESPONSE:this.connectResponse(A.data);break;}},connectResponse:function(A){$("#serverVersion").html(A.shortServerVersion);},showServerNotification:function(D){var C=$("#continueAfterServerWarning"),E=$("#dialogServerMessage"),A=D.respite,B=this;C.unbind("click").bind("click",function(){$("#dialogServerMessage").modalClose();if(A){B.sendEvent(RespiteControl.CONTINUE);}}).show();E.find(".dialogHeader h2").html(D.header);E.find(".dialogText div p").html(D.message);E.find(".dialogText img").removeClass("warning info custom").attr("src",resource_null_gif);
switch(D.notificationType){case"CUSTOM":E.find(".dialogText img").addClass("custom").attr("src",getImageUrl("QS",D.icon,"plain"));C.show();break;case"WARNING":E.find(".dialogText img").addClass("warning");C.show();break;case"INFO":E.find(".dialogText img").addClass("info");C.show();break;default:E.find(".dialogText img").addClass("warning");C.hide();$.modal.close();break;}E.modal();},loginToFacebookPlease:function(A){$("#loadingArea, #siteMain, #clockContinueButton").hide();$("#clockPauseButton").show();console.log("-- this never happens");$.modal.close();$("#dialogBetaUser").modal();},newQuizResponse:function(C){if(C.availableMasteryPoints>0){}$("#siteMain").show();if(this.loadingScreenVisible){if(this.showingWaitingForFB){$.modal.close();console.log("-- we closed a modal?");this.showingWaitingForFB=false;}this.loadingScreenVisible=false;}if(connectedToGoogle){$("#facebookLogin").show();$("#startKnText").hide();$("#inviteFriends").hide();$(".loginProviders").hide();$("#dialogStart .create").hide();$("#dialogStart .startPlayingButton.guest").hide();}else{if(connectedToFB){$("#startKnText").show();$("#facebookLogin").hide();$(".loginProviders").hide();$(".inviteFriends").show();$("#dialogStart .startPlayingButton.guest").hide();$(".guestWarning").hide();}else{$("#facebookLogin").show();$("#startKnText").hide();$("#inviteFriends").hide();$(".loginProviders").show();$("#dialogStart .create").hide();$("#dialogStart .startPlayingButton.guest").hide();}}if(C.bulletins&&C.bulletins.length>0&&totalQuestions>0){var B=$("#continueAfterServerWarning"),D=$("#dialogServerMessage"),A=function(E,F){if(C.bulletins[E].important){D.find(".dialogHeader h2").html(F[E].title);D.find(".dialogText div p").html(F[E].message);D.find(".dialogText img").removeClass("warning info custom").attr("src",resource_null_gif);D.find(".dialogText img").addClass("custom").attr("src",getImageUrl("QS",F[E].imageUrl,"plain"));B.unbind("click");if(E+1==F.length){B.bind("click",function(){$("#dialogServerMessage").modalClose();$("#dialogStart").modal({fixed:108,over:true});});}else{B.bind("click",function(){A(E+1,F);});}B.show("click").show();D.modal();}else{if(E+1==F.length){$("#dialogServerMessage").modalClose();$("#dialogStart").modal({fixed:108,over:true});}else{A(E+1,F);}}};A(0,C.bulletins);}else{if(!qsOrSqPlayed){$("#dialogStart").modal({fixed:108,over:true});}else{this.sendEvent(Planeto.Player.Control.START_LANDING);}}},slideInColumn1:function(){$("#column1").stop().animate({left:20},200);},slideOutColumn1:function(){$("#column1").stop().animate({left:-135},200);},slideInColumn3:function(){$("#column3").stop().animate({left:495},200);},slideOutColumn3:function(){$("#column3").stop().animate({left:675},200);},resizeRoot:function(){var B=$(window).height(),A=$(document).height();this.rootContainer.css("height",B);}});Planeto.Game.View.SHOW_SERVER_NOTIFICATION="Planeto.Game.View.SHOW_SERVER_NOTIFICATION";BasicMVC.Facade.getInstance().register(new Planeto.Game.View());Planeto.Player=Planeto.Player||{};Planeto.Player.Model=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Player.Model";this.playerVO=null;this.drops=[];this.currentDrop=null;},eventListeners:function(){return[PlanetoEvents.NEW_QUIZ_RESPONSE,PlanetoEvents.PLAYER_UPDATED_EVENT,PlanetoEvents.TRIGGER_DROPPED_ITEMS,Planeto.Player.Model.MOVE_ITEM,Planeto.Player.Model.DISCARD_ITEM,PlanetoService.STOP_GAME,PlanetoEvents.GAME_STARTED_EVENT];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.NEW_QUIZ_RESPONSE:this.onNewQuizSession(A.data);break;case PlanetoEvents.PLAYER_UPDATED_EVENT:this.displayPlayerData(A.data);break;case PlanetoEvents.TRIGGER_DROPPED_ITEMS:this.drops[A.data.drop.identity]=A.data.drop;break;case Planeto.Player.Model.MOVE_ITEM:this.moveItem(A.data);break;case Planeto.Player.Model.DISCARD_ITEM:this.discardItem(A.data);break;case Planeto.Player.Model.DISCARD_DROP:this.discardDrop(A.data.dropId);break;case PlanetoService.STOP_GAME:this.onGameStop();break;case PlanetoEvents.GAME_STARTED_EVENT:this.onGameStarted(A.data);
break;}},onNewQuizSession:function(A){this.playerVO=A.player;playerModel=this.playerVO;this.sendEvent(Planeto.Facebook.QuizFeed.Control.UPDATED,this.playerVO);},onGameStop:function(){},onGameStarted:function(A){Planeto.Globals.currentGameType=A.gameType;},displayPlayerData:function(A){this.playerVO=A.player;this.sendEvent(Planeto.Facebook.QuizFeed.Control.UPDATED,this.playerVO);},updatePlayerData:function(A){this.playerVO.score=A.afterQuestionDTO.score;this.playerVO.streak=A.afterQuestionDTO.streak;this.playerVO.level=A.afterQuestionDTO.level;this.playerVO.gold=A.afterQuestionDTO.gold;this.playerVO.scoreMultiplier=A.afterQuestionDTO.scoreMultiplier;this.sendEvent(Planeto.Facebook.QuizFeed.Control.UPDATED,this.playerVO);},moveItem:function(A){var B;switch(A.updateItem.source){case"ATTIRE":B=this.getItemFromArray(A.updateItem.id,this.playerVO.activeAttire.items);break;case"INVENTORY":B=this.getItemFromArray(A.updateItem.id,this.playerVO.inventory.items);break;case"ACTIONBAR":B=this.getItemFromArray(A.updateItem.id,this.playerVO.standardActions.actions);break;case"DROP":B=this.getItemFromArray(A.updateItem.id,this.drops[A.dropId].items);break;}if(B){switch(A.updateItem.target){case"ATTIRE":this.addItemToArray(B,this.playerVO.activeAttire.items);break;case"INVENTORY":this.addItemToArray(B,this.playerVO.inventory.items);break;case"ACTIONBAR":this.addItemToArray(B,this.playerVO.standardActions.actions);break;}}this.sendEvent(PlanetoService.MOVE_ITEM,A.updateItem,A.dropId);},discardItem:function(A){var B;switch(A.source){case"ATTIRE":B=this.getItemFromArray(A.itemId,this.playerVO.activeAttire.items);break;case"INVENTORY":B=this.getItemFromArray(A.itemId,this.playerVO.inventory.items);break;case"ACTIONBAR":B=this.getItemFromArray(A.itemId,this.playerVO.standardActions.actions);break;case"DROP":B=this.getItemFromArray(A.itemId,this.drops[A.dropId].items);break;}this.sendEvent(PlanetoService.DISCARD_ITEM,A.itemId,A.source,A.sourceSlot,A.dropId);},discardDrop:function(B){var A=this.drops[B],C=A.length>0;this.drops[B]=null;delete this.drops[B];if(C){this.sendEvent(PlanetoService.DISCARD_DROP,B);}},getItemFromArray:function(F,B){var A=B.length,D=-1,E=null;for(var C=0;C<B.length;C++){if(B[C].id==F){E=B[C];D=C;break;}}if(D>-1){B.splice(D,1);}return E;},addItemToArray:function(B,A){A.push(B);}});Planeto.Player.Model.MOVE_ITEM="Planeto.Player.Model.MOVE_ITEM";Planeto.Player.Model.DISCARD_ITEM="Planeto.Player.Model.DISCARD_ITEM";Planeto.Player.Model.DISCARD_DROP="Planeto.Player.Model.DISCARD_DROP";BasicMVC.Facade.getInstance().register(new Planeto.Player.Model());Planeto.Inventory=Planeto.Inventory||{};Planeto.Inventory.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Inventory.Control";this.dropId="";this.warningTimeout=null;this.planetoItemMenuTimer=null;$("#dialogBuyExtraInventory .closeModal").live("click",this.localScopeFull(this.closeModal));$("#actionBarSlotSpecial").delegate("div.planetoItem:not(.disabledItem)","click",this.localScopeFull(this.executeAction));$("#droppedItems").delegate("#discardButton:not(.disabledButton)","click",this.localScopeFull(this.discardAll));$("#droppedItems").delegate("#takeAllButton:not(.disabledButton)","click",this.localScopeFull(this.takeAll));$("#droppedItems").delegate("div.continueButton","click",this.localScopeFull(this.closeInventory));$("#actionBarSlot, #attireSlotsHolder, #inventorySlots, #droppedItemsHolder, #messageContainer").delegate("div.planetoItem","click",this.localScopeFull(this.openMenu));$("#planetoItemMenu").delegate("li","click",this.localScopeFull(this.moveItem));$("#planetoItemMenu").live("mouseleave",this.localScopeFull(this.closeMenuTimer));$("#planetoItemMenu").live("mouseenter",this.localScopeFull(this.resetCloseMenuTimer));$("#buyMoreInventoryButton").unbind("click").bind("click",this.localScopeFull(this.openBuyMoreInventory));},eventListeners:function(){return[PlanetoEvents.PLAYER_UPDATED_EVENT,PlanetoEvents.NEW_QUIZ_RESPONSE,PlanetoEvents.TRIGGER_DROPPED_ITEMS,Planeto.Inventory.CLOSE_INVENTORY,PlanetoEvents.LEVEL_UP_EVENT,Planeto.Inventory.OPEN_BUY_MORE_INVENTORY,PlanetoEvents.BUY_MORE_INVENTORY_SPACE_RESPONSE];
},eventHandlers:function(A){switch(A.name){case PlanetoEvents.PLAYER_UPDATED_EVENT:case PlanetoEvents.NEW_QUIZ_RESPONSE:this.onInventoryUpdate(A.data);break;case PlanetoEvents.TRIGGER_DROPPED_ITEMS:this.triggerDroppedItems(A.data);break;case Planeto.Inventory.CLOSE_INVENTORY:this.closeInventory();break;case PlanetoEvents.LEVEL_UP_EVENT:break;case Planeto.Inventory.OPEN_BUY_MORE_INVENTORY:this.openBuyMoreInventory();break;case PlanetoEvents.BUY_MORE_INVENTORY_SPACE_RESPONSE:this.onBuyMoreInventorySpaceResponse(A.data);break;}},onInventoryUpdate:function(A){this.player=A.player;},triggerDroppedItems:function(A){this.dropId=A.drop.identity;},openMenu:function(D){var B=$(D.currentTarget),H=B.attr("id"),G=D.liveFired.id,A="",C=false,F=false,E=B.find("div.tooltipRequiredLevel").hasClass("red");this.planetoId=H;this.parentId=G;$("#planetoItemMenu li").show();if(G=="actionBarSlot"&&($("#"+this.planetoId).parent().hasClass("pendingFrame")||$("#"+this.planetoId).parent().hasClass("activeFrame"))){A+=(A!=""?", ":"")+"#menuUse";A+=(A!=""?", ":"")+"#menuInventory";}if(G!="actionBarSlot"||B.hasClass("disabledItem")){A+=(A!=""?", ":"")+"#menuUse";}if(G=="actionBarSlot"||G=="attireSlotsHolder"){A+=(A!=""?", ":"")+"#menuActiveAttire";A+=(A!=""?", ":"")+"#menuActionBar";}if(G=="inventorySlots"){A+=(A!=""?", ":"")+"#menuInventory";}if(B.hasClass("wearable")){A+=(A!=""?", ":"")+"#menuActionBar";if(E){A+=(A!=""?", ":"")+"#menuActiveAttire";}}else{if(B.hasClass("collectible")){A+=(A!=""?", ":"")+"#menuActionBar";A+=(A!=""?", ":"")+"#menuActiveAttire";}else{if(B.hasClass("action")||B.hasClass("questionSet")){A+=(A!=""?", ":"")+"#menuActiveAttire";if(E){A+=(A!=""?", ":"")+"#menuActionBar";}else{$("#actionBarSlot > div").each(function(){if($(this).children(".planetoItem").length==0){C=true;return false;}});if(C==false){A+=(A!=""?", ":"")+"#menuActionBar";}}}}}$("#inventorySlots > div").each(function(){if($(this).children(".planetoItem").length==0){console.warn("A free slot!");F=true;return false;}});if(F==false){A+=(A!=""?", ":"")+"#menuInventory";if(G=="droppedItemsHolder"||G=="messageContainer"){A+=(A!=""?", ":"")+"#menuActiveAttire";}}if(A!=""){$(A).hide();}$("#planetoItemMenu").css({top:(D.pageY-5)+"px",left:(D.pageX-5)+"px"}).show();},moveItem:function(N){var D=this.planetoId,O=this.parentId,I=N.currentTarget.id,H=$("#"+D),B=H.clone(true),K="",R="",F="-1",M="-1",S=false,Q=true;switch(O){case"actionBarSlot":K="ACTIONBAR";F=H.parent().attr("id").replace("actionBarSlot","");break;case"attireSlotsHolder":K="ATTIRE";break;case"inventorySlots":K="INVENTORY";F=H.parent().attr("id").replace("inventorySlot","");break;case"droppedItemsHolder":K="DROP";break;case"messageContainer":K="DROP";this.dropId=B.data("dropId");B.attr("id","planetoItem-"+B.data("itemId")).data("id",B.data("itemId")).removeAttr("style").removeClass("messageItem");D="planetoItem-"+B.data("itemId");this.sendEvent(Planeto.MessageView.REMOVEMESSAGE,{messageId:this.planetoId.replace("planetoMessage-","")});break;}switch(I){case"menuInventory":$("#tabContent_2").show().siblings("div").hide();$("#tabContent_2_2").show().siblings("div").hide();$("#tab_2").addClass("active").siblings("li").removeClass("active");$("#tab_2_2").addClass("active").siblings("li").removeClass("active");$("#inventorySlots > div").each(function(){var T=this;if($(this).children(".planetoItem").length==0){B.find("div.planetoItemIcon").toolTiper();$(this).html(B);M=$(this).attr("id").replace("inventorySlot","");S=true;return false;}});R="INVENTORY";break;case"menuActiveAttire":$("#attireSlots").show();$("#avatarTab2").addClass("active").siblings("img").removeClass("active");var P=H.attr("rel"),L=$("#attireSlot_"+P).children("div.planetoItem");if(L.length>0){var E=L.clone();B.find(".comparedItem").empty();B.find(".tooltipcomparecontent").hide();B.find("div.planetoItemIcon").toolTiper();$("#attireSlot_"+P).html(B);H.remove();if(K=="DROP"){var J=this;$("#inventorySlots > div").each(function(){Q=false;if($(this).children(".planetoItem").length==0){E.find("div.planetoItemIcon").toolTiper({beforeDisplay:J.localScopeFull(initWearableTooltipComparison,E)});
$(this).html(E);Q=true;return false;}});}else{E.find("div.planetoItemIcon").toolTiper({beforeDisplay:this.localScopeFull(initWearableTooltipComparison,E)});$("#inventorySlot"+F).html(E);}R="ATTIRE";}else{B.find("div.planetoItemIcon").toolTiper();$("#attireSlot_"+H.attr("rel")).html(B);S=true;R="ATTIRE";}break;case"menuActionBar":$("#actionBarSlot > div").each(function(){if($(this).children(".planetoItem").length==0){B.attr("id",D).find("div.planetoItemIcon").toolTiper();$(this).html(B);M=$(this).attr("id").replace("actionBarSlot","");S=true;return false;}});R="ACTIONBAR";break;case"menuDiscard":this.sendEvent(Planeto.Player.Model.DISCARD_ITEM,{itemId:D.replace("planetoItem-",""),source:K,sourceSlot:parseInt(F),dropId:this.dropId});if(K=="DROP"){$("#planetoItemTooltip-"+D.replace("planetoItem-","")).remove();}if(K=="ACTIONBAR"){H.parent().removeClass("pendingFrame activeFrame").empty();}S=true;break;case"menuUse":this.executeAction(N);break;}var A=$("#planetoMessage-"+this.dropId),C={id:D.replace("planetoItem-",""),source:K,target:R,sourceSlot:parseInt(F),targetSlot:parseInt(M)},G=this.facade.getInstanceByName("Planeto.Player.Model").drops[this.dropId];$("#planetoItemTooltip-"+C.id).remove();if(G){$("#planetoItemTooltip-"+C.id).remove();}if(R!=""&&Q==true){this.sendEvent(Planeto.Player.Model.MOVE_ITEM,{updateItem:C,dropId:this.dropId});}if(S==true){H.remove();}this.closeMenu();if(R=="ACTIONBAR"){this.sendEvent(PlanetoEvents.UPDATE_PERFORMING_ACTIONS_EVENT);}this.sendEvent(Planeto.Inventory.UPDATE_INVENTORY_STATUS);if(G){if(G.items.length==0){$("#discardButton, #takeAllButton").addClass("disabledButton");}}},closeMenu:function(A){$("#planetoItemMenu").hide();},closeMenuTimer:function(){var A=600;if(this.planetoItemMenuTimer){clearTimeout(this.planetoItemMenuTimer);}this.planetoItemMenuTimer=setTimeout(function(){$("#planetoItemMenu").hide();},A);},resetCloseMenuTimer:function(){if(this.planetoItemMenuTimer){clearTimeout(this.planetoItemMenuTimer);}},executeAction:function(C){if(C.liveFired.id=="planetoItemMenu"){var J=$("#"+this.planetoId),G=J.parent().attr("id").replace("actionBarSlot",""),D=false,H="action",F="";}else{var J=$(C.currentTarget),G="-1",D=true,H="standard",F=J.data("identity");if(F=="04bd95bc-00fb-477c-be22-4ef929cf0d53"){this.sendEvent(PlanetoEvents.RESET_INACTIVITY);}}var E=J.parent("div").parent("div"),A=J.attr("id"),K=J.data("groupName"),I=J.data("goldCost"),B=J.data("name");this.sendEvent(PlanetoService.EXECUTE_ACTION,parseInt(G),D,F);this.sendEvent(GoogleAnalyticsControl.TRACK_EVENT,{category:"Player",action:"Used Gold",value:I});this.sendEvent(GoogleAnalyticsControl.TRACK_EVENT,{category:"Actionbar",action:"Use "+H+" - "+B,value:I});},closeInventoryAndContinue:function(A){if(A==true){this.sendEvent(Planeto.MessageView.REMOVEMESSAGE,{messageId:this.dropId});}$("#droppedItems").hide();if($("#gamePausOverlay").hasClass("showAfterDrop")){$("#gamePausOverlay").removeClass("showAfterDrop").show();}if(this.dropId){this.sendEvent(Planeto.MessageView.BIND_DROP,{dropId:this.dropId});}if(!Planeto.Globals.gamePaused){this.sendEvent(Planeto.Quiz.Control.COMMAND_CONTINUE_GAME);}this.sendEvent(RespiteControl.CONTINUE);},discardAll:function(A){this.sendEvent(Planeto.Player.Model.DISCARD_DROP,{dropId:this.dropId});this.closeInventoryAndContinue(true);},takeAll:function(C){var A="DROP",J=-1,F="INVENTORY",D,H,K=this,G=$("#droppedItemsHolder div.planetoItem"),I=G.length,E=$("#inventorySlots > div").length-$("#inventorySlots div.planetoItem").length;G.each(function(){D=$(this);H=D.attr("id");$("#inventorySlots > div").each(function(){if($(this).children(".planetoItem").length==0){D.find("div.planetoItemIcon").toolTiper();$(this).html(D);targetSlot=$(this).attr("id").replace("inventorySlot","");var L={id:H.replace("planetoItem-",""),source:A,target:F,sourceSlot:parseInt(J),targetSlot:parseInt(targetSlot)};K.sendEvent(Planeto.Player.Model.MOVE_ITEM,{updateItem:L,dropId:K.dropId});return false;}});});if(I>E){var B=$("#droppedItems h3.warning");
if(this.warningTimeout){clearTimeout(this.warningTimeout);}this.warningTimeout=setTimeout(function(){B.css("visibility","hidden");},10000);B.css("visibility","visible");}else{this.closeInventoryAndContinue(true);}this.sendEvent(Planeto.Inventory.UPDATE_INVENTORY_STATUS);},closeInventory:function(A){this.sendEvent(GoogleAnalyticsControl.TRACK_EVENT,{category:"Inventory",action:"Clicked Close"});this.closeInventoryAndContinue($("#droppedItemsHolder div.planetoItem").length==0?true:false);},openBuyMoreInventory:function(){var B=$("#dialogBuyExtraInventory"),A=B.find(".buy");cost=300,userGold=parseInt($("#ingameGoldInfo .userGold").html()),slotCount=$("#inventorySlots > div").length,purchasePossible=true,self=this;B.find(".error").hide();if(slotCount>=120){B.find(".maxslots").show();purchasePossible=false;}else{if(cost>userGold){B.find(".nogold").show();purchasePossible=false;}}if(purchasePossible){A.removeClass("disabledButton").unbind("click").bind("click",this.localScopeFull(this.purchaseMoreInventory));}else{A.addClass("disabledButton").unbind("click");}B.find(".getmoregold").unbind("click").bind("click",function(){self.closeModal();self.sendEvent(RespiteControl.GET_MORE_GOLD_CLICKED);});B.modal();},purchaseMoreInventory:function(){this.sendEvent(PlanetoService.BUY_MORE_INVENTORY_SPACE);},onBuyMoreInventorySpaceResponse:function(C){if(C.ok==true){var B=$("#ingameGoldInfo .userGold"),A=parseInt(B.html()),D=500;this.closeModal();this.sendEvent(PlanetoEvents.INVENTORY_CHANGED_EVENT,C);}else{$("#dialogBuyExtraInventory .servererror").html(C.errorMessage).show();}},closeModal:function(){$("#dialogBuyExtraInventory").modalClose();}});PlanetoEvents.TRIGGER_DROPPED_ITEMS="PlanetoEvents.TRIGGER_DROPPED_ITEMS";Planeto.Inventory.CLOSE_INVENTORY="Planeto.Inventory.CLOSE_INVENTORY";Planeto.Inventory.OPEN_BUY_MORE_INVENTORY="Planeto.OPEN_BUY_MORE_INVENTORY";Planeto.Inventory.UPDATE_INVENTORY_STATUS="Planeto.Inventory.UPDATE_INVENTORY_STATUS";BasicMVC.Facade.getInstance().register(new Planeto.Inventory.Control());Planeto.Inventory=Planeto.Inventory||{};if(typeof RespiteControl=="undefined"){var RespiteControl={};}Planeto.Inventory.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Inventory.View";this.inventoryResponse="";this.performingActions="";this.planetoItem=$("#templates div.planetoItem").clone();$("#avatarTab1, #avatarTab2").toolTiper();this.actionCardsDisabled=false;this.skipQuestionDisabled=false;this.removeWrongAnswerDisabled=false;},eventListeners:function(){return[PlanetoEvents.PLAYER_UPDATED_EVENT,PlanetoEvents.NEW_QUIZ_RESPONSE,PlanetoEvents.TRIGGER_DROPPED_ITEMS,RespiteControl.TRIGGER_LEVEL_UP,PlanetoEvents.UPDATE_STANDARD_ACTIONS_EVENT,PlanetoEvents.INVENTORY_CHANGED_EVENT,PlanetoEvents.ACTIONBAR_CHANGED_RESPONSE_EVENT,PlanetoEvents.UPDATE_PERFORMING_ACTIONS_EVENT,PlanetoEvents.ACTION_BAR_ITEM_REMOVED_EVENT,Planeto.Inventory.UPDATE_INVENTORY_STATUS,Planeto.Inventory.DISABLE_REMOVE_INCORRECT_QUESTION,Planeto.Inventory.DISABLE_SKIP_QUESTION,Planeto.Inventory.DISABLE_ACTIONBAR_CARDS];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.PLAYER_UPDATED_EVENT:case PlanetoEvents.NEW_QUIZ_RESPONSE:this.onInventoryUpdate(A.data);break;case PlanetoEvents.TRIGGER_DROPPED_ITEMS:this.triggerDroppedItems(A.data);break;case RespiteControl.TRIGGER_LEVEL_UP:this.onLevelUpEvent(A.data);break;case PlanetoEvents.UPDATE_STANDARD_ACTIONS_EVENT:this.updateStandardActions(A.data);break;case PlanetoEvents.ACTIONBAR_CHANGED_RESPONSE_EVENT:this.actionbarChanged(A.data);break;case PlanetoEvents.INVENTORY_CHANGED_EVENT:this.inventoryChanged(A.data);break;case PlanetoEvents.UPDATE_PERFORMING_ACTIONS_EVENT:this.updatePerformingActions(A.data);break;case PlanetoEvents.ACTION_BAR_ITEM_REMOVED_EVENT:this.actionBarItemRemoved(A.data);break;case Planeto.Inventory.UPDATE_INVENTORY_STATUS:this.checkDisabledStatuses();break;case Planeto.Inventory.DISABLE_REMOVE_INCORRECT_QUESTION:this.disableRemoveIncorrectQuestion(A.data);break;case Planeto.Inventory.DISABLE_SKIP_QUESTION:this.disableSkipQuestion(A.data);
break;case Planeto.Inventory.DISABLE_ACTIONBAR_CARDS:this.disableActionBarCards(A.data);break;case RENDER_ITEM_REWARDS_REQUEST:this.renderItemRewards(A.data);break;}},setPlanetoItemTooltip:function(A,B){planetoItemTooltip(A,B,this.player.level.value);},onLevelUpEvent:function(A){this.player.level.value=A.level;this.updateInventoryTooltips();},actionBarItemRemoved:function(A){$("#actionBarSlot"+A.slotIndex).removeClass("pendingFrame activeFrame").empty();},updatePerformingActions:function(B){if(B!=undefined){this.performingActions=B;}else{B=this.performingActions;}if(B.performingActions){var H=B.performingActions.length,J=B.queuedActions.length,F=false,G=false,E=false;for(var C=0;C<H;C++){var I=B.performingActions[C].groupName,A=$("#actionBarSlot"+B.performingActions[C].actionBarSlotIndex);if(I!=""){if(I=="removeWrongAnswer"){F=true;}else{if(I=="forceCategory"){G=true;}else{if(I=="plentyOfTime"){E=true;}}}}A.removeClass("pendingFrame").addClass("activeFrame");var D=A.children(".activeNumber");if(D.length>0){D.html(B.performingActions[C].timeToLiveAsInt);}else{A.append("<div class='activeNumber'>"+B.performingActions[C].timeToLiveAsInt+"</div>");}}for(var C=0;C<J;C++){var I=B.queuedActions[C].groupName;if(I!=""){if(I=="removeWrongAnswer"){F=true;}else{if(I=="forceCategory"){G=true;}else{if(I=="plentyOfTime"){E=true;}}}}$("#actionBarSlot"+B.queuedActions[C].actionBarSlotIndex).removeClass("activeFrame").addClass("pendingFrame");}if(F==false){$("#actionBarSlot div.group-removeWrongAnswer").removeClass("disabledItem");}else{$("#actionBarSlot > div:not(.pendingFrame, .activeFrame) div.group-removeWrongAnswer").addClass("disabledItem");}if(G==false){$("#actionBarSlot div.group-forceCategory").removeClass("disabledItem");}else{$("#actionBarSlot > div:not(.pendingFrame, .activeFrame) div.group-forceCategory").addClass("disabledItem");}if(E==false){$("#actionBarSlot div.group-plentyOfTime").removeClass("disabledItem");}else{$("#actionBarSlot > div:not(.pendingFrame, .activeFrame) div.group-plentyOfTime").addClass("disabledItem");}}},updateInventoryTooltips:function(){var E=this.facade.getInstanceByName("Planeto.Player.Model").playerVO.inventory.items,A=E.length;for(var B=0;B<A;B++){var D=$("#planetoItem-"+E[B].id),C=E[B];this.setPlanetoItemTooltip(D,C);}},updateStandardActions:function(A){var D=A.standardActions.actions,B=D.length;for(var C=0;C<B;C++){var F=D[C],E=this.planetoItem.clone();E.attr("id","standardAction-"+F.id).data({goldCost:F.goldCost,name:F.name,identity:F.identity}).find("img.planetoItemImage").addClass("spr_stdactions spr_stdaction_"+F.iconId);if(F.groupName!=""){E.addClass("group-"+F.groupName).data("groupName",F.groupName);}this.setPlanetoItemTooltip(E,F);E.find(".tooltip").addClass("standardActionTooltip");E.find("div.planetoItemIcon").toolTiper();$("#actionBarSlotSpecial"+C).html(E);$("#actionBarSlotSpecial"+C).append("<div class='standardReminder'><p>Don't forget the "+F.name+" option!</p></div>");}},onInventoryUpdate:function(B){if(B.player){this.player=B.player;}this.updateStandardActions(B.player);this.actionbarChanged(B.player);this.inventoryChanged(B.player);var A=B.player.activeAttire.items,C=A.length;$("#attireSlotsHolder > div").empty();for(var D=0;D<C;D++){var F=A[D],E=this.planetoItem.clone();E.attr({id:"planetoItem-"+F.id,rel:F.wearableSlot}).addClass(F.type).find("img.planetoItemImage").addClass("spr_wearables spr_wearable_"+F.iconId);this.setPlanetoItemTooltip(E,F);E.find("div.planetoItemIcon").toolTiper();$("#attireSlot_"+F.wearableSlot).html(E);}},actionbarChanged:function(B){this.inventoryResponse=B;var A=B.actionBar.items,C=A.length;$("#actionBarSlot > div").empty().removeClass("pendingFrame activeFrame");for(var D=0;D<C;D++){var F=A[D],E=this.planetoItem.clone();E.attr("id","planetoItem-"+F.id).addClass(F.type).data({goldCost:F.goldCost,name:F.name});if(F.type=="questionSet"){E.find("img.planetoItemImage").attr("src",getImageUrl("QS",F.iconId,42));}else{E.find("img.planetoItemImage").addClass("spr_"+F.type+"s spr_"+F.type+"_"+F.iconId);
}if(F.groupName!=""){E.addClass("group-"+F.groupName).data("groupName",F.groupName);}E.data("item",F);this.setPlanetoItemTooltip(E,F);E.find("div.planetoItemIcon").toolTiper();$("#actionBarSlot"+F.slotIndex).html(E);if(this.actionCardsDisabled){E.addClass("disabledButton");}else{E.removeClass("disabledButton");}}this.updatePerformingActions(this.performingActions);},inventoryChanged:function(C){this.inventoryResponse=C;var G=C.inventory.items,H=G.length,F=C.inventory.slotCount,A=$("#inventorySlots > div").length;$("#inventorySlots > div").empty();if(F>=120){$("#buyMoreInventoryButton").hide();}if(C.inventory.slotCount>$("#inventorySlots > div").length){var D=new Array();for(var E=A;E<F;E++){D.push("<div id='inventorySlot"+E+"'></div>");}$("#inventorySlots").append(D.join(""));}for(var E=0;E<H;E++){var I=G[E],B=this.planetoItem.clone();B.attr("id","planetoItem-"+I.id).addClass(I.type).data({goldCost:I.goldCost,name:I.name});if(I.type=="questionSet"){B.find("img.planetoItemImage").attr("src",getImageUrl("QS",I.iconId,42));}else{B.find("img.planetoItemImage").addClass("spr_"+I.type+"s spr_"+I.type+"_"+I.iconId);}if(I.groupName!=""){B.addClass("group-"+I.groupName).data("groupName",I.groupName);}B.data("item",I);this.setPlanetoItemTooltip(B,I);if(I.type=="wearable"){B.attr({rel:I.wearableSlot}).find("div.planetoItemIcon").toolTiper({beforeDisplay:this.localScopeFull(initWearableTooltipComparison,B)});}else{B.find("div.planetoItemIcon").toolTiper();}$("#inventorySlot"+I.slotIndex).html(B);}},triggerDroppedItems:function(B){if(tutorial_done>=2||location.href.indexOf("notutorial")!=-1){$("#questionContainer, #answerContainer, #quizBanner, #summaryScreen, #questionSetSummaryScreen, #domainQuestionsSummary, #questionSetProgress, #domainQuestionsSummary").hide();$("#droppedItemsHolder > div").empty();var A=B.drop.items,C=A.length,E=$("<div>");for(var D=0;D<C;D++){var G=A[D],F=this.planetoItem.clone();F.attr({id:"planetoItem-"+G.id,rel:G.wearableSlot}).addClass(G.type).data({goldCost:G.goldCost,name:G.name});if(G.type=="questionSet"){F.find("img.planetoItemImage").attr("src",getImageUrl("QS",G.iconId,42));}else{F.find("img.planetoItemImage").addClass("spr_"+G.type+"s spr_"+G.type+"_"+G.iconId);}if(G.groupName!=""){F.addClass("group-"+G.groupName).data("groupName",G.groupName);}this.setPlanetoItemTooltip(F,G);if(G.type=="wearable"){F.find("div.planetoItemIcon").toolTiper({beforeDisplay:this.localScopeFull(initWearableTooltipComparison,F)});}else{F.find("div.planetoItemIcon").toolTiper();}$("#droppedItem"+D).html(F);}$("#gamePausOverlay").hide();$("#avatarTab2").addClass("active").siblings("img").removeClass("active");$("#droppedItems, #attireSlots").show();$("#discardButton, #takeAllButton").removeClass("disabledButton");$("#tab_2, #tab_2_2").addClass("active").siblings("li").removeClass("active");$("#tabContent_2, #tabContent_2_2").show().siblings(".tabContent").hide();}else{this.sendEvent(RespiteControl.CONTINUE);}},checkDisabledStatuses:function(){this.disableActionBarCards(this.actionCardsDisabled);this.disableSkipQuestion(this.skipQuestionDisabled);this.disableRemoveIncorrectQuestion(this.removeWrongAnswerDisabled);},disableActionBarCards:function(B){var A=$("#actionBarSlot .planetoItem");this.actionCardsDisabled=B;if(B){A.addClass("disabledItem");}else{A.removeClass("disabledItem");}},disableSkipQuestion:function(B){var A=$("#actionBarSlotSpecial .group-skip");this.skipQuestionDisabled=B;if(B){A.addClass("disabledItem");}else{A.removeClass("disabledItem");}},disableRemoveIncorrectQuestion:function(B){var A=$("#actionBarSlotSpecial .group-removeWrongAnswer");this.removeWrongAnswerDisabled=B;if(B){A.addClass("disabledItem");}else{A.removeClass("disabledItem");}}});PlanetoEvents.TRIGGER_DROPPED_ITEMS="PlanetoEvents.TRIGGER_DROPPED_ITEMS";RespiteControl.TRIGGER_LEVEL_UP="RespiteControl.TRIGGER_LEVEL_UP";Planeto.Inventory.DISABLE_REMOVE_INCORRECT_QUESTION="Planeto.Inventory.DISABLE_REMOVE_INCORRECT_QUESTION";Planeto.Inventory.DISABLE_SKIP_QUESTION="Planeto.Inventory.DISABLE_SKIP_QUESTION";
Planeto.Inventory.DISABLE_ACTIONBAR_CARDS="Planeto.Inventory.DISABLE_ACTIONBAR_CARDS";BasicMVC.Facade.getInstance().register(new Planeto.Inventory.View());Planeto.MessageView=Planeto.MessageView||{};MessageView=MessageStackBaseView.extend({constructor:function(){this.name="MessageView";this.config({messageStackId:"#messageContainerContent",messageTemplate:"#templates div.messageItem",messageItemId:"#planetoMessage-",dataId:"id"});this.list=[];},eventListeners:function(){return[PlanetoEvents.END_QUIZ_EVENT,PlanetoEvents.GET_DROP_RESPONSE,Planeto.MessageView.REMOVEMESSAGE,Planeto.MessageView.BIND_DROP];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.GET_DROP_RESPONSE:case PlanetoEvents.END_QUIZ_EVENT:this.onEndQuiz(A.data);break;case Planeto.MessageView.REMOVEMESSAGE:this.removeMessage(A.data.messageId);break;case Planeto.MessageView.BIND_DROP:this.bindDrop(A.data);break;}},onEndQuiz:function(A){if(A.drop&&A.drop.items.length>0){this.dropReceived(A.drop);}},dropReceived:function(A){var B={id:A.identity,title:"Treasure Bag",type:"drop",content:A};if(A.items.length==1){B.type="item";B.title="item: "+A.items[0].name;}if(this.list.length>=5){var C=this.list[0].id;this.removeMessage(C);}this.addToView(B);},removeMessage:function(A){var C=$(this.messageItemId+A);for(var B=0;B<this.list.length;B++){if(this.list[B][this.dataId]==A){this.list.splice(B,1);break;}}C.remove();this.renderCurrentList();this.sendEvent(GoogleAnalyticsControl.TRACK_EVENT,{category:"Messages",action:"Closed Message"});},removeMessageClick:function(A){this.removeMessage($(A.currentTarget).parent().data("id"));},createMessageDom:function(C,A){var D,B=null;switch(C.type){case"medal":D=this.createMedalMessageDom(C.content);break;case"drop":D=this.createTreasureBagDom(C.content);break;case"item":D=this.createSingeItemDom(C.content);B=C.content.items[0];break;}if(B){D.attr({id:"planetoMessage-"+C.id,rel:B.wearableSlot}).addClass("messageItem").addClass(B.type).data({id:C.id,itemId:B.id,dropId:C.id,goldCost:B.goldCost,name:B.name});}else{D.attr("id","planetoMessage-"+C.id).data("id",C.id);}D.find(".messageIcon,.planetoItemIcon").toolTiper();if(B&&B.type=="wearable"){D.attr({rel:B.wearableSlot}).find("div.planetoItemIcon").toolTiper({beforeDisplay:this.localScopeFull(initWearableTooltipComparison,D)});}D.find("div.messageRemoveButton").bind("click",CallbackProxy(this,this.removeMessageClick));return D;},createMedalMessageDom:function(B){var A=$("#templates div.messageItemMedal").clone();A.find("img.messageIcon").addClass(this.getMedalClass(B,"42"));A.find("img.planetoMedalEmblem").addClass(this.getMedalClass(B,"64"));A.find("div.planetoMedalName").html(B.name);A.find("div.planetoMedalDescription").html(B.description);if(B.medalCount>0&&B.medalCount<=40){A.find(".medalMultiplier").addClass("medalMultiplier"+B.medalCount);}else{if(B.medalCount>40){A.find(".medalMultiplier").addClass("medalMultiplier40Plus");}}A.data("messageType","medal");return A;},bindDrop:function(A){$("#messageContainer img.messageIcon").removeClass("alreadyInUse");},createTreasureBagDom:function(A){var B=$("#templates div.messageItemLoot").clone();B.attr("id",A.identity).data({messageType:"drop",drop:A,identity:A.identity});B.find("div.messageTooltip").html("<div class='tooltipHeader'><h3>Click to open</h3></div><div class='tooltipText'>"+this.createTreasureBagToolTip(A.items)+"</div>");B.find("img.messageIcon").addClass(this.getTreasureBagClass(A.highestRarity)).bind("click",CallbackProxy(this,this.openDrop));return B;},createSingeItemDom:function(B){var C=$("#templates div.planetoItem").clone(),D=B.items[0];C.attr("id",B.identity).data({messageType:"drop",drop:B,identity:B.identity});this.facade.getInstanceByName("Planeto.Player.Model").drops[B.identity]=B;var A=this.facade.getInstanceByName("Planeto.Player.Model").playerVO.level.value;planetoItemTooltip(C,D,A);C.find("img.planetoItemImage").addClass("spr_"+D.type+"s spr_"+D.type+"_"+D.iconId);return C;},openDrop:function(B){var A=$(B.currentTarget);
if(!A.hasClass("alreadyInUse")){A.addClass("alreadyInUse");this.sendEvent(RespiteControl.DROPPED_ITEMS,{drop:A.parent().data("drop")});}},createTreasureBagToolTip:function(F){var I=$("#templates div.planetoItem").clone(),H=F.length,A=$("<div>");for(var E=0;E<H;E++){var K=F[E],B=K.rarity.toLowerCase(),D=I.clone(),C=K.type=="questionSet"?true:false,G=C?"question_set":K.type;D.attr("id","planetoItemTooltip-"+K.id).addClass(K.type+" floatleft");if(C){D.find("img.planetoItemImage").attr("src",getImageUrl("QS",K.iconId,42));}else{D.find("img.planetoItemImage").addClass("spr_"+K.type+"s spr_"+K.type+"_"+K.iconId);D.find(".planetoItemRarity").addClass(K.type+" "+K.type+"_rarity_"+B);}if(K.category!=null){var J=K.category.id;D.find(".planetoItemCategory").addClass(G+" "+G+"_category_"+J);}A.append(D);}return A.html();},getMedalClass:function(A,B){return"spr_medals_"+B+" spr_medal_"+B+"_"+A.medalId;},getTreasureBagClass:function(A){return"spr_treasure_bag spr_treasure_bag_"+A.toLowerCase();},removeMedalMultiplier:function(A){for(var B=1;B<45;B++){A.removeClass("medalMultiplier"+B);}A.removeClass("medalMultiplier40Plus");},updateMessageDom:function(A){},opacity:function(){return 1;}});Planeto.MessageView.REMOVEMESSAGE="Planeto.MessageView.REMOVEMESSAGE";Planeto.MessageView.BIND_DROP="Planeto.MessageView.BIND_DROP";BasicMVC.Facade.getInstance().register(new MessageView());Planeto.Interface=Planeto.Interface||{};Planeto.Interface.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Interface.View";var B=this,A=$("#tabMenu li, #column3 .tabSubMenu li");A.live("click",function(D){var C=this.id.replace("tab_","");$(D.currentTarget).addClass("active").children("span.notification:not(.stuck)").fadeOut();$(D.currentTarget).siblings("li").removeClass("active");$("#tabContent_"+C).show().siblings(".tabContent").hide();B.sendEvent(GoogleAnalyticsControl.TRACK_EVENT,{category:"Tabs",action:"Clicked "+$(this).attr("id")});});A.toolTiper();$(document).bind("keyup",function(D){var C=D.target.tagName.toLowerCase();if(D.keyCode==81&&(C=="html"||C=="body")){$("#bosscreen").toggle();}});}});BasicMVC.Facade.getInstance().register(new Planeto.Interface.View());Planeto.Friends=Planeto.Friends||{};Planeto.Friends.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Friends.View";this.templateFriend=selector_templates_friend.outerHtml();this.hideOfflineFriends=false;this.gamePlayFriendList=$("#gamePlayFriendsList .tabContainer");this.sortFriendsList_timer=null;$("#gamePlayFriendsListShowOnline, #landingScreen > a").live("click",this.localScopeFull(this.showOnlineFriends));$("#gamePlayFriendsListShowAll").live("click",this.localScopeFull(this.showAllFriends));},eventListeners:function(){return[Planeto.Friends.View.UPDATE_FRIENDS_LIST,PlanetoEvents.FRIEND_SCORE_CHANGED_EVENT,PlanetoEvents.FRIEND_ONLINE_STATUS_CHANGED_EVENT,PlanetoEvents.SCORE_CHANGED_EVENT];},eventHandlers:function(A){switch(A.name){case Planeto.Friends.View.UPDATE_FRIENDS_LIST:this.onUpdateFriendsEvent(A.data);break;case PlanetoEvents.FRIEND_SCORE_CHANGED_EVENT:this.onUpdateFriendScoreEvent(A.data);break;case PlanetoEvents.FRIEND_ONLINE_STATUS_CHANGED_EVENT:this.friendOnlineStatusChangedEvent(A.data);break;case PlanetoEvents.SCORE_CHANGED_EVENT:this.updateYou(A.data);break;}},onUpdateFriendsEvent:function(A){if(connectedAsGuest){$("#tabContent_1_2 .tabGrey h3").hide();$("#tabContent_1_2 .facebookConnect").show();this.gamePlayFriendList.hide();}else{$("#tabContent_1_2 .tabGrey h3").show();$("#tabContent_1_2 .facebookConnect").hide();this.gamePlayFriendList.show();this.renderFriendsList("#gamePlayFriendsList .tabContainer",A.persons);}},onUpdateFriendScoreEvent:function(A){var B=$("#friendId-"+A.friendIdentity).attr({rel:A.score});B.find("span.friendScore").html(A.score+"p");B.find("div.friendLevel").css("background-position","0 -"+(A.level*27)+"px");this.sortFriendsList();},friendOnlineStatusChangedEvent:function(D){var B=$("#friendId-"+D.friendIdentity);B.removeClass("isOnline isOffline");
if(D.onlineStatus>0){B.removeClass("hide").addClass("isOnline");}else{B.addClass("isOffline");if(this.hideOfflineFriends){B.addClass("hide");}}if(D.friendIdentity==user_id){B.addClass("isPlayer");}var C,A,E;switch(D.onlineStatus){case 0:C="spr_icon_offline";A="Offline";E="isOffline";break;case 1:C="spr_icon_online";A="Online";E="isOnline";break;case 2:C="spr_icon_idle";A="Online but inactive";E="isOnline";break;}B.find("div.friendOnlineStatusTooltip .tooltipText").html(A);B.find("img.friendOnlineStatus").removeClass("spr_icon_online spr_icon_idle spr_icon_offline").addClass(C);$("#updateFeedContent .updateFeedRow.friendId-"+D.friendIdentity).removeClass("isOffline isOnline").addClass(E);},updateYou:function(A){var B=$("#friendId-"+user_id).attr("rel",A.score);B.find("span.friendScore").html(A.score+"p");this.sortFriendsList();},sortFriendsList:function(){clearTimeout(this.sortFriendsList_timer);this.sortFriendsList_timer=setTimeout(this.localScopeFull(this.sortFriendsListAfterDelay),2000);},renderFriendsList:function(F,H){var C=$(F),G={},A=$(F+" > div.friend"),I=0;for(var E=0;E<H.length;E++){G[H[E].id]="exists";}for(var E=0;E<A.length;E++){var B=$(A[E]);if(G[B.data("id")]!=="exists"){B.remove();}}delete G;for(var E=0;E<H.length;E++){var D=H[E],J=$(F+" > #friendId-"+D.id);if(J.length==0){J=this.createFriendsDOM(D);C.append(J);}this.updateFriendsDOM(J,D);delete J;if(D.onlineStatus==1){I++;}}this.sortFriendsList();if(I>0){$("#landingScreen > a").css({visibility:"visible","text-decoration":"underline"}).html(I+" friend"+(I==1?"":"s")+" online");}else{$("#landingScreen > a").css({visibility:"hidden","text-decoration":"none"});}},sortFriendsListAfterDelay:function(){this.gamePlayFriendList.find("div.friend").tsort("",{attr:"rel",order:"desc"});},createFriendsDOM:function(A){return $(this.templateFriend);},updateFriendsDOM:function(B,D){B.attr({id:"friendId-"+D.id,rel:D.score}).data("id",D.id);if(D.isPlayer===true||D.id==user_id){B.addClass("isPlayer");B.find("div.friendNickName").html("You");}else{B.removeClass("isOnline isOffline").find("div.friendNickName").html(D.nickName);if(D.onlineStatus>0){B.removeClass("hide").addClass("isOnline");}else{B.addClass("isOffline");if(this.hideOfflineFriends){B.addClass("hide");}}}if(D.profilePicture.squarePixelUrl!=null){B.find("img.friendAvatar").attr("src",D.profilePicture.squarePixelUrl);}var C,A,E;switch(D.onlineStatus){case 0:C="spr_icon_offline";A="Offline";E="isOffline";break;case 1:C="spr_icon_online";A="Online";E="isOnline";break;case 2:C="spr_icon_idle";A="Online but inactive";E="isOnline";break;}B.find("div.friendOnlineStatusTooltip .tooltipText").html(A);B.find("img.friendOnlineStatus").removeClass("spr_icon_online spr_icon_idle spr_icon_offline").addClass(C).toolTiper();$("#updateFeedContent .friendId-"+D.id).removeClass("isOffline isOnline").addClass(E);if(D.location){if(D.location.country.name=="Unspecified"){D.location.country.name="Unknown country";}if(D.location.city.name=="Unspecified"){D.location.city.name="Unknown city";}B.find(".friendCountry span").html(D.location.city.name);B.find(".friendCountry .tooltip .tooltipText").html(D.location.country.name);B.find(".friendCountry img").addClass("spr_flag_"+D.location.country.isoCode.toLowerCase()).toolTiper();}B.find("span.friendScore").html(D.score+"p");B.find("div.friendLevel").css("background-position","0 "+(D.level.value*-27)+"px");return B;},showOnlineFriends:function(){if($("#tab_1").is(":visible")&&$("#tab_1_2").is(":visible")){$("#tab_1, #tab_1_2").addClass("active").siblings("li").removeClass("active");$("#tabContent_1, #tabContent_1_2").show().siblings(".tabContent").hide();}$("#gamePlayFriendsList div.isOffline").addClass("hide");$("#gamePlayFriendsListShowOnline").addClass("selected");$("#gamePlayFriendsListShowAll").removeClass("selected");this.hideOfflineFriends=true;return false;},showAllFriends:function(){$("#gamePlayFriendsList div.friend").removeClass("hide");$("#gamePlayFriendsListShowOnline").removeClass("selected");
$("#gamePlayFriendsListShowAll").addClass("selected");this.hideOfflineFriends=false;}});Planeto.Friends.View.UPDATE_FRIENDS_LIST="Planeto.Friends.View.UPDATE_FRIENDS_LIST";BasicMVC.Facade.getInstance().register(new Planeto.Friends.View());Planeto.Friends=Planeto.Friends||{};Planeto.Friends.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Friends.Control";this.teams="";$("#friendMenuItemPost").live("click",this.localScopeFull(this.friendPostToWall));},eventListeners:function(){return[Planeto.Friends.Control.HIDE_FRIENDS_MENU,PlanetoEvents.SHOW_FRIENDS_LIST_EVENT,PlanetoEvents.GET_TEAMS_LIST_RESPONSE,PlanetoEvents.GET_FACEBOOK_ID_FOR_FRIEND_RESPONSE];},eventHandlers:function(A){switch(A.name){case Planeto.Friends.Control.HIDE_FRIENDS_MENU:this.hideFriendMenu();break;case PlanetoEvents.SHOW_FRIENDS_LIST_EVENT:this.updateFriendsList(A.data);break;case PlanetoEvents.GET_TEAMS_LIST_RESPONSE:this.getTeamList(A.data);break;case PlanetoEvents.GET_FACEBOOK_ID_FOR_FRIEND_RESPONSE:this.friendPostToWallResponse(A.data);break;}},friendPostToWall:function(A){this.sendEvent(PlanetoService.GET_FB_ID_FOR_FRIEND_REQUEST,$("#friendMenuHolder").data("friendId"));},friendPostToWallResponse:function(A){if(A.facebookId!=-1){this.sendEvent(PlanetoEvents.POST_TO_FRIENDS_FACEBOOK_WALL,{friendId:A.facebookId});}},getTeamList:function(A){this.teams=A.teams;},updateFriendsList:function(A){this.sendEvent(Planeto.Friends.View.UPDATE_FRIENDS_LIST,A);$("#gamePlayFriendsList div.friend:not(.binded)").unbind("click").bind("click",this.localScopeFull(this.friendMenuOver)).addClass("binded");},friendMenuOver:function(E){if($(E.target).parents("#userProfile").length==0&&!$(E.target).is("#userProfile")){var A=$(E.target).hasClass("friend")?$(E.target):$(E.target).parents(".friend");var D=ignoredByUser(A.data("id"));this.hideFriendMenu();$("#friendMenuHolder").removeClass("isPlayer isOffline isOnline isIgnored").addClass("friendMenuCurrent"+(A.hasClass("isPlayer")?" isPlayer":"")).addClass((A.hasClass("isOnline")?"isOnline":"isOffline")).addClass((D?" isIgnored":"")).data("friendId",A.data("id")).css({top:E.pageY+"px",left:E.pageX+"px"}).show();if(HIDE_FRIEND_MENU_TIMEOUT!=-1){clearTimeout(HIDE_FRIEND_MENU_TIMEOUT);}$("div.friendMenuCurrent").unbind("mouseleave").bind("mouseleave",CallbackProxy(this,function(){HIDE_FRIEND_MENU_TIMEOUT=setTimeout(CallbackProxyTimeouts(this,this.hideFriendMenu),500);})).unbind("mouseenter").bind("mouseenter",function(){clearTimeout(HIDE_FRIEND_MENU_TIMEOUT);});$("div.friendMenuCurrent").unbind("click").bind("click",CallbackProxy(this,function(){this.hideFriendMenu();}));$("#friendMenuItemKick, #friendMenuItemIgnore, #friendMenuItemStopIgnoring").hide();var C=this.teams.length,F=false;if(C>0){for(var B=0;B<C;B++){if(this.teams[B].leader==true){F=true;break;}}}$("#friendMenuItemChat, #friendMenuItemChallenge").show();if(F==true){$("#friendMenuItemInvite").show();}else{$("#friendMenuItemInvite").hide();}}},hideFriendMenu:function(){if($("div.friendMenuCurrent")){$("div.friendMenuCurrent").unbind("mouseleave").removeClass("friendMenuCurrent").hide();}}});Planeto.Friends.Control.HIDE_FRIENDS_MENU="Planeto.Friends.Control.HIDE_FRIENDS_MENU";BasicMVC.Facade.getInstance().register(new Planeto.Friends.Control());StatusView=BasicMVC.Base.extend({constructor:function(){this.name="StatusView";this.currentMessageJQuerySelector="";this.statusOn=false;$(window).bind("resize",CallbackProxy(this,this.positionMessage));},eventListeners:function(){return[StatusView.SHOW_MESSAGE,StatusView.SHOW_PAUSE,StatusView.HIDE_MESSAGE,StatusView.POSITION_MESSAGE,PlanetoEvents.FORCED_LOGOUT_EVENT];},eventHandlers:function(A){switch(A.name){case StatusView.SHOW_MESSAGE:this.showMessage(A.data);break;case StatusView.SHOW_PAUSE:this.showPause();break;case StatusView.HIDE_MESSAGE:case PlanetoEvents.FORCED_LOGOUT_EVENT:this.hideStatus();break;case StatusView.POSITION_MESSAGE:this.positionMessage();break;}},hideStatus:function(){selector_statusContainer.animate({top:"-60px"});
this.currentMessageJQuerySelector="";this.statusOn=false;},showMessage:function(A){if(this.currentMessageJQuerySelector!=A){if(!this.statusOn){$("#statusContent").children().hide();selector_statusContainer.find(A).show();this.positionMessage();selector_statusContainer.animate({top:"0"});this.currentMessageJQuerySelector=A;}else{selector_statusContainer.animate({top:"-40px"},500,"",CallbackProxy(this,function(){$("#statusContent").children().hide();selector_statusContainer.find(A).show();this.positionMessage();this.currentMessageJQuerySelector=A;})).animate({top:"0"});}this.statusOn=true;}},positionMessage:function(){$("#statusWrapper").css("left",Math.round(($("#column2").width()-selector_statusContainer.width()-38)/2)+19+"px");},showPause:function(){if($("#playerAutoPauseContent").is(":hidden")&&$("#tutorialWrapper").is(":hidden")&&$(".summaryScreen").is(":hidden")){this.showMessage("#playerReturningPauseContent");}}});StatusView.SHOW_MESSAGE="StatusView.showMessage";StatusView.SHOW_PAUSE="StatusView.showPause";StatusView.HIDE_MESSAGE="StatusView.hideStatus";StatusView.POSITION_MESSAGE="StatusView.POSITION_MESSAGE";BasicMVC.Facade.getInstance().register(new StatusView());Planeto=window.Planeto||{};Planeto.Medal=Planeto.Medal||{};Planeto.Medal.Model=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Medal.Model";this.medalList=null;this.medalListRef={};},eventListeners:function(){return[PlanetoEvents.SET_MEDALS_AND_PROGRESS_EVENT,PlanetoEvents.MEDAL_RECEIVED_EVENT];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.SET_MEDALS_AND_PROGRESS_EVENT:this.medalListRecieved(A.data);break;case PlanetoEvents.MEDAL_RECEIVED_EVENT:this.singleMedalRecieved(A.data);break;}},medalListRecieved:function(B){this.medalList=B.medalProgress;for(var D=0,A=this.medalList.length;D<A;D++){var C=this.medalList[D];this.medalListRef[C.medalId]=C;}this.sendEvent(Planeto.Medal.Model.COMPLETE_MEDAL_LIST_RECEIVED,this.medalList);},singleMedalRecieved:function(A){var B=this.medalListRef[A.medalId];B.postToFacebook=A.postToFacebook;B.medalCount++;this.sendEvent(RespiteControl.SINGLE_MEDAL_RECEIVED,B);}});Planeto.Medal.Model.COMPLETE_MEDAL_LIST_RECEIVED="Planeto.Medal.Model.COMPLETE_MEDAL_LIST_RECEIVED";BasicMVC.Facade.getInstance().register(new Planeto.Medal.Model());Planeto.Medal=Planeto.Medal||{};Planeto.Medal.Control=BasicMVC.Base.extend({constructor:function(){this.name="MedalControl";this.receivedMedals=0;$("#tab_4").live("click",this.localScopeFull(this.tabClicked));},eventListeners:function(){return[RespiteControl.SINGLE_MEDAL_RECEIVED];},eventHandlers:function(A){switch(A.name){case RespiteControl.SINGLE_MEDAL_RECEIVED:this.singleMedalReceived(A.data);break;}},tabClicked:function(){this.receivedMedals=0;},singleMedalReceived:function(A,B){if(!$("#tab_4").is(".active")){this.sendEvent(Planeto.Medal.Control.MEDALS_COUNT_UPDATED,++this.receivedMedals);}}});Planeto.Medal.Control.MEDALS_COUNT_UPDATED="Planeto.Medal.Control.medalsCountUpdated";BasicMVC.Facade.getInstance().register(new Planeto.Medal.Control());Planeto.Medal=Planeto.Medal||{};Planeto.Medal.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Medal.View";this.notificationTimeoutRef=0;this.tab_3_notification=$("#tab_2_3 span.notification");this.notificationClasses=this.tab_3_notification.attr("class");},eventListeners:function(){return[Planeto.Medal.Model.COMPLETE_MEDAL_LIST_RECEIVED,RespiteControl.SINGLE_MEDAL_RECEIVED,Planeto.Medal.Control.MEDALS_COUNT_UPDATED];},eventHandlers:function(A){switch(A.name){case Planeto.Medal.Model.COMPLETE_MEDAL_LIST_RECEIVED:this.renderMedals(A.data);break;case RespiteControl.SINGLE_MEDAL_RECEIVED:this.singleMedalReceived(A.data);break;case Planeto.Medal.Control.MEDALS_COUNT_UPDATED:this.showNotification(A.data);break;}},renderMedals:function(H){var B=$("#gamePlayMedalSlots"),F=$("#templates > div.medalSlot");for(var E=0;E<H.length;E++){var D=H[E],C=$("#medalId-"+D.medalId);if(C.length==0){var C=F.clone();C.attr("id","medalId-"+D.medalId);
B.append(C);C.find("img.planetoMedalIcon").toolTiper();}C.removeClass("medalLastInRow");if((E+1)%4==0){C.addClass("medalLastInRow");}C.find("img.planetoMedalIcon").addClass(this.getMedalClass(D,"42"));C.find("img.planetoMedalIconBig").addClass(this.getMedalClass(D,"64"));var G=C.children("div.planetoMedalSmall").children("img.planetoMedalIcon");G.removeClass("medalReceived").removeClass("medalNotReceived");if(D.medalCount>0){G.addClass("medalReceived");}else{G.addClass("medalNotReceived");}var A=C.find(".redCounter").removeClass("redCounter"+(D.medalCount-1));if((D.medalCount>1)&&(D.medalCount<=40)){A.addClass("redCounter"+D.medalCount);}else{if(D.medalCount>40){A.addClass("redCounter40Plus");}}A.data("medalCount",D.medalCount);C.find(".tooltip div.planetoMedalName").html(D.name);C.find(".tooltip div.planetoMedalDescription").html(D.description);delete C;}},singleMedalReceived:function(D){var C=$("#medalId-"+D.medalId),B=C.find("img.planetoMedalIcon"),A=C.find(".redCounter"),E=A.data("medalCount");if(B.hasClass("medalNotReceived")){B.removeClass("medalNotReceived").addClass("medalReceived");E=D.medalCount;}else{A.removeClass("redCounter"+E);E=D.medalCount;if(E>1&&E<=40){A.addClass("redCounter"+E);}else{if(E>40){A.addClass("redCounter40Plus");}}}C.find(".redCounter").data("medalCount",E);},clearCounter:function(A){A.removeClass().addClass(this.notificationClasses);},showNotification:function(B){clearTimeout(this.notificationTimeoutRef);var A=this.tab_3_notification;this.clearCounter(A);if(B>40){B="40Plus";}A.addClass("redCounter"+B).fadeIn();this.notificationTimeoutRef=setTimeout(function(){$("#tab_2_3 span.notification").fadeOut();},30000);delete A;},getMedalClass:function(A,B){return"spr_medals_"+B+" spr_medal_"+B+"_"+A.medalId;}});BasicMVC.Facade.getInstance().register(new Planeto.Medal.View());Planeto.Chat=Planeto.Chat||{};Planeto.Chat.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Chat.Control";this.quizTopic;this.quizTopic_temp;this.quizQuestion;this.quizAnswers;this.quizAnswers_temp;$("#tab_1_3:not(.active)").live("click",this.localScopeFull(this.getAvailableChatRooms));$("#chatSend input").bind("focus",CallbackProxy(this,this.chatSendFocus)).bind("blur",CallbackProxy(this,this.chatSendBlur));$(document).bind("keydown",this.localScopeFull(this.checkChatSendFocus));},eventListeners:function(){return[PlanetoEvents.NEW_QUIZ_EVENT,PlanetoEvents.SHOW_QUESTION_EVENT,PlanetoEvents.DUEL_SHOW_ANSWER_ALTERNATIVES_EVENT,PlanetoEvents.DUEL_SHOW_QUESTIONS_EVENT,Planeto.Application.Control.LOAD_FINISHED,ConnectionControl.NOT_LOGGED_IN_TO_FACEBOOK,PlanetoEvents.MESSAGE_RECEIVED_EVENT];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.NEW_QUIZ_EVENT:this.onNewQuiz(A.data);break;case PlanetoEvents.SHOW_QUESTION_EVENT:this.onShowQuestionEvent(A.data);break;case PlanetoEvents.DUEL_SHOW_ANSWER_ALTERNATIVES_EVENT:this.duelShowAnswerAlternatives(A.data);break;case PlanetoEvents.DUEL_SHOW_QUESTIONS_EVENT:this.duelShowQuestions(A.data);break;case Planeto.Application.Control.LOAD_FINISHED:this.init();break;case PlanetoEvents.MESSAGE_RECEIVED_EVENT:this.messageReceived(A.data);break;case ConnectionControl.NOT_LOGGED_IN_TO_FACEBOOK:this.logout();break;}},checkChatSendFocus:function(B){var A=B.keyCode;if(A>=48&&A<=90){if(!$(B.target).is("input")&&!$(B.target).is("textarea")){$("#chatSend input").focus();this.chatSendFocus({target:"#chatSend input"});}}},init:function(){$("#friendMenuHolder.isOnline:not(.isPlayer,.isIgnored) #friendMenuItemChat").live("click",this.localScopeFull(this.inviteToChat));$("#chatTabs div.chatTabs span").live("click",this.localScopeFull(this.tabClick));$("#chatSend input").bind("keyup",this.localScopeFull(this.sendMessage));$("#chatTabs div.chatTabClose").live("click",this.localScopeFull(this.closeChatRoom));$("#chatScrollUp, #chatScrollDown").live("click",this.localScopeFull(this.adjustChatHeight));},adjustChatHeight:function(B){var A=$(B.target).attr("id");if(A=="chatScrollUp"){if($("#chatContainer").is(":hidden")){$("#chatContainer").show();
}else{if(chatBodyRest==610){chatBodyRest=300;this.sendEvent(Planeto.SET_CHAT_SIZE);}}}if(A=="chatScrollDown"){if(chatBodyRest==300){chatBodyRest=610;this.sendEvent(Planeto.SET_CHAT_SIZE);}else{if($("#chatContainer").is(":visible")){$("#chatContainer").hide();}}}},chatSendFocus:function(A){if($(A.target).val()=="Enter your message here..."||$(A.target).hasClass("grey")){$(A.target).val("").removeClass("grey");}},chatSendBlur:function(A){if($(A.target).val()==""){$(A.target).val("Enter your message here...").addClass("grey");}},getAvailableChatRooms:function(){this.sendEvent(PlanetoService.GET_AVAILABLE_CHAT_ROOMS);},onNewQuiz:function(A){this.quizTopic_temp=A.topic;this.quizAnswers_temp=A.answers;},onShowQuestionEvent:function(A){this.quizTopic=this.quizTopic_temp;this.quizAnswers=this.quizAnswers_temp;this.quizQuestion=A.question;},duelShowAnswerAlternatives:function(A){this.quizTopic_temp=A.playerQuestion.topic;this.quizAnswers_temp=A.playerQuestion.answers;},duelShowQuestions:function(A){this.quizTopic=this.quizTopic_temp;this.quizAnswers=this.quizAnswers_temp;this.quizQuestion=A.playerQuestion.question;},inviteToChat:function(A){this.sendEvent(PlanetoService.INVITE_PLAYER_TO_CHAT,$("#friendMenuHolder").data("friendId"));this.sendEvent(Planeto.Chat.Control.REQUESTED_CHAT);},messageReceived:function(A){this.sendEvent(Planeto.Chat.Control.MESSAGE_RECEIVED,A);},sendMessage:function(A){if(A.keyCode==13){this.sendEvent(PlanetoService.SEND_MESSAGE_WITH_CHAT,$("#chatTabs div.active").data("chatRoomId"),A.target.value);$(A.target).val("");}},tabClick:function(B){var A=$(B.target).parent("div.chatTabs").attr("rel");this.sendEvent(Planeto.Chat.Control.TAB_CLICKED,A);},logout:function(){this.sendEvent(Planeto.Chat.Control.CLEAR_ALL_CHATS);},closeChatRoom:function(C){var B=$(C.target).parent("div.chatTabs").attr("rel");$("#chatTab_"+B+", #chatRoom_"+B).remove();this.sendEvent(PlanetoService.LEAVE_CHAT_REQUEST,B);if($("#chatTabs div.chatTabs").length==0){this.close();}else{var A=$("#chatTabs div.chatTabs:last").attr("rel");$("#chatTab_"+A).addClass("active");$("#chatRoom_"+A).show();}},close:function(){$("#chatSend input").val("");this.sendEvent(Planeto.Chat.Control.CLOSE);}});Planeto.Chat.Control.JOINED_CHAT="Planeto.Chat.Control.JOINED_CHAT";Planeto.Chat.Control.REQUESTED_CHAT="Planeto.Chat.Control.REQUESTED_CHAT";Planeto.Chat.Control.MESSAGE_RECEIVED="Planeto.Chat.Control.MESSAGE_RECEIVED";Planeto.Chat.Control.TAB_CLICKED="Planeto.Chat.Control.TAB_CLICKED";Planeto.Chat.Control.CLEAR_ALL_CHATS="Planeto.Chat.Control.CLEAR_ALL_CHATS";Planeto.Chat.Control.CLOSE="Planeto.Chat.Control.CLOSE";BasicMVC.Facade.getInstance().register(new Planeto.Chat.Control());Planeto.Chat=Planeto.Chat||{};Planeto.Chat.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Chat.View";this.activeChatRoom="";this.scroll_top="";$(window).bind("resize.chat",this.localScope(this.setChatSize));$("#chatListContainer .chatList > li").live("click",this.localScopeFull(this.chatListClicked));$("#chatListContainer .chatList .chatListPerson").live("click",this.localScopeFull(this.playerMenuOver));},eventListeners:function(){return[PlanetoEvents.CHAT_ROOM_STATE_EVENT,Planeto.Chat.Control.REQUESTED_CHAT,Planeto.Chat.Control.MESSAGE_RECEIVED,Planeto.Chat.Control.TAB_CLICKED,Planeto.Chat.Control.CLEAR_ALL_CHATS,Planeto.Chat.Control.CLOSE,PlanetoEvents.CHAT_ROOMS_AVAILABLE_EVENT,Planeto.SET_CHAT_SIZE,PlanetoEvents.IGNORE_USER_LIST_CHANGED];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.CHAT_ROOM_STATE_EVENT:this.joinedChat(A.data);break;case Planeto.Chat.Control.MESSAGE_RECEIVED:this.messageReceived(A.data);break;case Planeto.Chat.Control.TAB_CLICKED:this.tabClicked(A.data);break;case Planeto.Chat.Control.CLEAR_ALL_CHATS:this.clearAllChats();break;case Planeto.Chat.Control.CLOSE:this.close();break;case PlanetoEvents.CHAT_ROOMS_AVAILABLE_EVENT:this.chatRoomsAvailable(A.data);break;case Planeto.SET_CHAT_SIZE:this.setChatSize();break;case PlanetoEvents.IGNORE_USER_LIST_CHANGED:this.updateIgnoredPersons();
break;}},tabClicked:function(A){this.activeChatRoom=A;var B=$("#chatRoom_"+A);$("#chatTabs div.active").removeClass("active");$("#chatRooms div.chatRooms").hide();$("#chatTab_"+A).addClass("active").removeClass("received");B.show();if($("#chatContainer").is(":hidden")){$("#chatContainer").show();}this.scrollDown(B);},chatListClicked:function(A){if($(A.target).is(".personAmount")){$(A.currentTarget).children(".personAmount").toggleClass("active");$(A.currentTarget).children("ul").toggle();}else{this.sendEvent(PlanetoService.OPEN_CHAT_REQUEST,$(A.currentTarget).attr("rel"));}},joinedChat:function(B){var R=B.chatRoom.id,F=B.chatRoom.topic,G=B.chatRoom.participants,Q=false,L=R.startsWith("GR_"),K=R.startsWith("gl_"),J=false,P=new Date(B.timestamp),E=P.getHours()+":"+(P.getMinutes()<10?"0":"")+P.getMinutes();if(B.joined.length>0||B.left.length>0){var N=$("#chatListContainer .nthRow:[rel="+B.chatRoom.id+"]"),D=N.children("ul"),S=B.chatRoom.participants.length;N.find("h2").html(B.chatRoom.topic+(S>0?" ("+S+")":""));D.empty();if(S==0){N.find(".personAmount").removeClass("active").hide();D.hide();}else{var T=$("#templates ul.chatList ul > li").clone();for(var M=0;M<S;M++){var I=T.clone();if(ignoredByUser(B.chatRoom.participants[M].id)){I.addClass("ignoredPlayer");}I.attr("identity",B.chatRoom.participants[M].id);I.children("h3").html(B.chatRoom.participants[M].nick);D.append(I);}N.find(".personAmount").show();}}if(B.joined.length>0){for(var O=0;O<B.joined.length;O++){if(B.joined[O].id!=user_id&&!ignoredByUser(B.joined[O].id)&&!K){$("#chatRoom_"+R+" div.innerChatRoomContainer").append("<div>"+B.joined[O].nick+" joined the chat room "+E+"</div>");}else{J=true;}}}if(B.left.length>0){for(var O=0;O<B.left.length;O++){if(B.left[O].id==user_id){$("#chatTab_"+R+", #chatRoom_"+R).remove();var C=$("#chatListContainer .nthRow[rel="+R+"]");C.find("h2").html(F);C.find(".personAmount").hide();break;}else{if(!ignoredByUser(B.left[O].id)&&!K){$("#chatRoom_"+R+" div.innerChatRoomContainer").append("<div>"+B.left[O].nick+" left the chat room "+E+"</div>");}}}}if(J==true){if($("#chatTabs div.chatTabs[rel='"+R+"']").length==0){this.activeChatRoom=R;var H=$("#templates > div.chatTabs").clone(),A=$("#templates > div.chatRooms").clone();$("#chatTabsScrollArea div.active").removeClass("active");H.data("chatRoomId",R).attr({id:"chatTab_"+R,rel:R}).addClass("active").children("span").html(F);$("#chatTabsScrollArea").append(H);$("#chatRooms div.chatRooms").hide();A.attr("id","chatRoom_"+R).show();$("#chatRooms").append(A);Q=true;}this.sendEvent(Planeto.Chat.Control.JOINED_CHAT);$("#chatWrapper").show();this.setScrollButtonState();if(Q){this.setChatSize();this.scrollToTab($("#chatTabsScrollArea > .chatTabs").length-1);}}if(L){$("#chatTab_"+R+" div.chatTabClose").hide();}},playerMenuOver:function(D){if($(D.target).parents("#userProfile").length==0&&!$(D.target).is("#userProfile")){var C=$(D.target).hasClass("chatListPerson")?$(D.target):$(D.target).parents(".chatListPerson");var A=C.attr("identity");var B=ignoredByUser(A);this.hidePlayerMenu();$("#friendMenuHolder").removeClass("isPlayer isOffline isOnline isIgnored").addClass("friendMenuCurrent isOnline").addClass((B?" isIgnored":"")).data("friendId",A).css({top:D.pageY+"px",left:D.pageX+"px"}).show();if(A==user_id){$("#friendMenuHolder").addClass("isPlayer");}if(HIDE_FRIEND_MENU_TIMEOUT!=-1){clearTimeout(HIDE_FRIEND_MENU_TIMEOUT);}$("div.friendMenuCurrent").unbind("mouseleave").bind("mouseleave",CallbackProxy(this,function(){HIDE_FRIEND_MENU_TIMEOUT=setTimeout(CallbackProxyTimeouts(this,this.hidePlayerMenu),500);})).unbind("mouseenter").bind("mouseenter",function(){clearTimeout(HIDE_FRIEND_MENU_TIMEOUT);});$("div.friendMenuCurrent").unbind("click").bind("click",CallbackProxy(this,function(){this.hidePlayerMenu();}));$("#friendMenuItemKick").hide();$("#friendMenuItemChallenge, #friendMenuItemPost, #friendMenuItemInvite").hide();$("#friendMenuItemChat").show();if(C.hasClass("ignoredPlayer")){$("#friendMenuItemIgnore").hide();
$("#friendMenuItemStopIgnoring").show();}else{$("#friendMenuItemIgnore").show();$("#friendMenuItemStopIgnoring").hide();}}},hidePlayerMenu:function(){if($("div.friendMenuCurrent")){$("div.friendMenuCurrent").unbind("mouseleave").removeClass("friendMenuCurrent").hide();}},messageReceived:function(A){var B=$("#chatRoom_"+A.chatRoomId),C=$("#chatTab_"+A.chatRoomId);if(B.length&&C.length){var E=$("#templates > div.chatMessage").clone();if(A.from.id==user_id){E.addClass("chatMessageMe");}if(A.chatRoomId.endsWith(A.from.id)){E.addClass("chatMessageGameMaster");}var F=new Date(A.timestamp),D=F.getHours()+":"+(F.getMinutes()<10?"0":"")+F.getMinutes();E.children("div.chatMessageName").html(A.from.nick);E.children("div.chatMessageText").html(A.text);E.children("div.chatMessageTime").html(D);if(!C.hasClass("active")&&!C.hasClass("received")){C.addClass("received");}B.find("div.innerChatRoomContainer").append(E);this.scrollDown(B);}},scrollDown:function(C){var B=C[0].scrollHeight,A=C[0].scrollTop;C.animate({scrollTop:B});this.scroll_top=C[0].scrollTop;},setChatSize:function(){if($("#chatWrapper").is(":visible")){var B=$(window).height(),A=B-chatBodyRest;if(A<60){A=60;}$("#chatRooms, #chatRooms .chatRooms").height(A);}},clearAllChats:function(){$("#chatRooms").empty();this.close();},close:function(){$("#chatWrapper").hide();},scrollTabsRight:function(){this.scrollToTab(this.getLastVisibleTabIndex()+1);},scrollTabsLeft:function(){this.scrollToTab(this.getLastVisibleTabIndex()-1);},scrollToTab:function(A){var B=-this.getTabLeftOffset(A);if(B>0){B=0;}$("#chatTabsScrollArea").animate({"margin-left":B+"px"},200,this.localScopeFull(this.setScrollButtonState));},setScrollButtonState:function(){var D=$("#chatScrollLeft"),F=$("#chatScrollRight"),B=this.getLastVisibleTabIndex(),E=$("#chatTabsScrollArea > .chatTabs").length-1,G=parseInt($("#chatTabsScrollArea").css("margin-left")),C=this.getTotalTabsWidth(),A=$("#chatTabs").width();D.removeClass("disabled hide");F.removeClass("disabled hide");if(C<A){D.addClass("disabled");F.addClass("disabled");}else{if(G>=0){D.addClass("disabled");}if(B>=E&&G<0){F.addClass("disabled");}}},getLastVisibleTabIndex:function(){var A=$("#chatTabs").width();marginLeft=parseInt($("#chatTabsScrollArea").css("margin-left")),currentWidth=0;lastVisibleTabIndex=0;$("#chatTabsScrollArea .chatTabs").each(function(){currentWidth+=$(this).outerWidth(true);if((marginLeft+currentWidth)<A){lastVisibleTabIndex++;}else{return false;}});return lastVisibleTabIndex;},getTabLeftOffset:function(B){var A=$("#chatTabs").width();width=0,leftOffset=0;$("#chatTabsScrollArea .chatTabs").each(function(C){width+=$(this).outerWidth(true);if(C==B){return false;}});leftOffset=width-A;return leftOffset;},getTotalTabsWidth:function(){var A=0;$("#chatTabsScrollArea .chatTabs").each(function(){A+=$(this).outerWidth(true);});return A;},chatRoomsAvailable:function(D){var B=$("#templates ul.chatList").clone(),C=B.clone().empty(),H=B.children("li").clone(),J=B.find("ul > li").clone();for(var F=0;F<D.chatRooms.length;F++){var A=H.clone(),G=D.chatRooms[F].participants.length;A.children("img.floatleft").addClass("chat_"+D.chatRooms[F].type.toLowerCase());A.attr("rel",D.chatRooms[F].id).children("h2").html(D.chatRooms[F].topic+(G>0?" ("+G+")":""));A.children("ul").empty();if(G==0){A.find(".personAmount").hide();}else{for(var E=0;E<G;E++){var I=J.clone();if(ignoredByUser(D.chatRooms[F].participants[E].id)){I.addClass("ignoredPlayer");}I.attr("identity",D.chatRooms[F].participants[E].id);I.children("h3").html(D.chatRooms[F].participants[E].nick);A.children("ul").append(I);}}C.append(A);}$("#chatListContainer").html(C);},updateIgnoredPersons:function(A){var C=$("#chatListContainer .chatListPerson");for(var B=0;B<C.length;B++){$(C[B]).removeClass("ignoredPlayer");if(ignoredByUser($(C[B]).attr("identity"))){$(C[B]).addClass("ignoredPlayer");}}}});Planeto.SET_CHAT_SIZE="Planeto.SET_CHAT_SIZE";BasicMVC.Facade.getInstance().register(new Planeto.Chat.View());Planeto.UpdateFeed=Planeto.UpdateFeed||{};
Planeto.UpdateFeed.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.UpdateFeed.Control";this.createdContainers={};this.currentToday=this.getSimpleDate(new Date);this.newFeedItemsCounter=0;this.initNewDayTimer();$("#tab_1").live("click",this.localScopeFull(this.tabClicked));},eventListeners:function(){return[PlanetoEvents.UPDATE_FEED_FULL_UPDATE_EVENT,PlanetoEvents.UPDATE_FEED_SINGLE_UPDATE_EVENT];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.UPDATE_FEED_FULL_UPDATE_EVENT:this.updateFullFeed(A.data);break;case PlanetoEvents.UPDATE_FEED_SINGLE_UPDATE_EVENT:this.updateSingleFeed(A.data);break;}},updateFullFeed:function(B){var A=B.events.length;for(var C=0;C<A;C++){var D=B.events[C],E=this.getSimpleDate(new Date(D.timestamp));D.containerId=this.getContainerId(E);}this.sendEvent(Planeto.UpdateFeed.Control.UPDATE_FULL_FEED,B.events);},updateSingleFeed:function(B){var C=B.update,D=this.getSimpleDate(new Date(C.timestamp)),A=this.getContainerId(D);C.containerId=A;this.sendEvent(Planeto.UpdateFeed.Control.UPDATE_FEED,C);this.updateCounter();},getContainerId:function(B){var A=this.getSimpleDate(new Date),C="";if(A.getTime()==B.getTime()){C="feedContainerToday";}else{if(this.addDays(A,-1).getTime()==B.getTime()){C="feedContainerYesterday";}else{C="feedContainerEarlier";}}return C;},getSimpleDate:function(A){var B=new Date(Math.round(A.getTime()/1000)*1000);B.setHours(0);B.setMinutes(0);B.setSeconds(0);return B;},addDays:function(A,B){return new Date(A.getTime()+B*24*60*60*1000);},updateCounter:function(){if(!$("#tab_1").hasClass("active")){this.newFeedItemsCounter++;this.sendEvent(Planeto.UpdateFeed.Control.TAB_CLICKED,this.newFeedItemsCounter);}},tabClicked:function(){this.newFeedItemsCounter=0;},initNewDayTimer:function(){var B=this.addDays(this.getSimpleDate((new Date)),1);var A=B.getTime()-(new Date).getTime()+30*1000;setTimeout(this.localScopeFull(this.newDay),A);},newDay:function(){this.sendEvent(Planeto.UpdateFeed.Control.NEW_DAY);setTimeout(this.localScopeFull(this.newDay),1000*60*60*24);}});Planeto.UpdateFeed.Control.UPDATE_FULL_FEED="Planeto.UpdateFeed.Control.UPDATE_FULL_FEED";Planeto.UpdateFeed.Control.UPDATE_FEED="Planeto.UpdateFeed.Control.UPDATE_FEED";Planeto.UpdateFeed.Control.TAB_CLICKED="Planeto.UpdateFeed.Control.TAB_CLICKED";Planeto.UpdateFeed.Control.NEW_DAY="Planeto.UpdateFeed.Control.NEW_DAY";BasicMVC.Facade.getInstance().register(new Planeto.UpdateFeed.Control());Planeto.UpdateFeed=Planeto.UpdateFeed||{};Planeto.UpdateFeed.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.UpdateFeed.View";this.teams="";this.feedRowTemplate=$("#templates > div.updateFeedRow").outerHtml();this.notificationTimeoutRef=-1;this.notificationClasses=$("#tab_1_1 span.notification").attr("class");this.showDependingOnContent();this.feedContainerToday=$("#feedContainerToday > div");this.feedContainerYesterday=$("#feedContainerYesterday > div");this.feedContainerEarlier=$("#feedContainerEarlier > div");$("#updateFeedContent div.updateFeedRow").live("click",this.localScopeFull(this.friendMenuOver));},eventListeners:function(){return[Planeto.UpdateFeed.Control.UPDATE_FEED,Planeto.UpdateFeed.Control.UPDATE_FULL_FEED,Planeto.UpdateFeed.Control.TAB_CLICKED,Planeto.UpdateFeed.Control.NEW_DAY,PlanetoEvents.GET_TEAMS_LIST_RESPONSE];},eventHandlers:function(A){switch(A.name){case Planeto.UpdateFeed.Control.UPDATE_FEED:this.updateFeed(A.data);break;case Planeto.UpdateFeed.Control.UPDATE_FULL_FEED:this.renderAllFeeds(A.data);break;case Planeto.UpdateFeed.Control.TAB_CLICKED:this.showNotification(A.data);break;case Planeto.UpdateFeed.Control.NEW_DAY:this.newDay();break;case PlanetoEvents.GET_TEAMS_LIST_RESPONSE:this.getTeamList(A.data);break;}},getTeamList:function(A){this.teams=A.teams;},updateFeed:function(A){setTimeout(this.localScope(function(){this.updateFeedAfterDelay(A);}),500);},checkLengthOfFeed:function(){var A=this.feedContainerToday,B=this.feedContainerYesterday,D=this.feedContainerEarlier,C=A.length+B.length+D.length;
if(C>4){if(D.length>0){delete D.pop();}else{if(B.length>0){delete B.pop();}else{if(A.length>0){delete A.pop();}}}}this.showDependingOnContent();},renderAllFeeds:function(A){this.feedContainerToday.empty();this.feedContainerYesterday.empty();this.feedContainerEarlier.empty();if(A.length>0){this.processAsync(A,this.processListItem,this.showDependingOnContent,this);}this.showDependingOnContent();},updateFeedAfterDelay:function(E){var B=$(this.feedRowTemplate),F=new Date(E.timestamp),A=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),C=A[F.getMonth()]+" "+F.getDate()+", ",D=F.getHours()+":"+(F.getMinutes()<10?"0":"")+F.getMinutes();B.find("div.updateFeedTitle").html(E.nickname);B.find("div.updateFeedTime").html("<span class='date'>"+C+"</span>"+D);B.find("div.updateFeedInfo").encodeHtml(E.info);B.find("div.feedImage img").attr("src",E.profilePicture.squarePixelUrl);if(E.identity){B.data("id",E.identity).addClass((E.nickname=="You"?"isPlayer ":"isOnline")+" friendId-"+E.identity);}B.hide();$("#"+E.containerId).show().children("div").prepend(B);B.slideDown();},processListItem:function(E){var B=$(this.feedRowTemplate),F=new Date(E.timestamp),A=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),C=A[F.getMonth()]+" "+F.getDate()+", ",D=F.getHours()+":"+(F.getMinutes()<10?"0":"")+F.getMinutes();B.find("div.updateFeedTitle").html(E.nickname);B.find("div.updateFeedTime").html("<span class='date'>"+C+"</span>"+D);B.find("div.updateFeedInfo").encodeHtml(E.info);B.find("div.feedImage img").attr("src",E.profilePicture.squarePixelUrl);if(E.identity){B.data("id",E.identity).addClass((E.nickname=="You"?"isPlayer":"")+" friendId-"+E.identity);}$("#"+E.containerId).children("div").append(B);},friendMenuOver:function(E){if($(E.target).parents("#userProfile").length==0&&!$(E.target).is("#userProfile")){var A=$(E.target).hasClass("updateFeedRow")?$(E.target):$(E.target).parents(".updateFeedRow"),F=$("#friendMenuHolder"),D=ignoredByUser(A.data("id"));F.removeClass("isPlayer isOffline isOnline isIgnored").addClass("friendMenuCurrent"+(A.hasClass("isPlayer")?" isPlayer":"")).addClass((A.hasClass("isOnline")?"isOnline":"isOffline")).addClass((D?" isIgnored":"")).data("friendId",A.data("id")).css({top:(E.pageY-5)+"px",left:(E.pageX-5)+"px"}).show();if(HIDE_FRIEND_MENU_TIMEOUT!=-1){clearTimeout(HIDE_FRIEND_MENU_TIMEOUT);}$("div.friendMenuCurrent").unbind("mouseleave").bind("mouseleave",CallbackProxy(this,function(){HIDE_FRIEND_MENU_TIMEOUT=setTimeout(CallbackProxy(this,function(){F.hide();}),500);})).unbind("mouseenter").bind("mouseenter",function(){clearTimeout(HIDE_FRIEND_MENU_TIMEOUT);});$("div.friendMenuCurrent").unbind("click").bind("click",CallbackProxy(this,function(){F.hide();}));$("#friendMenuItemKick, #friendMenuItemIgnore, #friendMenuItemStopIgnoring").hide();var C=this.teams.length,G=false;if(C>0){for(var B=0;B<C;B++){if(this.teams[B].leader==true){G=true;break;}}}if(G==true){$("#friendMenuItemInvite").show();}else{$("#friendMenuItemInvite").hide();}}},processAsync:function(E,C,D,B){var A=E.concat();setTimeout(function(){var F=A.shift();C.call(B,F);if(A.length>0){setTimeout(arguments.callee,10);}else{D.call(B);}},10);},clearCounter:function(A){A.removeClass().addClass(this.notificationClasses);},showNotification:function(B){clearTimeout(this.notificationTimeoutRef);var A=$("#tab_1_1 span.notification");this.clearCounter(A);if(B>40){B="40Plus";}A.addClass("redCounter"+B).fadeIn();this.notificationTimeoutRef=setTimeout(function(){$("#tab_1_1 span.notification").fadeOut();},30000);delete A;},newDay:function(){var A=this.feedContainerToday,B=this.feedContainerYesterday,C=this.feedContainerEarlier;C.prepend(B.children());B.prepend(A.children());this.showDependingOnContent();},showDependingOnContent:function(){var A=$("#feedContainerToday"),B=$("#feedContainerYesterday"),C=$("#feedContainerEarlier");if(A.children("div").children().length>0){A.show();}else{A.hide();}if(B.children("div").children().length>0){B.show();
}else{B.hide();}if(C.children("div").children().length>0){C.show();}else{C.hide();}}});BasicMVC.Facade.getInstance().register(new Planeto.UpdateFeed.View());Planeto.ReportQuestion=Planeto.ReportQuestion||{};Planeto.ReportQuestion.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.ReportQuestion.Control";this.quizHistoryId=new Array("","","","","");this.quizHistoryTopic=new Array("","","","","");this.quizHistoryQuestion=new Array("","","","","");this.quizHistoryAnswers=new Array("","","","","");$("#dialogReportQuestionContent div div.question").live("click",function(B){var A=$(this).parent("div");A.siblings("div").removeClass("active").children("div.form").hide();A.toggleClass("active").children("div.form").toggle();});$("#dialogReportQuestionContent .questionReport").live("click",this.localScopeFull(this.sendReportQuestion));$("#dialogCloseButton").live("click",this.localScopeFull(this.closeReportQuestion));$("#reportQuestionButton").live("click",this.localScopeFull(this.triggerReportQuestion));},eventListeners:function(){return[PlanetoEvents.NEW_QUIZ_EVENT,PlanetoEvents.SHOW_QUESTION_EVENT,Planeto.ReportQuestion.Control.REPORT_QUESTION,Planeto.ReportQuestion.Control.CLOSE_REPORTED_QUESTION];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.NEW_QUIZ_EVENT:this.onNewQuiz(A.data);break;case PlanetoEvents.SHOW_QUESTION_EVENT:this.onShowQuestionEvent(A.data);break;case Planeto.ReportQuestion.Control.REPORT_QUESTION:this.showReportQuestion(A.data);break;case Planeto.ReportQuestion.Control.CLOSE_REPORTED_QUESTION:this.closeReportQuestion(A.data);break;}},triggerReportQuestion:function(){this.sendEvent("RespiteControl.REPORT_QUESTION_CLICKED");},sendReportQuestion:function(C){var A=$(C.target).parent("div").parent("div").parent("div").attr("rel"),B=$(C.target).parent("div").siblings("span").children("input[type=radio]:checked").val(),D=$(C.target).parent("div").siblings("textarea").val();if(B+""!="undefined"){this.sendEvent(PlanetoService.REPORT_QUESTION,A,D,B);$(C.target).parent("div").removeClass("questionReport").html("Report sent successfully. Thank you for your help.");}},closeReportQuestion:function(A){if(A.target){$(A.target).parents("div.dialogWrapper").modalClose();}else{if(A.id){$(A.id).modalClose();}}this.sendEvent(RespiteControl.CONTINUE);},onNewQuiz:function(A){this.quizHistoryTopic[4]=this.quizHistoryTopic[3];this.quizHistoryTopic[3]=this.quizHistoryTopic[2];this.quizHistoryTopic[2]=this.quizHistoryTopic[1];this.quizHistoryTopic[1]=this.quizHistoryTopic[0];this.quizHistoryTopic[0]=A.topic;this.quizHistoryAnswers[4]=this.quizHistoryAnswers[3];this.quizHistoryAnswers[3]=this.quizHistoryAnswers[2];this.quizHistoryAnswers[2]=this.quizHistoryAnswers[1];this.quizHistoryAnswers[1]=this.quizHistoryAnswers[0];this.quizHistoryAnswers[0]=A.answers;},onShowQuestionEvent:function(A){this.quizHistoryId[4]=this.quizHistoryId[3];this.quizHistoryId[3]=this.quizHistoryId[2];this.quizHistoryId[2]=this.quizHistoryId[1];this.quizHistoryId[1]=this.quizHistoryId[0];this.quizHistoryId[0]=A.questionId;this.quizHistoryQuestion[4]=this.quizHistoryQuestion[3];this.quizHistoryQuestion[3]=this.quizHistoryQuestion[2];this.quizHistoryQuestion[2]=this.quizHistoryQuestion[1];this.quizHistoryQuestion[1]=this.quizHistoryQuestion[0];this.quizHistoryQuestion[0]=A.question;},showReportQuestion:function(){this.sendEvent(Planeto.ReportQuestion.View.REPORT_QUESTION,new Array(this.quizHistoryId,this.quizHistoryTopic,this.quizHistoryQuestion,this.quizHistoryAnswers));}});Planeto.ReportQuestion.Control.REPORT_QUESTION="Planeto.ReportQuestion.Control.REPORT_QUESTION";Planeto.ReportQuestion.Control.SEND_REPORTED_QUESTION="Planeto.ReportQuestion.Control.SEND_REPORTED_QUESTION";Planeto.ReportQuestion.Control.CLOSE_REPORTED_QUESTION="Planeto.ReportQuestion.Control.CLOSE_REPORTED_QUESTION";BasicMVC.Facade.getInstance().register(new Planeto.ReportQuestion.Control());Planeto.ReportQuestion=Planeto.ReportQuestion||{};Planeto.ReportQuestion.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.ReportQuestion.View";
},eventListeners:function(){return[Planeto.ReportQuestion.View.REPORT_QUESTION];},eventHandlers:function(A){switch(A.name){case Planeto.ReportQuestion.View.REPORT_QUESTION:this.showReportQuestion(A.data);break;}},showReportQuestion:function(A){var E="",H=A[0],C=A[1],G=A[2],F=A[3];for(var D=0;D<G.length;D++){if(G[D]!=""){E+="<div rel='"+H[D]+"'"+(D%2==1?" class='color'":"")+"><div class='question'><div class='number'>"+(D+1)+"</div><div class='text'><span class='strong'>"+C[D]+"</span> "+G[D]+"<br/>A) "+F[D][0]+" B) "+F[D][1]+" C) "+F[D][2]+" D) "+F[D][3]+"</div></div><div class='form hide'><strong>Tell us what you think is wrong with the question.</strong><br/>";E+="<span id='reporttype0-"+D+"'><input type='radio' name='radio' value='BAD_QUESTION' checked='checked'/> Bad Question</span><div class='tooltip'><div class='tooltipText'>The question is irrelevant, incomprehensible, boring, or plain bad</div></div> ";E+="<span id='reporttype1-"+D+"'><input type='radio' name='radio' value='BAD_ANSWERS'/> Bad Answers</span><div class='tooltip'><div class='tooltipText'>The answer alternatives are incomprehensible</div></div> ";E+="<span id='reporttype2-"+D+"'><input type='radio' name='radio' value='BAD_WRITING'/> Bad Writing</span><div class='tooltip'><div class='tooltipText'>Bad grammar or spelling in the topic, question, or answer alternatives</div></div> ";E+="<span id='reporttype3-"+D+"'><input type='radio' name='radio' value='INCORRECT_ANSWER'/> Incorrect Answer</span><div class='tooltip'><div class='tooltipText'>The answer indicated as correct is wrong</div></div> ";E+="<span id='reporttype4-"+D+"'><input type='radio' name='radio' value='OFFENSIVE'/> Offensive Content</span><div class='tooltip'><div class='tooltipText'>The topic, question, or answers contain offensive language</div></div> ";E+="<span id='reporttype5-"+D+"'><input type='radio' name='radio' value='OTHER'/> Other Concern</span><div class='tooltip'><div class='tooltipText'>Please specify in comments field</div></div><br/><br/>";E+="Add optional comment:<br/><textarea class='restrict_maxlength' maxlength='250'></textarea> <div class='spr_button_small_orange questionReport'><div class='left'>Send report</div><div class='right'></div></div></div></div>";}}if(E!=""){$("#dialogReportQuestionContent").html(E);$("#dialogReportQuestion").modal({fixed:108});for(var D=0;D<G.length;D++){for(var B=0;B<6;B++){$("#reporttype"+B+"-"+D).toolTiper();}}}}});Planeto.ReportQuestion.View.REPORT_QUESTION="Planeto.ReportQuestion.View.REPORT_QUESTION";BasicMVC.Facade.getInstance().register(new Planeto.ReportQuestion.View());Planeto.Leaderboard=Planeto.Leaderboard||{};Planeto.Leaderboard.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Leaderboard.Control";this.fragmentLoaded=false;this.leaderboardType="players";this.paging=0;this.selectedTime="";this.selectedContinent="";this.selectedCountry="";this.selectedCity="";this.selectedLevel="";this.personLimit=100;this.questionSetIdentity=null;$("#leaderBoardSearch, #dialogLeaderboardContentTableHead .selectable, #dialogLeaderboardContentTableFooter span").live("click",this.localScopeFull(this.leaderboardSearch));},eventListeners:function(){return[Planeto.Leaderboard.Control.SHOW,Planeto.Leaderboard.Control.HIDE,Planeto.Leaderboard.Control.FRAGMENT_LOADED,Planeto.Leaderboard.Control.CONTINENT_CHANGED,Planeto.Leaderboard.Control.COUNTRY_CHANGED,Planeto.Leaderboard.Control.LEADERBOARD_PLAYER_SEARCH];},eventHandlers:function(A){switch(A.name){case Planeto.Leaderboard.Control.SHOW:this.leaderboardType=A.data.leaderboardType;if(A.data.questionSetIdentity){this.questionSetIdentity=A.data.questionSetIdentity;}this.showLeaderboard();break;case Planeto.Leaderboard.Control.FRAGMENT_LOADED:this.showLeaderboard();break;case Planeto.Leaderboard.Control.HIDE:this.hideLeaderboard();break;case Planeto.Leaderboard.Control.CONTINENT_CHANGED:this.updateCountries(A.data);this.initBindings();break;case Planeto.Leaderboard.Control.COUNTRY_CHANGED:this.updateCities(A.data);
this.initBindings();break;case Planeto.Leaderboard.Control.LEADERBOARD_PLAYER_SEARCH:this.leaderboardPlayerSearch();break;}},initBindings:function(){$("#dialogLeaderboardContentFilter div.dropDown").unbind("click").bind("click",this.localScopeFull(this.menuClicked));$("#dialogLeaderboardContentFilter div.dropDownMenu ul li div").unbind("click").bind("click",this.localScopeFull(this.specialFunctions));},specialFunctions:function(C){var A=$(C.target),B=A.attr("rel"),D=A.html();switch(B){case"time":this.sendEvent(Planeto.Leaderboard.Control.TIME_CHANGED,D);break;case"continent":if(this.selectedContinent!=D){this.sendEvent(Planeto.Leaderboard.Control.CONTINENT_CHANGED,D);this.selectedContinent=D;}break;case"country":if(this.selectedCountry!=D){this.sendEvent(Planeto.Leaderboard.Control.COUNTRY_CHANGED,D);this.selectedCountry=D;}break;case"city":this.sendEvent(Planeto.Leaderboard.Control.CITY_CHANGED,D);break;case"level":this.sendEvent(Planeto.Leaderboard.Control.LEVEL_CHANGED,D);break;default:console.warn(B);break;}},customLevelKeyup:function(C){var B="0123456789-",A=$("#customLevel").val();if(B.indexOf(A.charAt(A.length-1))==-1){$("#customLevel").val(A.substring(0,A.length-1));}},leaderboardSearch:function(A){switch(this.leaderboardType){case"players":this.leaderboardPlayerSearch(A);break;case"teams":this.leaderboardTeamSearch(A);break;case"questionset":this.leaderboardQuestionSetSearch(A);break;}},leaderboardPlayerSearch:function(B){if(B&&$(B.target).parents("#dialogLeaderboardContentTableFooter").length>0){if($(B.target).hasClass("prev")){this.paging--;}else{this.paging++;}}else{this.paging=0;}var I=$("#leaderboardFilterButtonTime .dropDownLabel").html(),L=$("#leaderboardFilterButtonCity .dropDownLabel").html(),D=$("#dialogLeaderboardContentTableHead > .players div.selected"),O=$("#leaderboardFilterButtonLevel").val(),J=$("#customLevel").val();if(J!=""){O=J.split("-");}else{if(O==""){O=new Array(0,0);}else{O=O.split("-");}}var A=O[0],M=O[1],N=$("#dialogLeaderboardContent .leaderboard_friends:checked").val(),P=D.attr("rel"),G=this.personLimit,E=(this.paging*this.personLimit)+1,C=$("#leaderboardCountryCityFilter select").val(),H=$("#leaderboardCountryCityFilter input[type=text]").val(),F=$("#leaderboardTeamFilter select").val(),K=false;if($("#leaderboardCountryCityFilter input[type=text]").hasClass("watermark")){H="";}if(M==undefined){M=A;}if(P==undefined){P="score";}if($("#leaderboardCountryCityFilter select option").length==0){K=true;}$("#dialogLeaderboardContentTableList").html("<div id='leaderboardLoading'>Loading...</div>");this.sendEvent(PlanetoService.SEND_LEADERBOARD_SEARCH,{minLevel:A,maxLevel:M,networkRange:N,columnToSortBy:P.toUpperCase(),nbrOfEntries:G,firstEntryPositionNumber:E,countryISOCode:C,cityId:H,teamId:F,allCountriesList:K});},leaderboardTeamSearch:function(D){if($(D.target).parents("#dialogLeaderboardContentTableFooter").length>0){if($(D.target).hasClass("prev")){this.paging--;}else{this.paging++;}}else{this.paging=0;}var C=$("#dialogLeaderboardContentTableHead > .teams div.selected"),B=C.attr("rel"),F=this.personLimit,E=(this.paging*this.personLimit)+1,A=$("#leaderboardFilterTeamType").val();if(B==undefined){B="current_score";}$("#dialogLeaderboardContentTableList").html("<div id='leaderboardLoading'>Loading...</div>");this.sendEvent(PlanetoService.FILTER_TEAMLEADERBOARD,{nbrOfEntries:F,firstEntryPosition:E,teamType:A,columnToSortBy:B.toUpperCase()});},leaderboardQuestionSetSearch:function(D){var B=$("#dialogLeaderboardContentFilter .questionset"),C=B.find(".leaderboard_friends:checked").val(),E=B.find(".leaderboard_teams select").val(),A=B.find(".leaderboard_questionsets select").val();$("#dialogLeaderboardContentTableList").html("<div id='leaderboardLoading'>Loading...</div>");if(E==""){this.sendEvent(PlanetoService.GET_QUESTIONSET_LEADERBOARD_REQUEST,{identity:A,nbrOfEntries:this.personLimit,firstEntryPositionNumber:1,networkRange:C});}else{this.sendEvent(PlanetoService.GET_QUESTIONSET_LEADERBOARD_FOR_TEAM_REQUEST,{identity:A,nbrOfEntries:this.personLimit,firstEntryPositionNumber:1,teamIdentity:E});
}},menuClicked:function(A){this.resetHideCurrentMenu();this.hideCurrentMenu();this.currentMenu=$(A.currentTarget).parent();this.sendEvent(Planeto.Leaderboard.Control.MENU_CLICKED,this.currentMenu);this.currentMenu.unbind("mouseleave.topMenu").bind("mouseleave.topMenu",this.localScopeFull(this.mouseOutsideMenu));this.currentMenu.unbind("mouseenter.topMenu").bind("mouseenter.topMenu",this.localScopeFull(this.resetHideCurrentMenu));$(document.body).unbind("click.hideTopMenu").bind("click.hideTopMenu",this.localScopeFull(this.documentClick));},resetHideCurrentMenu:function(){clearTimeout(this.hideTimeoutRef);},hideCurrentMenu:function(){if(this.currentMenu!=null){this.currentMenu.unbind("mouseenter.topMenu");this.sendEvent(Planeto.Leaderboard.Control.HIDE_CLICK,this.currentMenu);this.currentMenu=null;}},documentClick:function(B){var A=$(B.target);if(A.parents("div.dropDown").length==0){$(document.body).unbind("click.hideTopMenu");this.resetHideCurrentMenu();this.hideTimeoutRef=setTimeout(this.localScopeFull(this.hideCurrentMenu),500);}},mouseOutsideMenu:function(A){this.resetHideCurrentMenu();this.hideTimeoutRef=setTimeout(this.localScopeFull(this.hideCurrentMenu),500);},loadFragment:function(){$.get(resource_leaderboard_fragment,CallbackProxy(this,function(A){$("#dialogLeaderboardWrapper").html(A);this.initBindings();this.fragmentLoaded=true;this.sendEvent(Planeto.Leaderboard.Control.FRAGMENT_LOADED);}));},updateCountries:function(B){var A=this.getCountries(B);this.sendEvent(Planeto.Leaderboard.Control.COUNTRYLIST,A);},updateCities:function(B){var A=this.getCities(B);this.sendEvent(Planeto.Leaderboard.Control.CITYLIST,A);},showLeaderboard:function(){$("#customLevel").unbind("keyup").bind("keyup",this.localScopeFull(this.customLevelKeyup));if(!this.fragmentLoaded){this.loadFragment();}else{var A={};A.leaderboardType=this.leaderboardType;if(this.questionSetIdentity){A.questionSetIdentity=this.questionSetIdentity;}this.sendEvent(RespiteControl.SHOW_RESPITE,A);}},hideLeaderboard:function(){this.sendEvent(Planeto.Leaderboard.View.HIDE);this.sendEvent(RespiteControl.CONTINUE);}});Planeto.Leaderboard.Control.SHOW="Planeto.Leaderboard.Control.SHOW";Planeto.Leaderboard.Control.HIDE="Planeto.Leaderboard.Control.HIDE";Planeto.Leaderboard.Control.FRAGMENT_LOADED="Planeto.Leaderboard.Control.FRAGMENT_LOADED";Planeto.Leaderboard.Control.MENU_CLICKED="Planeto.Leaderboard.Control.MENU_CLICKED";Planeto.Leaderboard.Control.HIDE_CLICK="Planeto.Leaderboard.Control.HIDE_CLICK";Planeto.Leaderboard.Control.TIME_CHANGED="Planeto.Leaderboard.Control.TIME_CHANGED";Planeto.Leaderboard.Control.CONTINENT_CHANGED="Planeto.Leaderboard.Control.CONTINENT_CHANGED";Planeto.Leaderboard.Control.COUNTRY_CHANGED="Planeto.Leaderboard.Control.COUNTRY_CHANGED";Planeto.Leaderboard.Control.CITY_CHANGED="Planeto.Leaderboard.Control.CITY_CHANGED";Planeto.Leaderboard.Control.LEVEL_CHANGED="Planeto.Leaderboard.Control.LEVEL_CHANGED";Planeto.Leaderboard.Control.COUNTRYLIST="Planeto.Leaderboard.Control.COUNTRYLIST";Planeto.Leaderboard.Control.CITYLIST="Planeto.Leaderboard.Control.CITYLIST";Planeto.Leaderboard.Control.LEADERBOARD_PLAYER_SEARCH="Planeto.Leaderboard.Control.LEADERBOARD_PLAYER_SEARCH";BasicMVC.Facade.getInstance().register(new Planeto.Leaderboard.Control());Planeto.Leaderboard=Planeto.Leaderboard||{};Planeto.Leaderboard.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Leaderboard.View";this.leaderboardType="";this.leaderboardTypeChanged=false;this.teams="";this.templateRow=null;this.selectedColumn="score";this.user_id;this.listHover=false;this.listLimit=100;this.listStart="";this.listEnd="";this.questionSetIdentity=null;this.currentQuestionSet=null;$("#leaderboardCountryCityFilter .location_type").live("click",this.localScopeFull(this.leaderboardLocationFilter));},eventListeners:function(){return[RespiteControl.TRIGGER_SHOW_LEADERBOARD,Planeto.Leaderboard.Control.MENU_CLICKED,Planeto.Leaderboard.Control.HIDE_CLICK,Planeto.Leaderboard.Control.TIME_CHANGED,Planeto.Leaderboard.Control.CONTINENT_CHANGED,Planeto.Leaderboard.Control.COUNTRY_CHANGED,Planeto.Leaderboard.Control.CITY_CHANGED,Planeto.Leaderboard.Control.LEVEL_CHANGED,Planeto.Leaderboard.Control.COUNTRYLIST,Planeto.Leaderboard.Control.CITYLIST,PlanetoEvents.LEADER_BOARD_DATA_RESPONSE,PlanetoEvents.TEAM_LEADER_BOARD_DATA_RESPONSE,PlanetoEvents.GET_MATCHING_CITIES_RESPONSE,PlanetoEvents.GET_TEAMS_LIST_RESPONSE,PlanetoEvents.GET_QUESTION_SET_LEADERBOARD_RESPONSE,PlanetoEvents.GET_COMPLETED_QUESTION_SETS_RESPONSE];
},eventHandlers:function(A){switch(A.name){case PlanetoEvents.GET_TEAMS_LIST_RESPONSE:this.getTeamList(A.data);break;case RespiteControl.TRIGGER_SHOW_LEADERBOARD:this.setLeaderboardType(A.data.originalData.leaderboardType);if(A.data.originalData.questionSetIdentity){this.questionSetIdentity=A.data.originalData.questionSetIdentity;}else{this.questionSetIdentity=null;}this.showLeaderboard();break;case Planeto.Leaderboard.Control.MENU_CLICKED:this.showMenu(A.data);break;case Planeto.Leaderboard.Control.HIDE_CLICK:this.hideMenu(A.data);break;case PlanetoEvents.LEADER_BOARD_DATA_RESPONSE:this.renderPlayerLeaderboard(A.data);break;case PlanetoEvents.TEAM_LEADER_BOARD_DATA_RESPONSE:this.renderTeamLeaderboard(A.data);break;case Planeto.Leaderboard.Control.TIME_CHANGED:$("#leaderboardFilterButtonTime .dropDownLabel").html(A.data);break;case Planeto.Leaderboard.Control.CONTINENT_CHANGED:$("#leaderboardFilterButtonContinent .dropDownLabel").html(A.data);break;case Planeto.Leaderboard.Control.COUNTRY_CHANGED:$("#leaderboardFilterButtonCountry .dropDownLabel").html(A.data);break;case Planeto.Leaderboard.Control.CITY_CHANGED:$("#leaderboardFilterButtonCity .dropDownLabel").html(A.data);break;case Planeto.Leaderboard.Control.LEVEL_CHANGED:$("#customLevel").val("");$("#leaderboardFilterButtonLevel").val(A.data);break;case Planeto.Leaderboard.Control.COUNTRYLIST:this.renderCountryDropDown($("#leaderboardFilterButtonCountry"),"country",A.data);break;case PlanetoEvents.GET_MATCHING_CITIES_RESPONSE:this.displayMatchingCities(A.data);break;case PlanetoEvents.GET_QUESTION_SET_LEADERBOARD_RESPONSE:this.renderQuestionSetLeaderboard(A.data);break;case PlanetoEvents.GET_COMPLETED_QUESTION_SETS_RESPONSE:this.renderQuestionSetDropdown(A.data.questionSets);break;}},setLeaderboardType:function(A){if(this.leaderboardType!=A){this.leaderboardTypeChanged=true;this.leaderboardType=A;}else{this.leaderboardTypeChanged=false;}},getTeamList:function(A){this.teams=A.teams;},leaderboardLocationFilter:function(A){var D=$(A.target).val();if(D==1){$("#leaderboardCountryCityFilter select").val("");$("#leaderboardCountryCityFilter input[type=text]").val("All cities");}else{if(D==2){var B=$("#userFlag .tooltip .tooltipText").attr("rel"),C=$("#userFlag span").text();$("#leaderboardCountryCityFilter select").val(B);$("#leaderboardCountryCityFilter input[type=text]").val(C);}}},showLeaderboard:function(){if(this.leaderboardTypeChanged){this.clearLeaderboard();}switch(this.leaderboardType){case"players":this.showPlayerLeaderboard();break;case"teams":this.showTeamLeaderboard();break;case"questionset":this.showQuestionSetLeaderboard();break;}},clearLeaderboard:function(){$("#dialogLeaderboardContentTableList").html("<div id='leaderboardLoading'>Loading...</div>");},showPlayerLeaderboard:function(){if(this.leaderboardTypeChanged){if(connectedAsGuest==true){$("#dialogLeaderboardContentFilter .leaderboard_friends[value=EVERYONE]").check();}this.sendEvent(Planeto.Leaderboard.Control.LEADERBOARD_PLAYER_SEARCH);}$("#dialogLeaderboardCloseButton").unbind("click").bind("click",CallbackProxy(this,this.hideLeaderboard));$("#dialogLeaderboardContentTableHead .selectable").unbind("click").bind("click",CallbackProxy(this,this.selectColumn));this.selectCountry=$("#leaderboardCountryCityFilter select");this.inputCity=$("#leaderboardCountryCityFilter input[type=text]");this.selectTeam=$("#leaderboardTeamFilter select");$("#leaderboardCountryCityFilter ul").hide().unbind("mouseover").unbind("mouseout").bind("mouseover",CallbackProxy(this,function(){this.listHover=true;})).bind("mouseout",CallbackProxy(this,function(){this.listHover=false;}));this.inputCity.unbind("keydown").bind("keydown",CallbackProxy(this,this.keyPressHandler));this.inputCity.unbind("focus").bind("focus",CallbackProxy(this,this.removeDefaultCityText));this.inputCity.unbind("blur").bind("blur",CallbackProxy(this,this.hideCityList));this.selectCountry.live("change",function(){$("#leaderboardCountryCityFilter .location_type[value=3]").check();
$("#leaderboardCountryCityFilter input[type=text]").val("");});var A="<option value=''>All teams</option>",C=this.teams.length;for(var B=0;B<C;B++){A+="<option value='"+this.teams[B].teamId+"'>"+this.teams[B].teamName+" ("+this.teams[B].nbrOfMembers+")</option>";}this.selectTeam.html(A);this.templateRow=$("#leaderboardPlayerRowTemplate").html();$("#dialogLeaderboardContentTableHead .row > div:not(.tooltip)").toolTiper();$("#dialogLeaderboardContentTableHead .players").show().siblings().hide();$("#dialogLeaderboard h2.players").show().siblings("h2").hide();$("#dialogLeaderboardContentFilter .players").show();$("#dialogLeaderboardContentFilter .teams").hide();$("#dialogLeaderboardContentFilter .questionset").hide();$("#dialogLeaderboard").modal();},showTeamLeaderboard:function(){if(this.leaderboardTypeChanged){this.sendEvent(PlanetoService.GET_DEFAULT_TEAMLEADERBOARD,{nbrOfEntries:this.listLimit});}$("#dialogLeaderboardCloseButton").unbind("click").bind("click",CallbackProxy(this,this.hideLeaderboard));$("#dialogLeaderboardContentTableHead .selectable").unbind("click").bind("click",CallbackProxy(this,this.selectColumn));this.templateRow=$("#leaderboardTeamRowTemplate").html();$("#dialogLeaderboardContentTableHead .row > div:not(.tooltip)").toolTiper();$("#dialogLeaderboardContentTableHead .teams").show().siblings().hide();$("#dialogLeaderboard h2.teams").show().siblings("h2").hide();$("#dialogLeaderboardContentFilter .teams").show();$("#dialogLeaderboardContentFilter .players").hide();$("#dialogLeaderboardContentFilter .questionset").hide();$("#leaderboardLoading").html("");$("#dialogLeaderboard").modal();},showQuestionSetLeaderboard:function(){this.sendEvent(PlanetoService.GET_QUESTIONSET_LEADERBOARD_REQUEST,{identity:this.questionSetIdentity,nbrOfEntries:this.listLimit,firstEntryPositionNumber:1,networkRange:"FRIENDS"});this.sendEvent(PlanetoService.GET_COMPLETED_QUESTION_SETS_REQUEST);$("#dialogLeaderboardCloseButton").unbind("click").bind("click",CallbackProxy(this,this.hideLeaderboard));$("#dialogLeaderboardContentTableHead .selectable").unbind("click");this.templateRow=$("#leaderboardQuestionSetRowTemplate").html();$("#dialogLeaderboardContentTableHead .row > div:not(.tooltip)").toolTiper();$("#dialogLeaderboardContentTableHead .questionset").show().siblings().hide();$("#dialogLeaderboard h2.questionset").show().siblings("h2").hide();$("#dialogLeaderboardContentFilter .teams").hide();$("#dialogLeaderboardContentFilter .players").hide();$("#dialogLeaderboardContentFilter .questionset").show();var A="<option value=''>All teams</option>",C=this.teams.length;for(var B=0;B<C;B++){A+="<option value='"+this.teams[B].teamId+"'>"+this.teams[B].teamName+" ("+this.teams[B].nbrOfMembers+")</option>";}$("#dialogLeaderboardContentFilter .questionset .leaderboard_teams select").html(A);$("#leaderboardLoading").html("");$("#dialogLeaderboard").modal();},removeDefaultCityText:function(A){$("#leaderboardCountryCityFilter .location_type[value=3]").check();$(A.target).val("");},hideLeaderboard:function(){$("#dialogLeaderboard").modalClose();this.sendEvent(RespiteControl.CONTINUE,true);},showMenu:function(A){A.find("div.dropDownMenu").show();},hideMenu:function(A){A.find("div.dropDownMenu").hide();},selectColumn:function(B){var A=$(B.currentTarget);this.selectedColumn=A.attr("rel");A.addClass("selected").siblings().removeClass("selected");$("#dialogLeaderboardContentTableCurrentScore ."+this.selectedColumn).siblings().removeClass("selected");},renderPlayerLeaderboard:function(A){this.renderPlayer(A.playerLeaderBoardData);this.clearList();this.renderList(A.leaderBoardPersons);this.setAlternatingRowDecoration();if(A.countries&&A.countries.length>0){this.renderCountryDropDown(A.countries);}if(this.selectedColumn=="name"){$("#dialogLeaderboardContentTableList .image, #dialogLeaderboardContentTableCurrentScore .image").addClass("selected");}if(this.listStart>1){$("#dialogLeaderboardContentTableFooter .prev").show();}else{$("#dialogLeaderboardContentTableFooter .prev").hide();
}if(A.morePersons){$("#dialogLeaderboardContentTableFooter .next").show();}else{$("#dialogLeaderboardContentTableFooter .next").hide();}},renderTeamLeaderboard:function(A){this.renderTeam(A.primaryTeamData);this.clearList();this.renderList(A.leaderboardTeams);this.setAlternatingRowDecoration();if(this.selectedColumn=="name"){$("#dialogLeaderboardContentTableList .image, #dialogLeaderboardContentTableCurrentScore .image").addClass("selected");}if(this.listStart>1){$("#dialogLeaderboardContentTableFooter .prev").show();}else{$("#dialogLeaderboardContentTableFooter .prev").hide();}if(A.moreTeams){$("#dialogLeaderboardContentTableFooter .next").show();}else{$("#dialogLeaderboardContentTableFooter .next").hide();}$("#dialogLeaderboardContentTable .teamType").toolTiper();},renderQuestionSetLeaderboard:function(A){this.currentQuestionSet={};this.currentQuestionSet.identity=A.identity;this.currentQuestionSet.nbrOfQuestions=A.nbrOfQuestions;this.renderQuestionSetPlayer(A.playerData);this.clearList();this.renderList(A.persons);this.setAlternatingRowDecoration();},clearList:function(){$("#dialogLeaderboardContentTableList").html("");},renderList:function(C){var A=$("#dialogLeaderboardContentTableList");for(var B=0;B<C.length;B++){if(B==0){this.listStart=C[B].position;}else{if(B+1==C.length){this.listEnd=C[B].position;}}switch(this.leaderboardType){case"players":A.append(this.updatePlayerRow($(this.templateRow),C[B]));break;case"teams":A.append(this.updateTeamRow($(this.templateRow),C[B]));break;case"questionset":A.append(this.updateQuestionsetRow($(this.templateRow),C[B]));break;}}if(A.children().length==0){switch(this.leaderboardType){case"players":$("#dialogLeaderboardContentTableList").html("<div id='leaderboardLoading'>No players found...</div>");break;case"teams":$("#dialogLeaderboardContentTableList").html("<div id='leaderboardLoading'>No teams found...</div>");break;}}$("img").unbind("error").bind("error",function(){$(this).attr("src",resource_null_gif);});},renderPlayer:function(B){var A=$("#dialogLeaderboardContentTableCurrentScore > div.player");this.user_id=B.id;this.updatePlayerRow(A,B);A.show().siblings().hide();},renderTeam:function(A){var B=$("#dialogLeaderboardContentTableCurrentScore > div.team");if(A){this.team_id=A.identity;this.updateTeamRow($("#dialogLeaderboardContentTableCurrentScore > div.team"),A);B.show().siblings().hide();}else{B.hide().siblings().hide();}},renderQuestionSetPlayer:function(B){var A=$("#dialogLeaderboardContentTableCurrentScore > div.questionset");this.user_id=B.id;this.updateQuestionsetRow(A,B);A.show().siblings().hide();},updatePlayerRow:function(D,C){if(C.id==this.user_id){D.addClass("isPlayer");}D.find(".image img").attr("src",C.squarePictureUrl);D.find(".name").html((C.position>0?C.position+". ":"")+C.nickName);D.find(".score").html(C.score);D.find(".level").html(C.level);D.find(".streak").html(C.highestStreak);D.find(".medals").html(C.nbrOfMedals);D.find(".correct_answers").html(C.correctAnswers);D.find(".total_answers").html(C.totalAnswers);if(C.totalTimePlayed>0){var E=parseInt(C.totalTimePlayed/(3600*24)),A=parseInt((C.totalTimePlayed-(E*3600*24))/3600),B=parseInt((C.totalTimePlayed-(E*3600*24)-(A*3600))/60);D.find(".time_played").html(E+"d "+(A<10?"0":"")+A+"h "+(B<10?"0":"")+B+"m");}if(C.averageTimePerQuestion>0){D.find(".average_answer_time").html(format_time(C.averageTimePerQuestion));}D.find(".connected_friends").html(C.connectedFriends);if(this.selectedColumn){D.find("."+this.selectedColumn).addClass("selected");}return D;},updateTeamRow:function(C,B){try{if(B.identity==this.team_id){C.addClass("isTeam");}C.find(".teamType").addClass("team_"+B.teamType.toLowerCase());C.find(".teamTypeTooltip").html(B.teamType);C.find(".name").html((B.position>0?B.position+".&nbsp;":"")+B.name);C.find(".current_score").html(B.currentScore);C.find(".previous_score").html(B.previousScore);C.find(".accumulated_score").html(B.accumulatedScore);C.find(".best_score").html(B.bestScore);C.find(".members").html(B.nbrOfMembers);
C.find(".current_player").html(B.currentPlayerNick);if(this.selectedColumn){C.find("."+this.selectedColumn).addClass("selected");}return C;}catch(A){console.warn(A);}},updateQuestionsetRow:function(B,A){if(A.identity==this.user_id){B.addClass("isPlayer");}B.find(".image img").attr("src",A.profilePicture.squarePixelUrl);B.find(".name").html((A.position>0?A.position+". ":"")+A.nickName);B.find(".score").html(A.nbrOfCorrect+" / "+this.currentQuestionSet.nbrOfQuestions);B.find(".time").html(format_time(A.time,null,2));if(this.selectedColumn){B.find("."+this.selectedColumn).addClass("selected");}return B;},setAlternatingRowDecoration:function(){var A=$("#dialogLeaderboardContentTableList");A.find("div.row").addClass("alternate");A.find("div.row:even").removeClass("alternate");},renderDropDown:function(E,D,A){var B=E.find("ul");B.html("");for(var C=0;C<A.length;C++){B.append('<li><div rel="'+D+'">'+A[C]+"</div></li>");}E.find(".dropDownLabel").html("-");},renderCountryDropDown:function(A){var C="<option value=''>All countries</option>";for(var B=0;B<A.length;B++){if(A[B].isoCode!="??"){C+="<option value='"+A[B].isoCode+"'";C+=">"+A[B].name+"</option>";}}this.selectCountry.html(C);},renderQuestionSetDropdown:function(C){var E=$("#dialogLeaderboardContentFilter .questionset .leaderboard_questionsets select"),A="<option value=''>Select a question set</option>",B=C.length;if(E.length>0){for(var D=0;D<B;D++){A+="<option value='"+C[D].identity+"'>"+C[D].name+"</option>";}E.attr("disabled","");E.html(A);E.val(this.questionSetIdentity);}},keyPressHandler:function(A){this.lastKeyPressCode=A.keyCode;switch(A.keyCode){case 38:A.preventDefault();this.moveSelect(-1);break;case 40:A.preventDefault();this.moveSelect(1);break;case 9:case 13:if(this.selectCurrent()){this.inputCity.get(0).blur();A.preventDefault();}break;default:this.active=0;if(this.timeout){clearTimeout(this.timeout);}this.timeout=setTimeout(CallbackProxy(this,this.getMatchingCities),200);break;}},selectCurrent:function(){var A=$("#leaderboardCountryCityFilter ul li.selected"),B;if(A.length==0){A=$("#leaderboardCountryCityFilter ul li:first");}B=A.html();if(B){this.inputCity.val(B);}$("#leaderboardCountryCityFilter ul").hide();},moveSelect:function(B){var A=$("#leaderboardCountryCityFilter ul li");if(!A){return ;}this.active+=B;if(this.active<0){this.active=0;}else{if(this.active>=A.size()){this.active=A.size()-1;}}A.removeClass("selected");$(A[this.active]).addClass("selected");},hideCityList:function(){if(!this.listHover){$("#leaderboardCountryCityFilter ul").hide();}},getMatchingCities:function(){var A=this.inputCity.val(),B=this.selectCountry.val();if(A.length>0){this.sendEvent(PlanetoService.GET_MATCHING_CITIES,{countryIso:B,partialName:A});}},displayMatchingCities:function(B){var D=B.cityNames.slice(0,8),C="";for(var A=0;A<D.length;A++){if(D[A].toLowerCase()!="unknown city"){C+="<li";if(A==0){C+=" class='selected'";}C+=">"+D[A]+"</li>";}}if(C.length>0){$("#leaderboardCountryCityFilter ul").html(C).show();}$("#leaderboardCountryCityFilter ul li").bind("mouseover",function(){$(this).addClass("selected").siblings().removeClass("selected");}).bind("click",CallbackProxy(this,this.selectCurrent));},sortLeaderboard:function(){$("#dialogLeaderboardContentTableList").find(".row").tsort(".score",{order:"desc"});}});BasicMVC.Facade.getInstance().register(new Planeto.Leaderboard.View());Planeto.TopNavigation=Planeto.TopNavigation||{};Planeto.TopNavigation.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.TopNavigation.Control";this.currentMenu=null;this.hideTimeoutRef=-1;$("#topMenuRightContainer div.dropDown").live("click",this.localScopeFull(this.menuClicked));$("#topMenuRightContainer div.dropDownMenu ul li a").live("click",this.localScopeFull(this.autoPause));$("#topMenuRightContainer div.dropDownMenu ul li a, #topMenuCenteringContainer div.dropDownMenu ul li div").live("click.statistics",this.localScopeFull(this.statistics));$("#topMenuRightContainer div.dropDownMenu ul li div").live("click",this.localScopeFull(this.specialFunctions));
$("#topMenuRightContainer").live("mouseleave.topMenu",this.localScopeFull(this.mouseOutsideMenu));$(document.body).live("click.hideTopMenu",this.localScopeFull(this.documentClick));$("#topMenuButtonLogout").live("click.logout",this.localScopeFull(this.navigationLogout));$("#topMenuCenteringContainer").delegate("img","click",this.localScopeFull(this.startGameMode));$("#topMenuSoundControl img").live("click",this.localScopeFull(this.toggleSoundOnOff));},eventListeners:function(){return[PlanetoEvents.NEW_QUIZ_RESPONSE,PlanetoEvents.START_GAME_MODE,PlanetoEvents.OPEN_INFINITE_STREAM_GAME];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.NEW_QUIZ_RESPONSE:this.gameSessionLoaded(A.data);break;case PlanetoEvents.START_GAME_MODE:this.startGameMode(A.data);break;case PlanetoEvents.OPEN_INFINITE_STREAM_GAME:this.openInfinteStreamGame();break;}},startGameMode:function(A){$("#landingScreen").hide();var B="";if(A){if($(A.liveFired).attr("id")=="landingScreen"){if($(A.target).is("img")){B=$(A.target).parent("div").attr("id");}else{B=$(A.target).attr("id");}}else{B=$(A.target).parent("div").parent("div").attr("id");}}switch(B){case"topMenuTravel":case"landingScreenTravel":this.openTravelTheWorld();break;case"topMenuMulti":case"landingScreenMulti":this.openMultiplayer();break;case"topMenuSingle":case"landingScreenSingle":default:this.openInfinteStreamGame();break;}},specialFunctions:function(B){var A=$(B.target).attr("rel");if(A=="ReportQuestion"){this.sendEvent("RespiteControl.REPORT_QUESTION_CLICKED");}else{if(A=="Leaderboard"){this.sendEvent(Planeto.Leaderboard.Control.SHOW,{leaderboardType:"players"});}else{if(A=="TeamLeaderboard"){this.sendEvent(Planeto.Leaderboard.Control.SHOW,{leaderboardType:"teams"});}else{if(A=="QuestionSetLeaderboard"){this.sendEvent(Planeto.Leaderboard.Control.SHOW,{leaderboardType:"questionset"});}else{if(A=="UserSetting"){$("#dialogUserSettings .showUserSettings").show();$("#dialogUserSettings").removeClass("dialogDailyQuiz");$("#dialogUserSettings .showDailyQuiz").hide();this.sendEvent(RespiteControl.SHOW_USER_SETTINGS);}else{if(A=="InviteFriends"){this.sendEvent(PlanetoEvents.RESPITE_INVITE_DIALOG);}else{console.warn(A);}}}}}}},navigationLogout:function(){this.sendEvent(PlanetoService.GET_LOGOUT_SESSION_SUMMARY);},menuClicked:function(A){this.resetHideCurrentMenu();this.hideCurrentMenu();this.currentMenu=$(A.currentTarget).parent();this.currentMenu.find("div.dropDownMenu").show();},documentClick:function(A){if($(A.target).parents("div.dropDown").length==0){this.resetHideCurrentMenu();this.hideTimeoutRef=setTimeout(this.localScopeFull(this.hideCurrentMenu),500);}},resetHideCurrentMenu:function(){clearTimeout(this.hideTimeoutRef);},hideCurrentMenu:function(){if(this.currentMenu!=null){this.currentMenu.find("div.dropDownMenu").hide();this.currentMenu=null;}},mouseOutsideMenu:function(){this.resetHideCurrentMenu();this.hideTimeoutRef=setTimeout(this.localScopeFull(this.hideCurrentMenu),500);},autoPause:function(){if($("#clockPauseButton").is(":visible")){this.sendEvent(Planeto.Quiz.Control.COMMAND_PAUSE_GAME);}},openInfinteStreamGame:function(){$("#topMenuTravel > div, #topMenuMulti > div").removeClass("active");$("#topMenuSingle > div").addClass("active");this.sendEvent(Planeto.Multiplayer.EXIT);this.sendEvent(Planeto.Multiplayer.HIDE_TRAVEL);this.sendEvent(Planeto.Player.Control.START_PLAYING,"START_PLAYING");},openMultiplayer:function(){$("#topMenuSingle > div, #topMenuTravel > div").removeClass("active");$("#topMenuMulti > div").addClass("active");this.sendEvent(PlanetoService.STOP_GAME);this.sendEvent(Planeto.Multiplayer.HIDE_TRAVEL);this.sendEvent(Planeto.Multiplayer.INIT);},openTravelTheWorld:function(){$("#topMenuSingle > div, #topMenuMulti > div").removeClass("active");$("#topMenuTravel > div").addClass("active");this.sendEvent(Planeto.Multiplayer.EXIT);this.sendEvent(PlanetoService.STOP_GAME);this.sendEvent(Planeto.Multiplayer.SHOW_TRAVEL);},toggleSoundOnOff:function(){var A=$("#topMenuSoundControl img");
muted=A.hasClass("muted");this.sendEvent(Planeto.SoundFX.DISABLE,!muted);A.toggleClass("muted");},statistics:function(A){this.sendEvent(GoogleAnalyticsControl.TRACK_EVENT,{category:"Top Navigation",action:$(A.currentTarget).attr("rel")});},gameSessionLoaded:function(){this.sendEvent(Planeto.TopNavigation.Control.GAME_SESSION_LOADED);}});Planeto.TopNavigation.Control.GAME_SESSION_LOADED="Planeto.TopNavigation.Control.GAME_SESSION_LOADED";PlanetoEvents.START_GAME_MODE="PlanetoEvents.START_GAME_MODE";PlanetoEvents.OPEN_INFINITE_STREAM_GAME="PlanetoEvents.OPEN_INFINITE_STREAM_GAME";BasicMVC.Facade.getInstance().register(new Planeto.TopNavigation.Control());Planeto.TopNavigation=Planeto.TopNavigation||{};Planeto.TopNavigation.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.TopNavigation.View";},eventListeners:function(){return[Planeto.TopNavigation.Control.GAME_SESSION_LOADED,PlanetoEvents.FORCED_LOGOUT_EVENT,Planeto.SoundFX.NO_AUDIO_SUPPORT];},eventHandlers:function(A){switch(A.name){case Planeto.TopNavigation.Control.GAME_SESSION_LOADED:this.showTopMenu();break;case PlanetoEvents.FORCED_LOGOUT_EVENT:this.forcedLogout();break;case Planeto.SoundFX.NO_AUDIO_SUPPORT:this.hideSoundControls();break;}},showTopMenu:function(A){$("#topMenuContainer").show();$("#topMenuSingle, #topMenuTravel, #topMenuMulti").toolTiper();},forcedLogout:function(A){$("#topMenuContainer").hide();},hideSoundControls:function(){$("#topMenuSoundControl").hide();}});BasicMVC.Facade.getInstance().register(new Planeto.TopNavigation.View());Planeto.Duel=Planeto.Duel||{};Planeto.Duel.Challenge=Planeto.Duel.Challenge||{};Planeto.Duel.Challenge.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Duel.Challenge.Control";this.currentChallengeId="";this.friendId="";$("#friendMenuHolder.isOnline:not(.isPlayer) #friendMenuItemChallenge").live("click",this.localScopeFull(this.challengeFriend));},eventListeners:function(){return[RespiteControl.TRIGGER_CHALLENGE_TO_DUEL_EVENT,PlanetoEvents.CHALLENGE_WITHDRAWN_EVENT,Planeto.Duel.Challenge.Control.CHALLENGED];},eventHandlers:function(A){switch(A.name){case RespiteControl.TRIGGER_CHALLENGE_TO_DUEL_EVENT:this.challengedToDuel(A.data);break;case PlanetoEvents.CHALLENGE_WITHDRAWN_EVENT:this.challengeWithdrawn(A.data);break;case Planeto.Duel.Challenge.Control.CHALLENGED:this.challengedSaveInfo(A.data);break;}},challengeFriend:function(A){this.sendEvent(PlanetoService.CHALLENGE_TO_DUEL,$("#friendMenuHolder").data("friendId"));this.sendEvent(Planeto.Duel.Challenge.Control.REQUESTED_CHALLENGE);},challengedSaveInfo:function(A){this.friendId=A.challenger.id;},enteredLobby:function(){this.sendEvent(StatusView.HIDE_MESSAGE);},challengedToDuel:function(A){$("#dialogDuelRequestAcceptButton").unbind("click.acceptDuel").bind("click.acceptDuel",this.localScope(this.acceptChallenge));$("#dialogDuelRequestDontAcceptButton").unbind("click.chickenOutFromDuel").bind("click.chickenOutFromDuel",this.localScope(this.dontAcceptChallenge));this.sendEvent(Planeto.Duel.Challenge.Control.CHALLENGED,A);this.currentChallengeId=A.challengeId;},acceptChallenge:function(){this.sendEvent(Planeto.Duel.Challenge.Control.CHALLENGE_ACCEPTED);this.sendEvent(PlanetoService.RESPONDE_TO_CHALLENGE,this.currentChallengeId,true);this.resetChallenge();this.sendEvent(PlanetoService.INVITE_PLAYER_TO_CHAT,this.friendId);this.sendEvent(Planeto.Chat.Control.REQUESTED_CHAT);},dontAcceptChallenge:function(){this.sendEvent(Planeto.Duel.Challenge.Control.CHALLENGE_NOT_ACCEPTED);this.sendEvent(PlanetoService.RESPONDE_TO_CHALLENGE,this.currentChallengeId,false);this.sendEvent(RespiteControl.CONTINUE);this.resetChallenge();},challengeWithdrawn:function(A){if(this.currentChallengeId!=""){this.sendEvent(RespiteControl.REMOVE_EVENT,RespiteControl.TRIGGER_CHALLENGE_TO_DUEL_EVENT);this.otherPlayerChickenedOut();this.resetChallenge();}else{this.sendEvent(RespiteControl.REMOVE_EVENT,RespiteControl.TRIGGER_CHALLENGE_TO_DUEL_EVENT);this.sendEvent(RespiteControl.CONTINUE);
this.resetChallenge();}},otherPlayerChickenedOut:function(){this.sendEvent(Planeto.Duel.Challenge.Control.OTHER_PLAYER_CHICKENED_OUT);$("#duelChickenContinue").unbind("click.continue").bind("click.continue",this.localScopeFull(this.continueAfterOtherPlayerChickenedOut));},continueAfterOtherPlayerChickenedOut:function(){this.sendEvent(Planeto.Duel.Challenge.Control.OTHER_PLAYER_CHICKENED_OUT_CONTINUE);$("#duelChickenContinue").unbind("click.continue");this.sendEvent(RespiteControl.REMOVE_EVENT,RespiteControl.TRIGGER_CHALLENGE_TO_DUEL_EVENT);this.sendEvent(RespiteControl.CONTINUE);},resetChallenge:function(){this.currentChallengeId="";}});Planeto.Duel.Challenge.Control.REQUESTED_CHALLENGE="PlanetoDuel.Challenge.Control.REQUESTED_CHALLENGE";Planeto.Duel.Challenge.Control.CHALLENGED="PlanetoDuel.Challenge.Control.CHALLENGED";Planeto.Duel.Challenge.Control.CHALLENGE_ACCEPTED="PlanetoDuel.Challenge.Control.CHALLENGE_ACCEPTED";Planeto.Duel.Challenge.Control.CHALLENGE_NOT_ACCEPTED="PlanetoDuel.Challenge.Control.CHALLENGE_NOT_ACCEPTED";Planeto.Duel.Challenge.Control.OTHER_PLAYER_CHICKENED_OUT="PlanetoDuel.Challenge.Control.OTHER_PLAYER_CHICKENED_OUT";Planeto.Duel.Challenge.Control.OTHER_PLAYER_CHICKENED_OUT_CONTINUE="PlanetoDuel.Challenge.Control.OTHER_PLAYER_CHICKENED_OUT_CONTINUE";BasicMVC.Facade.getInstance().register(new Planeto.Duel.Challenge.Control());Planeto.Duel=Planeto.Duel||{};Planeto.Duel.Challenge=Planeto.Duel.Challenge||{};Planeto.Duel.Challenge.View=BasicMVC.Base.extend({constructor:function(){this.name="Duel.Challenge.View";this.templateFriend=selector_templates_friend.outerHtml();},eventListeners:function(){return[Planeto.Duel.Challenge.Control.CHALLENGED,Planeto.Duel.Challenge.Control.CHALLENGE_ACCEPTED,Planeto.Duel.Challenge.Control.CHALLENGE_NOT_ACCEPTED,Planeto.Duel.Challenge.Control.OTHER_PLAYER_CHICKENED_OUT,Planeto.Duel.Challenge.Control.OTHER_PLAYER_CHICKENED_OUT_CONTINUE];},eventHandlers:function(A){switch(A.name){case Planeto.Duel.Challenge.Control.CHALLENGED:this.challenged(A.data);break;case Planeto.Duel.Challenge.Control.CHALLENGE_ACCEPTED:case Planeto.Duel.Challenge.Control.CHALLENGE_NOT_ACCEPTED:this.closeChallengedQuestion();break;case Planeto.Duel.Challenge.Control.OTHER_PLAYER_CHICKENED_OUT:this.otherPlayerChickenedOut();break;case Planeto.Duel.Challenge.Control.OTHER_PLAYER_CHICKENED_OUT_CONTINUE:this.otherPlayerChickenedOutContinue();break;}},challenged:function(A){$("#duelRequestFriendContainer").html(this.createFriendsDOM(A.challenger));$("#duelRequestName").html(A.challenger.nickname);$("#duelRequestLang").html(A.language);$("#dialogDuelRequest").modal();},closeChallengedQuestion:function(){$("#dialogDuelRequest").modalClose();},challengeNotAccepted:function(){this.closeChallengedQuestion();$("#dialogDuelChicken").modal();},createFriendsDOM:function(B){var A=$(this.templateFriend);A.attr({id:"friendIdInDuelChallenge-"+B.id,rel:B.score}).data("id",B.id);if(B.profilePicture.squarePixelUrl!=null){A.find("img.friendAvatar").attr("src",B.profilePicture.squarePixelUrl);}A.find("img.friendOnlineStatus").addClass("spr_icon_online");if(B.location){A.find(".friendCountry img").addClass("spr_flag_"+B.location.country.isoCode.toLowerCase());if(B.location.country.name=="Unspecified"){B.location.country.name="Unknown country";}A.find(".friendCountry span").html(B.location.city.name);}A.find("span.friendScore").html(B.score+"p");A.find("div.friendNickName").html(B.nickname);A.find("div.friendLevel").css("background-position","0 "+(B.level*-27)+"px");return A;},otherPlayerChickenedOut:function(){$("#dialogDuelChicken").modal();},otherPlayerChickenedOutContinue:function(){$("#dialogDuelChicken").modalClose();this.sendEvent(Planeto.Duel.Lobby.LEAVE_LOBBY_HANDLER);this.closeChallengedQuestion();}});BasicMVC.Facade.getInstance().register(new Planeto.Duel.Challenge.View());Planeto.Duel=Planeto.Duel||{};Planeto.Duel.Lobby=Planeto.Duel.Lobby||{};Planeto.Duel.Lobby.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Duel.Lobby.Control";
this.playerReadyFlag=false;},eventListeners:function(){return[PlanetoEvents.LOBBY_LEFT_EVENT,PlanetoEvents.LOBBY_STATE_EVENT,PlanetoEvents.LOBBY_CHANGED_OTHER_PLAYER_DECLINED_CHALLENGE_EVENT,PlanetoEvents.LOBBY_CHANGED_OTHER_PLAYER_LEFT_EVENT,Planeto.Application.Control.LOAD_FINISHED,Planeto.Duel.Lobby.LEAVE_LOBBY_HANDLER];},eventHandlers:function(A){switch(A.name){case Planeto.Application.Control.LOAD_FINISHED:this.init();break;case PlanetoEvents.LOBBY_STATE_EVENT:this.lobbyStateUpdate(A.data);break;case PlanetoEvents.LOBBY_LEFT_EVENT:this.leftLobbyEvent(A.data);break;case PlanetoEvents.LOBBY_CHANGED_OTHER_PLAYER_DECLINED_CHALLENGE_EVENT:case PlanetoEvents.LOBBY_CHANGED_OTHER_PLAYER_LEFT_EVENT:this.otherPlayerChickenedOut(true);break;case Planeto.Duel.Lobby.LEAVE_LOBBY_HANDLER:this.leaveLobbyHandler();break;}},init:function(){$("#duelLobbyClose, #duelLobby .duelFinishedClose").bind("click",this.localScopeFull(this.leaveLobbyHandler));$("#duelUserSelf div.readyButton").bind("click.ready",this.localScopeFull(this.playerReady));},lobbyStateUpdate:function(A){this.playerReadyFlag=A.lobby.self.ready;this.sendEvent(Planeto.Duel.Lobby.Control.UPDATE_LOBBY_STATE,A);},otherPlayerChickenedOut:function(A){this.sendEvent(Planeto.Duel.Lobby.Control.OTHER_PLAYER_CHICKENED_OUT);$("#duelChickenContinue").unbind("click.continue").bind("click.continue",this.localScopeFull(this.continueAfterOtherPlayerChickenedOut,A));},leaveLobbyHandler:function(){$("#quizComingQuestions, #quizCategory").show();this.sendEvent(PlanetoService.LEAVE_LOBBY);this.sendEvent(Planeto.Duel.Lobby.Control.LEFT_LOBBY);},continueAfterOtherPlayerChickenedOut:function(C,B,A){this.sendEvent(Planeto.Duel.Lobby.Control.OTHER_PLAYER_CHICKENED_OUT_CONTINUE);$("#duelChickenContinue").unbind("click.continue");this.leaveLobbyHandler();this.sendEvent(PlanetoService.START_PLAYING);},playerReady:function(A){this.playerReadyFlag=!this.playerReadyFlag;this.sendEvent(PlanetoService.SET_PLAYER_READY_STATE_REQUEST,this.playerReadyFlag);},leftLobbyEvent:function(A){if(A.reason=="SELF_LEFT"){this.sendEvent(PlanetoService.START_PLAYING);}else{if(A.reason=="OTHER_PLAYER_OWNING_LOBBY_LEFT"){this.otherPlayerChickenedOut(false);}}}});Planeto.Duel.Lobby.Control.UPDATE_LOBBY_STATE="Duel.Lobby.Control.UPDATE_LOBBY_STATE";Planeto.Duel.Lobby.Control.LEFT_LOBBY="Duel.Lobby.Control.LEFT_LOBBY";Planeto.Duel.Lobby.Control.OTHER_PLAYER_CHICKENED_OUT="Duel.Lobby.Control.OTHER_PLAYER_CHICKENED_OUT";Planeto.Duel.Lobby.Control.OTHER_PLAYER_CHICKENED_OUT_CONTINUE="Duel.Lobby.Control.OTHER_PLAYER_CHICKENED_OUT_CONTINUE";Planeto.Duel.Lobby.LEAVE_LOBBY_HANDLER="Planeto.Duel.Lobby.LEAVE_LOBBY_HANDLER";BasicMVC.Facade.getInstance().register(new Planeto.Duel.Lobby.Control());Planeto.Duel=Planeto.Duel||{};Planeto.Duel.Lobby=Planeto.Duel.Lobby||{};Planeto.Duel.Lobby.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Duel.Lobby.View";this.lobbyOn=false;},eventListeners:function(){return[Planeto.Duel.Lobby.Control.UPDATE_LOBBY_STATE,Planeto.Duel.Lobby.Control.LEFT_LOBBY,Planeto.Duel.Lobby.Control.OTHER_PLAYER_CHICKENED_OUT,Planeto.Duel.Lobby.Control.OTHER_PLAYER_CHICKENED_OUT_CONTINUE,PlanetoService.SET_PLAYER_READY_STATE_REQUEST,Planeto.Duel.Lobby.View.SHOW];},eventHandlers:function(A){switch(A.name){case Planeto.Duel.Lobby.Control.UPDATE_LOBBY_STATE:this.updateLobby(A.data);break;case Planeto.Duel.Lobby.Control.LEFT_LOBBY:this.leftLobby();break;case Planeto.Duel.Lobby.Control.OTHER_PLAYER_CHICKENED_OUT:this.otherPlayerChickenedOut();break;case Planeto.Duel.Lobby.Control.OTHER_PLAYER_CHICKENED_OUT_CONTINUE:this.otherPlayerChickenedOutContinue();break;case PlanetoService.SET_PLAYER_READY_STATE_REQUEST:this.updatePlayerState(A.data,true,true);break;case Planeto.Duel.Lobby.View.SHOW:this.showDuel();break;}},updateLobby:function(A){this.updateUserData(A.lobby.self,true,true);if(A.lobby.challenged.length>=1){this.updateUserData(A.lobby.challenged[0],false,false);}else{if(A.lobby.participants.length>=1){this.updateUserData(A.lobby.participants[0],false,true);
}}if(!this.lobbyOn){this.lobbyOn=true;this.sendEvent(StatusView.HIDE_MESSAGE);$("#gameplayContainer, #quizComingQuestions, #quizCategory").hide();$("#lobbyCurrentTopic").html("Duel Lobby");$("#duelLobby .duelAfterGame").hide();$("#duelLobby, #duelLobby .duelBeforeGame").show();}},updatePlayerState:function(D,B,A){var C=B?$("#duelUserSelf").find("div.readyButton"):$("#duelUserOther").find("div.readyButton");if(D){C.removeClass(B?"spr_toggle_orange":"spr_toggle_grey").addClass("spr_toggle_green").find("div.left").html("<img src='"+duel_ready_icon+"'/> Ready to play");}else{C.removeClass("spr_toggle_green").addClass(B?"spr_toggle_orange":"spr_toggle_grey").find("div.left").html(B?"Click to play":(A==true?"Not ready":"Waiting for player"));}},updateUserData:function(C,B,A){var D=B?$("#duelUserSelf"):$("#duelUserOther"),E=B?$("#duelLobby .duelAfterGame .duelUserBox"):$("#duelLobby .duelAfterGame .duelOtherBox");D.find("div.name").html(C.nickname);D.find("div.avatar img").attr("src",C.profilePicture.bigPictureUrl);E.find("div.name").html(C.nickname);E.find("div.avatar img").attr("src",C.profilePicture.squarePixelUrl);this.updatePlayerState(C.ready,B,A);},leftLobby:function(){$("#duelLobby").hide();$("#gameplayContainer").show();this.lobbyOn=false;this.sendEvent(PlanetoService.START_PLAYING);},emptyPlayer:function(){var A={nickname:"",ready:false,profilePicture:{bigPictureUrl:resource_null_gif}};this.updateUserData(A,false,true);},otherPlayerChickenedOut:function(){this.emptyPlayer();$("#dialogDuelChicken").modal();},otherPlayerChickenedOutContinue:function(){$("#dialogDuelChicken").modalClose();$("#duelLobby").hide();$("#gameplayContainer").show();this.sendEvent(PlanetoService.START_PLAYING);},showDuel:function(){this.lobbyOn=false;}});Planeto.Duel.Lobby.View.SHOW="Planeto.Duel.Lobby.View.SHOW";BasicMVC.Facade.getInstance().register(new Planeto.Duel.Lobby.View());Planeto.Duel=Planeto.Duel||{};Planeto.Duel.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Duel.Control";this.fragmentLoaded=false;$("#duelClockContainer").live("click",this.localScopeFull(this.duelPauseOrContinue));$("#duelClockPauseButton").live("click",this.localScopeFull(this.duelPause));$("#duelClockContinueButton").live("click",this.localScopeFull(this.duelContinue));},eventListeners:function(){return[PlanetoEvents.START_DUEL_EVENT,PlanetoEvents.DUEL_SHOW_ANSWER_ALTERNATIVES_EVENT,PlanetoEvents.DUEL_SHOW_QUESTIONS_EVENT,PlanetoEvents.DUEL_SHOW_CORRECT_ANSWER_EVENT,PlanetoEvents.PAUSE_EVENT,PlanetoEvents.DUEL_ROUND_SUMMARY_EVENT,Planeto.Duel.Control.SHOW,Planeto.Duel.Control.HIDE,Planeto.Duel.Control.FRAGMENT_LOADED];},eventHandlers:function(A){switch(A.name){case Planeto.Duel.Control.SHOW:case Planeto.Duel.Control.FRAGMENT_LOADED:case PlanetoEvents.START_DUEL_EVENT:this.showDuel();break;case Planeto.Duel.Control.HIDE:this.hideDuel();break;case PlanetoEvents.DUEL_SHOW_ANSWER_ALTERNATIVES_EVENT:this.showAnswerAlternatives(A.data);break;case PlanetoEvents.DUEL_SHOW_QUESTIONS_EVENT:this.showQuestions(A.data);break;case PlanetoEvents.DUEL_SHOW_CORRECT_ANSWER_EVENT:this.showCorrectAnswer(A.data);break;case PlanetoEvents.PAUSE_EVENT:this.showPauseStatus(A.data);break;case PlanetoEvents.DUEL_ROUND_SUMMARY_EVENT:this.roundSummary(A.data);break;}},showDuel:function(){if(!this.fragmentLoaded){this.loadFragment();}else{this.sendEvent(Planeto.Duel.Lobby.View.SHOW);this.sendEvent(PlanetoService.DUEL_READY_TO_PLAY);}},hideDuel:function(){this.sendEvent(Planeto.Duel.Control.HIDE_CLICK);},loadFragment:function(){this.sendEvent(Planeto.Duel.Control.FRAGMENT_LOADING);$.get(resource_duel_fragment,CallbackProxy(this,function(A){$("#dialogDuelWrapper").html(A);this.fragmentLoaded=true;this.sendEvent(Planeto.Duel.Control.FRAGMENT_LOADED);}));},showAnswerAlternatives:function(C){$("#duelGameplayContainer .duelQuestionContainer span").html("");$("#duelPlayerUser .duelQuestionContainer").css("visibility","visible");$("#duelPlayerOther .duelQuestionContainer").css("visibility","hidden");
if(duelRoundIndex==0){$("#duelPlayerUser .standardReminder").show();}else{$("#duelGameplayContainer .standardReminder").hide();}$("#duelGameplayContainer .duelOpponentAnswered").hide();$("#duelPlayerUserQuizArea .duelAnswerContainer td, #duelPlayerOtherQuizArea .duelAnswerContainer td").removeClass("selectable exclude correctAnswer wrongAnswerAll wrongAnswer answerButtonSelected long").unbind("click");$("#duelPlayerUserCurrentTopic").html(C.playerQuestion.topic);$("#duelPlayerUserQuizArea .duelQuestionWaitContainer div").html(C.playerQuestion.topic).fadeIn();var F=$("#duelPlayerUser .gameplayStatusArea"),B;for(var E=0;E<6;E++){B+=" categoryColor"+E;}F.removeClass(B);F.addClass("categoryColor"+C.playerQuestion.category.id);var D=false,A=false;for(var E=0;E<4;E++){$("#duelPlayerUserAnswer"+(E+1)+" > div").html(C.playerQuestion.answers[E]);if(C.playerQuestion.answers[E].length>15&&D==false){D=true;$("#duelPlayerUserQuizArea .duelAnswerContainer td").addClass("long");}if(C.playerQuestion.answers[E].length>80&&A==false){A=true;$("#duelPlayerUserQuizArea .duelAnswerContainer td").addClass("longer");}}$("#duelPlayerOtherCurrentTopic").html(C.opponentQuestion.topic);F=$("#duelPlayerOther .gameplayStatusArea");B="";for(var E=0;E<6;E++){B+=" categoryColor"+E;}F.removeClass(B);F.addClass("categoryColor"+C.opponentQuestion.category.id);bigAnswer=false;for(var E=0;E<4;E++){$("#duelPlayerOtherAnswer"+(E+1)+" > div").html(C.opponentQuestion.answers[E]);if(C.opponentQuestion.answers[E].length>15){bigAnswer=true;}}if(bigAnswer){$("#duelPlayerOtherQuizArea .duelAnswerContainer td").addClass("long");}},showQuestions:function(A){$("#duelPlayerUserQuizArea .duelQuestionWaitContainer div").fadeOut();$("#duelPlayerUserQuestionContent").html(A.playerQuestion.question);$("#duelPlayerOtherQuizArea .duelQuestionWaitContainer div").fadeOut();$("#duelPlayerOtherQuestionContent").html(A.opponentQuestion.question);$("#duelPlayerUserQuizArea .duelAnswerContainer td").addClass("selectable").bind("click",CallbackProxy(this,this.answerQuestion));},showCorrectAnswer:function(A){$("#duelPlayerUserQuizArea .duelAnswerContainer td, #duelPlayerOtherQuizArea .duelAnswerContainer td").removeClass("selectable").unbind("click");var C=$("#duelPlayerUserQuizArea .duelAnswerContainer");playerCorrectAnswer=$("#duelPlayerUserAnswer"+(A.playerQuestion.correctAnswerIndex+1));playerCorrectAnswer.addClass("correctAnswer");if(A.playerQuestion.playerCorrect==false){if(C.find("td.answerButtonSelected").length==0){C.find("td:not(.correctAnswer, .exclude, .wrongAnswer)").addClass("wrongAnswerAll");}else{C.find("td:not(.correctAnswer)").removeClass("selectable").addClass("exclude");C.find("td.answerButtonSelected").removeClass("exclude").addClass("wrongAnswer");if(playerCorrectAnswer.hasClass("answerButtonSelected")){playerCorrectAnswer.removeClass("correctAnswer");}}}else{C.find("td:not(.correctAnswer)").removeClass("selectable").addClass("exclude");}C.find("td.answerButtonSelected").removeClass("answerButtonSelected");var B=$("#duelPlayerOtherQuizArea .duelAnswerContainer");opponentCorrectAnswer=$("#duelPlayerOtherAnswer"+(A.opponentQuestion.correctAnswerIndex+1));opponentCorrectAnswer.addClass("correctAnswer");if(A.opponentQuestion.playerCorrect==false){if(B.find("td.answerButtonSelected").length==0){B.find("td:not(.correctAnswer, .exclude, .wrongAnswer)").addClass("wrongAnswerAll");}else{B.find("td:not(.correctAnswer)").removeClass("selectable").addClass("exclude");B.find("td.answerButtonSelected").removeClass("exclude").addClass("wrongAnswer");if(opponentCorrectAnswer.hasClass("answerButtonSelected")){opponentCorrectAnswer.removeClass("correctAnswer");}}}else{B.find("td:not(.correctAnswer)").removeClass("selectable").addClass("exclude");}B.find("td.answerButtonSelected").removeClass("answerButtonSelected");},answerQuestion:function(C){var E,B,D=C.currentTarget.id.replace("duelPlayerUserAnswer",""),A=C.currentTarget.id.replace("duelPlayerOtherAnswer","");if(D==parseInt(D)){B="MY_QUESTION";
E=D-1;$("#duelPlayerUserQuizArea .duelAnswerContainer td.selectable").unbind("click").removeClass("selectable");$("#duelPlayerOtherQuizArea .duelAnswerContainer td").addClass("selectable").bind("click",CallbackProxy(this,this.answerQuestion));$("#duelPlayerUser .duelQuestionContainer").css("visibility","hidden");$("#duelPlayerOther .duelQuestionContainer").css("visibility","visible");if(duelRoundIndex==0){$("#duelPlayerUser .standardReminder").hide();$("#duelPlayerOther .standardReminder").show();}}else{B="OPPONENTS_QUESTION";E=A-1;$("#duelPlayerOtherQuizArea .duelAnswerContainer td.selectable").unbind("click").removeClass("selectable");$(".duelQuestionContainer").css("visibility","visible");$("#duelPlayerOther .standardReminder").hide();}$(C.currentTarget).addClass("answerButtonSelected");this.sendEvent(PlanetoService.DUEL_ANSWER_COMMAND,{question:B,answerIndex:E});},roundSummary:function(){this.showPauseStatus({paused:false});},duelPauseOrContinue:function(){this.sendEvent(PlanetoService.PAUSE_PLAYING,($("#duelClockPauseButton").is(":visible")?true:false));},duelPause:function(){this.sendEvent(PlanetoService.PAUSE_PLAYING,true);},duelContinue:function(){this.sendEvent(PlanetoService.PAUSE_PLAYING,false);},showPauseStatus:function(A){if(A.paused){$("#duelClockContinueButton").show();$("#duelClockPauseButton, #duelClockPie, #duelClockNumber").hide();}else{$("#duelClockPauseButton, #duelClockPie, #duelClockNumber").show();$("#duelClockContinueButton").hide();}}});Planeto.Duel.Control.SHOW="Planeto.Duel.Control.SHOW";Planeto.Duel.Control.HIDE="Planeto.Duel.Control.HIDE";Planeto.Duel.Control.FRAGMENT_LOADING="Planeto.Duel.Control.FRAGMENT_LOADING";Planeto.Duel.Control.FRAGMENT_LOADED="Planeto.Duel.Control.FRAGMENT_LOADED";BasicMVC.Facade.getInstance().register(new Planeto.Duel.Control());Planeto.Duel=Planeto.Duel||{};Planeto.Duel.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Duel.View";this.timerRef=0;this.currentTime=0;this.roundTime=15000;this.currentClockStep=0;this.currentTimeLeft="";this.chi_orig_height=234;this.chi_max=2000;this.chi_user_before=this.chi_max;this.chi_other_before=this.chi_max;$("#duelGameplayCloseButton").live("click",this.localScopeFull(this.hideDuel));},eventListeners:function(){return[Planeto.Duel.Lobby.View.SHOW,PlanetoEvents.DUEL_PLAYER_UPDATED_EVENT,PlanetoEvents.DUEL_OPPONENT_UPDATED_EVENT,PlanetoEvents.DUEL_SHOW_ANSWER_ALTERNATIVES_EVENT,PlanetoEvents.DUEL_SHOW_QUESTIONS_EVENT,PlanetoEvents.DUEL_SHOW_CORRECT_ANSWER_EVENT,PlanetoEvents.DUEL_CHI_CHANGED_EVENT,PlanetoEvents.DUEL_OPPONENT_CHI_CHANGED_EVENT,PlanetoEvents.DUEL_STREAK_CHANGED_EVENT,PlanetoEvents.DUEL_OPPONENT_STREAK_CHANGED_EVENT,PlanetoEvents.DUEL_PLAYER_ANSWERED_QUESTION_EVENT,PlanetoEvents.DUEL_OPPONENT_ANSWERED_QUESTION_EVENT,PlanetoEvents.DUEL_ROUND_SUMMARY_EVENT,PlanetoEvents.DUEL_ENDED_EVENT];},eventHandlers:function(A){switch(A.name){case Planeto.Duel.Lobby.View.SHOW:this.showDuel();break;case PlanetoEvents.DUEL_PLAYER_UPDATED_EVENT:this.playerUpdateInfo("User",A.data.player);break;case PlanetoEvents.DUEL_OPPONENT_UPDATED_EVENT:this.playerUpdateInfo("Other",A.data.opponent);break;case PlanetoEvents.DUEL_SHOW_ANSWER_ALTERNATIVES_EVENT:this.showAnswerAlternatives(A.data);break;case PlanetoEvents.DUEL_SHOW_QUESTIONS_EVENT:this.showQuestions(A.data);break;case PlanetoEvents.DUEL_SHOW_CORRECT_ANSWER_EVENT:this.showCorrectAnswer();break;case PlanetoEvents.DUEL_ENDED_EVENT:this.duelEnded(A.data);break;case PlanetoEvents.DUEL_CHI_CHANGED_EVENT:this.chiChanged("User",A.data.chi);break;case PlanetoEvents.DUEL_OPPONENT_CHI_CHANGED_EVENT:this.chiChanged("Other",A.data.chi);break;case PlanetoEvents.DUEL_STREAK_CHANGED_EVENT:this.streakChanged("User",A.data.streak);break;case PlanetoEvents.DUEL_OPPONENT_STREAK_CHANGED_EVENT:this.streakChanged("Other",A.data.streak);break;case PlanetoEvents.DUEL_SCORE_MULTIPLIER_CHANGED_EVENT:this.scoreMultiplierChanged("User",A.data.scoreMultiplier);break;case PlanetoEvents.DUEL_OPPONENT_SCORE_MULTIPLIER_CHANGED_EVENT:this.scoreMultiplierChanged("Other",A.data.scoreMultiplier);
break;case PlanetoEvents.DUEL_PLAYER_ANSWERED_QUESTION_EVENT:this.playerAnsweredQuestion(A.data);break;case PlanetoEvents.DUEL_OPPONENT_ANSWERED_QUESTION_EVENT:this.opponentAnsweredQuestion(A.data);break;case PlanetoEvents.DUEL_ROUND_SUMMARY_EVENT:this.roundSummary(A.data);break;}},showDuel:function(){$("#duelGameplayContainer").modal({fixed:88});$("#chatWrapper").css("z-index",1011);},hideDuel:function(){$("#duelGameplayContainer").modalClose();$("#chatWrapper").css("z-index",1000);this.sendEvent(PlanetoService.DUEL_CLIENT_GIVES_UP);},playerUpdateInfo:function(B,A){$("#duelPlayer"+B+"Avatar img").attr("src",A.profilePicture.bigPictureUrl);$("#duelPlayer"+B+"Info .nickName").html(A.nickName);$("#duelPlayer"+B+"Info .userGold").html(A.gold);$("#duelPlayer"+B+"Info .levelPoints span").html(A.score);this.scoreMultiplierChanged(B,A.scoreMultiplier);this.streakChanged(B,A.streak);this.chiChanged(B,A.chi);},scoreMultiplierChanged:function(A,B){$("#duelPlayer"+A+"MultiplierContent").html(B);},streakChanged:function(B,A){$("#duelPlayer"+B+" .gameplayStatusArea .playerCurrentStreak").html(A);},chiChanged:function(B,A){$("#dualPlayer"+B+"EnerygValue").html(A);$("#duelPlayer"+B+"EnergyBar div").animate({height:Math.round(this.chi_orig_height*A/this.chi_max)});if(B=="User"){this.chi_user_before=A;}else{this.chi_other_before=A;}},showAnswerAlternatives:function(A){$("#duelRoundInfo").fadeOut();$("#duelPlayerUserEnergyBar div").animate({height:Math.round(this.chi_orig_height*this.chi_user_before/this.chi_max)});$("#duelPlayerOtherEnergyBar div").delay(500).animate({height:Math.round(this.chi_orig_height*this.chi_other_before/this.chi_max)});this.resetTimer(A);},showQuestions:function(A){this.resetTimer(A);},showCorrectAnswer:function(){this.closeTimer();},playerAnsweredQuestion:function(B){var E=$("#duelPlayer"+(B.question=="MY_QUESTION"?"User":"Other")+"QuizArea .duelAnswerContainer"),A=$("#duelPlayerOtherEnergyBar div.duelEnergyBar3"),C=Math.abs(B.chi);this.chi_other_before-=C;A.animate({height:Math.round(this.chi_orig_height*this.chi_other_before/this.chi_max)});if(B.correct){E.find(".answerButtonSelected").removeClass("answerButtonSelected").addClass("correctAnswer");var D=$("#templates div.correctAnswerReceivedPoints").clone(),F=A.position();D.find("div.correctAnswerReceivedPointsContent").css({left:(F.left-65)+"px",top:F.top+"px"}).html("+"+C).show().animate({top:(F.top-40)+"px"},1000,"",function(){$(this).parent().remove();}).fadeOut("slow");$("#duelPlayerOtherQuizArea").prepend(D);}else{E.find(".answerButtonSelected").removeClass("answerButtonSelected").addClass("wrongAnswer");}},opponentAnsweredQuestion:function(A){var B=Math.abs(A.chi);this.chi_user_before-=B;$("#duelPlayerUserEnergyBar div.duelEnergyBar3").animate({height:Math.round(this.chi_orig_height*this.chi_user_before/this.chi_max)});},roundSummary:function(A){duelRoundIndex=A.roundIndex;$("#roundInfoNo span").html(A.roundIndex);$("#userCorrectAnswers").html(A.player.correctAnswers);$("#userScoreEarned").html(A.player.scoreEarned);$("#userChiLost").html(A.player.chiLost);$("#opponentCorrectAnswers").html(A.opponent.correctAnswers);$("#opponentScoreEarned").html(A.opponent.scoreEarned);$("#opponentChiLost").html(A.opponent.chiLost);$("#duelRoundInfo").fadeIn();this.resetTimer(A);},resetTimer:function(A){this.currentTime=new Date();this.timeUntilNextEvent=A.timeUntilNextEvent;this.roundTime=this.timeUntilNextEvent*20;if(this.roundTime<100){this.roundTime*=3;this.plotUpdate=6;}else{this.plotUpdate=2;}this.currentTimeLeft=this.timeUntilNextEvent;$("#duelClockNumber").html(this.currentTimeLeft);this.stopClockInterval();this.timerRef=setInterval(CallbackProxy(this,this.updateTimer),this.roundTime);},stopClockInterval:function(){clearInterval(this.timerRef);},addTimeToTimer:function(A){this.closeTimer();this.roundTime+=A*20;this.timerRef=setInterval(CallbackProxy(this,this.updateTimer),this.roundTime);},onTimeChangedEvent:function(A){this.addTimeToTimer(A.timeUntilNextEvent);},updateTimer:function(){var D=new Date(),B=this.timeUntilNextEvent;
this.currentTimeLeft=Math.round(this.timeUntilNextEvent-(D.getTime()-this.currentTime.getTime())/1000);$("#duelClockNumber").html((this.currentTimeLeft>0?this.currentTimeLeft:""));this.currentClockStep=Math.round((D.getTime()-this.currentTime.getTime())/this.roundTime*this.plotUpdate);if(this.currentClockStep>=100){this.closeTimer();}else{if(B>10){var A=100,C=this.currentClockStep;Raphael.fn.pieChart=function(K){var M="#857364",L="#e57d1a",J="#cf1896",N=40+0.001,F=(N-0.001)/2,E=360-(360*K/A),I=-(E+90)*Math.PI/180,H=N+F*Math.cos(I),G=N+F*Math.sin(I);if(E<=90&&B>5){color=J;}else{if(E<=180&&B>5){color=L;}else{color=M;}}return this.path(["M",N,N,"L",N,(N-F),"A",F,F,0,+(E>180),0,H,G]).attr({fill:color,stroke:color});};$("#duelClockPie").empty();if(C>=0&&C<A){Raphael($("#duelClockPie").attr("id"),70,70).pieChart(C);}}else{$("#duelClockPie").html("");}}},closeTimer:function(){this.stopClockInterval();this.currentClockStep=0;$("#duelClockPie, #duelClockNumber").html("");},duelEnded:function(A){$("#duelGameplayContainer").modalClose();$("#chatWrapper").css("z-index",1000);$("#statusWrapper, #playerReturningPauseContent").hide();$("#duelRoundInfo").hide();var B;if(A.outcome=="VICTORY"){B=$(".duelUserBox .name").html()+" is the winner!";$(".duelUserBox .winnerStars").show();}else{if(A.outcome=="DEFEAT"){B=$(".duelOtherBox .name").html()+" is the winner!";$(".duelOtherBox .winnerStars").show();}else{B="The duel ended in a draw";}}$("#lobbyCurrentTopic").html(B);$("#duelQuestionsTotal").html(A.numberOfQuestions);$("#duelRounds").html(A.numberOfRounds);$("#userCorrect").html(A.player.correctAnswers);$("#userIncorrect").html(A.player.incorrectAnswers);$("#userTime").html(A.player.averageAnswerTime>0?A.player.averageAnswerTime.toFixed(2):"");$("#userScore").html(A.player.scoreEarned);$("#userChi").html(A.player.chiLost);$("#userStreak").html(A.player.longestStreak);$("#opponentCorrect").html(A.opponent.correctAnswers);$("#opponentIncorrect").html(A.opponent.incorrectAnswers);$("#opponentTime").html(A.opponent.averageAnswerTime>0?A.opponent.averageAnswerTime.toFixed(2):"");$("#opponentScore").html(A.opponent.scoreEarned);$("#opponentChi").html(A.opponent.chiLost);$("#opponentStreak").html(A.opponent.longestStreak);$("#duelLobby .duelBeforeGame").hide();$("#duelLobby, #duelLobby .duelAfterGame").show();this.sendEvent(Planeto.Facebook.QuizFeed.Control.PUBLISH_TO_FACEBOOK,{outcome:A.outcome,opponent:$("#duelPlayerOtherInfo .nickName").html()});}});BasicMVC.Facade.getInstance().register(new Planeto.Duel.View());Planeto.LoadingScreen=Planeto.LoadingScreen||{};Planeto.LoadingScreen.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.LoadingScreen.View";this.currentProgressValue=0;this.loadingArea=$("#loadingArea");this.connectingScreenContent=$("#connectingScreen p");this.connectingProgress=$("#connectingScreen > div > div");},eventListeners:function(){return[PlanetoService.CONNECT,Planeto.Facebook.Control.CONNECT,Planeto.Facebook.Control.CONNECTED,PlanetoService.FACEBOOK_LOGIN,PlanetoEvents.LOGIN_RESPONSE,PlanetoService.NEW_QUIZ_SESSION,PlanetoEvents.NEW_QUIZ_RESPONSE,PlanetoService.NEW_UCQ_SESSION,PlanetoEvents.NEW_UCQSESSION_RESPONSE,PlanetoEvents.QUESTION_SET_LOADING_EVENT,PlanetoService.OPEN_ID_LOGIN_REQUEST];},eventHandlers:function(A){switch(A.name){case PlanetoService.CONNECT:this.showLoadingScreen(A.data);this.updateLoadingProgressBar(20);break;case Planeto.Facebook.Control.CONNECT:this.updateLoadingScreenText("Connecting to Facebook...");this.updateLoadingProgressBar(20);break;case PlanetoService.OPEN_ID_LOGIN_REQUEST:this.updateLoadingScreenText("Connecting with Google OpenID...");this.updateLoadingProgressBar(20);break;case Planeto.Facebook.Control.CONNECTED:this.updateLoadingScreenText("Logging in to Planeto...");this.updateLoadingProgressBar(20);break;case PlanetoEvents.LOGIN_RESPONSE:this.updateLoadingScreenText("Login complete. Loading play session...");this.updateLoadingProgressBar(10);break;case PlanetoService.NEW_QUIZ_SESSION:this.updateLoadingScreenText("Asking Planeto for a new quiz session...");
this.updateLoadingProgressBar(20);break;case PlanetoService.NEW_UCQ_SESSION:this.updateLoadingScreenText("Asking Planeto for a new qreator session...");this.updateLoadingProgressBar(20);break;case PlanetoService.FACEBOOK_LOGIN:$("#dialogBetaUser").modalClose();this.loadingArea.show();break;case PlanetoEvents.NEW_QUIZ_RESPONSE:case PlanetoEvents.NEW_UCQSESSION_RESPONSE:this.loadingArea.hide();break;case PlanetoEvents.QUESTION_SET_LOADING_EVENT:this.questionSetLoading(A.data);break;}},showLoadingScreen:function(){this.updateLoadingScreenText("Connecting to Planeto game server...");this.loadingArea.show();},updateLoadingProgressBar:function(A){var B;this.currentProgressValue+=A;B=this.currentProgressValue/100;B=B>1?1:B;this.connectingProgress.animate({width:Math.round(B*199)},500);},updateLoadingScreenText:function(A){this.connectingScreenContent.html(A);},questionSetLoading:function(A){var B=$("#loadingArea");B.addClass("questionset");B.find("img").attr("src",getImageUrl("QS",A.icon,"plain"));B.find(".questionset").encodeHtml(A.name);B.find(".message").hide();}});PlanetoEvents.QUESTION_SET_LOADING_EVENT="PlanetoEvents.QUESTION_SET_LOADING_EVENT";BasicMVC.Facade.getInstance().register(new Planeto.LoadingScreen.View());Planeto.Payment=Planeto.Payment||{};Planeto.Payment.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Payment.Control";},eventListeners:function(){return[PlanetoEvents.INITIATE_SOCIAL_GOLD_PURCHASE_RESPONSE];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.INITIATE_SOCIAL_GOLD_PURCHASE_RESPONSE:this.setupIframe(A.data);break;}},setupIframe:function(A){$("#dialogSocialGoldDiscontinued").modal();}});BasicMVC.Facade.getInstance().register(new Planeto.Payment.Control());Planeto.Payment=Planeto.Payment||{};Planeto.Payment.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Payment.View";$("#dialogSocialGold > img").live("click",this.localScopeFull(this.closeGetMoreGold));},eventListeners:function(){return[Planeto.Payment.View.OPEN_IFRAME];},eventHandlers:function(A){switch(A.name){case Planeto.Payment.View.OPEN_IFRAME:this.openIframe(A.data);break;}},openIframe:function(A){$("#dialogSocialGold").modal();},closeGetMoreGold:function(A){$("#dialogSocialGold").modalClose();this.sendEvent(RespiteControl.CONTINUE);}});Planeto.Payment.View.OPEN_IFRAME="Planeto.Payment.View.OPEN_IFRAME";BasicMVC.Facade.getInstance().register(new Planeto.Payment.View());Planeto.UserProfile=Planeto.UserProfile||{};Planeto.UserProfile.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.UserProfile.Control";$("#userProfile ul li").live("click",this.localScopeFull(this.showUserProfileTab));},showUserProfileTab:function(B){var A=$(B.target);if(A.is("img")){A=A.parent();}A.addClass("selected").siblings("li").removeClass("selected");A.parent("ul").siblings("."+A.attr("rel")).show().siblings("div:not(.profileName)").hide();}});BasicMVC.Facade.getInstance().register(new Planeto.UserProfile.Control());Planeto.IgnoreUser=Planeto.IgnoreUser||{};Planeto.IgnoreUser.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.IgnoreUser.Control";$("#friendMenuHolder:not(.isPlayer) #friendMenuItemIgnore").live("click",this.localScopeFull(this.ignoreUser));$("#friendMenuHolder:not(.isPlayer) #friendMenuItemStopIgnoring").live("click",this.localScopeFull(this.unIgnoreUser));},ignoreUser:function(A){this.sendEvent(PlanetoService.IGNORE_USER_REQUEST,$("#friendMenuHolder").data("friendId"));},unIgnoreUser:function(A){this.sendEvent(PlanetoService.STOP_IGNORING_USER_REQUEST,$("#friendMenuHolder").data("friendId"));}});BasicMVC.Facade.getInstance().register(new Planeto.IgnoreUser.Control());Planeto.UserProfile=Planeto.UserProfile||{};Planeto.UserProfile.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.UserProfile.View";$("#friendMenuItemProfile").live("click",this.localScopeFull(this.requestUserProfile));$("#userProfile img.btnClose").live("click",function(){$(this).parent("div").hide();
});},eventListeners:function(){return[PlanetoEvents.VIEW_USER_PROFILE_RESPONSE];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.VIEW_USER_PROFILE_RESPONSE:this.showUserProfile(A.data);break;}},requestUserProfile:function(A){this.sendEvent(PlanetoService.VIEW_USER_PROFILE,{id:$("#friendMenuHolder").data("friendId")});},setPlanetoItemTooltip:function(A,B){planetoItemTooltip(A,B,0);A.find("div.tooltipRequiredLevel").removeClass("red").siblings(".tooltipWrongLevel").hide();},showUserProfile:function(A){var L=$("#userProfile");L.hide();L.find(".profileName").html(A.playerStats.name);L.find(".profileLevel img").css("background-position","0 "+((A.playerStats.level.value*-27)-1)+"px");L.find(".profileLevel span").html(A.playerStats.score+" points");L.find(".profileTimeToAns span").html(A.playerStats.timeToAns.toFixed(2)+" s/question");L.find(".profileStreak span").html(A.playerStats.streak+" streak");L.find(".profileNbrQ span").html(A.playerStats.nbrQ+" answered questions");if(A.playerStats.location){var J=A.playerStats.location.country.name,K=A.playerStats.location.city.name,I=A.playerStats.location.country.isoCode.toLowerCase();if(J=="Unspecified"){J="Unknown country";}if(K=="Unspecified"){K="Unknown city";}K=K.split(",")[0];L.find(".profileLocation span").html(J);L.find(".profileLocation img").addClass("spr_flag_"+I);L.find(".profileTeam span").html(K);}L.find(".attireSlots > div").empty();for(var M=0;M<A.attire.items.length;M++){var Q=selector_templates_planetoItem.clone(),E=A.attire.items[M],G=E.id,H=E.wearableSlot,R=E.type,D=E.iconId,N=E.name;Q.addClass("planetoItem-"+G);var B=L.find(".userProfileAvatar ."+H);B.html(Q).find("img.planetoItemImage").addClass("spr_"+R+"s spr_"+R+"_"+D);if(typeof E.ttlDescription!="undefined"&&E.ttlDescription!=""){B.find("div.remove").html(E.ttlDescription).show();}this.setPlanetoItemTooltip(B,E);B.find(".planetoItemIcon").toolTiper();}L.find(".planetoItemImage").toolTiper();var P="",S="",O=$("#templates > div.medalSlot");for(var M=0;M<A.medals.length;M++){var F=A.medals[M],C;C="<div><img src='"+resource_null_gif+"' class='planetoMedalIcon spr_medals_42 spr_medal_42_"+F.medalId+" medalReceived'/><div class='tooltip'>"+F.description+"</div><span>"+F.name+"</span></div>";C+="";if(F.medalCount>0){P+=C;}else{S+=C;}}L.find(".medalsEarned > div").html(P);L.find(".medalsLeft > div").html(S);L.find(".planetoMedalIcon").toolTiper();L.show();}});BasicMVC.Facade.getInstance().register(new Planeto.UserProfile.View());Planeto.UserSettings=Planeto.UserSettings||{};Planeto.UserSettings.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.UserSettings.Control";},eventListeners:function(){return[Planeto.UserSettings.Control.SHOW_USER_SETTINGS];},eventHandlers:function(A){switch(A.name){case Planeto.UserSettings.Control.SHOW_USER_SETTINGS:this.showUserSettings();break;}},showUserSettings:function(){this.sendEvent(PlanetoService.GET_USER_SETTINGS);},hideLeaderboard:function(){this.sendEvent(Planeto.UserSettings.View.HIDE);this.sendEvent(RespiteControl.CONTINUE);}});Planeto.UserSettings.Control.SET_FIRSTTIME="Planeto.UserSettings.Control.SET_FIRSTTIME";Planeto.UserSettings.Control.HIDE="Planeto.UserSettings.Control.HIDE";Planeto.UserSettings.Control.SHOW_USER_SETTINGS="Planeto.UserSettings.Control.SHOW_USER_SETTINGS";Planeto.UserSettings.Control.SHOW_RESPITE="Planeto.UserSettings.Control.SHOW_RESPITE";BasicMVC.Facade.getInstance().register(new Planeto.UserSettings.Control());Planeto.UserSettings=Planeto.UserSettings||{};Planeto.UserSettings.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.UserSettings.View";this.timeout=null;this.prev="";this.active=0;this.cache={};this.keyb=false;this.hasFocus=false;this.lastKeyPressCode=null;this.firstTime=false;this.listHover=false;this.selectCountry=$("#userSettingsCountry select");this.inputCity=$("#userSettingsCountry input");this.selectCountry.live("change",function(){$("#userSettingsCountry input").val("");});$("#dialogUserSettings .closeModal").live("click",this.localScopeFull(this.closeUserSettings));
$("#dialogUserSettingsSaveButton").live("click",this.localScopeFull(this.saveUserSettings));$("#dialogUserSettings .showUserSettings").show();$("#dialogUserSettings").removeClass("dialogDailyQuiz");$("#dialogUserSettings .showDailyQuiz").hide();},eventListeners:function(){return[PlanetoEvents.GET_USER_SETTINGS_RESPONSE,PlanetoEvents.GET_MATCHING_CITIES_RESPONSE,Planeto.UserSettings.Control.SET_FIRSTTIME];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.GET_USER_SETTINGS_RESPONSE:this.showUserSettings(A.data);break;case PlanetoEvents.GET_MATCHING_CITIES_RESPONSE:this.displayMatchingCities(A.data);break;case Planeto.UserSettings.Control.SET_FIRSTTIME:this.firstTime=A.data.firstTime;break;}},showUserSettings:function(C){var A,B="",D="";if(C.email.email=="temporary@test.com"){C.email.email="";}if($("#dialogUserSettings").hasClass("dialogDailyQuiz")&&C.email.email!=""){this.sendEvent(RespiteControl.CONTINUE);}else{for(A=0;A<C.availableLanguages.length;A++){B+="<option value='"+C.availableLanguages[A].id+"'";if(C.availableLanguages[A].id==C.currentQuestionLanguage.id){B+=" selected='selected'";}B+=">"+C.availableLanguages[A].name+"</option>";}$("#userSettingsQuestionChannel select").html(B);D+="<option value=''>Select country</option>";for(A=0;A<C.countries.length;A++){if(C.countries[A].isoCode!="??"){D+="<option value='"+C.countries[A].isoCode+"'";if(C.countries[A].isoCode==C.currentLocation.country.isoCode){D+=" selected='selected'";}D+=">"+C.countries[A].name+"</option>";}}this.selectCountry.html(D);this.inputCity.val(C.currentLocation.city.name);if(C.currentLocation.city.name.toLowerCase().indexOf("unknown")!=-1||C.currentLocation.city.name.toLowerCase().indexOf("unspecified")!=-1){this.inputCity.val("");}$("#userSettingsEmail input[type=text]").val(C.email.email);$("#userSettingsSubscription input[type=radio][value="+C.emailSettings.wantQuestionSetEmail+"]").check();this.inputCity.unbind("keydown").bind("keydown",CallbackProxy(this,this.keyPressHandler));this.inputCity.unbind("blur").bind("blur",CallbackProxy(this,this.hideCityList));$("#userSettingsCountry ul").hide().unbind("mouseover").unbind("mouseout").bind("mouseover",CallbackProxy(this,function(){this.listHover=true;})).bind("mouseout",CallbackProxy(this,function(){this.listHover=false;}));$("#dialogUserSettings").modal();}},saveUserSettings:function(){var H=$("#dialogUserSettingsSelectSiteLanguage").val(),B=$("#userSettingsQuestionChannel select").val(),J=this.selectCountry.val(),D=this.inputCity.val(),F=$("#userSettingsEmail input[type=text]").val(),E=$("#userSettingsSubscription input[type=radio]:checked").val(),C=true,I=true,A=true,G=true;this.sendEvent(PlanetoService.SET_USER_SETTINGS,{currentSiteLanguageId:H,currentQuestionLanguageId:B,countryId:J,cityId:D,email:F,wantsQuestionSetEmail:E,wantsWeeklyNewsLetter:C,wantsUpdateAboutFriends:I,wantsGameUpdates:A,wantsPopularCommunityActivities:G});this.closeUserSettings();},closeUserSettings:function(){$("#dialogUserSettings").modalClose();if(this.firstTime||location.href.indexOf("settings")!=-1){this.firstTime=false;this.sendEvent(PlanetoService.NEW_QUIZ_SESSION);}else{this.sendEvent(RespiteControl.CONTINUE);}},hideCityList:function(){if(!this.listHover){$("#userSettingsCountry ul").hide();}},getMatchingCities:function(){var A=this.inputCity.val(),B=this.selectCountry.val();if(A.length>0){this.sendEvent(PlanetoService.GET_MATCHING_CITIES,{countryIso:B,partialName:A});}},displayMatchingCities:function(A){var C=A.cityNames.slice(0,8),B="";for(i=0;i<C.length;i++){if(C[i].toLowerCase()!="unknown city"){B+="<li";if(i==0){B+=" class='selected'";}B+=">"+C[i]+"</li>";}}$("#userSettingsCountry ul").html(B).show();$("#userSettingsCountry ul li").bind("mouseover",function(){$(this).addClass("selected").siblings().removeClass("selected");}).bind("click",CallbackProxy(this,this.selectCurrent));},keyPressHandler:function(A){this.lastKeyPressCode=A.keyCode;switch(A.keyCode){case 38:A.preventDefault();this.moveSelect(-1);break;
case 40:A.preventDefault();this.moveSelect(1);break;case 9:case 13:if(this.selectCurrent()){this.inputCity.get(0).blur();A.preventDefault();}break;default:this.active=0;if(this.timeout){clearTimeout(this.timeout);}this.timeout=setTimeout(CallbackProxy(this,this.getMatchingCities),200);break;}},moveSelect:function(B){var A=$("#userSettingsCountry ul li");if(!A){return ;}this.active+=B;if(this.active<0){this.active=0;}else{if(this.active>=A.size()){this.active=A.size()-1;}}A.removeClass("selected");$(A[this.active]).addClass("selected");},selectCurrent:function(){var A=$("#userSettingsCountry ul li.selected"),B;if(A.length==0){A=$("#userSettingsCountry ul li:first");}B=A.html();if(B){this.inputCity.val(B);}$("#userSettingsCountry ul").hide();},selectClicked:function(B){var A=$(B),C=A.html();if(C){this.inputCity.val(C);}$("#userSettingsCountry ul").hide();}});BasicMVC.Facade.getInstance().register(new Planeto.UserSettings.View());Planeto.Tutorial=Planeto.Tutorial||{};Planeto.Tutorial.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Tutorial.View";this.fadeSpeed=300;this.questionInterval=1;this.tutorialResponse="";this.boolScore=false;this.boolUpdateFeed=false;this.boolMedals=false;this.boolLanguage=false;this.boolPause=false;this.boolTopic=false;this.boolFriends=false;this.boolInvites=false;this.boolStreak=false;this.boolDailyQuiz=false;this.boolActionBar=false;this.boolGold=false;this.questionSetQuestions=0;this.tutorialWrapper=$("#tutorialWrapper");$("#siteTop").css({top:"-140px"});},eventListeners:function(){return[PlanetoEvents.NEW_QUIZ_RESPONSE,PlanetoService.START_PLAYING,PlanetoEvents.NEW_QUIZ_EVENT,PlanetoEvents.END_QUIZ_EVENT,PlanetoEvents.PAUSE_EVENT,Planeto.Tutorial.View.FIRST_TUTORIAL_EVENT,PlanetoEvents.META_DATA_CHANGED_EVENT,PlanetoEvents.QUESTION_SET_STARTED_EVENT,PlanetoEvents.QUESTION_SET_STOPPED_EVENT,PlanetoEvents.LINK_BONUS_WILL_BE_RECEIVED_EVENT,PlanetoEvents.SUBMIT_SELF_QUIZ_ANSWERS_RESPONSE,PlanetoService.START_QUESTION_SET,PlanetoService.START_SELF_QUIZ,PlanetoEvents.SHOW_LOGO,PlanetoEvents.WAVE_MESSAGE_RECEIVED_EVENT,PlanetoService.REJECT_WAVE_REQUEST,PlanetoEvents.LOGIN_RESPONSE];},eventHandlers:function(A){switch(A.name){case PlanetoService.START_PLAYING:this.showLogo();break;case PlanetoEvents.SHOW_LOGO:this.showLogo();break;case PlanetoEvents.NEW_QUIZ_RESPONSE:this.newQuiz(A.data);break;case PlanetoEvents.NEW_QUIZ_EVENT:this.sendEvent(PlanetoService.SET_META_DATA,{key:"tutorial_questionsetanswers",value:this.questionSetQuestions});break;case PlanetoEvents.END_QUIZ_EVENT:this.onEndQuiz(A.data);break;case PlanetoEvents.PAUSE_EVENT:this.onPause(A.data);break;case Planeto.Tutorial.View.FIRST_TUTORIAL_EVENT:this.showFirstTutorial();break;case PlanetoEvents.META_DATA_CHANGED_EVENT:this.metaDataChanged(A.data);break;case PlanetoEvents.LOGIN_RESPONSE:this.metaDataRefreshed(A.data.account.metaData);break;case PlanetoEvents.QUESTION_SET_STARTED_EVENT:case PlanetoService.START_QUESTION_SET:case PlanetoService.START_SELF_QUIZ:ignoreTutorial=true;break;case PlanetoEvents.QUESTION_SET_STOPPED_EVENT:case PlanetoEvents.SUBMIT_SELF_QUIZ_ANSWERS_RESPONSE:ignoreTutorial=false;break;case PlanetoEvents.LINK_BONUS_WILL_BE_RECEIVED_EVENT:switch(A.data.linkBonusType){case"QUESTIONSET":case"SELF_QUIZ":ignoreTutorial=true;qsOrSqPlayed=true;break;}break;case PlanetoEvents.WAVE_MESSAGE_RECEIVED_EVENT:ignoreTutorial=true;break;case PlanetoService.REJECT_WAVE_REQUEST:ignoreTutorial=false;break;}},metaDataChanged:function(A){switch(A.key){case"tutorial_done":tutorial_done=A.value;break;case"tutorial_questionsetanswers":this.questionSetQuestions=A.value;break;}},metaDataRefreshed:function(A){for(var B=0;B<A.length;B++){this.metaDataChanged(A[B]);}},pauseAndPrepare:function(A){this.tutorialResponse=A;this.sendEvent(PlanetoService.PAUSE_PLAYING,true);$("#gamePausOverlay h2").html("Paused for tutorial...");$("#statusWrapper").css("visibility","hidden");},onPause:function(A){if(A.paused==true&&this.tutorialResponse!=""){this.showTutorial(this.tutorialResponse);
this.tutorialResponse="";}},showTutorial:function(A){if(!ignoreTutorial){$("#statusWrapper").css("visibility","hidden");if(A.select){A.select.fadeIn(this.fadeSpeed);}this.tutorialWrapper.find(".tutorialContent > span").html(A.header);this.tutorialWrapper.find(".tutorialContent > p").html(A.text);this.tutorialWrapper.find(".tutorialCornerTL, .tutorialCornerTR, .tutorialCornerBR, .tutorialCornerBL").hide();if(A.arrow){this.tutorialWrapper.find(".tutorialCorner"+A.arrow).show();}this.tutorialWrapper.css({top:A.top+"px",left:A.left+"px"}).fadeIn(this.fadeSpeed);this.tutorialWrapper.find(".spr_button_small_orange").unbind("click").bind("click",this.localScopeFull(this.closeTutorial,A.unpause,A.after));$("#questionClockContainer").unbind("click").bind("click",this.localScopeFull(this.closeTutorial,A.unpause,A.after));}},closeTutorial:function(B,A,D,C){this.tutorialWrapper.hide();if(D==true){this.sendEvent(PlanetoService.PAUSE_PLAYING,false);this.sendEvent(StatusView.HIDE_MESSAGE);setTimeout(function(){$("#gamePausOverlay h2").html("Game Paused");$("#statusWrapper").css("visibility","visible");},2000);if(totalQuestions==0){this.sendEvent(PlanetoService.START_PLAYING);}}else{this.showTutorial(C);}},hideTabs:function(){$("#column3 li").removeClass("active");$("#tabContentContainer .tabContent").hide();},newQuiz:function(A){if(location.href.indexOf("resettutorial")!=-1){totalQuestions=0;tutorial_done=0;this.sendEvent(PlanetoService.SET_META_DATA,{key:"tutorial_done",value:0});}else{if(location.href.indexOf("resetinventory")!=-1){totalQuestions=this.questionInterval*12;tutorial_done=1;this.sendEvent(PlanetoService.SET_META_DATA,{key:"tutorial_done",value:1});}else{totalQuestions=A.totalQuestions-this.questionSetQuestions;}}if(totalQuestions<this.questionInterval*2){$("#ingameLevelBox, #levelProgressBubbleContainer").hide();}if(totalQuestions<this.questionInterval*3){$("#gameplayStatusArea .playerCurrentInfoBox.multiplier, #gameplayStatusArea .playerCurrentInfoBox.streak").hide();}if(totalQuestions<this.questionInterval*5){$("#column3, #tab_1, #tabContent_1, #tabContent_1_1").hide();}if(totalQuestions<this.questionInterval*7){$("#getMoreGold").hide();}if(totalQuestions<this.questionInterval*8){$("#tab_2, #tabContent_2, #tabContent_2_3, #messageContainer").hide();}if(totalQuestions<this.questionInterval*9){$("#tabContent_1, #tabContent_1_2").hide();}if(tutorial_done<=2){$("#attireSlots, #avatarTabs").hide();}},onEndQuiz:function(A){if(ignoreTutorial){this.questionSetQuestions++;}else{totalQuestions++;if(this.boolPause==false&&totalQuestions==this.questionInterval*1){this.boolPause=true;this.showPause();}else{if(this.boolScore==false&&totalQuestions==this.questionInterval*2){this.boolScore=true;this.showScore();}else{if(this.boolStreak==false&&totalQuestions==this.questionInterval*3){this.boolStreak=true;this.showStreakNMultiplier();}else{if(this.boolDailyQuiz==false&&totalQuestions==this.questionInterval*4){this.boolDailyQuiz=true;this.showDailyQuiz();}else{if(this.boolUpdateFeed==false&&totalQuestions==this.questionInterval*5){this.boolUpdateFeed=true;this.showUpdateFeed();}else{if(this.boolActionBar==false&&totalQuestions==this.questionInterval*6){this.boolActionBar=true;this.showActionBar();}else{if(this.boolGold==false&&totalQuestions==this.questionInterval*7){this.boolGold=true;this.showGold();}else{if(this.boolMedals==false&&totalQuestions==this.questionInterval*8){this.boolMedals=true;this.showMedals();}else{if(this.boolFriends==false&&totalQuestions==this.questionInterval*9){this.boolFriends=true;this.showFriends();}else{if(this.boolFriends==true&&totalQuestions==this.questionInterval*12){this.sendEvent(PlanetoService.SET_META_DATA,{key:"tutorial_done",value:1});}else{if(totalQuestions>this.questionInterval*12&&tutorial_done==0){this.sendEvent(PlanetoService.SET_META_DATA,{key:"tutorial_done",value:4});}else{if(tutorial_done==3){this.showLastTutorial();}}}}}}}}}}}}if(A.drop&&A.drop.items.length>0){this.showDroppedItems();}}$("#questionsAnswered span").html(totalQuestions+", "+this.questionSetQuestions+" ("+tutorial_done+")");
},showLogo:function(){$("#siteTop").animate({top:"0"},2000);},showFirstTutorial:function(){this.showLogo();$("#answerContainer").hide();this.showTutorial({left:352,top:230,header:texts.tutorial_welcome_header,text:texts.tutorial_welcome_text,unpause:true});},showPause:function(){this.pauseAndPrepare({left:338,top:136,arrow:"TL",header:texts.tutorial_time_header,text:texts.tutorial_time_text,unpause:true});},showScore:function(A){this.pauseAndPrepare({select:$("#ingameLevelBox, #levelProgressBubbleContainer"),left:209,top:306,arrow:"BL",header:texts.tutorial_level_header,text:texts.tutorial_level_text,unpause:true});},showStreakNMultiplier:function(){this.pauseAndPrepare({select:$("#gameplayStatusArea .playerCurrentInfoBox.streak"),left:357,top:136,arrow:"TR",header:texts.tutorial_streak_header,text:texts.tutorial_streak_text,unpause:true});},showDailyQuiz:function(){$("#dialogUserSettings .showUserSettings").hide();$("#dialogUserSettings").addClass("dialogDailyQuiz");$("#dialogUserSettings .showDailyQuiz").show();this.sendEvent(RespiteControl.SHOW_USER_SETTINGS);},showUpdateFeed:function(){this.hideTabs();$("#tab_1, #tab_1_1").addClass("active");this.pauseAndPrepare({select:$("#column3, #tab_1, #tabContent_1, #tabContent_1_1"),left:533,top:240,arrow:"TR",header:texts.tutorial_friends_header,text:texts.tutorial_friends_text,unpause:true});},showActionBar:function(){this.pauseAndPrepare({select:$("#actionBar"),left:341,top:330,arrow:"BL",header:texts.tutorial_actionbar_header,text:texts.tutorial_actionbar_text,unpause:true});},showGold:function(){this.pauseAndPrepare({select:$("#getMoreGold"),left:211,top:365,arrow:"BL",header:texts.tutorial_gold_header,text:texts.tutorial_gold_text,unpause:true});},showMedals:function(){this.hideTabs();$("#tab_2, #tab_2_3").addClass("active");this.pauseAndPrepare({select:$("#tab_2, #tabContent_2, #tabContent_2_3, #messageContainer"),left:533,top:265,arrow:"TR",header:texts.tutorial_medals_header,text:texts.tutorial_medals_text,unpause:true});},showFriends:function(){this.hideTabs();$("#tab_1, #tab_1_2").addClass("active");this.pauseAndPrepare({select:$("#tabContent_1, #tabContent_1_2"),left:533,top:265,arrow:"TR",header:texts.tutorial_friendslist_header,text:texts.tutorial_friendslist_text,unpause:false,after:{left:533,top:95,arrow:"BR",header:texts.tutorial_clickfriend_header,text:texts.tutorial_clickfriend_text,unpause:true}});},showDroppedItems:function(){if(tutorial_done==1){$("#avatarTab2").addClass("active").siblings("img").removeClass("active");$("#attireSlots").show();$("#tab_2, #tab_2_2").addClass("active").siblings("li").removeClass("active");$("#tabContent_2, #tabContent_2_2").show().siblings(".tabContent").hide();this.pauseAndPrepare({left:430,top:242,arrow:"BR",header:texts.tutorial_treasure_header,text:texts.tutorial_treasure_text,unpause:false,after:{left:201,top:278,arrow:"TL",header:texts.tutorial_attire_header,text:texts.tutorial_attire_text,unpause:false,after:{left:538,top:329,arrow:"BL",header:texts.tutorial_actioncards_header,text:texts.tutorial_actioncards_text,unpause:false,after:{left:538,top:284,arrow:"TR",header:texts.tutorial_inventory_header,text:texts.tutorial_inventory_text,unpause:true}}}});this.sendEvent(PlanetoService.SET_META_DATA,{key:"tutorial_done",value:3});}},showLastTutorial:function(){this.pauseAndPrepare({left:352,top:230,header:texts.tutorial_enjoy_header,text:texts.tutorial_enjoy_text,unpause:true});this.sendEvent(PlanetoService.SET_META_DATA,{key:"tutorial_done",value:4});}});Planeto.Tutorial.View.FIRST_TUTORIAL_EVENT="Planeto.Tutorial.View.FIRST_TUTORIAL_EVENT";PlanetoEvents.SHOW_LOGO="PlanetoEvents.SHOW_LOGO";BasicMVC.Facade.getInstance().register(new Planeto.Tutorial.View());Planeto.Team=Planeto.Team||{};Planeto.Team.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Team.View";this.goldCost="";this.maxDescriptionLength="";this.teams="";this.teamId="";$("#dialogCreateTeam .closeModal, #dialogDisbandTeam .closeModal, #dialogLeaveTeam .closeModal, #dialogKickPlayer .closeModal, #dialogInvitePlayer .closeModal, #dialogKickedFromTeam .closeModal, #dialogDisbandedTeam .closeModal").live("click",this.localScopeFull(this.closeModal));
$("#tab_1_4:not(.active)").live("click",this.localScopeFull(this.getTeamListRequest));$("#createTeam").live("click",this.localScopeFull(this.initiateCreateTeam));$("#dialogCreateTeam .spr_button_orange:not(.disabledButton)").live("click",this.localScopeFull(this.submitTeamCreation));$("#dialogCreateTeam textarea").live("keyup",this.localScopeFull(this.limitTextarea));$("#teamListContainer .nthRow").live("click",this.localScopeFull(this.teamMenuOver));$("#teamMenuHolder li").live("click",this.localScopeFull(this.teamMenuClick));$("#dialogLeaveTeam .spr_button_orange").live("click",this.localScopeFull(this.teamLeave));$("#dialogDisbandTeam .spr_button_orange").live("click",this.localScopeFull(this.teamDisband));$("#dialogKickPlayer .spr_button_orange").live("click",this.localScopeFull(this.teamKickPlayer));$("#dialogInvitePlayer .spr_button_orange").live("click",this.localScopeFull(this.teamInvitePlayer));$("#friendMenuItemKick").live("click",this.localScopeFull(this.teamKick));$("#friendMenuItemInvite").live("click",this.localScopeFull(this.teamInvite));$("#dialogTeamInvitation .spr_button_grey, #dialogTeamInvitation .spr_button_orange").live("click",this.localScopeFull(this.acceptInvitation));$("#teamInfo img.btnClose").live("click",function(){$(this).parent("div").hide();});$("#createTeamName input").live("focusout",this.localScopeFull(this.isTeamNameAvailable));},eventListeners:function(){return[PlanetoEvents.GET_TEAMS_LIST_RESPONSE,PlanetoEvents.INITIATE_CREATE_TEAM_RESPONSE,PlanetoEvents.CREATE_TEAM_RESPONSE,PlanetoEvents.GET_TEAM_MEMBERS_RESPONSE,PlanetoEvents.DISBAND_TEAM_RESPONSE,PlanetoEvents.INVITE_TO_TEAM_RESPONSE,RespiteControl.TEAM_INVITATION_RESPONSE,PlanetoEvents.KICK_PLAYER_FROM_TEAM_RESPONSE,PlanetoEvents.TEAM_MEMBER_LEFT_EVENT,PlanetoEvents.TEAM_DISBANDED_EVENT,PlanetoEvents.GET_TEAM_INFO_RESPONSE,PlanetoEvents.KICKED_FROM_TEAM_EVENT,PlanetoEvents.IS_TEAM_NAME_AVAILABLE_RESPONSE,PlanetoEvents.LEFT_TEAM_RESPONSE];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.GET_TEAMS_LIST_RESPONSE:this.getTeamList(A.data);break;case PlanetoEvents.INITIATE_CREATE_TEAM_RESPONSE:this.createTeam(A.data);break;case PlanetoEvents.CREATE_TEAM_RESPONSE:this.createTeamResponse(A.data);break;case PlanetoEvents.GET_TEAM_MEMBERS_RESPONSE:this.getTeamMembers(A.data);break;case PlanetoEvents.LEFT_TEAM_RESPONSE:this.leftTeamResponse(A.data);break;case PlanetoEvents.DISBAND_TEAM_RESPONSE:this.disbandTeamResponse(A.data);break;case PlanetoEvents.INVITE_TO_TEAM_RESPONSE:this.inviteToTeam(A.data);break;case RespiteControl.TEAM_INVITATION_RESPONSE:this.teamInvitation(A.data);break;case PlanetoEvents.KICK_PLAYER_FROM_TEAM_RESPONSE:this.kickPlayerFromTeam(A.data);break;case PlanetoEvents.GET_TEAM_INFO_RESPONSE:this.getTeamInfo(A.data);break;case PlanetoEvents.TEAM_MEMBER_LEFT_EVENT:case PlanetoEvents.PLAYER_JOINED_TEAM_EVENT:this.teamListChanged(A.data);break;case PlanetoEvents.TEAM_DISBANDED_EVENT:this.teamDisbanded(A.data);break;case PlanetoEvents.KICKED_FROM_TEAM_EVENT:this.kickedFromTeam(A.data);break;case PlanetoEvents.IS_TEAM_NAME_AVAILABLE_RESPONSE:this.isTeamNameAvailableResponse(A.data);break;}},getTeamListRequest:function(A){this.sendEvent(PlanetoService.GET_TEAMS_LIST);},teamDisbanded:function(A){$("#dialogDisbandedTeam .teamName").html(A.teamName);$("#dialogDisbandedTeam").modal();this.getTeamListRequest();},kickedFromTeam:function(A){$("#dialogKickedFromTeam .teamName").html(A.team.type+" "+A.team.teamName);$("#dialogKickedFromTeam").modal();this.getTeamListRequest();},isTeamNameAvailable:function(){this.sendEvent(PlanetoService.IS_TEAM_NAME_AVAILABLE,$("#createTeamName input").val());},isTeamNameAvailableResponse:function(A){if(A.available==true){$("#dialogCreateTeam .error").hide();}else{$("#dialogCreateTeam .error").html("The name "+A.name+" is not available").show();}},getTeamInfo:function(A){$("#teamInfo").hide();var C=new Date(A.teamInfo.creationDate),B=C.getFullYear()+"-"+(C.getMonth()<10?"0":"")+C.getMonth()+"-"+(C.getDate()<10?"0":"")+C.getDate();
$("#teamInfo .teamName").html(A.teamInfo.name);$("#teamInfo .teamLeader span").html(A.teamInfo.leader);$("#teamInfo .teamMembers span").html(A.teamInfo.nbrOfMembers+" member"+(A.teamInfo.nbrOfMembers>1?"s":""));$("#teamInfo .teamCreated span").html(B);if(A.teamInfo.slogan!=""){$("#teamInfo .teamSlogan").show().find("span").html(A.teamInfo.slogan);}else{$("#teamInfo .teamSlogan").hide();}if(A.teamInfo.description!=""){$("#teamInfo .teamDescription").show().find("span").html(A.teamInfo.description);}else{$("#teamInfo .teamDescription").hide();}$("#teamInfo .teamLeader img, #teamInfo .teamCreated img").toolTiper();$("#teamInfo").show();},leftTeamResponse:function(A){this.getTeamListRequest();},disbandTeamResponse:function(A){this.getTeamListRequest();},getTeamList:function(C){var F=C.teams.length;if(F==0){$("#teamListContainer").hide();$("#teamInfoContainer").show();}else{this.teams=C.teams;if(C.primary){var G=C.primary.teamId;}$("#teamInfoContainer").hide();var E=$("#templates ul.teamList").clone(),B=E.clone().empty(),D=E.children("li").clone();for(i=0;i<C.teams.length;i++){var A=D.clone().attr({id:"teamId-"+C.teams[i].teamId,rel:C.teams[i].teamId});if(C.teams[i].teamId==G){A.addClass("isPrimary");}if(C.teams[i].leader==false){A.addClass("isNotTeamLeader");}A.children("img.team_type").addClass("team_"+C.teams[i].type.toLowerCase()).after("<div class='tooltip'><div class='tooltipText'>"+C.teams[i].type+(C.teams[i].teamId==G?" (Primary)":"")+"</div></div>");A.children("h2").html(C.teams[i].teamName+" ("+C.teams[i].nbrOfMembers+")");B.append(A);}$("#teamListContainer").html(B).show();$("img.team_type, img.team_leader").toolTiper();}},getTeamMembers:function(B){var E=$("#templates ul.teamList").clone(),I=E.find("ul > li").clone(),C=B.members.length,F="",A=$("#teamId-"+B.teamId+" ul"),K=B.leader.identity;A.html("");for(var D=0;D<C;D++){var J=B.members[D].identity,G=I.clone().addClass("friendId-"+J).attr({rel:J}),H=K==J?"<img src='"+resource_null_gif+"' class='spr_icons team_leader'/><div class='tooltip'><div class='tooltipText'>Team leader</div></div>":"";if(J==user_id){G.addClass("isPlayer");}G.children("h3").html("<span>"+B.members[D].name+"</span>"+H);A.append(G);}$("h3 img.team_leader").toolTiper();},closeModal:function(B){var A=$(B.target).parents(".dialogWrapper");A.modalClose();if(A.is("#dialogCreateTeam")||A.is("#dialogKickedFromTeam")||A.is("#dialogDisbandedTeam")){this.sendEvent(RespiteControl.CONTINUE);}},initiateCreateTeam:function(){this.sendEvent(RespiteControl.INITIATE_CREATE_TEAM);},createTeam:function(C){$("#dialogCreateTeam .error").hide();$("#dialogCreateTeam p span").html(C.goldCost);this.goldCost=C.goldCost;this.maxDescriptionLength=C.maxDescriptionLength;$("#createTeamName label span").html(C.maxNameLength);$("#createTeamName input").attr("maxlength",C.maxNameLength);$("#createTeamSlogan label span").html(C.maxSloganLength);$("#createTeamSlogan input").attr("maxlength",C.maxSloganLength);var B=C.types.length,A="";for(var D=0;D<B;D++){A+="<option value='"+C.types[D]+"'>"+C.types[D]+"</option>";}$("#dialogCreateTeam select").html(A);$("#createTeamName input, #createTeamSlogan input, #dialogCreateTeam textarea").val("");$("#dialogCreateTeam").modal();if($("#ingameGoldInfo .userGold").text()>=this.goldCost){$("#spr_button_orange").removeClass("disabledButton");}else{$("#spr_button_orange").addClass("disabledButton");}},createTeamResponse:function(A){if(A.success==false){$("#dialogCreateTeam .error").html(A.errorMessage).show();}else{$("#dialogCreateTeam").modalClose();this.sendEvent(RespiteControl.CONTINUE);this.getTeamListRequest();}},submitTeamCreation:function(E){var A=$("#dialogCreateTeam select").val(),B=$("#createTeamName input").val(),C=$("#createTeamSlogan input").val(),D=$("#dialogCreateTeam textarea").val();this.sendEvent(PlanetoService.CREATE_TEAM,{teamType:A,name:B,slogan:C,description:D});},limitTextarea:function(A){var C=$(A.target).val(),B=C.length;if(B>this.maxDescriptionLength){$(A.target).val(C.substring(0,this.maxDescriptionLength));
}},teamMenuOver:function(F){var E=$(F.target),B=E.is("h3")?E:E.parent("h3"),D=E.is("li")?E:E.parents("li"),C=D.attr("rel");if(E.is(".personAmount")){this.teamId=C;if(E.siblings("ul").is(":hidden")){this.sendEvent(PlanetoService.GET_TEAM_MEMBERS,this.teamId);E.siblings("ul").html("Loading...").show();E.addClass("active");}else{E.removeClass("active").siblings("ul").hide();}}else{if(B.is("h3")){var G=$("#friendMenuHolder");G.attr("rel",C).data("friendId",C).css({top:(F.pageY-5)+"px",left:(F.pageX-5)+"px"}).show();if(HIDE_FRIEND_MENU_TIMEOUT!=-1){clearTimeout(HIDE_FRIEND_MENU_TIMEOUT);}G.unbind("mouseleave").bind("mouseleave",CallbackProxy(this,function(){HIDE_FRIEND_MENU_TIMEOUT=setTimeout(CallbackProxy(this,function(){G.hide();}),500);})).unbind("mouseenter").bind("mouseenter",function(){clearTimeout(HIDE_FRIEND_MENU_TIMEOUT);});G.unbind("click").bind("click",CallbackProxy(this,function(){G.hide();}));if(B.parents(".nthRow").hasClass("isNotTeamLeader")||B.parent("li").hasClass("isPlayer")){$("#friendMenuItemKick").hide();}else{$("#friendMenuItemKick").show();}$("#friendMenuItemChat, #friendMenuItemChallenge, #friendMenuItemInvite, #friendMenuItemIgnore, #friendMenuItemStopIgnoring").hide();}else{this.teamId=C;var A=$("#teamMenuHolder");A.attr("rel",C).css({top:(F.pageY-5)+"px",left:(F.pageX-5)+"px"}).show();if(HIDE_FRIEND_MENU_TIMEOUT!=-1){clearTimeout(HIDE_FRIEND_MENU_TIMEOUT);}A.unbind("mouseleave").bind("mouseleave",CallbackProxy(this,function(){HIDE_FRIEND_MENU_TIMEOUT=setTimeout(CallbackProxy(this,function(){A.hide();}),500);})).unbind("mouseenter").bind("mouseenter",function(){clearTimeout(HIDE_FRIEND_MENU_TIMEOUT);});A.unbind("click").bind("click",CallbackProxy(this,function(){A.hide();}));if(D.hasClass("isNotTeamLeader")){$("#teamMenuItemDisband").hide();}else{$("#teamMenuItemDisband").show();}}}},teamMenuClick:function(C){var B=$(C.target).is("li")?$(C.target):$(C.target).parent("li"),A=B.attr("id");if(A=="teamMenuItemInfo"){this.sendEvent(PlanetoService.GET_TEAM_INFO,this.teamId);}else{if(A=="teamMenuItemPrimary"){this.sendEvent(PlanetoService.SET_PRIMARY_TEAM,this.teamId);}else{if(A=="teamMenuItemLeave"){$("#dialogLeaveTeam").modal();$("#dialogLeaveTeam p span").html($("#teamId-"+this.teamId+" h2").html());}else{if(A=="teamMenuItemDisband"){$("#dialogDisbandTeam").modal();$("#dialogDisbandTeam p span").html($("#teamId-"+this.teamId+" h2").html());}}}}},teamLeave:function(){this.sendEvent(PlanetoService.LEAVE_TEAM,this.teamId);$("#dialogLeaveTeam").modalClose();},teamDisband:function(){this.sendEvent(PlanetoService.DISBAND_TEAM,this.teamId);$("#dialogDisbandTeam").modalClose();},teamKick:function(B){$("#dialogKickPlayer .error").hide();var A=$("#friendMenuHolder").attr("rel");$("#kickFriend").html($("#teamListContainer .friendId-"+A+" h3 span").html());$("#kickTeam").html($("#teamId-"+this.teamId+" h2").html());$("#dialogKickPlayer").modal();},teamInvite:function(D){$("#dialogInvitePlayer .error").hide();var C=this.teams.length,A="";for(var B=0;B<C;B++){if(this.teams[B].leader==true){A+="<div><input type='radio' name='team' value='"+this.teams[B].teamId+"'/> "+this.teams[B].teamName+", "+this.teams[B].type+" with "+this.teams[B].nbrOfMembers+" member"+(this.teams[B].nbrOfMembers>1?"s":"")+"</div>";}}$("#teamInviteContainer").html(A);$("#dialogInvitePlayer").modal();},teamKickPlayer:function(){var A=$("#friendMenuHolder").attr("rel");this.sendEvent(PlanetoService.KICK_PLAYER_FROM_TEAM,A,this.teamId);},teamInvitePlayer:function(){var A=$("#friendMenuHolder").data("friendId"),B=$("#teamInviteContainer input[type=radio]:checked").val();this.sendEvent(PlanetoService.INVITE_TO_TEAM,B,A);},inviteToTeam:function(A){if(A.success==true){$("#dialogInvitePlayer .error").hide();$("#dialogInvitePlayer").modalClose();}else{$("#dialogInvitePlayer .error").html(A.errorMessage).show();}},teamInvitation:function(A){this.teamId=A.team.teamId;$("#dialogTeamInvitation .teamInviter").html(A.inviter.name);$("#dialogTeamInvitation .teamName").html(A.team.teamName);
$("#dialogTeamInvitation .teamMembers").html(A.team.nbrOfMembers);$("#dialogTeamInvitation").modal();},acceptInvitation:function(A){var B=$(A.currentTarget).hasClass("spr_button_orange")?true:false;this.sendEvent(PlanetoService.RESPOND_TO_TEAM_INVITE,this.teamId,B);$("#dialogTeamInvitation").modalClose();this.sendEvent(RespiteControl.CONTINUE);},kickPlayerFromTeam:function(A){if(A.success==true){$("#dialogKickPlayer .error").hide();$("#dialogKickPlayer").modalClose();}else{$("#dialogKickPlayer .error").html(A.errorMessage).show();}},teamListChanged:function(){this.getTeamListRequest();}});RespiteControl.TEAM_INVITATION_RESPONSE="RespiteControl.TEAM_INVITATION_RESPONSE";BasicMVC.Facade.getInstance().register(new Planeto.Team.View());Planeto.TipsAndTricks=Planeto.TipsAndTricks||{};Planeto.TipsAndTricks.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.TipsAndTricks.View";var A=this;$("#dialogTipsAndTricks .closeModal").live("click",this.localScope(this.closeModal));$("#dialogTipsAndTricks .spr_button_orange").live("click",this.localScope(this.getNextTipsAndTricks));},eventListeners:function(){return[PlanetoEvents.NEXT_TIPS_AND_TRICKS_RESPONSE];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.NEXT_TIPS_AND_TRICKS_RESPONSE:this.showTipsAndTricks(A.data);break;}},showTipsAndTricks:function(A){$("#dialogTipsAndTricks .dialogText h3").html(A.topic);$("#dialogTipsAndTricks .dialogText > div > p").html(A.message);$("#dialogTipsAndTricks").modal();},getNextTipsAndTricks:function(){this.sendEvent(PlanetoService.NEXT_TAT_REQUEST);},closeModal:function(){$(event.target).parents(".dialogWrapper").modalClose();}});BasicMVC.Facade.getInstance().register(new Planeto.TipsAndTricks.View());Planeto.Quests=Planeto.Quests||{};Planeto.Quests.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Quests.Control";var A=this;this.quests={};this.currentQuestIndex=-1;this.questListPopulated=false;$("#gamePlayAvailableQuests .accept").live("click",this.localScopeFull(this.acceptQuest));$("#gamePlayAvailableQuests .dismiss").live("click",this.localScopeFull(this.dismissQuest));$("#gamePlayAvailableQuests .abandon").live("click",this.localScopeFull(this.confirmAbandonQuest));$("#gamePlayAvailableQuests .buyNewQuest").live("click",this.localScopeFull(this.buyNewQuest));$("#gamePlayAvailableQuests .claimReward").live("click",this.localScopeFull(this.claimReward));$("#dialogQuestCompleted .share").live("click",this.localScopeFull(this.publishQuestCompleted));$("#dialogQuestCompleted .skip").live("click",this.localScopeFull(this.closeQuestCompletedDialog));$("#dialogQuestAbandon .close").live("click",this.localScopeFull(this.closeAbandonQuest));$("#dialogQuestAbandon .abandon").live("click",this.localScopeFull(this.abandonQuest));$("#tab_3").live("click",this.localScopeFull(this.requestQuests));$("#gamePlayAvailableQuests h2, #gamePlayAvailableQuests .listItemExpander").live("click",this.localScopeFull(this.onItemExpanderClicked));},eventListeners:function(){return[PlanetoEvents.GET_QUESTS_RESPONSE,PlanetoEvents.GET_COMPLETED_QUESTS_RESPONSE,PlanetoEvents.ACTIVATE_QUEST_EVENT,PlanetoEvents.QUEST_PROGRESS_UPDATED_EVENT,PlanetoEvents.QUEST_FULFILLED_EVENT,PlanetoEvents.QUEST_FAILED_EVENT,PlanetoEvents.QUEST_SLOT_CLEARED_EVENT,PlanetoEvents.QUEST_ASSIGNED_EVENT,PlanetoEvents.NO_QUEST_AVAILABLE_EVENT];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.GET_QUESTS_RESPONSE:this.onQuestsResponse(A.data);break;case PlanetoEvents.GET_COMPLETED_QUESTS_RESPONSE:this.onCompletedQuestsResponse(A.data);break;case PlanetoEvents.ACTIVATE_QUEST_EVENT:this.onActivateQuestEvent(A.data);break;case PlanetoEvents.QUEST_PROGRESS_UPDATED_EVENT:this.onQuestProgressUpdate(A.data);break;case PlanetoEvents.QUEST_FULFILLED_EVENT:this.onQuestFulfilled(A.data);break;case PlanetoEvents.QUEST_FAILED_EVENT:this.onQuestFailed(A.data);break;case PlanetoEvents.QUEST_SLOT_CLEARED_EVENT:this.onQuestSlotCleared(A.data);break;case PlanetoEvents.QUEST_ASSIGNED_EVENT:this.onQuestAssigned(A.data);
break;case PlanetoEvents.NO_QUEST_AVAILABLE_EVENT:this.onNoQuestAvailable(A.data);break;}},requestQuests:function(){if(!this.questListPopulated){this.sendEvent(PlanetoService.GET_QUESTS_REQUEST);}},requestCompletedQuests:function(){this.sendEvent(PlanetoService.GET_COMPLETED_QUESTS_REQUEST);},onQuestsResponse:function(A){this.quests=A.quests;this.sendEvent(Planeto.Quests.View.UPDATE_AVAILABLE_QUESTS,A);this.questListPopulated=true;},onCompletedQuestsResponse:function(A){this.completedQuests=A.quests;this.updateCompletedQuests();},onActivateQuestEvent:function(A){var B=this.quests[A.slotIndex].quest;B.activated=true;B.failed=false;B.timerStarted=false;B.expanded=false;B.deadLine=A.deadLine;B.fulfilled=A.fulfilled;B.progress=A.progress;this.updateQuestSlot(A.slotIndex);},onQuestProgressUpdate:function(A){if(this.questListPopulated){var B=this.quests[A.slotIndex].quest;B.progress=A.progress;this.updateQuestSlot(A.slotIndex);}this.showQuestNotification("Quest progress!","progress");},onQuestFulfilled:function(A){if(this.questListPopulated){var B=this.quests[A.slotIndex].quest;B.fulfilled=true;B.progress=A.progress;B.completionFlavor=A.completionFlavor;this.updateQuestSlot(A.slotIndex);}this.showQuestNotification("Quest completed!","completed");},onQuestFailed:function(A){if(this.questListPopulated){var B=this.quests[A.slotIndex].quest;B.reason=A.reaseon;B.hint=A.hint;B.failed=true;B.activated=false;this.updateQuestSlot(A.slotIndex);}this.showQuestNotification("Quest failed!","failed");},onQuestSlotCleared:function(A){if(this.questListPopulated){this.quests[A.slotIndex]=A.slot;this.updateQuestSlot(A.slotIndex);}},onQuestAssigned:function(A){if($("#tab_3").is(":visible")){if(this.questListPopulated){this.quests[A.slotIndex].empty=false;this.quests[A.slotIndex].quest=A.quest;this.updateQuestSlot(A.slotIndex);}this.showQuestNotification("New Quest available!","progress");}},onNoQuestAvailable:function(A){this.sendEvent(Planeto.Quests.View.REMOVE_EMPTY_SLOTS);},onItemExpanderClicked:function(D){var E=$(D.currentTarget),C=E.parent().find(".questInfo"),A=this.getSlotIndexFromEventTarget(D.currentTarget),B=this.quests[A].quest;E.toggleClass("active");B.expanded=E.hasClass("active");C.toggle();if(B.expanded){C.parent().find(".titleProgress, .titleTimelimit").hide();C.parent().find(".questButtons").addClass("expandedButtons").show();}else{C.parent().find(".titleProgress, .titleTimelimit").show();C.parent().find(".questButtons").removeClass("expandedButtons").hide();}},updateCompletedQuests:function(){this.sendEvent(Planeto.Quests.View.UPDATE_COMPLETED_QUESTS,this.completedQuests);},updateQuestSlot:function(A){var B=this.quests[A];this.sendEvent(Planeto.Quests.View.UPDATE_QUEST_SLOT,{questSlot:B,slotIndex:A});},showQuestNotification:function(B,A){var B={text:B,"type:":A};this.sendEvent(Planeto.Quests.View.SHOW_QUEST_NOTIFICATION,B);},buyNewQuest:function(C){var A=this.getSlotIndexFromEventTarget(C.currentTarget),D=10,B=parseInt($("#ingameGoldInfo .userGold").html());if(D>B){this.sendEvent(Planeto.Quests.View.SHOW_NOT_ENOUGH_GOLD_NOTIFICATION,A);}else{this.sendEvent(PlanetoService.BUY_NEW_QUEST,A);}},claimReward:function(B){var A=this.getSlotIndexFromEventTarget(B.currentTarget);quest=this.quests[A].quest;this.currentQuestIndex=A;this.sendEvent(RespiteControl.SHOW_CLAIM_QUEST_REWARD,quest);},closeQuestCompletedDialog:function(){this.sendEvent(PlanetoService.CLAIM_QUEST_REWARD,this.currentQuestIndex);this.sendEvent(Planeto.Quests.View.CLOSE_QUEST_COMPLETED_DIALOG);this.sendEvent(RespiteControl.CONTINUE);},closeQuestAbandonDialog:function(){this.sendEvent(Planeto.Quests.View.CLOSE_QUEST_ABANDON_DIALOG);},publishQuestCompleted:function(){var A=this.quests[this.currentQuestIndex].quest;A.slotIndex=this.currentQuestIndex;this.sendEvent(Planeto.Facebook.QuizFeed.Control.PUBLISH_QUEST_COMPLETED,A);},acceptQuest:function(B){var A=this.getSlotIndexFromEventTarget(B.currentTarget);this.sendEvent(PlanetoService.ACCEPT_QUEST_REQUEST,A);this.closeDialog();
},dismissQuest:function(B){var A=this.getSlotIndexFromEventTarget(B.currentTarget);this.sendEvent(PlanetoService.DISMISS_REQUEST,A);this.closeDialog();},confirmAbandonQuest:function(C){var A=this.getSlotIndexFromEventTarget(C.currentTarget),B=this.quests[A].quest;this.currentQuestIndex=A;this.sendEvent(Planeto.Quests.View.SHOW_QUEST_ABANDON_DIALOG,B);},closeAbandonQuest:function(){this.currentQuestIndex=-1;this.sendEvent(Planeto.Quests.View.CLOSE_QUEST_ABANDON_DIALOG);},abandonQuest:function(){this.sendEvent(PlanetoService.DISMISS_REQUEST,this.currentQuestIndex);this.closeAbandonQuest();},closeDialog:function(){this.currentQuestIndex=-1;},getSlotIndexFromEventTarget:function(C){var B=$(C).parents("li"),A=B.attr("id").split("_")[1];return A;}});BasicMVC.Facade.getInstance().register(new Planeto.Quests.Control());Planeto.Quests=Planeto.Quests||{};Planeto.Quests.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Quests.View";var A=this;this.timer=null;$("#tab_3, #gamePlayAvailableQuests .ongoingQuests, #gamePlayAvailableQuests .availableQuests").hide();$("#tab_3").live("click",function(){$("#tabContent_3_1").show();});$("#tabContent_3 .buttonContainer > div").live("click",this.localScopeFull(this.onTabButtonClicked));$("#gamePlayCompletedQuests h2, #gamePlayCompletedQuests .listItemExpander").live("click",this.localScopeFull(this.toggleCompletedQuestInfo));},eventListeners:function(){return[Planeto.Quests.View.UPDATE_AVAILABLE_QUESTS,Planeto.Quests.View.UPDATE_COMPLETED_QUESTS,Planeto.Quests.View.UPDATE_QUEST_SLOT,Planeto.Quests.View.SHOW_QUEST_COMPLETED_DIALOG,Planeto.Quests.View.CLOSE_QUEST_COMPLETED_DIALOG,Planeto.Quests.View.SHOW_QUEST_NOTIFICATION,Planeto.Quests.View.SHOW_NOT_ENOUGH_GOLD_NOTIFICATION,PlanetoEvents.NEW_QUIZ_RESPONSE,PlanetoEvents.LEVEL_UP_EVENT,Planeto.Quests.View.SHOW_QUEST_ABANDON_DIALOG,Planeto.Quests.View.CLOSE_QUEST_ABANDON_DIALOG,Planeto.Quests.View.REMOVE_EMPTY_SLOTS];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.LEVEL_UP_EVENT:this.checkPlayerLevel(A.data.level);break;case PlanetoEvents.NEW_QUIZ_RESPONSE:this.checkPlayerLevel(A.data.player.level.value);break;case Planeto.Quests.View.UPDATE_AVAILABLE_QUESTS:this.onUpdateAvailableQuests(A.data);break;case Planeto.Quests.View.UPDATE_COMPLETED_QUESTS:this.renderCompletedQuests(A.data);break;case Planeto.Quests.View.UPDATE_QUEST_SLOT:this.onUpdateQuestSlot(A.data);break;case Planeto.Quests.View.SHOW_QUEST_COMPLETED_DIALOG:this.onShowQuestCompletedDialog(A.data.quest);break;case Planeto.Quests.View.CLOSE_QUEST_COMPLETED_DIALOG:this.onCloseQuestCompletedDialog();break;case Planeto.Quests.View.SHOW_QUEST_NOTIFICATION:this.onShowQuestNotification(A.data);break;case Planeto.Quests.View.SHOW_NOT_ENOUGH_GOLD_NOTIFICATION:this.onShowNotEnoughGoldNotification(A.data);break;case Planeto.Quests.View.SHOW_QUEST_ABANDON_DIALOG:this.onShowQuestAbandonDialog(A.data);break;case Planeto.Quests.View.CLOSE_QUEST_ABANDON_DIALOG:this.onHideQuestAbandonDialog();break;case Planeto.Quests.View.REMOVE_EMPTY_SLOTS:this.onRemoveEmptySlots();break;}},checkPlayerLevel:function(A){if(A>2){$("#tab_3").show();}},onTabButtonClicked:function(C){var A=$(C.currentTarget),B=null;if(A.hasClass("spr_toggle_small_grey")){A.addClass("spr_toggle_small_orange").removeClass("spr_toggle_small_grey").siblings().removeClass("spr_toggle_small_orange").addClass("spr_toggle_small_grey");}if(A.hasClass("showActiveButton")){B=$("#tabContent_3_1");}if(A.hasClass("showCompletedButton")){B=$("#tabContent_3_2");this.sendEvent(PlanetoService.GET_COMPLETED_QUESTS_REQUEST);}B.show().siblings(".tabContent").hide();},onShowQuestCompletedDialog:function(A){var B=$("#dialogQuestCompleted");B.find(".name").html(A.name);B.find(".message").html(A.completionFlavor);B.find(".reward").html(this.renderRewards(A.rewards));B.find(".rewardScore, .rewardGold, .planetoItemIcon").toolTiper();B.modal();},onCloseQuestCompletedDialog:function(){$("#dialogQuestCompleted").modalClose();},onShowQuestAbandonDialog:function(A){$("#dialogQuestAbandon").modal();
},onHideQuestAbandonDialog:function(){$("#dialogQuestAbandon").modalClose();},onUpdateAvailableQuests:function(C){var A=$("#gamePlayAvailableQuests .ongoingQuests ul"),B=$("#gamePlayAvailableQuests .availableQuests ul");$("#questsMessage").hide();A.html("");B.html("");for(var E=0;E<C.quests.length;E++){var H=C.quests[E],D=H.quest,G=H.empty,F=this.renderQuestSlot(C.quests[E],E);if(!G&&D.activated){A.append(F);}else{B.append(F);}F.attr("rel",(G?"2":"1"));}B.find("li").tsort("",{attr:"rel",order:"asc"});this.showOrHideListContainers();this.startCountDowns();},onUpdateQuestSlot:function(D){var G=D.slotIndex,A=D.questSlot,E=A.empty,F=A.quest,I=this.renderQuestSlot(A,G),H=$("#questSlot_"+G),C=$("#gamePlayAvailableQuests .ongoingQuests ul"),B=$("#gamePlayAvailableQuests .availableQuests ul");H.show();if(!E&&F.activated){if(B.find("#questSlot_"+G).length>0){B.find("#questSlot_"+G).remove();C.append(I);}else{H.replaceWith(I);}}else{if(C.find("#questSlot_"+G).length>0){C.find("#questSlot_"+G).remove();B.append(I);}else{H.replaceWith(I);}}I.attr("rel",(E?"2":"1"));B.find("li").tsort("",{attr:"rel",order:"asc"});this.showOrHideListContainers();},onShowQuestNotification:function(C){var E=$("#questProgressNotification"),D=$("#column3").offset().left,B=$("#tab_3"),A=function(){setTimeout(function(){E.fadeOut(200);},3000);};if(!B.hasClass("active")){E.removeClass("completed failed");switch(C.type){case"completed":E.addClass("completed");break;case"failed":E.addClass("failed");break;}E.css("left",D+"px").html(C.text).show(0,A);}},onShowNotEnoughGoldNotification:function(B){var A=$("#questSlot_"+B);notification=A.find(".notEnoughGold");$("#gamePlayAvailableQuests .notEnoughGold").hide();fadeOut=function(){setTimeout(function(){notification.fadeOut(200);},2000);};notification.show(0,fadeOut);},onRemoveEmptySlots:function(){$("#gamePlayAvailableQuests .questEmptySlot").removeClass("usable").hide();this.showOrHideListContainers();},renderQuestSlot:function(B,G){var H=$("#templates .questItem"),D=$("#templates .questEmptySlot"),F=B.quest,E=B.empty,I=null;if(E){var C=new Date().getTime()+B.timeToRefill;I=D.clone();I.addClass("empty usable").find(".countdown").data("timeout",C).html(this.renderDeadline(C));I.find(".listItemExpander, .notEnoughGold").hide();if(B.timeToRefill<-100000){I.removeClass("usable").hide();}}else{I=H.clone();I.addClass("usable");I.find("h2").html(F.name);I.find(".description").html(F.description);I.find(".goal > span").html(F.goalDescription);I.find(".reward").html(this.renderRewards(F.rewards));I.find(".accept, .dismiss, .abandon, .claimReward, .timelimit, .failed, .titleProgress, .titleTimelimit, .titleMessage").hide();if(F.expanded){I.find(".listItemExpander").addClass("active");I.find(".questInfo, .questButtons").show();}else{I.find(".questInfo, .questButtons").hide();}I.find(".questLevel").css("background-position","0 -"+(F.level*27)+"px");I.find(".questRarity").css("background-position",this.getRarityIndex(F.rewards)*-27+"px 0");if(F.fulfilled){I.addClass("fulfilled");I.find(".reward").html(this.renderRewards(F.rewards));I.find(".failed, .progress, .titleTimelimit").remove();I.find(".claimReward").show();I.find(".titleMessage").addClass("goodGreen").html("Quest completed! Don't forget to claim your reward.").show();}else{if(F.failed){I.addClass("activated");I.find(".failed, .progress, .accept, .dismiss").show();I.find(".hint.tooltip .tooltipText").html(F.hint);I.find(".progress > span").html(F.progress.progressDescription);I.find(".reward").html(this.renderRewards(F.rewards));I.find(".titleMessage").html("Quest failed! Click play to try again.").show();}else{if(F.activated){I.addClass("activated");I.find(".claim, .failed").remove();I.find(".progress").show();I.find(".progress > span, .titleProgress").html(F.progress.progressDescription);I.find(".reward").html(this.renderRewards(F.rewards));if(F.timeLimit>0){if(!F.timerStarted){var A=new Date().getTime()+F.timeLimit;F.timerStarted=true;F.expireDateTime=A;}I.find(".countdown").data("timeout",F.expireDateTime).html(this.renderDeadline(F.expireDateTime));
I.find(".timelimit").show();}else{I.find(".titleTimelimit").remove();}if(F.expanded){I.find(".titleProgress, .titleTimelimit").hide();}else{I.find(".titleProgress, .titleTimelimit").show();}I.find(".abandon").show();}else{I.find("h2").html(F.name);I.find(".progress, .failed, .claim").remove();I.find(".reward").html(this.renderRewards(F.rewards));I.addClass("available");I.find(".accept, .dismiss").show();I.find(".titleProgress, .titleTimelimit").remove();}}}}I.attr("id","questSlot_"+G).css("cursor","auto");I.find(".rewardScore, .rewardGold, .planetoItemIcon, .orange_button").toolTiper();this.startCountDowns();return I;},renderCompletedQuests:function(F){var E=$("#templates .questItem"),D=$("#gamePlayCompletedQuests .completedQuests ul"),C=null,A=null;D.html("");for(var B=0;B<F.length;B++){A=F[B];C=E.clone();C.find("h2").html(A.name);C.find(".description").html(A.description);C.find(".goal > span").html(A.goalDescription);C.find(".reward").html(this.renderRewards(A.rewards));C.find(".accept, .dismiss, .abandon, .claimReward, .timelimit, .failed, .titleProgress, .titleTimelimit, .titleMessage, .questInfo, .questButtons").hide();C.find(".questLevel").css("background-position","0 -"+(A.level*27)+"px");C.find(".questRarity").css("background-position",this.getRarityIndex(A.rewards)*-27+"px 0");D.append(C);}},showOrHideListContainers:function(){var A=$("#gamePlayAvailableQuests .ongoingQuests ul"),B=$("#gamePlayAvailableQuests .availableQuests ul"),C=true;if(A.children(".usable").length==0){A.parent().hide();}else{A.parent().show();C=false;}if(B.children(".usable").length==0){B.parent().hide();}else{B.parent().show();C=false;}if(C){$("#questsMessage").html("No available quests").show();}else{$("#questsMessage").hide();}},startCountDowns:function(){if(this.timer){clearInterval(this.timer);}this.timer=setInterval(this.localScopeFull(this.updateCountDowns),990);},renderTooltip:function(A){var B=$("#questTooltip").clone();B.removeAttr("id");if(A.activated){B.find("h2.inactive").remove();}else{B.find("h2.active").remove();}B.find(".name").html(A.name);B.find(".description").html(A.description);B.find(".goal").html(A.goalDescription);if(!A.deadLine){B.find(".timelimit").remove();}if(A.activated){B.find(".timelimit").addClass("countdown");}B.find(".timelimit").html(this.renderDeadline(A.deadLine));B.find(".reward").html(this.renderRewards(A.rewards));if(A.progress){B.find(".progress").html(A.progress.progressDescription).show();}else{B.find(".progress").hide();}return B;},renderDeadline:function(B){var C=this.getTimeFractions(B),A="";if(C.hours>0){A=C.hours+"h "+C.minutes+"m";}else{A=C.minutes+"m "+C.seconds+"s";}return A;},renderRewards:function(E){var B=new Array(),A=new Array();if(E){for(var C=0;C<E.length;C++){var D=E[C];switch(D.type){case"SCORE":B.push("<div class='rewardScore'>"+D.description+"</div><span class='tooltip'><div class='tooltipText'>"+D.title+": "+D.description+"</div></span>");break;case"GOLD":B.push("<div class='rewardGold'>"+D.description+"</div><span class='tooltip'><div class='tooltipText'>"+D.title+": "+D.description+"</div></span>");break;case"ITEM":B.push("<div class='rewardItem'>"+this.renderPlanetoItem(D.item)+"</div>");break;}}}return B.join("");},renderPlanetoItem:function(C){var B=$("#templates div.planetoItem").clone();B.attr({id:"planetoItem-"+C.id,rel:C.wearableSlot}).addClass(C.type).data({goldCost:C.goldCost,name:C.name});if(C.type=="questionSet"){B.find("img.planetoItemImage").attr("src",getImageUrl("QS",C.iconId,42));}else{B.find("img.planetoItemImage").addClass("spr_"+C.type+"s spr_"+C.type+"_"+C.iconId);}if(C.groupName!=""){B.addClass("group-"+C.groupName).data("groupName",C.groupName);}var A=this.facade.getInstanceByName("Planeto.Player.Model").playerVO.level.value;planetoItemTooltip(B,C,A);B.find("div.tooltipRequiredLevel").removeClass("red").siblings(".tooltipWrongLevel").hide();return B.outerHtml();},updateCountDowns:function(){var A=this;$("#gamePlayAvailableQuests .countdown").each(function(){var B=$(this);
timeout=B.data("timeout");B.html(A.renderDeadline(timeout));});},getTimeFractions:function(D){var A=new Date().getTime(),E=Math.floor((D-A)/1000),C={hours:0,minutes:0,seconds:0},B=function(G){var F=Math.floor(E/G);E-=F*G;return F;};if(E>0){C.hours=B(3600);C.minutes=B(60);C.seconds=B(1);}return C;},getRarityIndex:function(F){var E=0;for(var B=0;B<F.length;B++){var D=F[B],C=D.item,A=0;if(C){switch(C.rarity){case"Poor":A=0;break;case"Common":A=1;break;case"Uncommon":A=2;break;case"Rare":A=3;break;case"Epic":A=4;break;case"Legendary":A=5;break;}}if(A>E){E=A;}}return E;},toggleCompletedQuestInfo:function(B){var C=$(B.currentTarget),A=C.parents(".questItem");A.find(".questInfo, .questButtons").toggle();C.toggleClass("active");}});Planeto.Quests.View.UPDATE_AVAILABLE_QUESTS="Planeto.Quests.View.UPDATE_AVAILABLE_QUESTS";Planeto.Quests.View.UPDATE_COMPLETED_QUESTS="Planeto.Quests.View.UPDATE_COMPLETED_QUESTS";Planeto.Quests.View.UPDATE_QUEST_SLOT="Planeto.Quests.View.UPDATE_QUEST_SLOT";Planeto.Quests.View.SHOW_QUEST_COMPLETED_DIALOG="Planeto.Quests.View.SHOW_QUEST_COMPLETED_DIALOG";Planeto.Quests.View.CLOSE_QUEST_COMPLETED_DIALOG="Planeto.Quests.View.CLOSE_QUEST_COMPLETED_DIALOG";Planeto.Quests.View.SHOW_QUEST_NOTIFICATION="Planeto.Quests.View.SHOW_QUEST_NOTIFICATION";Planeto.Quests.View.SHOW_QUEST_ABANDON_DIALOG="Planeto.Quests.View.SHOW_QUEST_ABANDON_DIALOG";Planeto.Quests.View.CLOSE_QUEST_ABANDON_DIALOG="Planeto.Quests.View.CLOSE_QUEST_ABANDON_DIALOG";Planeto.Quests.View.SHOW_NOT_ENOUGH_GOLD_NOTIFICATION="Planeto.Quests.View.SHOW_NOT_ENOUGH_GOLD_NOTIFICATION";Planeto.Quests.View.REMOVE_EMPTY_SLOTS="Planeto.Quests.View.REMOVE_EMPTY_SLOTS";BasicMVC.Facade.getInstance().register(new Planeto.Quests.View());Planeto.QuestionSet=Planeto.QuestionSet||{};Planeto.QuestionSet.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.QuestionSet.Control";this.questionSetActive=false;this.questionSet={};$("#questionSetSummaryScreen .share").live("click",this.localScopeFull(this.showChallengeFriends));$("#questionSetSummaryScreen .continue").live("click",this.localScopeFull(this.onSummaryContinue));$(".summaryRate img").live("click",this.localScopeFull(this.summaryRateSend));$(".summaryComment .spr_button_small_orange:not(.disabled)").live("click",this.localScopeFull(this.summaryCommentSend));},eventListeners:function(){return[PlanetoEvents.QUESTION_SET_STARTED_EVENT,PlanetoEvents.QUESTION_SET_STOPPED_EVENT,PlanetoEvents.END_QUIZ_EVENT,PlanetoEvents.QUESTION_SKIPPED_EVENT,PlanetoEvents.GET_REWARD_FOR_CHALLENGING_AFRIEND_RESPONSE];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.QUESTION_SET_STARTED_EVENT:this.onQuestionSetStart(A.data);break;case PlanetoEvents.QUESTION_SET_STOPPED_EVENT:this.onQuestionSetStopped(A.data);break;case PlanetoEvents.END_QUIZ_EVENT:this.onEndQuizEvent(A.data);break;case PlanetoEvents.QUESTION_SKIPPED_EVENT:this.questionSkippedEvent();break;case PlanetoEvents.GET_REWARD_FOR_CHALLENGING_AFRIEND_RESPONSE:this.questionSet.hasGottenReward=true;break;}},summaryRateSend:function(A){this.sendEvent(PlanetoService.RATE_QUESTION_SET_REQUEST,{mood:$(A.target).attr("rel"),identity:this.questionSet.identity});$(A.target).addClass("active").siblings("img").removeClass("active");},summaryCommentSend:function(A){var B=$("#questionSetSummaryScreen .summaryComment input").val();if(B!=""){this.sendEvent(PlanetoService.ADD_COMMENT_TO_QUESTION_SET_REQUEST,{identity:this.questionSet.identity,comment:B});$("#questionSetSummaryScreen .summaryComment input").val("").siblings("div").addClass("disabled").removeClass("spr_button_small_orange").addClass("spr_button_small_grey");}},onQuestionSetStart:function(A){this.questionSetActive=true;this.questionSet={};this.questionSet.usedTime=0;this.questionSet.startTime=new Date().getTime();this.questionSet.correctAnswers=0;this.questionSet.currentQuestionIndex=0;this.questionSet.nbrOfQuestions=A.questionSet.nbrOfQuestions;this.questionSet.identity=A.questionSet.identity;this.sendEvent(Planeto.QuestionSet.Control.PROGRESS_SHOW,A);
},onQuestionSetStopped:function(A){this.questionSet.summary=A.summary;this.questionSet.linkBonus=A.linkBonus;this.questionSet.friendsWhoPlayedIt=A.friendsWhoPlayedIt;if(connectedToFB){$("#questionSetSummaryScreen .share").show();$("#questionSetSummaryScreen .facebook_post").show();}else{$("#questionSetSummaryScreen .share").hide();$("#questionSetSummaryScreen .facebook_post").hide();}this.sendEvent(PlanetoService.RATE_QUESTION_SET_REQUEST,{mood:"BLANK",identity:A.linkBonus.identity});this.sendEvent(Planeto.QuestionSet.Control.PROGRESS_HIDE);},onEndQuizEvent:function(A){if(this.questionSetActive){if(A.correct){this.questionSet.correctAnswers++;}this.questionSet.currentQuestionIndex++;this.questionSet.usedTime+=A.usedTime;var B={};B.questionIndex=this.questionSet.currentQuestionIndex-1;B.correct=A.correct;B.usedTime=this.questionSet.usedTime;this.sendEvent(Planeto.QuestionSet.Control.PROGRESS_UPDATE,B);}},questionSkippedEvent:function(){var A={};this.questionSet.currentQuestionIndex++;A.questionIndex=this.questionSet.currentQuestionIndex-1;A.correct=false;A.usedTime=0;this.sendEvent(Planeto.QuestionSet.Control.PROGRESS_UPDATE,A);},onSummaryShare:function(){this.sendEvent(Planeto.Facebook.QuizFeed.Control.PUBLISH_QUESTIONSET,this.questionSet);this.questionSetActive=false;},onSummaryContinue:function(){var B=$("#questionSetSummaryScreen .facebook_post > input");var A=B.attr("checked");if(A&&connectedToFB){this.sendEvent(Planeto.Facebook.QuizFeed.Control.PUBLISH_QUESTIONSET,this.questionSet);}this.questionSetActive=false;this.questionSet={};this.sendEvent(Planeto.Player.Control.START_PLAYING);this.sendEvent(Planeto.QuestionSet.Control.SUMMARY_CLOSED);B.attr("checked",true);setTimeout(function(){$("#statusWrapper").css("visibility","visible");},2000);},showChallengeFriends:function(A){var C={};if(this.questionSet.linkBonus){C.linkBonus={};C.linkBonus.identity=this.questionSet.linkBonus.identity;C.linkBonus.description=this.questionSet.linkBonus.description;C.iconUrl=this.questionSet.summary.imageUrl;C.description=this.questionSet.summary.description;C.nbrOfCorrect=this.questionSet.summary.nbrOfCorrect;C.time=this.questionSet.summary.time;C.totalNbrOfQuestions=this.questionSet.summary.totalNbrOfQuestions;C.friendsWhoPlayedIt=this.questionSet.friendsWhoPlayedIt;var B=true;if(this.questionSet.hasGottenReward){B=false;}this.sendEvent(Planeto.ChallengeFriends.SHOW,C,B);}}});Planeto.QuestionSet.Control.PROGRESS_SHOW="Planeto.QuestionSet.Control.PROGRESS_SHOW";Planeto.QuestionSet.Control.PROGRESS_HIDE="Planeto.QuestionSet.Control.PROGRESS_HIDE";Planeto.QuestionSet.Control.PROGRESS_UPDATE="Planeto.QuestionSet.Control.PROGRESS_UPDATE";Planeto.QuestionSet.Control.SUMMARY_CLOSED="Planeto.QuestionSet.Control.SUMMARY_CLOSED";BasicMVC.Facade.getInstance().register(new Planeto.QuestionSet.Control());Planeto.QuestionSet=Planeto.QuestionSet||{};Planeto.QuestionSet.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.QuestionSet.View";this.questionSetActive=false;$("#tab_4:not(.active)").live("click",this.localScopeFull(this.getCompletedQuestionSetsRequest));$("#questionSetStart .startButton").live("click",this.localScopeFull(this.startQuestionSet));$("#gamePlayCompletedQS li").live("click",this.localScopeFull(this.questionSetMenuOver));$("#questionsetMenuHolder li").live("click",this.localScopeFull(this.questionSetMenuAction));$(".summaryRate img").toolTiper();$("#questionSetSummaryScreen .summaryComment input").live("keyup",function(){$("#questionSetSummaryScreen .summaryComment .spr_button_small_grey").removeClass("spr_button_small_grey").addClass("spr_button_small_orange");});},eventListeners:function(){return[Planeto.QuestionSet.Control.PROGRESS_SHOW,Planeto.QuestionSet.Control.PROGRESS_HIDE,Planeto.QuestionSet.Control.PROGRESS_UPDATE,Planeto.QuestionSet.Control.SUMMARY_CLOSED,PlanetoEvents.QUESTION_SET_STARTED_EVENT,PlanetoEvents.QUESTION_SET_STOPPED_EVENT,PlanetoEvents.NEW_QUIZ_EVENT,PlanetoEvents.SHOW_QUESTION_EVENT,Planeto.Quiz.Control.ANSWER_CLICKED,PlanetoEvents.GET_COMPLETED_QUESTION_SETS_RESPONSE];
},eventHandlers:function(A){switch(A.name){case Planeto.QuestionSet.Control.PROGRESS_SHOW:this.questionSetActive=true;this.onQuestionSetShow(A.data);break;case PlanetoEvents.GET_COMPLETED_QUESTION_SETS_RESPONSE:this.getCompletedQuestionSetsResponse(A.data);break;case Planeto.QuestionSet.Control.PROGRESS_HIDE:this.onQuestionSetHide();break;case Planeto.QuestionSet.Control.PROGRESS_UPDATE:this.onQuestionSetProgress(A.data);break;case PlanetoEvents.QUESTION_SET_STOPPED_EVENT:this.questionSetActive=false;this.showQuestionSetSummary(A.data);break;case PlanetoEvents.QUESTION_SET_STARTED_EVENT:this.questionSetActive=true;this.showQuestionSetProvider(A.data.questionSet);break;case Planeto.QuestionSet.Control.SUMMARY_CLOSED:this.hideQuestionSetProvider();this.closeQuestionSetSummary();break;case PlanetoEvents.NEW_QUIZ_EVENT:if(this.questionSetActive){$("#questionSetProgress").show();}break;}},getCompletedQuestionSetsRequest:function(){this.sendEvent(PlanetoService.GET_COMPLETED_QUESTION_SETS_REQUEST);},getCompletedQuestionSetsResponse:function(C){creator_content=C;this.questionSets=C.questionSets;var D=$("#gamePlayCompletedQS > ul"),A=C.questionSets.length,F="";if(A>0){for(var E=0;E<A;E++){var B=C.questionSets[E];F+="<li class='questionSetItem nthRow' rel='"+B.identity+"'><div><img src='"+getImageUrl("QS",B.imageUrl,42)+"'/><h2>"+B.name+"</h2><span class='bg_green'>"+B.nbrOfCorrect+" of "+B.totalNbrOfQuestions+" - "+format_time(B.time)+"</span></div><div class='tooltip'><div class='tooltipcontent item'><div class='tooltipHeader'><div class='planetoItemTooltipIcon'><img src='"+getImageUrl("QS",B.imageUrl,42)+"' class='planetoItemImage'></div><h3 class='planetoItemTooltipName color_rarity_poor_color' style='font-size: 12px; line-height: 14px;'>"+B.name+"</h3></div><div class='tooltipText'><p class='planetoItemToolTipDesc'>"+B.description+"</p></div></div></div></li>";}}else{F+="<li><h2>It looks like you haven't had the fortune to receive a question set and complete it</h2></li>";}D.html(F);$("#gamePlayCompletedQS li > div").toolTiper();},onQuestionSetShow:function(B){var A=$("#questionSetProgress"),G=A.find("ul"),E=Math.floor((360-B.questionSet.nbrOfQuestions)/B.questionSet.nbrOfQuestions),C=$("#quizCategory img"),F=$("#questionSetStart");G.html("");for(var D=0;D<B.questionSet.nbrOfQuestions;D++){G.append("<li></li>");}G.find("li").css("width",E);C.attr("src",getImageUrl("QS",B.questionSet.imageUrl,42)).show();F.find("img").attr("src",getImageUrl("QS",B.questionSet.imageUrl,"plain"));F.find(".name").encodeHtml(B.questionSet.name);F.find(".nbrOfQuestions").html(B.questionSet.nbrOfQuestions+" questions");F.find(".percentMaxCorrect").html("Of "+B.nbrOfPeople+" players, "+B.percentageMaxCorrect+"% have answered all questions correctly");F.find(".description").encodeHtml(B.questionSet.description);$("#gamePausOverlay").hide();$("#statusWrapper").css("visibility","hidden");F.show();},questionSetMenuOver:function(D){var C=$(D.target).is("li")?$(D.target):$(D.target).parents("li"),A=C.attr("rel"),B=$("#questionsetMenuHolder");if(fb_friends.length>0){$("#menuShare2").show();}else{$("#menuShare2").hide();}B.addClass("friendMenuCurrent").data("questionsetId",A).css({top:(D.pageY-5)+"px",left:(D.pageX-5)+"px"}).show();if(HIDE_FRIEND_MENU_TIMEOUT!=-1){clearTimeout(HIDE_FRIEND_MENU_TIMEOUT);}$("div.friendMenuCurrent").unbind("mouseleave").bind("mouseleave",CallbackProxy(this,function(){HIDE_FRIEND_MENU_TIMEOUT=setTimeout(CallbackProxy(this,function(){B.hide();}),500);})).unbind("mouseenter").bind("mouseenter",function(){clearTimeout(HIDE_FRIEND_MENU_TIMEOUT);});$("div.friendMenuCurrent").unbind("click").bind("click",CallbackProxy(this,function(){B.hide();}));},startQuestionSet:function(A){$("#questionSetStart").hide();this.sendEvent(PlanetoService.PAUSE_PLAYING,false);this.sendEvent(StatusView.HIDE_MESSAGE);setTimeout(this.localScopeFull(function(){$("#statusWrapper").css("visibility","visible");}),2000);},onQuestionSetHide:function(){var A=$("#questionSetProgress"),B=$("#quizCategory img");
B.attr("src","");B.hide();A.hide();},onQuestionSetProgress:function(A){$("#questionSetProgress .questions").html((A.questionIndex+1)+" / "+$("#questionSetProgress ul li").length);$($("#questionSetProgress ul li")[A.questionIndex]).addClass(A.correct?"correct":"wrong");$("#questionSetProgress .time").html(format_time(A.usedTime,true));},showQuestionSetSummary:function(A){question_set_summary=A;var B=$("#questionSetSummaryScreen"),C=$("#questionSetStart");$("#quizBanner, #questionContainer, #answerContainer").hide();C.find("img").attr("src",resource_null_gif);C.find(".name").html("");C.find(".nbrOfQuestions").html("");C.find(".percentMaxCorrect").html("");C.find(".description").html("");B.find(".summaryCorrect").html(A.summary.nbrOfCorrect);B.find(".summaryNbrOfQuestions").html(A.summary.totalNbrOfQuestions);B.find(".summaryTime").html(format_time(A.summary.time));B.find(".position").html(number_suffix(A.placementAmongFriends)+" position");B.find(".percentage").html(A.percentageBetterThan+"%");B.find(".buttons .leaderboard span").html(A.friendsWhoPlayedIt.length+" friend"+(A.friendsWhoPlayedIt.length==1?"":"s"));B.find(".summaryRate0, .summaryRate1, .summaryRate2").removeClass("active");B.find(".summaryComment input").val("");if(connectedAsGuest){$(".facebookNotLoggedIn").show();$(".facebookLoggedIn").hide();}else{$(".facebookNotLoggedIn").hide();$(".facebookLoggedIn").show();}$("#statusWrapper").css("visibility","hidden");B.show();if($("#tabContent_4_1").is(":visible")){this.getCompletedQuestionSetsRequest();}$("#questionSetSummaryScreen .buttons > .leaderboard").unbind("click").bind("click",this.localScopeFull(this.openQuestionSetLeaderboardFromSummary,A.summary.identity));},closeQuestionSetSummary:function(){$("#questionSetSummaryScreen").hide();},openQuestionSetLeaderboardFromSummary:function(C,B,A){this.showQuestionSetLeaderboard(A);},questionSetMenuAction:function(H){var C=$(H.target).is("li")?$(H.target):$(H.target).parent("li"),B=C.attr("id"),G=$("#questionsetMenuHolder").data("questionsetId");if(B=="menuShare"){var F="",A=this.questionSets.length;if(A>0){for(var D=0;D<A;D++){if(this.questionSets[D].identity==G){F=this.questionSets[D];F.title=F.name;break;}}}if(F!=""){this.sendEvent(Planeto.SHARE_QUESTIONSET,{linkBonusIdentity:F.identity,content:F,source:"game"});}}else{if(B=="menuShare2"){var E={},A=this.questionSets.length;E.linkBonus={};if(A>0){for(var D=0;D<A;D++){if(this.questionSets[D].identity==G){E.linkBonus.identity=this.questionSets[D].identity;E.linkBonus.description=this.questionSets[D].name;E.iconUrl=this.questionSets[D].imageUrl;E.description=this.questionSets[D].description;E.nbrOfCorrect=this.questionSets[D].nbrOfCorrect;E.time=this.questionSets[D].time;E.totalNbrOfQuestions=this.questionSets[D].totalNbrOfQuestions;break;}}}if(E.linkBonus.identity){this.sendEvent(Planeto.ChallengeFriends.SHOW,E,false);}}else{if(B=="questionsetMenuItemLeaderboard"){this.showQuestionSetLeaderboard(G);}}}},showQuestionSetLeaderboard:function(A){this.sendEvent(Planeto.Leaderboard.Control.SHOW,{leaderboardType:"questionset",questionSetIdentity:A});},getTimeFractionFromTime:function(A){var C=A/1000,B={hours:0,minutes:0,seconds:0};getTimeFraction=function(E){var D=Math.floor(C/E);C-=D*E;return D;};if(C>0){B.hours=getTimeFraction(3600);B.minutes=getTimeFraction(60);B.seconds=getTimeFraction(1);}return B;},showQuestionSetProvider:function(A){if(A.creatorName){$("#quizProvider .other").html("Questions by "+A.creatorName).show().siblings().hide();}},hideQuestionSetProvider:function(){$("#quizProvider .planeto").show().siblings().hide();}});BasicMVC.Facade.getInstance().register(new Planeto.QuestionSet.View());Planeto.QuizStreamGame=Planeto.QuizStreamGame||{};Planeto.QuizStreamGame.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.QuizStreamGame.Control";this.facade.debug=location.href.indexOf("debug")!=-1;this.sendEvent(Planeto.QuizStreamGame.Control.LOAD_FINISHED);},eventListeners:function(){return[ConnectionControl.LOGIN_RESPONSE,ConnectionControl.NOT_LOGGED_IN_TO_FACEBOOK];
},eventHandlers:function(A){switch(A.name){case ConnectionControl.LOGIN_RESPONSE:this.onLoginResponse(A.data);break;case ConnectionControl.NOT_LOGGED_IN_TO_FACEBOOK:this.onNotLoggedInToFacebook(A.data);break;}},onLoginResponse:function(A){if(href_match_wm&&href_match_wm[1]){this.sendEvent(PlanetoService.BE_PART_OF_WAVE_REQUEST,href_match_wm[1]);}if(location.href.indexOf("settings")!=-1){this.sendEvent(Planeto.UserSettings.Control.SHOW_USER_SETTINGS);}else{if(A.account.user.hasSetLocation||A.connectedAsGuest){this.sendEvent(PlanetoService.NEW_QUIZ_SESSION);}else{this.sendEvent(Planeto.UserSettings.Control.SET_FIRSTTIME,{firstTime:true});this.sendEvent(Planeto.UserSettings.Control.SHOW_USER_SETTINGS);}}},onNotLoggedInToFacebook:function(A){}});Planeto.QuizStreamGame.Control.LOAD_FINISHED="Planeto.QuizStreamGame.Control.LOAD_FINISHED";BasicMVC.Facade.getInstance().register(new Planeto.QuizStreamGame.Control());Planeto.SelfQuiz=Planeto.SelfQuiz||{};Planeto.SelfQuiz.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.SelfQuiz.Control";$("#popularQuizSelector .selfQuizzes > ul li").live("click",this.localScopeFull(this.selfQuizClicked));$("#popularQuizSelector .questionSets > ul li").live("click",this.localScopeFull(this.questionSetClicked));$("#popularQuizSelector .bannerCreate > div").live("click",function(){location.href="http://create.planeto.com";});},eventListeners:function(){return[PlanetoEvents.SELF_QUIZ_STARTED_EVENT];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.SELF_QUIZ_STARTED_EVENT:this.selfQuizStarted(A.data);break;}},selfQuizStarted:function(A){currentSelfQuiz=A;this.currentQuestionIndex=0;this.sendEvent(Planeto.SelfQuiz.START,currentSelfQuiz);$("#selfQuizNavigation .next").unbind("click").bind("click",this.localScopeFull(this.onNextButtonClick));$("#selfQuizNavigation .prev").unbind("click").bind("click",this.localScopeFull(this.onPreviousButtonClick));$("#selfQuizNavigation .submit").unbind("click").bind("click",this.localScopeFull(this.submitQuiz));$("#answerContainer td").removeClass("exclude").unbind().bind("click",this.localScopeFull(this.answerQuestion));$("#popularQuizSelector .bannerPlay > .play").unbind("click").bind("click",this.localScopeFull(this.startInfiniteStreamGame));},selfQuizClicked:function(B){var A=$(B.target).parents("li.nthRow"),C=A.attr("rel");this.sendEvent(PlanetoService.START_SELF_QUIZ,C);this.sendEvent(Planeto.SelfQuiz.LEAVE);this.sendEvent(PlanetoService.PAUSE_PLAYING,false);},questionSetClicked:function(B){var A=$(B.target).parents("li.nthRow"),C=A.attr("rel");this.sendEvent(PlanetoService.START_QUESTION_SET,C);this.startInfiniteStreamGame();},answerQuestion:function(A){var B=parseInt(A.currentTarget.id.replace("answer",""))-1;this.sendEvent(Planeto.SelfQuiz.QUESTION_ANSWERED,B);this.nextQuestion();},onNextButtonClick:function(A){var B=$(A.currentTarget).hasClass("disabledButton");if(!B){this.nextQuestion();}},onPreviousButtonClick:function(A){var B=$(A.currentTarget).hasClass("disabledButton");if(!B){this.previousQuestion();}},nextQuestion:function(){if(this.currentQuestionIndex<currentSelfQuiz.questions.length-1){this.currentQuestionIndex+=1;this.sendEvent(Planeto.SelfQuiz.NAVIGATE,this.currentQuestionIndex);}},previousQuestion:function(){if(this.currentQuestionIndex>0){this.currentQuestionIndex-=1;this.sendEvent(Planeto.SelfQuiz.NAVIGATE,this.currentQuestionIndex);}},submitQuiz:function(D){var C=$(D.currentTarget).hasClass("disabledButton"),F=[];if(C){return ;}for(var B=0;B<currentSelfQuiz.questions.length;B++){var A=currentSelfQuiz.questions[B],E={};E.questionIndex=B;E.answerIndex=A.answerIndex;F.push(E);}this.sendEvent(PlanetoService.SUBMIT_SELF_QUIZ,{answers:F,identity:currentSelfQuiz.identity});this.sendEvent(PlanetoService.GET_SOME_SELF_QUIZES);this.sendEvent(PlanetoService.GET_SOME_QUESTION_SETS);},startInfiniteStreamGame:function(){this.sendEvent(Planeto.SelfQuiz.LEAVE);this.sendEvent(Planeto.Player.Control.START_PLAYING);}});Planeto.SelfQuiz.LEAVE="Planeto.SelfQuiz.LEAVE";
Planeto.SelfQuiz.QUESTION_ANSWERED="Planeto.SelfQuiz.QUESTION_ANSWERED";Planeto.SelfQuiz.NAVIGATE="Planeto.SelfQuiz.NAVIGATE";BasicMVC.Facade.getInstance().register(new Planeto.SelfQuiz.Control());Planeto.SelfQuiz=Planeto.SelfQuiz||{};Planeto.SelfQuiz.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.SelfQuiz.View";this.currentQuestionIndex=0;$("#selfQuizStart .startButton").live("click",this.localScopeFull(this.startSelfQuiz));},eventListeners:function(){return[PlanetoEvents.SELF_QUIZ_STARTED_EVENT,PlanetoEvents.SUBMIT_SELF_QUIZ_ANSWERS_RESPONSE,Planeto.SelfQuiz.START,Planeto.SelfQuiz.LEAVE,Planeto.SelfQuiz.QUESTION_ANSWERED,Planeto.SelfQuiz.NAVIGATE,PlanetoEvents.GET_SOME_SELF_QUIZES_RESPONSE,PlanetoEvents.GET_SOME_QUESTION_SETS_RESPONSE,Planeto.SelfQuiz.CLOSE_SELF_QUIZ_RESULT];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.SELF_QUIZ_STARTED_EVENT:this.showSelfQuiz(A.data);break;case PlanetoEvents.SUBMIT_SELF_QUIZ_ANSWERS_RESPONSE:this.showSelfQuizResult(A.data);break;case Planeto.SelfQuiz.START:this.showSelfQuizProvider(A.data);break;case Planeto.SelfQuiz.LEAVE:this.resetUIOnExit();this.hideSelfQuizProvider();break;case Planeto.SelfQuiz.QUESTION_ANSWERED:this.questionAnswered(A.data);this.updateNavigation();break;case Planeto.SelfQuiz.NAVIGATE:this.showSelfQuizQuestion(A.data);this.updateNavigation();break;case PlanetoEvents.GET_SOME_SELF_QUIZES_RESPONSE:this.renderSelfQuizList(A.data);break;case PlanetoEvents.GET_SOME_QUESTION_SETS_RESPONSE:this.renderQuestionSetList(A.data);break;case Planeto.SelfQuiz.CLOSE_SELF_QUIZ_RESULT:this.closeSelfQuizResult(A.data);break;}},showSelfQuizProvider:function(A){if(A.creatorName){$("#quizProvider .other").encodeHtml("Questions by "+A.creatorName).show().siblings().hide();}},hideSelfQuizProvider:function(){$("#quizProvider .planeto").show().siblings().hide();},showSelfQuiz:function(A){var B=$("#selfQuizStart");this.selfQuiz=A;B.find("img").attr("src",getImageUrl("QS",this.selfQuiz.iconUrl,"plain"));B.find(".name").encodeHtml(this.selfQuiz.name);B.find(".description").encodeHtml(this.selfQuiz.description);$("#questionContainer, #answerContainer").addClass("selfquiz");$("#quizComingQuestions, #messageContainer, #questionClockContainer, #gamePausOverlay, #statusContainer").hide();$("#quizCategory").attr("class","selfquiz");$("#quizCategory img").attr("class","selfquiz").attr("src",resource_null_gif);$("#gameplayStatusArea").addClass("selfquiz").removeClass("categoryColor0 categoryColor1 categoryColor2 categoryColor3  categoryColor4 categoryColor5");$("#playerCurrentTopic").html("");$("#popularQuizSelector").hide();$("#quizProvider, #reportQuestionButton").hide();$("#gamePausOverlay").hide();$("#statusWrapper").css("visibility","hidden");$("#gameplayStatusArea .multiplier, #gameplayStatusArea .multiplier").attr("style","");B.show();},startSelfQuiz:function(){var B=this.selfQuiz.name.length>35?this.selfQuiz.name.substring(0,35):this.selfQuiz.name;$("#selfQuizStart").hide();$("#selfQuizNavigation, #reportQuestionButton").show();$("#quizProvider").show();$("#playerCurrentTopic").encodeHtml(B);$("#quizCategory img").removeClass("planeto, selfquiz").attr("src",getImageUrl("SQ",this.selfQuiz.iconUrl,42));this.currentQuestionIndex=0;this.renderQuestion(this.selfQuiz.questions[0]);var E=this.selfQuiz.questions.length,A=$("#questionSetProgress"),F=A.find("ul"),D=Math.floor((360-E)/E);F.html("");for(var C=0;C<E;C++){F.append("<li></li>");}F.find("li").css("width",D);A.find(".time").html((this.currentQuestionIndex+1)+" / "+E);A.show();this.updateNavigation();},showSelfQuizQuestion:function(A){this.currentQuestionIndex=A;this.renderQuestion(this.selfQuiz.questions[A]);},showSelfQuizResult:function(A){var B=$("#dialogSelfQuizCompleted");this.outcome=A.outcomes[0];question_set_summary=null;B.find(".name").encodeHtml(this.selfQuiz.name);B.find("img").attr("src",getImageUrl("SQ",this.outcome.image,"plain"));B.find(".description").encodeHtml(this.outcome.description);B.find(".title").encodeHtml(this.outcome.title);
B.find(".skip").unbind("click").bind("click",this.localScopeFull(this.closeSelfQuizResult));B.find(".share").unbind("click").bind("click",this.localScopeFull(this.shareSelfQuizResult));B.modal();this.showPopularQuizzes();},showPopularQuizzes:function(){$("#answerContainer, #questionContainer, #selfQuizNavigation, #quizProvider, #questionSetProgress, #reportQuestionButton").hide();$("#playerCurrentTopic").html("Try other popular Quizzes");$("#quizCategory img").addClass("planeto").attr("src",resource_null_gif);$("#popularQuizSelector").show();},resetUIOnExit:function(){$(".selfquiz").removeClass("selfquiz");$("#playerCurrentTopic").html("");$("#quizComingQuestions, #messageContainer, #questionClockContainer, #gamePausOverlay, #statusContainer").show();$("#answer1, #answer2, #answer3, #answer4").removeClass("hide").show();$("#answer5, #popularQuizSelector").hide();$("#quizCategory img").attr("src","/media/img/null.gif").removeClass("planeto");$("#questionSetProgress").find(".time");},renderQuestion:function(B){var H=B.alternatives.length,F=$("#questionContent"),C=false,A=false;F.removeClass("questionMedium questionSmall questionMini");if(B.text.length>=200){F.addClass("questionMini");}else{if(B.text.length>=60){F.addClass("questionSmall");}else{F.addClass("questionMedium");}}F.encodeHtml(B.text).show();$("#questionContainer").show();$("#answerContainer td").addClass("hide").removeClass("exclude wrongAnswer wrongAnswerAll correctAnswer selected long longer");for(var E=0;E<H;E++){var G=$("#answer"+(E+1)),D=B.alternatives[E];G.removeClass("hide").addClass("selectable").find("div").encodeHtml(D);if(B.answerIndex==E){G.addClass("selected");}if(D.length>15){C=true;}if(D.length>80){A=true;}}if(C){$("#answerContainer td").addClass("long");}if(A){$("#answerContainer td").addClass("longer");}$("#answerContainer").show();},renderSelfQuizList:function(C){var D=$("#popularQuizSelector .selfQuizzes > ul"),A=C.selfQuizes.length,F="";if(A>0){for(var E=0;E<A;E++){var B=C.selfQuizes[E];F+="<li class='questionSetItem nthRow' rel='"+B.identity+"'><img src='"+getImageUrl("SQ",B.image,42)+"'/><h2>"+htmlEncode(B.name)+"</h2></li>";}}else{F+="<li><h2>No Self Quizzes available</h2></li>";}D.html(F);},renderQuestionSetList:function(C){var D=$("#popularQuizSelector .questionSets > ul"),A=C.questionSets.length,F="";if(A>0){for(var E=0;E<A;E++){var B=C.questionSets[E];F+="<li class='questionSetItem nthRow' rel='"+B.identity+"'><img src='"+getImageUrl("SQ",B.imageUrl,42)+"'/><h2>"+htmlEncode(B.name)+"</h2></li>";}}else{F+="<li><h2>No Question Sets available</h2></li>";}D.html(F);},questionAnswered:function(F){var B=this.selfQuiz.questions[this.currentQuestionIndex],E=$("#answerContainer td"),C=$("#answer"+(F+1)),A=$("#questionSetProgress"),D=$(A.find("ul li").get(this.currentQuestionIndex));B.answerIndex=F;E.removeClass("selected");C.addClass("selected");D.addClass("answered");},updateNavigation:function(){var D=$("#selfQuizNavigation .next"),E=$("#selfQuizNavigation .prev"),F=$("#selfQuizNavigation .submit"),B=$("#questionSetProgress"),H=$(B.find("ul li").get(this.currentQuestionIndex)),G=this.currentQuestionIndex==0,C=this.currentQuestionIndex==this.selfQuiz.questions.length-1,A=this.selfQuiz.questions[this.currentQuestionIndex].answerIndex>-1;H.addClass("active").siblings().removeClass("active");B.find(".time").html((this.currentQuestionIndex+1)+" / "+this.selfQuiz.questions.length);if(G){E.hide();}else{if(C){E.show();}else{E.show();}}if(A&&C){F.show();D.hide();}else{if(A){D.show();F.hide();}else{D.hide();F.hide();}}},closeSelfQuizResult:function(){$("#dialogSelfQuizCompleted").modalClose();var A={};A.linkBonus={};A.linkBonus.identity=this.selfQuiz.identity;A.linkBonus.description=this.selfQuiz.name;A.iconUrl=this.selfQuiz.iconUrl;A.description=this.selfQuiz.description;this.sendEvent(Planeto.ChallengeFriends.SHOW,A,false);},shareSelfQuizResult:function(){var A={};A.selfQuiz=this.selfQuiz;A.outcome=this.outcome;this.sendEvent(Planeto.Facebook.QuizFeed.Control.PUBLISH_SELFQUIZ,A);
}});Planeto.SelfQuiz.START="Planeto.SelfQuiz.START";Planeto.SelfQuiz.CLOSE_SELF_QUIZ_RESULT="Planeto.SelfQuiz.CLOSE_SELF_QUIZ_RESULT";BasicMVC.Facade.getInstance().register(new Planeto.SelfQuiz.View());Planeto.ChallengeFriends=Planeto.ChallengeFriends||{};Planeto.ChallengeFriends.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.ChallengeFriends.View";this.challengeObject=null;this.inputTimeout=400;this.inputTimer=null;$("#dialogChallengeFriends .rewards div.reward").live("click",this.localScopeFull(this.onRewardSelected));$("#dialogChallengeFriends .friendslist > div").live("click",this.localScopeFull(this.onFriendSelected));$("#dialogChallengeFriends .close").live("click",this.localScopeFull(this.closeDialog));$("#dialogChallengeFriends .showall").live("click",this.localScopeFull(this.renderAllFriends));$("#dialogChallengeFriends input.filter").live("keyup",this.localScopeFull(this.filterInputHandler));},eventListeners:function(){return[Planeto.ChallengeFriends.SHOW,Planeto.ChallengeFriends.GENERATE_FRIENDS,Planeto.ChallengeFriends.SHOW_ALL_FRIENDS,PlanetoService.GET_REWARD_FOR_CHALLENGING_A_FRIEND_REQUEST,PlanetoEvents.GET_REWARD_FOR_CHALLENGING_AFRIEND_RESPONSE];},eventHandlers:function(A){switch(A.name){case Planeto.ChallengeFriends.SHOW:this.showChallengeFriends(A.data[0],A.data[1]);break;case Planeto.ChallengeFriends.GENERATE_FRIENDS:this.generateFriends(A.data);break;case Planeto.ChallengeFriends.SHOW_ALL_FRIENDS:$(".friendfilter input").val("");this.renderAllFriends();break;case PlanetoService.GET_REWARD_FOR_CHALLENGING_A_FRIEND_REQUEST:this.onRewardRequested();break;case PlanetoEvents.GET_REWARD_FOR_CHALLENGING_AFRIEND_RESPONSE:this.getRewardForChallengingAFriendResponse(A.data);break;}},getRewardForChallengingAFriendResponse:function(A){var D=$("#dialogChallengeFriends .rewards"),B=$("#dialogChallengeFriends .rewardResponse"),C=B.find(".message");D.hide();if(A.gotReward){switch(A.rewardType){case"GOLD":C.html("Thank you. You have now received "+A.goldAmount+" gold.");break;case"QUESTION_SET":if(A.questionSetName){C.html("Thank you. You have received a new quiz: '"+A.questionSetName+"'");}else{C.html("We're very sorry, but we have no available quiz to give you. You have received "+A.goldAmount+" gold instead.");}break;case"FORTUNE_COOKIE":C.html('<em>"'+A.fortuneCookie+'"</em>');break;}B.show();}},showChallengeFriends:function(B,A){if(fb_friends.length>0){if(A==true){$("#dialogChallengeFriends .rewards").show();}else{$("#dialogChallengeFriends .rewards").hide();}$("#dialogChallengeFriends .rewardResponse").hide();if(B.friendsWhoPlayedIt){question_set_summary.friendsWhoPlayedIt=B.friendsWhoPlayedIt;}else{question_set_summary=get_quiz_info(B.linkBonus.identity,creator_content);}this.challengeObject=B;var C=$("#dialogChallengeFriends");if(B.linkBonus){C.find(".dialogHeader span").html(B.linkBonus.description);}C.find("input.filter").val("");setTimeout(function(){C.modal();},500);setTimeout(this.localScopeFull(this.renderAllFriends),500);}else{this.closeDialog();}},closeDialog:function(){$("#dialogChallengeFriends").modalClose();},renderAllFriends:function(){this.renderFriends(fb_friends);},renderFriends:function(D){var C=$("#dialogChallengeFriends"),E=C.find(".friendslist"),B=D.length;tmp=[];for(var A=0;A<B;A++){var G=D[A],F="<div class='friendItem' id='challenge-friend-"+G.id+"' rel='"+G.id+"'><img src='http://graph.facebook.com/"+G.id+"/picture'/><h4>"+shortenString(G.name,8,"..",true)+"</h4></div>";tmp.push(F);}E.html(tmp.join(""));},filterInputHandler:function(){clearTimeout(this.inputTimer);if(this.filtering){this.abortFilter=true;}this.inputTimer=setTimeout(this.localScopeFull(this.filterFriends),this.inputTimeout);},filterFriends:function(){var G=fb_friends.length,A=$("#dialogChallengeFriends input.filter").val().toLowerCase(),B=[];this.filtering=true;if(A==""){this.renderAllFriends();this.abortFilter=false;this.filtering=false;return ;}for(var D=0;D<G;D++){var C=fb_friends[D],H=C.name.split(" "),E=false,F=$("#challenge-friend-"+C.id);
if(C.name.toLowerCase().startsWith(A)){E=true;}else{for(var I=0;I<H.length;I++){if(H[I].toLowerCase().startsWith(A)){E=true;}}}if(E){B.push(C);}if(this.abortFilter){this.abortFilter=false;return ;}}this.abortFilter=false;this.filtering=false;this.renderFriends(B);},onRewardRequested:function(){},onRewardSelected:function(B){var A=$(B.target).is("div")?$(B.target):$(B.target).parent("div");A.addClass("active").siblings("div").removeClass("active");},onFriendSelected:function(D){var A=$(D.target);if(!A.hasClass("friendItem")){A=A.parent(".friendItem");}message=this.challengeObject;message.target_id=A.attr("rel");if(question_set_summary&&question_set_summary.friendsWhoPlayedIt){var C=question_set_summary.friendsWhoPlayedIt.length,E=false;for(var B=0;B<C;B++){if(parseInt(message.target_id)==parseInt(question_set_summary.friendsWhoPlayedIt[B])){E=true;break;}}}if(E==true){this.friendHasPlayedIt(message);}else{this.sendEvent(Planeto.Facebook.QuizFeed.Control.CHALLENGE_FRIEND,message);}},friendHasPlayedIt:function(A){var B=$("#dialogFriendHasPlayedIt");B.modal();$("#dialogFriendHasPlayedIt .continueButton").unbind("click").bind("click",this.localScopeFull(this.challengeFriendAnyway,A));$("#dialogFriendHasPlayedIt .declineButton").unbind("click").bind("click",function(){$("#dialogFriendHasPlayedIt").modalClose();});},challengeFriendAnyway:function(C,B,A){$("#dialogFriendHasPlayedIt").modalClose();this.sendEvent(Planeto.Facebook.QuizFeed.Control.CHALLENGE_FRIEND,A);},generateFriends:function(B){var D=[],A=4;for(var C=0;C<B;C++){var E=[];E.id=A+C;E.name=this.generateName(3,10,"","")+" "+this.generateName(4,16,"","");D.push(E);}fb_friends=D;},rnd:function(B,A){if(A<B){return 0;}return Math.floor(Math.random()*(A-B+1))+B;},generateName:function(E,C,H,J){H=H||"";J=J||"";var F="aeiouyhaeiouaeiou";var A="bcdfghjklmnpqrstvwxzbcdfgjklmnprstvwbcdfgjklmnprst";var K=F+A;var D=this.rnd(E,C)-H.length-J.length;if(D<1){D=1;}var I=0;if(H.length>0){for(var G=0;G<H.length;G++){if(I==2){I=0;}if(A.indexOf(H[G])!=-1){I++;}}}else{I=1;}var B=H;for(var G=0;G<D;G++){if(I==2){touse=F;I=0;}else{touse=K;}c=touse.charAt(this.rnd(0,touse.length-1));B=B+c;if(A.indexOf(c)!=-1){I++;}}B=B.charAt(0).toUpperCase()+B.substring(1,B.length)+J;return B;}});Planeto.ChallengeFriends.SHOW="Planeto.ChallengeFriends.SHOW";Planeto.ChallengeFriends.GENERATE_FRIENDS="Planeto.ChallengeFriends.GENERATE_FRIENDS";Planeto.ChallengeFriends.SHOW_ALL_FRIENDS="Planeto.ChallengeFriends.SHOW_ALL_FRIENDS";BasicMVC.Facade.getInstance().register(new Planeto.ChallengeFriends.View());Planeto.Multiplayer=Planeto.Creator||{};Planeto.Multiplayer.Model=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Multiplayer.Model";this.games=[];this.gamerooms=[];this.activeGameRoom=null;},eventListeners:function(){return[PlanetoEvents.GET_AVAILABLE_GAME_ROOM_GAMES_RESPONSE,PlanetoEvents.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME_RESPONSE,PlanetoEvents.GAME_ROOM_JOINED_EVENT,PlanetoEvents.GAME_ROOM_UPDATED_EVENT,PlanetoEvents.TEAM_GAME_ROOM_FULL_EVENT];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.GET_AVAILABLE_GAME_ROOM_GAMES_RESPONSE:this.onGetAvailableGameRoomGames(A.data);break;case PlanetoEvents.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME_RESPONSE:this.onGetGameRoomsCollection(A.data);break;case PlanetoEvents.GAME_ROOM_JOINED_EVENT:this.onGameRoomJoined(A.data);break;case PlanetoEvents.GAME_ROOM_UPDATED_EVENT:this.onGameRoomUpdated(A.data);break;case PlanetoEvents.TEAM_GAME_ROOM_FULL_EVENT:this.onTeamGameRoomFull(A.data);break;}},onGetAvailableGameRoomGames:function(A){this.games=A.games;},onGetGameRoomsCollection:function(A){this.gamerooms=A;},onGameRoomJoined:function(A){this._updateGameRoom(A.gameRoom);this.sendEvent(Planeto.Multiplayer.GAME_ROOM_GAMES_UPDATED,this.gamerooms);},onGameRoomUpdated:function(A){this._updateGameRoom(A.gameRoom);this.sendEvent(Planeto.Multiplayer.GAME_ROOM_GAMES_UPDATED,this.gamerooms);},onTeamGameRoomFull:function(A){this._updateTeamGameRoom(A.teamGameRoomDTO);
this.sendEvent(Planeto.Multiplayer.GAME_ROOM_GAMES_UPDATED,this.gamerooms);},_updateGameRoom:function(A){for(var C=0;C<this.gamerooms.gameRoomCollectionDTOs.length;C++){var B=this.gamerooms.gameRoomCollectionDTOs[C].identity;if(A.identity==B){this.gamerooms.gameRoomCollectionDTOs[C]=A;break;}}},_updateTeamGameRoom:function(C){for(var B=0;B<this.gamerooms.teamRoomDTOs.length;B++){var A=this.gamerooms.teamRoomDTOs[B].team.identity;if(C.team.identity==A){this.gamerooms.teamRoomDTOs[B]=C;break;}}}});Planeto.Multiplayer.INIT="Planeto.Multiplayer.INIT";Planeto.Multiplayer.EXIT="Planeto.Multiplayer.EXIT";Planeto.Multiplayer.END_GAME="Planet.Multiplayer.END_GAME";Planeto.Multiplayer.GAME_ROOM_GAMES_UPDATED="Planeto.Multiplayer.GAME_ROOM_GAMES_UPDATED";BasicMVC.Facade.getInstance().register(new Planeto.Multiplayer.Model());Planeto.Multiplayer=Planeto.Multiplayer||{};Planeto.Multiplayer.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Multiplayer.View";this.currenGameTypeCode=null;$("#multiplayerArea .gamemodeInfo p.hilite").blink();$("#multiplayerTabActiveRoom li.player:not(.binded)").live("click",this.localScopeFull(this.playerMenuOver));$("#tabContent_5_1 .shareToMyWall, #tabContent_5_2 .shareToMyWall").live("click",this.localScopeFull(this.shareToMyWall));},eventListeners:function(){return[Planeto.Multiplayer.INIT,Planeto.Multiplayer.View.INIT,Planeto.Multiplayer.View.RESET,PlanetoEvents.GET_AVAILABLE_GAME_ROOM_GAMES_RESPONSE,Planeto.Multiplayer.GAME_ROOM_GAMES_UPDATED,PlanetoEvents.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME_RESPONSE,PlanetoEvents.GAME_ROOM_JOINED_EVENT,PlanetoEvents.GAME_ROOM_UPDATED_EVENT,PlanetoEvents.GAME_ROOM_FULL_EVENT,Planeto.Multiplayer.SHOW_TRAVEL,Planeto.Multiplayer.HIDE_TRAVEL,PlanetoEvents.GAME_ROOM_PARTICIPANT_CHANGED_EVENT,PlanetoEvents.PLAYERS_WAITING_FOR_OTHERS_CHANGED_EVENT,PlanetoEvents.IGNORE_USER_LIST_CHANGED];},eventHandlers:function(A){switch(A.name){case Planeto.Multiplayer.INIT:this.initUI();break;case PlanetoEvents.GAME_ROOM_PARTICIPANT_CHANGED_EVENT:this.gameRoomParticipantChanged(A.data);break;case Planeto.Multiplayer.View.INIT:this.initUI();break;case Planeto.Multiplayer.View.RESET:this.resetUI();break;case PlanetoEvents.GET_AVAILABLE_GAME_ROOM_GAMES_RESPONSE:this.currenGameTypeCode=null;this.showWaitingPlayersInGame(A.data);this.renderGames(A.data);break;case PlanetoEvents.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME_RESPONSE:if(this.currenGameTypeCode==A.data.game.typeCode){this.renderGameRooms(A.data);}else{this.currenGameTypeCode=A.data.game.typeCode;this.renderGameRoomsTab(A.data);}this.displayGameTypeInfo(A.data);this.displayGameRoomsTab();break;case Planeto.Multiplayer.GAME_ROOM_GAMES_UPDATED:this.renderGameRooms(A.data);break;case PlanetoEvents.GAME_ROOM_JOINED_EVENT:this.renderActiveGameRoom(A.data);this.displayActiveGameRoomTab();break;case PlanetoEvents.GAME_ROOM_UPDATED_EVENT:this.renderActiveGameRoom(A.data);break;case Planeto.Multiplayer.SHOW_TRAVEL:this.showTravel();break;case Planeto.Multiplayer.HIDE_TRAVEL:this.hideTravel();break;case PlanetoEvents.PLAYERS_WAITING_FOR_OTHERS_CHANGED_EVENT:this.showTotalWaitingPlayersInGame(A.data.waitingPlayers);break;case PlanetoEvents.IGNORE_USER_LIST_CHANGED:this.updateIgnoredPersons();break;}},shareToMyWall:function(){if(this.currenGameTypeCode=="QUIZ_RACE"){var A={gameType:"quizrace",name:"Quiz race",caption:"Come join me in a Quiz Race!"};}else{if(this.currenGameTypeCode=="PICTURE_QUIZ"){var A={gameType:"picturequiz",name:"Picture quiz",caption:"Come join me in a Picture Quiz!"};}else{if(this.currenGameTypeCode=="HOT_SEAT"){var A={gameType:"hotseat",name:"Hot seat",caption:"Come join me in the Hot Seat!"};}}}if(A){this.sendEvent(PlanetoEvents.POST_TO_FACEBOOK_WALL,A);}},gameRoomParticipantChanged:function(A){$("#multiplayerTabActiveRoom li[identity="+A.participant.identity+"] span.score").html(A.participant.currentScore);},showTotalWaitingPlayersInGame:function(A){var B=$("#topMenuMulti, #landingScreenMulti");B.find(".notification").attr("class","notification redCounter");
if(A>0){update_doc_title("("+A+") Waiting");if(A>40){B.find(".notification").addClass("redCounter40Plus");}else{if(A>0){B.find(".notification").addClass("redCounter"+A);}}}else{update_doc_title();}},showWaitingPlayersInGame:function(A){var C=0;for(var B=0;B<A.games.length;B++){C+=A.games[B].nbrOfWaitingPlayers;}this.showTotalWaitingPlayersInGame(C);},init:function(C){var A=this;try{if(Planeto.FragmentLoader.templateExist("multiplayer_gameroom_tabcontent")){A.initUI();A.renderGames(C);}else{Planeto.FragmentLoader.loadTemplates(resource_multiplayer_templates,function(){A.initUI();A.renderGames(C);});}}catch(B){console.error("--- ",B);}},initUI:function(){$("#gameplayHead, #quizArea, #quizArea .summaryScreen, #travelHead, #travelArea, #multiplayerArea .gamemodeInfo").hide();$("#multiplayerHead,#multiplayerArea,#multiplayerArea .gamemodes").show();$("#hotseatView").hide();this.sendEvent(StatusView.HIDE_MESSAGE);this.sendEvent(Planeto.Inventory.DISABLE_REMOVE_INCORRECT_QUESTION,true);this.sendEvent(Planeto.Inventory.DISABLE_SKIP_QUESTION,true);this.sendEvent(Planeto.Inventory.DISABLE_ACTIONBAR_CARDS,true);this.hideMultiplayerTab();},resetUI:function(A){$("#gameplayHead,#quizArea").show();$("#multiplayerHead,#multiplayerArea").hide();$("#hotseatView").hide();this.sendEvent(Planeto.Inventory.DISABLE_REMOVE_INCORRECT_QUESTION,false);this.sendEvent(Planeto.Inventory.DISABLE_SKIP_QUESTION,false);this.sendEvent(Planeto.Inventory.DISABLE_ACTIONBAR_CARDS,false);this.hideMultiplayerTab();},renderGames:function(C){var G=C.games,E=this;if(Planeto.FragmentLoader.templateExist("multiplayer_gameroom_tabcontent")){var F=G.length;for(var D=0;D<F;D++){var B=G[D],A;switch(B.typeCode){case"HOT_SEAT":gamemodeItem=$("#multiplayerArea .gamemodes .hotseat");break;case"QUIZ_RACE":gamemodeItem=$("#multiplayerArea .gamemodes .quizrace");break;case"PICTURE_QUIZ":gamemodeItem=$("#multiplayerArea .gamemodes .picturequiz");break;}if(gamemodeItem){gamemodeItem.find(".players span").html(B.nbrOfActivePlayers);gamemodeItem.find(".desc").html(B.shortDescription);gamemodeItem.find(".notification").attr("class","notification redCounter");if(B.nbrOfActivePlayers>40){gamemodeItem.find(".notification").addClass("redCounter40Plus");}else{if(B.nbrOfActivePlayers>0){gamemodeItem.find(".notification").addClass("redCounter"+B.nbrOfWaitingPlayers);}}}}}else{Planeto.FragmentLoader.loadTemplates(resource_multiplayer_templates,function(){E.renderGames(C);});}},renderGameRoomsTab:function(A){$("#quizArea").hide();$("#multiplayerArea").show();var B=$("#tabContent_5"),C=this;if(Planeto.FragmentLoader.templateExist("multiplayer_gameroom_tabcontent")){B.empty();$.tmpl("multiplayer_gameroom_tabcontent",A).appendTo(B);}else{Planeto.FragmentLoader.loadTemplates(resource_multiplayer_templates,function(){C.renderGameRoomsTab(A);});}},renderGameRooms:function(A){$.tmpl("multiplayer_gameroom_tabcontent_roomlist",A).appendTo($("#multiplayerTabGameRooms").empty());},renderActiveGameRoom:function(B){var A=$("#multiplayerTabActiveRoom").empty();B.gameRoom.type=Planeto.Globals.currentGameType;for(var C=0;C<B.gameRoom.participants.length;C++){if(ignoredByUser(B.gameRoom.participants[C].identity)){B.gameRoom.participants[C].ignored=true;}else{B.gameRoom.participants[C].ignored=false;}}$.tmpl("multiplayer_gameroom_tabcontent_activeroom",B).appendTo(A);},updateIgnoredPersons:function(A){var D=$("#multiplayerTabActiveRoom .player");for(var B=0;B<D.length;B++){var C=$(D[B]).children(".name");C.removeClass("ignoredPlayer");if(ignoredByUser($(D[B]).attr("identity"))){C.addClass("ignoredPlayer");}}},displayGameRoomsTab:function(){$("#column3 li").removeClass("active");$("#tabContentContainer > .tabContent").addClass("hide").hide();$("#tab_5").removeAttr("class").addClass(this.currenGameTypeCode);$("#tab_5, #tab_5_1").addClass("active");$("#column3, #tab_5, #tabContent_5, #tabContent_5_1").show();},displayActiveGameRoomTab:function(){$("#column3 li").removeClass("active");$("#tabContentContainer > .tabContent").addClass("hide").hide();
$("#tabContent_5_1").addClass("hide").hide();$("#tab_5, #tab_5_2").addClass("active");$("#tab_5, #tabContent_5, #tabContent_5_2").show();},hideMultiplayerTab:function(){$("#tab_5, #tabContent_5, #tabContent_5_1, #tabContent_5_2").hide();$("#tab_1, #tab_5_1").addClass("active");$("#tab_1, #tabContent_1, #tabContent_1_1").show();},displayGameTypeInfo:function(B){var A=$("#multiplayerArea .gamemodeInfo");$("#multiplayerArea .gamemodes").hide();A.children().hide();A.show();switch(B.game.typeCode){case"HOT_SEAT":A.find(".hotseat").show();break;case"QUIZ_RACE":A.find(".quizrace").show();break;case"PICTURE_QUIZ":A.find(".picturequiz").show();break;}},getTemplateData:function(B){var A=$.tmplItem(B);return A.data;},playerMenuOver:function(E){var F=this.getTemplateData(E.target);if($(E.target).parents("#userProfile").length==0&&!$(E.target).is("#userProfile")){var D=$(E.target).hasClass("player")?$(E.target):$(E.target).parents(".player");var C=ignoredByUser(F.identity);this.hidePlayerMenu();$("#friendMenuHolder").removeClass("isPlayer isOffline isOnline isIgnored").addClass("friendMenuCurrent isOnline").addClass((C?" isIgnored":"")).data("friendId",F.identity).css({top:E.pageY+"px",left:E.pageX+"px"}).show();if(F.identity==user_id){$("#friendMenuHolder").addClass("isPlayer");}if(HIDE_FRIEND_MENU_TIMEOUT!=-1){clearTimeout(HIDE_FRIEND_MENU_TIMEOUT);}$("div.friendMenuCurrent").unbind("mouseleave").bind("mouseleave",CallbackProxy(this,function(){HIDE_FRIEND_MENU_TIMEOUT=setTimeout(CallbackProxyTimeouts(this,this.hidePlayerMenu),500);})).unbind("mouseenter").bind("mouseenter",function(){clearTimeout(HIDE_FRIEND_MENU_TIMEOUT);});$("div.friendMenuCurrent").unbind("click").bind("click",CallbackProxy(this,function(){this.hidePlayerMenu();}));$("#friendMenuItemKick").hide();if(this.teams){var B=this.teams.length,G=false;if(B>0){for(var A=0;A<B;A++){if(this.teams[A].leader==true){G=true;break;}}}}$("#friendMenuItemChat").show();$("#friendMenuItemChallenge, #friendMenuItemPost").hide();if(G==true){$("#friendMenuItemInvite").show();}else{$("#friendMenuItemInvite").hide();}if(D.children(".name").hasClass("ignoredPlayer")){$("#friendMenuItemIgnore").hide();$("#friendMenuItemStopIgnoring").show();}else{$("#friendMenuItemIgnore").show();$("#friendMenuItemStopIgnoring").hide();}}},hidePlayerMenu:function(){if($("div.friendMenuCurrent")){$("div.friendMenuCurrent").unbind("mouseleave").removeClass("friendMenuCurrent").hide();}},showTravel:function(){$("#gameplayHead, #quizArea, multiplayerHead, #multiplayerArea").hide();$("#travelArea, #travelHead").show();$("#travelArea .back").unbind("click").bind("click",this.localScopeFull(this.travelBackClicked));},hideTravel:function(){$("#travelArea, #travelHead").hide();$("#gameplayHead, #quizArea").show();},travelBackClicked:function(){this.hideTravel();this.sendEvent(PlanetoEvents.SHOW_LANDING_SCREEN);}});Planeto.Multiplayer.View.INIT="Planeto.Multiplayer.View.INIT";Planeto.Multiplayer.View.RESET="Planeto.Multiplayer.View.RESET";Planeto.Multiplayer.HIDE_TRAVEL="Planeto.Multiplayer.HIDE_TRAVEL";Planeto.Multiplayer.SHOW_TRAVEL="Planeto.Multiplayer.SHOW_TRAVEL";BasicMVC.Facade.getInstance().register(new Planeto.Multiplayer.View());Planeto.Multiplayer=Planeto.Multiplayer||{};Planeto.Multiplayer.Control=BasicMVC.Base.extend({constructor:function(){var A=this;this.name="Planeto.Multiplayer.Control";this.currentGameType=null;$("#multiplayerArea .gamemodes .hotseat img").unbind("click").bind("click",this.localScopeFull(this.showHotSeatGames));$("#multiplayerArea .gamemodes .quizrace img").unbind("click").bind("click",this.localScopeFull(this.showQuizRaceGames));$("#multiplayerArea .gamemodes .picturequiz img").unbind("click").bind("click",this.localScopeFull(this.showPictureQuizGames));$("#multiplayerArea .gamemodes .quizwave img").unbind("click").bind("click",this.localScopeFull(this.showQuizWaves));$("#tab_5_1").die("click").live("click",this.localScopeFull(this.updateGameRoomsAndCollections));$("#multiplayerTabGameRooms li").die("click").live("click",function(){var B=$.tmplItem(this),C=B.data;
if(C.team){A.joinTeamGame(C.team.teamId,A.currentGameType);}else{A.sendEvent(PlanetoService.STOP_GAME);A.sendEvent(PlanetoService.SELECT_GAME_ROOM_COLLECTION_REQUEST,C.identity);}});},eventListeners:function(){return[Planeto.Multiplayer.INIT,Planeto.Multiplayer.EXIT,Planeto.Multiplayer.END_GAME,Planeto.Multiplayer.View.INIT,PlanetoEvents.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME_RESPONSE,PlanetoEvents.KICKED_FROM_GAME_ROOM_EVENT];},eventHandlers:function(A){switch(A.name){case Planeto.Multiplayer.INIT:this.init();this.disableTutorial();break;case Planeto.Multiplayer.EXIT:this.exit();this.enableTutorial();break;case Planeto.Multiplayer.END_GAME:this.endGame();break;case PlanetoEvents.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME_RESPONSE:this.currentGameType=A.data.game.typeCode;break;case PlanetoEvents.KICKED_FROM_GAME_ROOM_EVENT:this.kicked(A.data);this.endGame();break;}},init:function(){this.sendEvent(PlanetoService.STOP_GAME);this.sendEvent(PlanetoService.GET_AVAILABLE_GAME_ROOM_GAMES);},exit:function(){this.currentGameType=null;this.sendEvent(PlanetoService.STOP_GAME);this.sendEvent(Planeto.Multiplayer.View.RESET);},showHotSeatGames:function(){this.sendEvent(PlanetoService.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME,"HOT_SEAT");},showQuizRaceGames:function(){this.sendEvent(PlanetoService.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME,"QUIZ_RACE");},showPictureQuizGames:function(){this.sendEvent(PlanetoService.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME,"PICTURE_QUIZ");},showQuizWaves:function(){this.sendEvent(Planeto.QuizWave.CREATE_WAVE);},updateGameRoomsAndCollections:function(){this.sendEvent(PlanetoService.GET_GAME_ROOMS_AND_COLLECTIONS_FOR_GAME,this.currentGameType);},joinTeamGame:function(B,C){var A={teamIdentity:B,gameRoomGame:C};this.sendEvent(PlanetoService.STOP_GAME);this.sendEvent(PlanetoService.JOIN_TEAM_GAME_ROOM_REQUEST,A);},joinGameRoom:function(A){this.sendEvent(PlanetoService.STOP_GAME);this.sendEvent(PlanetoService.SELECT_GAME_ROOM_COLLECTION_REQUEST,gameroom.identity);},kicked:function(A){var C=$("#dialogGameRoomKicked"),B=C.find(".closeModal");B.unbind("click").bind("click",function(){C.modalClose();});C.modal();},endGame:function(){this.currentGameType=null;this.sendEvent(Planeto.Multiplayer.INIT);},disableTutorial:function(){BasicMVC.Facade.getInstance().unregister("Planeto.Tutorial.View");},enableTutorial:function(){if(location.href.indexOf("notutorial")==-1){try{BasicMVC.Facade.getInstance().getInstanceByName("Planeto.Tutorial.View");}catch(A){BasicMVC.Facade.getInstance().register(new Planeto.Tutorial.View());}}}});BasicMVC.Facade.getInstance().register(new Planeto.Multiplayer.Control());Planeto.HotSeat=Planeto.HotSeat||{};Planeto.HotSeat.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.HotSeat.Control";$("#hotseatView .close").unbind("click").bind("click",this.localScopeFull(this.exitGame));},eventListeners:function(){return[PlanetoEvents.NEW_HOT_SEAT_HOLDER_EVENT];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.NEW_HOT_SEAT_HOLDER_EVENT:break;}},exitGame:function(){this.sendEvent(Planeto.Multiplayer.END_GAME);}});BasicMVC.Facade.getInstance().register(new Planeto.HotSeat.Control());Planeto.HotSeat=Planeto.HotSeat||{};Planeto.HotSeat.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.HotSeat.View";this.gameRoomParticipants=[];this.userInHotSeat=false;this.ui_initialized=false;this.questionContainerHidden=false;this.timerCountdownSounds=null;this.viewMode="left";this.nextPlayers=[];this.justJoined=false;},eventListeners:function(){return[Planeto.Multiplayer.EXIT,Planeto.HotSeat.View.INIT,Planeto.HotSeat.View.RESET,PlanetoEvents.GAME_ROOM_JOINED_EVENT,PlanetoEvents.GAME_ROOM_UPDATED_EVENT,PlanetoEvents.NEW_HOT_SEAT_HOLDER_EVENT,PlanetoEvents.NEW_QUIZ_EVENT,PlanetoEvents.END_QUIZ_EVENT,PlanetoEvents.SHOW_QUESTION_EVENT,PlanetoService.STOP_GAME];},eventHandlers:function(A){switch(A.name){case Planeto.HotSeat.View.INIT:this.viewMode=A.data;this.initUI();break;case Planeto.HotSeat.View.RESET:this.resetUI();
break;case PlanetoEvents.GAME_ROOM_JOINED_EVENT:if(this.gameTypeCheck()){this.gameRoomParticipants=A.data.gameRoom.participants;this.justJoined=true;this.initUI();$("#hotseatView").show();}break;case PlanetoEvents.GAME_ROOM_UPDATED_EVENT:this.gameRoomParticipants=A.data.gameRoom.participants;break;case PlanetoEvents.NEW_HOT_SEAT_HOLDER_EVENT:this.newHotSeatHolder(A.data);break;case PlanetoEvents.NEW_QUIZ_EVENT:if(this.gameTypeCheck()){$("#questionClock").show();if(!this.questionContainerHidden){this.showQuestionContainerLeft();}}break;case PlanetoEvents.END_QUIZ_EVENT:this.clearCountdownSounds();if(this.gameTypeCheck()){this.onEndQuizEvent(A.data);}break;case PlanetoService.STOP_GAME:if(this.gameTypeCheck()){this.resetUI();this.clearCountdownSounds();this.hideQuestionContainerLeft();}break;case PlanetoEvents.SHOW_QUESTION_EVENT:if(this.gameTypeCheck()){this.initCountdownSounds(A.data.timeUntilNextEvent);this.onShowQuestionEvent(A.data);}break;}},initUI:function(){$("#gameplayHead,#quizArea").show();$("#multiplayerHead,#multiplayerArea").hide();$("#gameplayStatusArea .streak").show();switch(this.viewMode){case"right":$("#answerContainer, #questionContainer, #questionWaitContainer, #quizProvider, #reportQuestionButton").hide().addClass("quizmode_right");break;case"left":$("#answerContainer, #questionContainer, #questionWaitContainer, #quizProvider, #reportQuestionButton").hide().addClass("quizmode_left");break;}$("#questionClock, #pauseContainer, #messageContainer").hide();$("#quizmode_questionContainerLeft").removeClass("minimized").show();$("#quizmode_questionContainerLeft .closebutton").unbind("click").bind("click",this.localScopeFull(this.toggleQuestionContainerLeft));$("#quizmode_questionContainerLeft .preview").unbind("click").bind("click",this.localScopeFull(this.showQuestionContainerLeft));this.sendEvent(Planeto.Inventory.DISABLE_REMOVE_INCORRECT_QUESTION,false);this.sendEvent(Planeto.Inventory.DISABLE_SKIP_QUESTION,true);this.sendEvent(Planeto.Inventory.DISABLE_ACTIONBAR_CARDS,true);this.ui_initialized=true;},resetUI:function(){$("#quizmode_questionContainerLeft").removeClass("minimized").hide();$("#answerContainer, #questionContainer, #questionWaitContainer, #quizProvider, #reportQuestionButton").removeClass("quizmode_right quizmode_left");$("#hotseatView").hide();$("#quizArea, #quizProvider, #reportQuestionButton").show();$("#column3, #pauseContainer, #messageContainer").show();this.sendEvent(Planeto.Inventory.DISABLE_SKIP_QUESTION,false);this.sendEvent(Planeto.Inventory.DISABLE_ACTIONBAR_CARDS,false);this.ui_initialized=false;},gameTypeCheck:function(){return(Planeto.Globals.currentGameType=="HOT_SEAT_GAME");},newHotSeatHolder:function(B){var A=$("#hotseatView"),C=A.find("h1"),D=A.find(".areis");if(B.identity==user_id){this.userInHotSeat=true;C.addClass("me");C.html("You");D.html("are");this.sendEvent(Planeto.SoundFX.PLAY,{name:"inhotseat",fadeOutTime:500});}else{this.userInHotSeat=false;C.removeClass("me");C.html(B.name);D.html("is");}this.nextPlayers=[];this.nextPlayers[0]=B;this.nextPlayers[1]=this.getPlayerAfter(B.identity);this.nextPlayers[2]=this.getPlayerAfter(this.nextPlayers[1].identity);if(this.justJoined){this.displayPlayers();}else{this.animatePlayers();}this.justJoined=false;},displayPlayers:function(){var A=$("#hotseatView"),B=A.find(".currentPlayer"),D=A.find(".nextPlayer1"),C=A.find(".nextPlayer2");B.find(".tooltipText").html(this.nextPlayers[0].name);B.find("img").attr("src",this.nextPlayers[0].smallPictureUrl).toolTiper();D.find(".tooltipText").html(this.nextPlayers[1].name);D.find("img").attr("src",this.nextPlayers[1].smallPictureUrl).toolTiper();C.find(".tooltipText").html(this.nextPlayers[2].name);C.find("img").attr("src",this.nextPlayers[2].smallPictureUrl).toolTiper();},animatePlayers:function(){var A=$("#hotseatView"),B=A.find(".currentPlayer"),E=A.find(".nextPlayer1"),C=A.find(".nextPlayer2"),D=this;E.find(".tooltipText").html(D.nextPlayers[0].name);E.find("img").attr("src",D.nextPlayers[0].smallPictureUrl).toolTiper();
C.find(".tooltipText").html(D.nextPlayers[1].name);C.find("img").attr("src",D.nextPlayers[1].smallPictureUrl).toolTiper();B.animate({left:400,opacity:0},600,function(){$(this).find("img").animate({width:30,height:30},700,function(){$(this).removeAttr("style").parent().removeClass("currentPlayer").addClass("nextPlayer2").removeAttr("style").hide().fadeIn(800);}).attr("src",D.nextPlayers[2].smallPictureUrl).toolTiper().parent().find(".tooltipText").html(D.nextPlayers[2].name);});E.animate({left:196,top:20,opacity:1},1200,function(){$(this).removeClass("nextPlayer1").addClass("currentPlayer").removeAttr("style").find("img").removeAttr("style");});E.find("img").animate({width:50,height:50},1200);C.animate({left:116,top:25,opacity:0.75},1200,function(){$(this).removeClass("nextPlayer2").addClass("nextPlayer1").removeAttr("style").find("img").removeAttr("style");});C.find("img").animate({width:40,height:40},1200);},getPlayerAfter:function(A){var C=-1,D=null;for(var B=0;B<this.gameRoomParticipants.length;B++){if(this.gameRoomParticipants[B].identity==A){C=B;break;}}if(C==this.gameRoomParticipants.length-1){D=this.gameRoomParticipants[0];}else{D=this.gameRoomParticipants[C+1];}return{identity:D.identity,name:D.name,smallPictureUrl:D.profilePicture.squarePixelUrl};},toggleQuestionContainerLeft:function(B){var A=$("#quizmode_questionContainerLeft");if(A.hasClass("minimized")){this.showQuestionContainerLeft();}else{this.hideQuestionContainerLeft();}},hideQuestionContainerLeft:function(){$("#quizmode_questionContainerLeft").addClass("minimized");$("#quizArea, #quizProvider, #reportQuestionButton").hide();this.questionContainerHidden=true;},showQuestionContainerLeft:function(){$("#quizmode_questionContainerLeft").removeClass("minimized");$("#quizmode_questionContainerLeft");$("#quizArea, #questionProvider").show();this.questionContainerHidden=false;},initCountdownSounds:function(C){var A=this,B=(C-5)*1000;this.clearCountdownSounds();this.timerCountdownSounds=setTimeout(this.localScopeFull(this.playCountDownSound),B);},clearCountdownSounds:function(){if(this.timerCountdownSounds){clearInterval(this.timerCountdownSounds);}this.sendEvent(Planeto.SoundFX.STOP,{name:"timer",fadeOutTime:500});},playCountDownSound:function(){this.sendEvent(Planeto.SoundFX.PLAY,{name:"timer"});},onEndQuizEvent:function(A){var B=A.correct,D=A.playerAnswerIndex+1;if(!this.userInHotSeat){$("#questionContent").empty();if(!B&&D>0){var C=$("#answer"+D);$("#answerContainer td").removeClass("wrongAnswerAll");C.addClass("wrongAnswer");}}},onShowQuestionEvent:function(B){var A=$("#questionContent");if(!this.userInHotSeat){$("#answerContainer td").removeClass("selectable");$("#answerContainer td").unbind();}$("#quizmode_questionContainerLeft .preview").encodeHtml(B.question);if(B.question.length>=90){A.addClass("questionSmall");}else{if(B.question.length>=75){A.addClass("questionMedium");}}}});Planeto.HotSeat.View.INIT="Planeto.HotSeat.View.INIT";Planeto.HotSeat.View.RESET="Planeto.HotSeat.View.RESET";BasicMVC.Facade.getInstance().register(new Planeto.HotSeat.View());Planeto.QuizRace=Planeto.QuizRace||{};Planeto.QuizRace.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.QuizRace.Control";},eventListeners:function(){return[PlanetoEvents.NEW_HOT_SEAT_HOLDER_EVENT];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.NEW_HOT_SEAT_HOLDER_EVENT:break;}},exitGame:function(){this.sendEvent(Planeto.Multiplayer.END_GAME);}});BasicMVC.Facade.getInstance().register(new Planeto.QuizRace.Control());Planeto.QuizRace=Planeto.QuizRace||{};Planeto.QuizRace.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.QuizRace.View";this.viewMode="left";this.questionContainerHidden=false;this.participants=[];this.dummyPlayer={name:"",identity:"dummy",profilePicture:{squarePixelUrl:resource_multiplayer_unknownplayer}};this.restartClock=null;},eventListeners:function(){return[Planeto.Multiplayer.EXIT,Planeto.QuizRace.View.INIT,Planeto.QuizRace.View.RESET,PlanetoEvents.GAME_ROOM_JOINED_EVENT,PlanetoEvents.GAME_ROOM_UPDATED_EVENT,PlanetoEvents.NEW_QUIZ_EVENT,PlanetoEvents.END_QUIZ_EVENT,PlanetoEvents.SHOW_QUESTION_EVENT,PlanetoService.STOP_GAME,PlanetoEvents.QUIZ_RACE_COUNT_DOWN_TO_START_EVENT,PlanetoEvents.QUIZ_RACE_LANE_PROGRESS_CHANGED_EVENT,PlanetoEvents.RESET_QUIZ_RACE_EVENT,PlanetoEvents.QUIZ_RACE_WON_BY_PLAYER_EVENT];
},eventHandlers:function(A){switch(A.name){case Planeto.HotSeat.View.INIT:this.viewMode=A.data;this.initUI();break;case Planeto.HotSeat.View.RESET:this.resetUI();break;case PlanetoEvents.GAME_ROOM_JOINED_EVENT:if(this.gameTypeCheck()){this.onGameRoomJoined(A.data);this.initUI();}break;case PlanetoEvents.GAME_ROOM_UPDATED_EVENT:if(this.gameTypeCheck()){this.onGameRoomUpdated(A.data);}break;case PlanetoEvents.SHOW_QUESTION_EVENT:if(this.gameTypeCheck()){this.onShowQuestionEvent(A.data);}break;case PlanetoEvents.QUIZ_RACE_COUNT_DOWN_TO_START_EVENT:this.onCountDownToStart(A.data);break;case PlanetoEvents.QUIZ_RACE_LANE_PROGRESS_CHANGED_EVENT:this.onRaceLaneProgressChanged(A.data);break;case PlanetoEvents.RESET_QUIZ_RACE_EVENT:this.onRaceReset(A.data);break;case PlanetoEvents.QUIZ_RACE_WON_BY_PLAYER_EVENT:this.onRaceWon(A.data);break;case PlanetoService.STOP_GAME:if(this.gameTypeCheck()){this.resetUI();this.hideQuestionContainerLeft();}break;case PlanetoEvents.NEW_QUIZ_EVENT:if(this.gameTypeCheck()){this.onNewQuizEvent(A.data);}break;}},initUI:function(){$("#gameplayHead, #quizArea").show();$("#multiplayerHead, #multiplayerArea").hide();$("#gameplayStatusArea .streak").show();switch(this.viewMode){case"right":$("#answerContainer, #questionContainer, #questionWaitContainer, #quizProvider, #reportQuestionButton").hide().addClass("quizmode_right");break;case"left":$("#answerContainer, #questionContainer, #questionWaitContainer, #quizProvider, #reportQuestionButton").hide().addClass("quizmode_left");break;}$("#pauseContainer, #messageContainer").hide();$("#questionClock").show();$("#quizmode_questionContainerLeft").removeClass("minimized");$("#quizmode_questionContainerLeft .closebutton").unbind("click").bind("click",this.localScopeFull(this.toggleQuestionContainerLeft));$("#quizmode_questionContainerLeft .preview").unbind("click").bind("click",this.localScopeFull(this.showQuestionContainerLeft));$("#quizraceView .close").unbind("click").bind("click",this.localScopeFull(this.exitGame));this.showRace();this.sendEvent(Planeto.Inventory.DISABLE_REMOVE_INCORRECT_QUESTION,false);this.sendEvent(Planeto.Inventory.DISABLE_SKIP_QUESTION,true);this.sendEvent(Planeto.Inventory.DISABLE_ACTIONBAR_CARDS,true);this.ui_initialized=true;this.restartClock=new Planeto.Clock.View("#quizraceView .winner .planetoClock");},resetUI:function(){$("#quizmode_questionContainerLeft").removeClass("minimized").hide();$("#answerContainer, #questionContainer, #questionWaitContainer, #quizProvider, #reportQuestionButton").removeClass("quizmode_right quizmode_left");$("#quizraceView").hide();$("#quizArea, #quizProvider, #reportQuestionButton").show();$("#column3, #pauseContainer, #messageContainer").show();$("#questionClock").show();this.sendEvent(Planeto.Inventory.DISABLE_SKIP_QUESTION,false);this.sendEvent(Planeto.Inventory.DISABLE_ACTIONBAR_CARDS,false);this.ui_initialized=false;},exitGame:function(){this.sendEvent(Planeto.Multiplayer.END_GAME);},onGameRoomJoined:function(B){var A=$("#quizraceView"),C=B.gameRoom.participants;this.participants=B.gameRoom.participants;this.resetPlayers();A.find(".players .player").addClass("empty").hide().find(".profile img").removeAttr("src");for(var E=0;E<C.length;E++){var D=C[E];this.addPlayer(D);}this.checkNumberOfParticipants();A.show();},checkNumberOfParticipants:function(){var A=$("#quizraceView");if(this.participants.length==1){A.find(".waiting").show();if($("#quizraceView .players .player[rel='"+this.dummyPlayer.identity+"']").length==0){this.addPlayer(this.dummyPlayer);}}else{this.removePlayer(this.dummyPlayer);A.find(".waiting").hide();}},onGameRoomUpdated:function(B){var A=$("#quizraceView");this.participants=B.gameRoom.participants;if(B.joined){this.addPlayer(B.joined);A.find(".waiting").hide();}if(B.left){this.removePlayer(B.left);}this.checkNumberOfParticipants();},onCountDownToStart:function(B){var A=$("#quizraceView"),D=A.find(".countdown"),F=D.find("span"),C=B.countDownLength,E=this;this.resetPlayers();F.html(C);D.show();
if(this.countdownInterval){clearInterval(this.countdownInterval);}this.countdownInterval=setInterval(function(){C=C-1;F.html(C);if(C<1){D.hide();clearInterval(E.countdownInterval);}},999);},onRaceLaneProgressChanged:function(A){this.movePlayer(A.contenderIdentity,A.delta,A.passedFinishLine);},onRaceWon:function(A){this.showWinner(A);this.restartClock.resetTimer(A.waitSeconds);$("#quizmode_questionContainerLeft").removeClass("minimized").hide();$("#quizArea").hide();$("#questionClock").hide();},onRaceReset:function(A){this.resetPlayers();this.showRace();this.checkNumberOfParticipants();},addPlayer:function(B){var A=$("#quizraceView"),C=$(A.find(".players .empty")[0]);this.removePlayer(B);C.removeClass("empty").attr("rel",B.identity).show();if(B.identity==user_id){C.find(".profile").addClass("me");}else{C.find(".profile").removeClass("me");}C.find(".profile img").attr("src",B.profilePicture.squarePixelUrl);C.find(".tooltipText").html(B.name);C.find(".profile").toolTiper();},movePlayer:function(G,M,B){var L=$("#quizraceView .players .player[rel='"+G+"']"),E=L.find(".progress ul"),J=L.find(".avatar"),I=J.find(".flames"),H=400,K=0,A=0,F=0;var C=0;E.children().map(function(){F+=$(this).outerWidth(true);});E.removeClass("correct wrong");if(M>0){E.addClass("correct");K=(M/100)*H;if((K+F)>H){A=H-F-1;}else{A=K;}I.show();var D="+="+K;if(B){D=425;}J.animate({left:D},1000,function(){I.fadeOut();var N=$("<li></li>");E.append(N);N.css("width",A);});}else{E.addClass("wrong");}},removePlayer:function(A){var B=$("#quizraceView .players .player[rel='"+A.identity+"']");B.removeAttr("rel").addClass("empty").hide();B.find(".profile img").removeAttr("src");},resetPlayers:function(){var B=$("#quizraceView .players .player .avatar"),A=$("#quizraceView .players .player .progress ul");B.css("left",0);B.find(".flames").hide();A.empty();},showRace:function(){var A=$("#quizraceView"),B=A.find(".race"),C=A.find(".winner");C.hide();B.show();},showWinner:function(B){var A=$("#quizraceView"),E=A.find(".race"),F=A.find(".winner"),G,D,C;G=this.getParticipant(B.winnersStandIdentities[0]);if(B.winnersStandIdentities.length==1){F.find("h2.normal").hide();F.find("h2.walkover").show();}else{F.find("h2.normal").show();F.find("h2.walkover").hide();}if(B.winnersStandIdentities.length==2){D=this.getParticipant(B.winnersStandIdentities[1]);}if(B.winnersStandIdentities.length==3){D=this.getParticipant(B.winnersStandIdentities[1]);C=this.getParticipant(B.winnersStandIdentities[2]);}F.find(".player").hide();F.find("h1").html(G.name);F.find(".first .profile img").attr("src",G.profilePicture.squarePixelUrl);F.find(".first .tooltipText").html(G.name);F.find(".first").show();if(D){F.find(".second .profile img").attr("src",D.profilePicture.squarePixelUrl);F.find(".second .tooltipText").html(D.name);F.find(".second").show();}if(C){F.find(".third .profile img").attr("src",C.profilePicture.squarePixelUrl);F.find(".third .tooltipText").html(C.name);F.find(".third").show();}F.find(".profile").toolTiper();this.hideQuestionContainerLeft();E.hide();F.show();},getParticipant:function(A){var C=null;for(var B=0;B<this.participants.length;B++){if(this.participants[B].identity==A){C=this.participants[B];break;}}return C;},gameTypeCheck:function(){return(Planeto.Globals.currentGameType=="QUIZ_RACE_GAME");},toggleQuestionContainerLeft:function(B){var A=$("#quizmode_questionContainerLeft");if(A.hasClass("minimized")){this.showQuestionContainerLeft();}else{this.hideQuestionContainerLeft();}},hideQuestionContainerLeft:function(){$("#quizmode_questionContainerLeft").addClass("minimized");$("#quizArea, #quizProvider, #reportQuestionButton").hide();this.questionContainerHidden=true;},showQuestionContainerLeft:function(){$("#quizmode_questionContainerLeft").removeClass("minimized");$("#quizmode_questionContainerLeft").show();$("#quizArea, #questionProvider").show();this.questionContainerHidden=false;},onShowQuestionEvent:function(B){var A=$("#questionContent");$("#quizmode_questionContainerLeft .preview").encodeHtml(B.question);
if(B.question.length>=90){A.addClass("questionSmall");}else{if(B.question.length>=75){A.addClass("questionMedium");}}},onNewQuizEvent:function(C){var A=$("#quizraceView"),B=$("#quizmode_questionContainerLeft").hasClass("minimized");if(!B){this.showQuestionContainerLeft();}$("#questionClock").show();A.find(".players .progress ul").removeClass("wrong correct");}});Planeto.QuizRace.View.INIT="Planeto.QuizRace.View.INIT";Planeto.QuizRace.View.RESET="Planeto.QuizRace.View.RESET";BasicMVC.Facade.getInstance().register(new Planeto.QuizRace.View());Planeto.PictureQuiz=Planeto.PictureQuiz||{};Planeto.PictureQuiz.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.PictureQuiz.View";this.gameRoomName="";this.participants=[];this.restartClock=null;this.gridVisible=true;this.justJoined=true;this.nbrOfNeededVotes=-1;this.activeQuestion=false;this.pictureQuizStopped=false;},eventListeners:function(){return[Planeto.Multiplayer.EXIT,Planeto.PictureQuiz.View.INIT,Planeto.PictureQuiz.View.RESET,PlanetoEvents.GAME_ROOM_JOINED_EVENT,PlanetoEvents.GAME_ROOM_UPDATED_EVENT,PlanetoEvents.NEW_QUIZ_EVENT,PlanetoEvents.END_QUIZ_EVENT,PlanetoEvents.SHOW_QUESTION_EVENT,PlanetoService.STOP_GAME,PlanetoEvents.STOP_DISPLAYING_QUESTION_EVENT,PlanetoEvents.NEW_PICTURE_QUIZ_GRID_EVENT,PlanetoEvents.PICTURE_GRID_CELL_SOLVER_CHANGED_EVENT,PlanetoEvents.PICTURE_GRID_CELL_SOLVED_EVENT,PlanetoEvents.UNVEIL_PICTURE_QUIZ_IMAGE_EVENT,PlanetoEvents.SHOW_MOTIF_DESCRIPTION_AND_WINNER,PlanetoEvents.SHOW_PICTURE_QUIZ_ROUND_SUMMARY_SCREEN_EVENT,PlanetoEvents.NEW_VOTE_TO_SKIP_PICTURE_EVENT,PlanetoEvents.SHOW_COUNT_DOWN_TO_NEXT_PICTURE_QUIZ_ROUND_EVENT];},eventHandlers:function(A){switch(A.name){case Planeto.PictureQuiz.View.INIT:this.pictureQuizStopped=false;this.viewMode=A.data;this.initUI();break;case Planeto.PictureQuiz.View.RESET:this.resetUI();break;case PlanetoEvents.GAME_ROOM_JOINED_EVENT:if(this.gameTypeCheck()){this.onGameRoomJoined(A.data);this.initUI();}break;case PlanetoEvents.GAME_ROOM_UPDATED_EVENT:if(this.gameTypeCheck()){this.onGameRoomUpdated(A.data);}break;case PlanetoEvents.SHOW_QUESTION_EVENT:if(this.gameTypeCheck()){this.onShowQuestionEvent(A.data);}break;case PlanetoService.STOP_GAME:if(this.gameTypeCheck()){this.resetUI();this.hideQuestionContainerLeft();this.pictureQuizStopped=true;}break;case PlanetoEvents.NEW_QUIZ_EVENT:if(this.gameTypeCheck()){this.onNewQuizEvent(A.data);}break;case PlanetoEvents.END_QUIZ_EVENT:if(this.gameTypeCheck()){this.onEndQuizEvent(A.data);}break;case PlanetoEvents.STOP_DISPLAYING_QUESTION_EVENT:if(this.gameTypeCheck()){this.onStopDisplayingQuesiton(A.data);}break;case PlanetoEvents.NEW_PICTURE_QUIZ_GRID_EVENT:this.onNewPictureQuizGrid(A.data);break;case PlanetoEvents.SHOW_COUNT_DOWN_TO_NEXT_PICTURE_QUIZ_ROUND_EVENT:this.onCountDownToNextPictureQuizRound(A.data);break;case PlanetoEvents.PICTURE_GRID_CELL_SOLVER_CHANGED_EVENT:this.onPictureGridSolverChanged(A.data);break;case PlanetoEvents.PICTURE_GRID_CELL_SOLVED_EVENT:this.onPictureGridSolved(A.data);break;case PlanetoEvents.UNVEIL_PICTURE_QUIZ_IMAGE_EVENT:this.onUnveilPictureQuizImage(A.data);break;case PlanetoEvents.SHOW_MOTIF_DESCRIPTION_AND_WINNER:this.onShowMotifDescriptionAndWinner(A.data);break;case PlanetoEvents.SHOW_PICTURE_QUIZ_ROUND_SUMMARY_SCREEN_EVENT:this.onShowPictureQuizRoundSummaryScreen(A.data);break;case PlanetoEvents.NEW_VOTE_TO_SKIP_PICTURE_EVENT:this.onNewVoteToSkipPicture(A.data);break;}},initUI:function(){this.pictureQuizStopped=false;$("#gameplayHead, #quizArea").show();$("#multiplayerHead, #multiplayerArea").hide();$("#gameplayStatusArea .streak").show();$("#answerContainer, #questionContainer, #questionWaitContainer, #quizProvider, #reportQuestionButton").hide().addClass("quizmode_left");$("#pauseContainer, #messageContainer, #quizComingQuestions").hide();$("#questionClock").show();$("#quizmode_questionContainerLeft").removeClass("minimized");$("#gameplayArea").addClass("background-only");$("#quizmode_questionContainerLeft .closebutton").unbind("click").bind("click",this.localScopeFull(this.toggleQuestionContainerLeft));
$("#quizmode_questionContainerLeft .preview").unbind("click").bind("click",this.localScopeFull(this.showQuestionContainerLeft));$("#pictureQuizView > div.close").unbind("click").bind("click",this.localScopeFull(this.exitGame));$("#pictureQuizView .instruction .close").unbind("click").bind("click",this.localScopeFull(this.closeInstruction));$("#pictureQuizView .btnVoteSkip").unbind("click").bind("click",this.localScopeFull(this.voteToSkip)).toolTiper();$("#pictureQuizView .btnContinue").unbind("click").bind("click",this.localScopeFull(this.continueGame));this.sendEvent(Planeto.Inventory.DISABLE_REMOVE_INCORRECT_QUESTION,false);this.sendEvent(Planeto.Inventory.DISABLE_SKIP_QUESTION,false);this.sendEvent(Planeto.Inventory.DISABLE_ACTIONBAR_CARDS,false);this.restartClock=new Planeto.Clock.View("#pictureQuizView .planetoClock");this.displayGameRoomTopic();this.ui_initialized=true;},resetUI:function(){var A=$("#pictureQuizView .pictureGrid");A.find("img").die();A.empty();$("#quizmode_questionContainerLeft").removeClass("minimized").hide();$("#answerContainer, #questionContainer, #questionWaitContainer, #quizProvider, #reportQuestionButton").removeClass("quizmode_right quizmode_left");$("#gameplayArea").removeClass("background-only");$("#pictureQuizView").hide();$("#quizArea, #quizProvider, #reportQuestionButton").show();$("#column3, #pauseContainer, #messageContainer").show();$("#questionClock").show();this.ui_initialized=false;},usePictureQuizBackground:function(A){if(A){$("#gameplayArea").addClass("background-only");}else{$("#gameplayArea").removeClass("background-only");}},exitGame:function(){this.sendEvent(Planeto.Quiz.View.STOP_CLOCK);this.sendEvent(Planeto.Multiplayer.END_GAME);},onGameRoomJoined:function(B){var A=$("#pictureQuizView");grid=A.find(".pictureGrid");winner=A.find(".winner"),skipped=A.find(".skipped"),failed=A.find(".failed"),button=A.find(".continuebutton"),restartclock=A.find(".restartclock");this.participants=B.gameRoom.participants;this.gameRoomName=B.gameRoom.name;this.gridVisible=true;this.displayGameRoomTopic();winner.hide();skipped.hide();failed.hide();button.hide();grid.hide();this.hideRestartClock();A.show();},onGameRoomUpdated:function(A){this.participants=A.gameRoom.participants;if(A.joined){}if(A.left){}},onCountDownToNextPictureQuizRound:function(A){var C=$("#pictureQuizView .countdown"),E=C.find("span"),B=A.waitSeconds,D=this;E.html(B);C.show();if(this.countdownInterval){clearInterval(this.countdownInterval);}this.countdownInterval=setInterval(function(){B=B-1;E.html(B);if(B<1){C.hide();clearInterval(D.countdownInterval);}},999);},closeInstruction:function(){var A=$("#pictureQuizView");A.find(".instruction").hide();},voteToSkip:function(){var A=$("#pictureQuizView .btnVoteSkip");if(!A.hasClass("voted")){this.sendEvent(PlanetoService.VOTE_TO_SKIP_CURRENT_PICTURE_REQUEST);A.addClass("voted");}},onNewVoteToSkipPicture:function(A){var C=$("#pictureQuizView .btnVoteSkip"),B=C.find(".votecount"),D=C.find(".votes");this.nbrOfNeededVotes=A.nbrOfNeededVotes;B.show();D.html(A.nbrOfNeededVotes);},resetVoteButton:function(){var B=$("#pictureQuizView .btnVoteSkip"),A=B.find(".votecount"),C=B.find(".votes");B.removeClass("voted");if(this.nbrOfNeededVotes>0){C.html(this.nbrOfNeededVotes);A.show();}else{C.html("");A.hide();}B.show();},hideVoteButton:function(){$("#pictureQuizView .btnVoteSkip").hide();},getParticipant:function(A){var C=null;for(var B=0;B<this.participants.length;B++){if(this.participants[B].identity==A){C=this.participants[B];break;}}return C;},gameTypeCheck:function(){return(Planeto.Globals.currentGameType=="PICTURE_QUIZ_GAME");},toggleQuestionContainerLeft:function(B){var A=$("#quizmode_questionContainerLeft");if(A.hasClass("minimized")){this.showQuestionContainerLeft();}else{this.hideQuestionContainerLeft();}},hideQuestionContainerLeft:function(){if(!this.pictureQuizStopped){$("#quizmode_questionContainerLeft").addClass("minimized");$("#quizArea, #quizProvider, #reportQuestionButton").hide();this.questionContainerHidden=true;
}},showQuestionContainerLeft:function(){$("#quizmode_questionContainerLeft").removeClass("minimized");$("#quizmode_questionContainerLeft").show();$("#quizArea, #questionProvider").show();$("#questionWaitContainer").show();this.questionContainerHidden=false;},onStopDisplayingQuesiton:function(){if(!this.pictureQuizStopped){$("#quizmode_questionContainerLeft").hide();$("#quizArea, #questionProvider").hide();this.questionContainerHidden=true;}this.sendEvent(Planeto.Quiz.View.STOP_CLOCK);this.enableGrid();this.displayGameRoomTopic();},onShowQuestionEvent:function(B){var A=$("#questionContent");$("#quizmode_questionContainerLeft .preview").encodeHtml(B.question);if(B.question.length>=90){A.addClass("questionSmall");}else{if(B.question.length>=75){A.addClass("questionMedium");}}},onNewPictureQuizGrid:function(F){var J=$("#pictureQuizView"),B=J.find(".pictureGrid"),G=J.find(".instruction"),L=J.find(".countdown"),E=J.find(".pictureAttribution"),C=F.cellSize,I=F.cols,M=F.rows;B.empty();E.hide();L.hide();this.enableGrid();if(this.gridVisible){if(this.justJoined){G.show();}this.resetVoteButton();B.show();}B.css("width",C*I);B.css("height",C*M);for(var A=0;A<M;A++){for(var H=0;H<I;H++){var K=$("<div />");var D=$("<img />");K.append(D);K.append('<div class="tooltip"><div class="tooltipText"></div></div>');B.append(K);D.attr("id","pictureQuizImage_c"+H+"_r"+A).attr("src",resource_picturequiz_box).css("width",C).css("height",C).data("row",A).data("col",H);}}this.displaySolvedCells(F.cells);B.find("img").die();B.find("img").live("click",this.localScopeFull(this.onPictureGridClicked));B.find("img").live("mouseover",this.localScopeFull(this.onPictureGridHoverStart));B.find("img").live("mouseout",this.localScopeFull(this.onPictureGridHoverEnd));this.justJoined=false;},showPictureAttribution:function(F,D){var C=$("#pictureQuizView"),B=C.find(".pictureAttribution"),E=B.find("span");E.empty();if(F){if(D){var A=$("<a />");A.attr("href",D);A.attr("target","_blank");A.html(F);E.append(A);}else{E.html(F);}B.show();}else{B.hide();}},onPictureGridClicked:function(C){var D=$(C.currentTarget),E=D.data("row"),A=D.data("col"),B=this.getParticipant(user_id);this.closeInstruction();if(!this.activeQuestion&&!D.hasClass("solved")){D.attr("src",B.profilePicture.squarePixelUrl);this.disableGrid();this.sendEvent(PlanetoService.PICK_PICTURE_GRID_CELL_REQUEST,{col:A,row:E});}},onPictureGridHoverStart:function(B){var A=$(B.currentTarget);if(!this.activeQuestion&&!A.hasClass("solved")&&!A.hasClass("active")){A.attr("src",resource_picturequiz_box_selected);}},onPictureGridHoverEnd:function(B){var A=$(B.currentTarget);if(!A.hasClass("solved")&&!A.hasClass("active")){A.attr("src",resource_picturequiz_box);}},onPictureGridSolverChanged:function(A){var D=$("#pictureQuizImage_c"+A.col+"_r"+A.row),C=D.siblings(".tooltip"),E=C.find(".tooltipText"),B;if(A.solverIdentity){B=this.getParticipant(A.solverIdentity);D.attr("src",B.profilePicture.squarePixelUrl);E.html(B.name);D.addClass("active").toolTiper();}else{D.attr("src",resource_picturequiz_box);D.removeClass("active");this.resetTooltip(D);}},resetTooltip:function(B){var A=B.siblings(".tooltip"),C=A.find(".tooltipText");C.html("");B.unToolTiper();},onPictureGridSolved:function(A){var C=$("#pictureQuizImage_c"+A.col+"_r"+A.row),B=A.pictureUrl;C.attr("src","/img/picturequiz/"+B).addClass("solved");this.resetTooltip(C);if(playerIdle==true){update_doc_title("Picture quiz progress");}},onUnveilPictureQuizImage:function(A){this.hideVoteButton();this.motif=A.motif;this.displaySolvedCells(A.cells);this.showPictureAttribution(A.attributionName,A.attributionUrl);},onShowMotifDescriptionAndWinner:function(D){var H=$("#pictureQuizView"),A=H.find(".pictureGrid"),E=H.find(".winner"),G=H.find(".skipped"),F=H.find(".failed"),B=H.find(".instruction"),C=H.find(".pictureAttribution"),I=this.getParticipant(D.winnerIdentity);this.usePictureQuizBackground(false);B.hide();C.hide();A.hide();this.gridVisible=false;this.nbrOfNeededVotes=-1;this.hideVoteButton();
if(I){E.find(".name").html(I.name);E.find("img.profile").attr("src",I.profilePicture.squarePixelUrl);E.find(".motif").html(this.motif);E.find(".description").html(D.motifDescription);E.show();}else{G.show();}this.showRestartClock(D.secondsToNextState);},onShowPictureQuizRoundSummaryScreen:function(F){var E=$("#pictureQuizView"),G=E.find(".pictureGrid"),H=E.find(".winner"),D=E.find(".skipped"),C=E.find(".failed"),A=E.find(".instruction"),B=E.find(".pictureAttribution");this.usePictureQuizBackground(false);A.hide();B.hide();G.hide();this.nbrOfNeededVotes=-1;this.gridVisible=false;this.hideVoteButton();if(F.allSolved){C.show();}else{D.show();}this.showRestartClock(F.waitSeconds);},showRestartClock:function(B){var A=$("#pictureQuizView"),D=A.find(".restartclock"),C=A.find(".continuebutton");D.show();C.hide();this.restartClock.resetTimer(B);this.restartClock.onTimerEnd=this.localScopeFull(this.showContinueButton);},hideRestartClock:function(){var A=$("#pictureQuizView"),B=A.find(".restartclock");B.hide();if(this.restartClock){this.restartClock.onTimerEnd=null;}},showContinueButton:function(){var A=$("#pictureQuizView"),C=A.find(".restartclock"),B=A.find(".continuebutton");this.hideRestartClock();B.show();},continueGame:function(){var D=$("#pictureQuizView"),F=D.find(".pictureGrid"),G=D.find(".winner"),C=D.find(".skipped"),B=D.find(".failed"),A=D.find(".instruction"),E=D.find(".continuebutton");this.usePictureQuizBackground(true);E.hide();G.hide();C.hide();F.show();B.hide();if(this.justJoined){A.show();}this.resetVoteButton();this.gridVisible=true;},displaySolvedCells:function(D){var C=0,B=this;D.sort(function(){return 0.5-Math.random();});for(var E=0;E<D.length;E++){var A=D[E],G=$("#pictureQuizImage_c"+A.col+"_r"+A.row);if(A.solverIdentity){player=this.getParticipant(A.solverIdentity);if(player){var F=G.siblings(".tooltip"),H=F.find(".tooltipText");H.html(player.name);G.attr("src",player.profilePicture.squarePixelUrl).addClass("active").toolTiper();}}else{G.attr("src","/img/picturequiz/"+A.pictureUrl).addClass("solved");}}},onNewQuizEvent:function(C){var B=$("#quizmode_questionContainerLeft").hasClass("minimized"),A=$("#pictureQuizView"),D=A.find(".pictureGrid");this.showQuestionContainerLeft();$("#questionClock").show();this.disableGrid();},onEndQuizEvent:function(A){this.displayGameRoomTopic();this.enableGrid();},displayGameRoomTopic:function(){var B=$("#gameplayStatusArea"),C=$("#quizCategory"),A=$("#playerCurrentTopic");B.attr("class","gameplayStatusArea categoryColor6");C.attr("class","multiplayer");C.find("img").addClass("qsSqIconBackground").attr("src",resource_null_gif).hide();A.removeClass("short").encodeHtml(this.gameRoomName);if(this.gameRoomName.length>24){A.addClass("short");}},enableGrid:function(){var A=$("#pictureQuizView"),B=A.find(".pictureGrid");this.activeQuestion=false;B.removeClass("active-question");this.sendEvent(Planeto.Inventory.DISABLE_REMOVE_INCORRECT_QUESTION,true);this.sendEvent(Planeto.Inventory.DISABLE_SKIP_QUESTION,true);},disableGrid:function(){var A=$("#pictureQuizView"),B=A.find(".pictureGrid");this.activeQuestion=true;B.addClass("active-question");this.sendEvent(Planeto.Inventory.DISABLE_REMOVE_INCORRECT_QUESTION,false);this.sendEvent(Planeto.Inventory.DISABLE_SKIP_QUESTION,false);}});Planeto.PictureQuiz.View.INIT="Planeto.PictureQuiz.View.INIT";Planeto.PictureQuiz.View.RESET="Planeto.PictureQuiz.View.RESET";BasicMVC.Facade.getInstance().register(new Planeto.PictureQuiz.View());Planeto.StarHunt=Planeto.StarHunt||{};Planeto.StarHunt.Control=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.StarHunt.Control";this.currentStreak=0;this.focus=0;this.decay=0;this.initEvents();this.chain=null;huntRef=this;},eventListeners:function(){return[PlanetoEvents.STREAK_CHANGED_EVENT,PlanetoEvents.NEW_STAR_HUNT_MAP_EVENT,PlanetoEvents.STAR_HUNT_MAP_CHANGED_EVENT,PlanetoEvents.STAR_HUNT_PLAYER_LOCATION_CHANGED_EVENT,PlanetoEvents.GET_STAR_HUNT_MAP_CHAINS_RESPONSE,PlanetoEvents.GET_STAR_HUNT_MISSION_PACKS_RESPONSE,Planeto.StarHunt.Canvas.POINT_CLICKED,Planeto.StarHunt.Canvas.EDGE_CLICKED,Planeto.StarHunt.DISPLAY_MISSION_LOADER,PlanetoEvents.STAR_HUNT_FOCUS_CHANGED_EVENT,PlanetoEvents.STAR_HUNT_FOCUS_DEPLETED_EVENT,PlanetoEvents.STAR_HUNT_MAP_COMPLETED_EVENT,PlanetoEvents.STAR_HUNT_MAP_CHAIN_COMPLETED_EVENT];
},eventHandlers:function(A){switch(A.name){case PlanetoEvents.NEW_STAR_HUNT_MAP_EVENT:this.onMapChange(A.data);break;case PlanetoEvents.STAR_HUNT_MAP_CHANGED_EVENT:this.onMapChange(A.data);break;case PlanetoEvents.GET_STAR_HUNT_MAP_RESPONSE:this.onMapChange(A.data);break;case PlanetoEvents.STAR_HUNT_PLAYER_LOCATION_CHANGED_EVENT:this.onPlayerLocationChanged(A.data);break;case PlanetoEvents.GET_STAR_HUNT_MAP_CHAINS_RESPONSE:this.onGetStarHuntMapChains(A.data);break;case PlanetoEvents.GET_STAR_HUNT_MISSION_PACKS_RESPONSE:this.onGetStarHuntMissionPacks(A.data);break;case Planeto.StarHunt.Canvas.POINT_CLICKED:this.onPointClicked(A.data);break;case Planeto.StarHunt.Canvas.EDGE_CLICKED:this.onEdgeClicked(A.data);break;case PlanetoEvents.STREAK_CHANGED_EVENT:this.currentStreak=A.data.streak;break;case Planeto.StarHunt.DISPLAY_MISSION_LOADER:this.getStarHuntMissionPacks();break;case PlanetoEvents.STAR_HUNT_FOCUS_CHANGED_EVENT:this.onFocusChanged(A.data);break;case PlanetoEvents.STAR_HUNT_FOCUS_DEPLETED_EVENT:this.onFocusDepleted();break;case PlanetoEvents.STAR_HUNT_MAP_COMPLETED_EVENT:this.onMapCompleted();break;case PlanetoEvents.STAR_HUNT_MAP_CHAIN_COMPLETED_EVENT:this.onMapChainCompleted();break;}},initEvents:function(){var A=$("#starhuntView");},onMapChange:function(A){this.map=A.map;this.startStarHunt();this.stopFocusTimer();},onGetStarHuntMissionPacks:function(B){var A=$("#starhunt-loader"),G=A.find("ul"),F=this;this.packs=B.packDtos;G.empty();for(var D=0;D<this.packs.length;D++){var C=this.packs[D],E=$("<li>");E.html(C.name);E.attr("rel",C.identity);G.append(E);}A.show();A.find("div.CLOSE").unbind("click").bind("click",function(){A.hide();});A.find("li").unbind("click").bind("click",function(){var H=$("#dialogUCQCreateStarHunt .chain-loader"),I=$(this).attr("rel");F.getMissionsInMissionPack(I);});},onGetStarHuntMapChains:function(B){var A=$("#starhunt-loader"),G=A.find("ul"),F=this;G.empty();this.chains=B.chainDtos;for(var D=0;D<B.chainDtos.length;D++){var C=B.chainDtos[D],E=$("<li>");E.html(C.name);E.attr("rel",C.identity);G.append(E);}A.show();A.find("div.CLOSE").unbind("click").bind("click",function(){A.hide();});A.find("li").unbind("click").bind("click",function(){var H=$(this).attr("rel");for(var I=0;I<F.chains.length;I++){if(H==F.chains[I].identity){F.chain=F.chains[I];break;}}F.startPlayingMapChain(H);A.hide();});},onMapCompleted:function(){this.sendEvent(PlanetoService.CONTINUE_STAR_HUNT_MAP_CHAIN_REQUEST);},onMapChainCompleted:function(){var A=$("#starhuntView .focus");this.stopFocusTimer();A.html("Yabba-Dabba Do! You completed the map chain!");},onFocusChanged:function(A){this.focus=A.focus;this.decay=A.decay;this.stopFocusTimer();this.startFocusTimer();this.sendEvent(Planeto.StarHunt.FOCUS_CHANGED,{focus:this.focus,maxFocus:this.chain.maxFocus});},onFocusDepleted:function(){var A=$("#starhuntView .focus");this.stopFocusTimer();A.html("Focus lost");},stopFocusTimer:function(){clearInterval(this.decayIntervalTimer);this.decayIntervalTimer=null;},startFocusTimer:function(){this.decayIntervalTimer=setInterval(this.localScopeFull(this.focusDecay),1000);},focusDecay:function(){this.focus=this.focus-this.decay;this.sendEvent(Planeto.StarHunt.FOCUS_CHANGED,{focus:this.focus,maxFocus:this.chain.maxFocus});},onPointClicked:function(A){this.sendEvent(PlanetoService.ATTEMPT_STAR_HUNT_MOVE_REQUEST,{row:A.point.row,col:A.point.col});},onEdgeClicked:function(A){},onPlayerLocationChanged:function(B){var A={col:B.col,row:B.row};this.sendEvent(Planeto.StarHunt.MOVE_PLAYER,A);this.updateAvailablePoints(A,B.edges);},startStarHunt:function(){this.sendEvent(Planeto.StarHunt.View.INIT,this.map);},startPlayingMapChain:function(A){this.sendEvent(PlanetoService.STOP_GAME);this.sendEvent(PlanetoService.START_PLAYING_STAR_HUNT_REQUEST,A);},getStarHuntMissionPacks:function(){this.sendEvent(PlanetoService.GET_STAR_HUNT_MISSION_PACKS_REQUEST,{amount:100,offset:1});},getMissionsInMissionPack:function(A){this.sendEvent(PlanetoService.GET_STAR_HUNT_MISSIONS_IN_MISSION_PACK_REQUEST,A);
},updateAvailablePoints:function(G,D){var I=G.col+"_"+G.row,B=[];for(var E=0;E<D.length;E++){var C=D[E],J=C.col1+"_"+C.row1,H=C.col2+"_"+C.row2;if(J!=I){B.push(J);}if(H!=I){B.push(H);}}for(var E=0;E<B.length;E++){var A=B[E];point=this.getPoint(A);for(var F=0;point.effects;F++){var K=point.effects[F];switch(K.typeName){case"STREAK_BLOCK":if(this.streak<parseInt(K.value)){delete B[E];}break;}}this.cleanArray(B);}this.sendEvent(Planeto.StarHunt.UPDATE_AVAILABLE_POINTS,B);},getPoint:function(C){var B=this.map.points;length=B.length,index=-1;for(var A=0;A<length;A++){if(C==this.getPointIdentity(B[A])){index=A;break;}}return index;},getPointIdentity:function(A){return A.col+"_"+A.row;},cleanArray:function(B){for(var A=0;A<B.length;A++){if(B[A]==null||B[A]===undefined){B.splice(A,1);A--;}}return B;}});Planeto.StarHunt.MOVE_PLAYER="Planeto.StarHunt.MOVE_PLAYER";Planeto.StarHunt.FOCUS_CHANGED="Planeto.StarHunt.FOCUS_CHANGED";Planeto.StarHunt.UPDATE_AVAILABLE_POINTS="Planeto.StarHunt.UPDATE_AVAILABLE_POINTS";Planeto.StarHunt.DISPLAY_MISSION_LOADER="Planeto.StarHunt.DISPLAY_MISSION_LOADER";$(function(){BasicMVC.Facade.getInstance().register(new Planeto.StarHunt.Control());BasicMVC.Facade.getInstance().register(new Planeto.StarHunt.View());});Planeto.StarHunt=Planeto.StarHunt||{};Planeto.StarHunt.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.StarHunt.View";this.starHuntCanvas=null;starHuntView=this;},eventListeners:function(){return[Planeto.StarHunt.View.INIT,Planeto.StarHunt.View.RESET,Planeto.StarHunt.MOVE_PLAYER,Planeto.StarHunt.UPDATE_AVAILABLE_POINTS,Planeto.StarHunt.FOCUS_CHANGED];},eventHandlers:function(A){switch(A.name){case Planeto.StarHunt.View.INIT:this.initUI(A.data);break;case Planeto.StarHunt.View.RESET:this.resetUI();break;case Planeto.StarHunt.MOVE_PLAYER:this.movePlayer(A.data.col,A.data.row);break;case Planeto.StarHunt.UPDATE_AVAILABLE_POINTS:this.updateAvailablePoints(A.data);break;case Planeto.StarHunt.FOCUS_CHANGED:this.updateFocus(A.data.focus,A.data.maxFocus);break;}},initUI:function(D){var A=$("#starhuntView"),B=A.find(".canvas")[0],C=this;$("#answerContainer, #questionContainer, #questionWaitContainer, #quizProvider, #reportQuestionButton").hide().addClass("quizmode_left");$("#quizmode_questionContainerLeft").removeClass("minimized").show();$("#questionClock, #pauseContainer, #messageContainer").hide();$("#landingScreen").hide();A.show();this.starHuntCanvas=new Planeto.StarHunt.Canvas(B);this.starHuntCanvas.render(D);},movePlayer:function(A,B){this.starHuntCanvas.movePlayer(A,B);},updateAvailablePoints:function(A){this.starHuntCanvas.updateAvailablePoints(A);},updateFocus:function(A,B){this.starHuntCanvas.renderFocusBar(A,B);}});Planeto.StarHunt.View.INIT="Planeto.StarHunt.View.INIT";Planeto.StarHunt.View.RESET="Planeto.StarHunt.View.RESET";Planeto.StarHunt=Planeto.StarHunt||{};Planeto.StarHunt.Canvas=BasicMVC.Base.extend({constructor:function(A,C,B){this.name="Planeto.StarHunt.Canvas";if(!A){console.warn("No canvas element supplied in constuct");return ;}$(A).empty();this.map=C;this.pointItems=[];this.edgeItems=[];this.player={row:0,col:0,elem:null};this.editMode=false;if(B){if(B.editMode){this.editMode=B.editMode;}}this.currentTool={name:null,type:null};this.drawstyle={};this.drawstyle.path_default={stroke:"#eee","stroke-width":4};this.drawstyle.path_hover={stroke:"#000","stroke-width":4};this.drawstyle.path_active={stroke:"#000","stroke-width":4};this.backgroundImage=null;this.backgroundImageOpacity=1;this.paper=Raphael(A,500,300);canvasRef=this;},eventListeners:function(){return[];},eventHandlers:function(A){},movePlayer:function(A,B){this.player.col=A;this.player.row=B;this.renderPlayer();},render:function(A){this.map=A;if(this.editMode){this.createEditorEdges();this.createEditorPoints();}else{this.renderFocusBar(500,500);}if(A){if(A.edges){this.renderEdges(A.edges);}if(A.points){this.renderPoints(A.points);}if(A.bgImgUrl){this.renderBackground(A.bgImgUrl,A.bgOpacity);}}},hideUnusedItems:function(){for(var C in this.pointItems){var B=this.pointItems[C];
if(!B.point.questionType){B.elem.hide();}}for(var C in this.edgeItems){var A=this.edgeItems[C];if(!A.activated){A.elem.hide();}}},showAll:function(){for(var C in this.pointItems){var B=this.pointItems[C];B.elem.show();}for(var C in this.edgeItems){var A=this.edgeItems[C];A.elem.show();}},updateAvailablePoints:function(A){for(var D in this.pointItems){var C=this.pointItems[D];C.enabled=false;this.renderPoint(C);}for(var B=0;B<A.length;B++){var D=A[B],C=this.pointItems[D];C.enabled=true;this.renderPoint(C);}},renderEdges:function(A){for(var C=0;C<A.length;C++){var D=A[C];var B={id:"P"+D.col1+"_"+D.row1+"-"+D.col2+"_"+D.row2,edge:D,elem:null,activated:true};this.renderEdge(B);}},createEditorEdges:function(){for(var A=0;A<12;A++){for(var D=0;D<6;D++){if(A<11){var C={col1:A,row1:D,col2:A,row2:D};C.col2=A+1;C.row2=D;var B={id:"P"+C.col1+"_"+C.row1+"-"+C.col2+"_"+C.row2,edge:C,elem:null};this.renderEdge(B);}if(D<5){var C={col1:A,row1:D,col2:A,row2:D};C.col2=A;C.row2=D+1;var B={id:"P"+C.col1+"_"+C.row1+"-"+C.col2+"_"+C.row2,edge:C,elem:null};this.renderEdge(B);}if(A<11&&D<5){var C={col1:A,row1:D,col2:A,row2:D};C.col2=A+1;C.row2=D+1;var B={id:"P"+C.col1+"_"+C.row1+"-"+C.col2+"_"+C.row2,edge:C,elem:null};this.renderEdge(B);}if(D>0&&A<11){var C={col1:A,row1:D,col2:A,row2:D};C.col2=A+1;C.row2=D-1;var B={id:"P"+C.col1+"_"+C.row1+"-"+C.col2+"_"+C.row2,edge:C,elem:null};this.renderEdge(B);}}}},renderEdge:function(B,A){var D,C=this;if(this.edgeItems[B.id]){D=this.getSVGElement(B.id);this.edgeItems[B.id].activated=B.activated;}else{D=this.paper.path(this.getPath(B.edge.col1,B.edge.row1,B.edge.col2,B.edge.row2,B.edge.direction));D.node.setAttribute("id",B.id);D.toBack();B.elem=D;this.edgeItems[B.id]=B;}if(B.activated){D.attr(this.drawstyle.path_active);}else{D.attr(this.drawstyle.path_default);}if(A){D.attr(A);}$(D.node).unbind("click").bind("click",function(){var E=C.edgeItems[this.id];C.sendEvent(Planeto.StarHunt.Canvas.EDGE_CLICKED,E);});$(D.node).unbind("mouseover").bind("mouseover",function(){var E=C.edgeItems[this.id];switch(C.currentTool.name){case"line":case"erase":if(!E.activated){$(this).attr(C.drawstyle.path_hover);}this.style.cursor="pointer";break;default:this.style.cursor="default";}});$(D.node).unbind("mouseout").bind("mouseout",function(){var E=C.edgeItems[this.id];if(!E.activated){$(this).attr(C.drawstyle.path_default);}});},renderPoints:function(C){for(var B=0;B<C.length;B++){var A=C[B];var D={id:A.col+"_"+A.row,enabled:true,point:A,elem:null};this.renderPoint(D);}},createEditorPoints:function(){var C=this;for(var B=0;B<12;B++){for(var D=0;D<6;D++){var A={col:B,row:D,questionType:null};var E={id:B+"_"+D,enabled:true,point:A,elem:null};this.renderPoint(E);}}},renderPoint:function(F){var C,A,E,D,B=this;if(this.pointItems[F.id]){C=this.pointItems[F.id].elem;F.elem=C;this.pointItems[F.id].point=F.point;}else{E=this.getGridXY(F.point.col,F.point.row);C=this.paper.image(resource_starhunt_square_empty_png,E.x-16,E.y-15,32,32);C.node.setAttribute("id",F.id);D=this.paper.text(E.x,E.y,"");D.attr({fill:"#fff"});D.attr("font-size",14);D.attr("font-weight","bold");F.elem=C;F.text=D;this.pointItems[F.id]=F;}if(this.editMode){this.renderPointEditImage(F);}else{this.renderPointCategoryImage(F);}this.renderEffectIcon(F);$(C.node).unbind("click").bind("click",function(){var G=B.pointItems[this.id];if(G.enabled){B.sendEvent(Planeto.StarHunt.Canvas.POINT_CLICKED,G);}});$(C.node).unbind("mouseover").bind("mouseover",function(){var G=B.pointItems[this.id];if(G.enabled){this.style.cursor="pointer";}});$(C.node).unbind("mouseout").bind("mouseout",function(){var G=B.pointItems[this.id];});if(F.effectIcon){$(F.effectIcon.node).unbind("click").bind("click",function(){var G=$(this).attr("rel"),H=B.pointItems[G];if(H.enabled){B.sendEvent(Planeto.StarHunt.Canvas.POINT_CLICKED,H);}});$(F.effectIcon.node).unbind("mouseover").bind("mouseover",function(){var G=$(this).attr("rel"),H=B.pointItems[G];if(H.enabled){this.style.cursor="pointer";}});$(F.effectIcon.node).unbind("mouseout").bind("mouseout",function(){var G=$(this).attr("rel"),H=B.pointItems[G];
});}},renderPointEditImage:function(B){var A=B.elem;if(B.point.questionType){switch(B.point.questionType.typeName){case"RANDOM":A.attr("src",resource_starhunt_square_random_png);break;case"MASTERY_DEPENDENT":A.attr("src",resource_starhunt_square_mastery_png);break;case"FAVORED":A.attr("src",resource_starhunt_square_favored_png);break;case"DISFAVORED":A.attr("src",resource_starhunt_square_disfavored_png);break;case"ENTERTAINMENT":A.attr("src",resource_starhunt_square_entertainment_png);break;case"GEOGRAPHY":A.attr("src",resource_starhunt_square_geography_png);break;case"HISTORY":A.attr("src",resource_starhunt_square_history_png);break;case"ARTS_AND_LITERATURE":A.attr("src",resource_starhunt_square_artsandlitterature_png);break;case"SCIENCE_AND_NATURE":A.attr("src",resource_starhunt_square_sciencenature_png);break;case"SPORTS_AND_LEISURE":A.attr("src",resource_starhunt_square_sportsleisure_png);break;}}else{A.attr("src",resource_starhunt_square_empty_png);}},renderPointCategoryImage:function(B){var A=B.elem;if(B.point.category){switch(B.point.category.id){case 0:A.attr("src",resource_starhunt_square_entertainment_png);break;case 1:A.attr("src",resource_starhunt_square_geography_png);break;case 2:A.attr("src",resource_starhunt_square_history_png);break;case 3:A.attr("src",resource_starhunt_square_artsandlitterature_png);break;case 4:A.attr("src",resource_starhunt_square_sciencenature_png);break;case 5:A.attr("src",resource_starhunt_square_sportsleisure_png);break;}}},renderEffectIcon:function(D){var A,C=this.getGridXY(D.point.col,D.point.row);if(D.point.effects&&D.point.effects.length>0){if(!D.effectIcon){D.effectIcon=this.paper.image(resource_null_gif,C.x-16,C.y-15,32,32);D.effectIcon.node.setAttribute("rel",D.id);}A=D.point.effects[0];var B="0";if(A.param!=null){B=A.param;}switch(A.typeName){case"STAR":D.effectIcon.attr("src",resource_starhunt_effect_star_png);break;case"START":D.effectIcon.attr("src",resource_starhunt_effect_start_png);break;case"FOCUS_DRAIN":D.text.attr("text","-"+B);break;case"FOCUS_GAIN":D.text.attr("text",B);break;case"SCRAMBLE":D.effectIcon.attr("src",resource_starhunt_effect_scramble_png);break;case"GAMBLE":D.effectIcon.attr("src",resource_starhunt_effect_gamble_png);break;case"STREAK_BLOCK":D.effectIcon.attr("src",resource_starhunt_effect_streakblock_png);D.text.attr("text",B);break;case"TRIGGER":D.effectIcon.attr("src",resource_starhunt_effect_trigger_png);break;case"TRIGGERED_BLOCK":D.effectIcon.attr("src",resource_starhunt_effect_triggeredblock_png);break;case"TELEPORT":D.effectIcon.attr("src",resource_starhunt_effect_teleport_png);break;case"COLOR_BLOCK":D.text.attr("text",B);break;}D.effectIcon.show();}else{if(D.effectIcon){D.effectIcon.hide();}}},renderBackground:function(B,A){if(A&&A>0){A=A/100;}if(this.backgroundImage){this.backgroundImage.attr("src",B);this.backgroundImage.attr("opacity",A);}else{this.backgroundImage=this.paper.image(B,0,0,500,300);this.backgroundImage.attr("opacity",A);this.backgroundImage.toBack();}},changeBackgroundOpacity:function(A){if(A>0){A=A/100;}this.backgroundImageOpacity=A;if(this.backgroundImage){this.backgroundImage.attr("opacity",A);}},renderPlayer:function(){var A=this.getGridXY(this.player.col,this.player.row);A.x=A.x-16;A.y=A.y-16;if(!this.player.elem){this.player.elem=this.paper.image(resource_starhunt_square_empty_png,A.x,A.y,32,32);this.player.elem.attr({stroke:"#700","stroke-width":"2"});}else{this.player.elem.attr({x:A.x,y:A.y});}},renderFocusBar:function(A,B){var D=320,E=D*(A/B);if(!this.focusBar){this.focusBar={};this.focusBar.elemBack=this.paper.rect(80,7,320,20,3);this.focusBar.elemBack.attr({"stroke-width":"0",fill:"90-#B0ABA5-#635F56"});this.focusBar.elemLevel=this.paper.rect(82,9,E-4,16,3);this.focusBar.elemLevel.attr({"stroke-width":"0",fill:"90-#6CC0DA-#509CB3"});this.focusBar.txtFocus=this.paper.text(50,17,"Focus");this.focusBar.txtFocus.attr({"font-size":12});this.focusBar.txtFocusLevel=this.paper.text(E+60,17,A);this.focusBar.txtFocusLevel.attr({"font-size":12});
this.focusBar.txtFocusMaxLevel=this.paper.text(422,17,B);this.focusBar.txtFocusMaxLevel.attr({"font-size":12});}else{var C=E+60;if(C<95){C=95;}this.focusBar.elemLevel.attr({width:E-4});this.focusBar.txtFocusLevel.attr({x:C,text:A});this.focusBar.txtFocusMaxLevel.attr({text:B});}},drawTeleport:function(G,F,C,B){var E=this.points[G+"_"+F].elem,D=this.points[C+"_"+B].elem,A=this.getPath(G,F,C,B,"FIRST_TO_SECOND");if(!this.line){this.line=this.paper.path(A);this.line.attr({stroke:"#f50","stroke-width":6});this.line.node.setAttribute("id","teleport-line");}else{this.line=this.getSVGElement("teleport-line");this.line.attr({d:A});}E.attr({stroke:"#f50"});D.attr({stroke:"#f50"});},getSVGElement:function(A){return $($("#"+A)[0]);},getPath:function(F,E,I,H,G){var A=this.getGridXY(F,E),C=this.getGridXY(I,H),K=50,J="M"+A.x+" "+A.y+" L"+C.x+" "+C.y;if(G=="FIRST_TO_SECOND"){var B=Math.atan2(F-I,H-E);B=(B/(2*Math.PI))*360;var D=this.path("M"+I+" "+H+" L"+(I-K)+" "+(H-K)+" L"+(I-K)+" "+(H+K)+" L"+I+" "+H);J=[J,D];}else{if(G=="SECOND_TO_FIRST"){var B=Math.atan2(I-F,E-H);B=(B/(2*Math.PI))*360;var D=this.path("M"+F+" "+E+" L"+(F-K)+" "+(E-K)+" L"+(F-K)+" "+(E+K)+" L"+F+" "+E);J=[J,D];}}console.log(J);return J;},getGridXY:function(A,B){var C={};C.x=(A*42)+20;C.y=(B*42)+40;return C;}});Planeto.StarHunt.Canvas.POINT_CLICKED="Planeto.StarHunt.Canvas.POINT_CLICKED";Planeto.StarHunt.Canvas.EDGE_CLICKED="Planeto.StarHunt.Canvas.EDGE_CLICKED";if(typeof (Planeto)=="undefined"){Planeto={};}Planeto.FragmentLoader={loadTemplates:function(B,C){var A=this;$.get(B,function(E){var D=A._templateFragmentLoadedHandler(E);if(C&&$.isFunction(C)){C(D);}});},templateExist:function(A){return $.template[A]?true:false;},_templateFragmentLoadedHandler:function(A){var D=$(A).find(".template");result=[];for(var C=0;C<D.length;C++){var E=$(D[C]),B=E.attr("id");if(E.hasClass("template")){$.template(B,E.html().replace(/&gt;/ig,">").replace(/&lt;/ig,"<"));result.push(B);}}return result;}};var swfobject=function(){var AQ="undefined",Ac="object",AB="Shockwave Flash",X="ShockwaveFlash.ShockwaveFlash",Ad="application/x-shockwave-flash",AC="SWFObjectExprInst",AW="onreadystatechange",AF=window,Ak=document,Aa=navigator,AA=false,Z=[Am],Af=[],AG=[],AL=[],Ai,AD,AP,AS,AK=false,At=false,Ag,AN,Ah=true,AH=function(){var A=typeof Ak.getElementById!=AQ&&typeof Ak.getElementsByTagName!=AQ&&typeof Ak.createElement!=AQ,E=Aa.userAgent.toLowerCase(),C=Aa.platform.toLowerCase(),H=C?/win/.test(C):/win/.test(E),J=C?/mac/.test(C):/mac/.test(E),G=/webkit/.test(E)?parseFloat(E.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,D=!+"\v1",F=[0,0,0],K=null;if(typeof Aa.plugins!=AQ&&typeof Aa.plugins[AB]==Ac){K=Aa.plugins[AB].description;if(K&&!(typeof Aa.mimeTypes!=AQ&&Aa.mimeTypes[Ad]&&!Aa.mimeTypes[Ad].enabledPlugin)){AA=true;D=false;K=K.replace(/^.*\s+(\S+\s+\S+$)/,"$1");F[0]=parseInt(K.replace(/^(.*)\..*$/,"$1"),10);F[1]=parseInt(K.replace(/^.*\.(.*)\s.*$/,"$1"),10);F[2]=/[a-zA-Z]/.test(K)?parseInt(K.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0;}}else{if(typeof AF.ActiveXObject!=AQ){try{var I=new ActiveXObject(X);if(I){K=I.GetVariable("$version");if(K){D=true;K=K.split(" ")[1].split(",");F=[parseInt(K[0],10),parseInt(K[1],10),parseInt(K[2],10)];}}}catch(B){}}}return{w3:A,pv:F,wk:G,ie:D,win:H,mac:J};}(),Aj=function(){if(!AH.w3){return ;}if((typeof Ak.readyState!=AQ&&Ak.readyState=="complete")||(typeof Ak.readyState==AQ&&(Ak.getElementsByTagName("body")[0]||Ak.body))){Ao();}if(!AK){if(typeof Ak.addEventListener!=AQ){Ak.addEventListener("DOMContentLoaded",Ao,false);}if(AH.ie&&AH.win){Ak.attachEvent(AW,function(){if(Ak.readyState=="complete"){Ak.detachEvent(AW,arguments.callee);Ao();}});if(AF==top){(function(){if(AK){return ;}try{Ak.documentElement.doScroll("left");}catch(A){setTimeout(arguments.callee,0);return ;}Ao();})();}}if(AH.wk){(function(){if(AK){return ;}if(!/loaded|complete/.test(Ak.readyState)){setTimeout(arguments.callee,0);return ;}Ao();})();}Ab(Ao);}}();function Ao(){if(AK){return ;}try{var B=Ak.getElementsByTagName("body")[0].appendChild(AR("span"));
B.parentNode.removeChild(B);}catch(A){return ;}AK=true;var D=Z.length;for(var C=0;C<D;C++){Z[C]();}}function AJ(A){if(AK){A();}else{Z[Z.length]=A;}}function Ab(A){if(typeof AF.addEventListener!=AQ){AF.addEventListener("load",A,false);}else{if(typeof Ak.addEventListener!=AQ){Ak.addEventListener("load",A,false);}else{if(typeof AF.attachEvent!=AQ){Al(AF,"onload",A);}else{if(typeof AF.onload=="function"){var B=AF.onload;AF.onload=function(){B();A();};}else{AF.onload=A;}}}}}function Am(){if(AA){Y();}else{AM();}}function Y(){var D=Ak.getElementsByTagName("body")[0];var B=AR(Ac);B.setAttribute("type",Ad);var A=D.appendChild(B);if(A){var C=0;(function(){if(typeof A.GetVariable!=AQ){var E=A.GetVariable("$version");if(E){E=E.split(" ")[1].split(",");AH.pv=[parseInt(E[0],10),parseInt(E[1],10),parseInt(E[2],10)];}}else{if(C<10){C++;setTimeout(arguments.callee,10);return ;}}D.removeChild(B);A=null;AM();})();}else{AM();}}function AM(){var G=Af.length;if(G>0){for(var H=0;H<G;H++){var C=Af[H].id;var L=Af[H].callbackFn;var A={success:false,id:C};if(AH.pv[0]>0){var I=Ar(C);if(I){if(AO(Af[H].swfVersion)&&!(AH.wk&&AH.wk<312)){AX(C,true);if(L){A.success=true;A.ref=AU(C);L(A);}}else{if(Af[H].expressInstall&&AT()){var E={};E.data=Af[H].expressInstall;E.width=I.getAttribute("width")||"0";E.height=I.getAttribute("height")||"0";if(I.getAttribute("class")){E.styleclass=I.getAttribute("class");}if(I.getAttribute("align")){E.align=I.getAttribute("align");}var F={};var D=I.getElementsByTagName("param");var K=D.length;for(var J=0;J<K;J++){if(D[J].getAttribute("name").toLowerCase()!="movie"){F[D[J].getAttribute("name")]=D[J].getAttribute("value");}}AE(E,F,C,L);}else{Ae(I);if(L){L(A);}}}}}else{AX(C,true);if(L){var B=AU(C);if(B&&typeof B.SetVariable!=AQ){A.success=true;A.ref=B;}L(A);}}}}}function AU(B){var D=null;var C=Ar(B);if(C&&C.nodeName=="OBJECT"){if(typeof C.SetVariable!=AQ){D=C;}else{var A=C.getElementsByTagName(Ac)[0];if(A){D=A;}}}return D;}function AT(){return !At&&AO("6.0.65")&&(AH.win||AH.mac)&&!(AH.wk&&AH.wk<312);}function AE(F,D,H,E){At=true;AP=E||null;AS={success:false,id:H};var A=Ar(H);if(A){if(A.nodeName=="OBJECT"){Ai=An(A);AD=null;}else{Ai=A;AD=H;}F.id=AC;if(typeof F.width==AQ||(!/%$/.test(F.width)&&parseInt(F.width,10)<310)){F.width="310";}if(typeof F.height==AQ||(!/%$/.test(F.height)&&parseInt(F.height,10)<137)){F.height="137";}Ak.title=Ak.title.slice(0,47)+" - Flash Player Installation";var B=AH.ie&&AH.win?"ActiveX":"PlugIn",C="MMredirectURL="+AF.location.toString().replace(/&/g,"%26")+"&MMplayerType="+B+"&MMdoctitle="+Ak.title;if(typeof D.flashvars!=AQ){D.flashvars+="&"+C;}else{D.flashvars=C;}if(AH.ie&&AH.win&&A.readyState!=4){var G=AR("div");H+="SWFObjectNew";G.setAttribute("id",H);A.parentNode.insertBefore(G,A);A.style.display="none";(function(){if(A.readyState==4){A.parentNode.removeChild(A);}else{setTimeout(arguments.callee,10);}})();}AZ(F,D,H);}}function Ae(A){if(AH.ie&&AH.win&&A.readyState!=4){var B=AR("div");A.parentNode.insertBefore(B,A);B.parentNode.replaceChild(An(A),B);A.style.display="none";(function(){if(A.readyState==4){A.parentNode.removeChild(A);}else{setTimeout(arguments.callee,10);}})();}else{A.parentNode.replaceChild(An(A),A);}}function An(B){var D=AR("div");if(AH.win&&AH.ie){D.innerHTML=B.innerHTML;}else{var E=B.getElementsByTagName(Ac)[0];if(E){var A=E.childNodes;if(A){var F=A.length;for(var C=0;C<F;C++){if(!(A[C].nodeType==1&&A[C].nodeName=="PARAM")&&!(A[C].nodeType==8)){D.appendChild(A[C].cloneNode(true));}}}}}return D;}function AZ(E,G,C){var D,A=Ar(C);if(AH.wk&&AH.wk<312){return D;}if(A){if(typeof E.id==AQ){E.id=C;}if(AH.ie&&AH.win){var F="";for(var I in E){if(E[I]!=Object.prototype[I]){if(I.toLowerCase()=="data"){G.movie=E[I];}else{if(I.toLowerCase()=="styleclass"){F+=' class="'+E[I]+'"';}else{if(I.toLowerCase()!="classid"){F+=" "+I+'="'+E[I]+'"';}}}}}var H="";for(var J in G){if(G[J]!=Object.prototype[J]){H+='<param name="'+J+'" value="'+G[J]+'" />';}}A.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+F+">"+H+"</object>";
AG[AG.length]=E.id;D=Ar(E.id);}else{var B=AR(Ac);B.setAttribute("type",Ad);for(var K in E){if(E[K]!=Object.prototype[K]){if(K.toLowerCase()=="styleclass"){B.setAttribute("class",E[K]);}else{if(K.toLowerCase()!="classid"){B.setAttribute(K,E[K]);}}}}for(var L in G){if(G[L]!=Object.prototype[L]&&L.toLowerCase()!="movie"){Ap(B,L,G[L]);}}A.parentNode.replaceChild(B,A);D=B;}}return D;}function Ap(B,D,C){var A=AR("param");A.setAttribute("name",D);A.setAttribute("value",C);B.appendChild(A);}function AV(A){var B=Ar(A);if(B&&B.nodeName=="OBJECT"){if(AH.ie&&AH.win){B.style.display="none";(function(){if(B.readyState==4){As(A);}else{setTimeout(arguments.callee,10);}})();}else{B.parentNode.removeChild(B);}}}function As(A){var B=Ar(A);if(B){for(var C in B){if(typeof B[C]=="function"){B[C]=null;}}B.parentNode.removeChild(B);}}function Ar(A){var C=null;try{C=Ak.getElementById(A);}catch(B){}return C;}function AR(A){return Ak.createElement(A);}function Al(A,C,B){A.attachEvent(C,B);AL[AL.length]=[A,C,B];}function AO(A){var B=AH.pv,C=A.split(".");C[0]=parseInt(C[0],10);C[1]=parseInt(C[1],10)||0;C[2]=parseInt(C[2],10)||0;return(B[0]>C[0]||(B[0]==C[0]&&B[1]>C[1])||(B[0]==C[0]&&B[1]==C[1]&&B[2]>=C[2]))?true:false;}function AY(B,F,A,C){if(AH.ie&&AH.mac){return ;}var E=Ak.getElementsByTagName("head")[0];if(!E){return ;}var G=(A&&typeof A=="string")?A:"screen";if(C){Ag=null;AN=null;}if(!Ag||AN!=G){var D=AR("style");D.setAttribute("type","text/css");D.setAttribute("media",G);Ag=E.appendChild(D);if(AH.ie&&AH.win&&typeof Ak.styleSheets!=AQ&&Ak.styleSheets.length>0){Ag=Ak.styleSheets[Ak.styleSheets.length-1];}AN=G;}if(AH.ie&&AH.win){if(Ag&&typeof Ag.addRule==Ac){Ag.addRule(B,F);}}else{if(Ag&&typeof Ak.createTextNode!=AQ){Ag.appendChild(Ak.createTextNode(B+" {"+F+"}"));}}}function AX(A,C){if(!Ah){return ;}var B=C?"visible":"hidden";if(AK&&Ar(A)){Ar(A).style.visibility=B;}else{AY("#"+A,"visibility:"+B);}}function AI(B){var A=/[\\\"<>\.;]/;var C=A.exec(B)!=null;return C&&typeof encodeURIComponent!=AQ?encodeURIComponent(B):B;}var Aq=function(){if(AH.ie&&AH.win){window.attachEvent("onunload",function(){var A=AL.length;for(var B=0;B<A;B++){AL[B][0].detachEvent(AL[B][1],AL[B][2]);}var D=AG.length;for(var C=0;C<D;C++){AV(AG[C]);}for(var E in AH){AH[E]=null;}AH=null;for(var F in swfobject){swfobject[F]=null;}swfobject=null;});}}();return{registerObject:function(A,E,C,B){if(AH.w3&&A&&E){var D={};D.id=A;D.swfVersion=E;D.expressInstall=C;D.callbackFn=B;Af[Af.length]=D;AX(A,false);}else{if(B){B({success:false,id:A});}}},getObjectById:function(A){if(AH.w3){return AU(A);}},embedSWF:function(K,E,H,F,C,A,B,I,G,J){var D={success:false,id:E};if(AH.w3&&!(AH.wk&&AH.wk<312)&&K&&E&&H&&F&&C){AX(E,false);AJ(function(){H+="";F+="";var Q={};if(G&&typeof G===Ac){for(var O in G){Q[O]=G[O];}}Q.data=K;Q.width=H;Q.height=F;var N={};if(I&&typeof I===Ac){for(var P in I){N[P]=I[P];}}if(B&&typeof B===Ac){for(var L in B){if(typeof N.flashvars!=AQ){N.flashvars+="&"+L+"="+B[L];}else{N.flashvars=L+"="+B[L];}}}if(AO(C)){var M=AZ(Q,N,E);if(Q.id==E){AX(E,true);}D.success=true;D.ref=M;}else{if(A&&AT()){Q.data=A;AE(Q,N,E,J);return ;}else{AX(E,true);}}if(J){J(D);}});}else{if(J){J(D);}}},switchOffAutoHideShow:function(){Ah=false;},ua:AH,getFlashPlayerVersion:function(){return{major:AH.pv[0],minor:AH.pv[1],release:AH.pv[2]};},hasFlashPlayerVersion:AO,createSWF:function(A,B,C){if(AH.w3){return AZ(A,B,C);}else{return undefined;}},showExpressInstall:function(B,A,D,C){if(AH.w3&&AT()){AE(B,A,D,C);}},removeSWF:function(A){if(AH.w3){AV(A);}},createCSS:function(B,A,C,D){if(AH.w3){AY(B,A,C,D);}},addDomLoadEvent:AJ,addLoadEvent:Ab,getQueryParamValue:function(B){var A=Ak.location.search||Ak.location.hash;if(A){if(/\?/.test(A)){A=A.split("?")[1];}if(B==null){return AI(A);}var C=A.split("&");for(var D=0;D<C.length;D++){if(C[D].substring(0,C[D].indexOf("="))==B){return AI(C[D].substring((C[D].indexOf("=")+1)));}}}return"";},expressInstallCallback:function(){if(At){var A=Ar(AC);if(A&&Ai){A.parentNode.replaceChild(Ai,A);
if(AD){AX(AD,true);if(AH.ie&&AH.win){Ai.style.display="block";}}if(AP){AP(AS);}}At=false;}}};}();function FABridge(B,A){this.target=B;this.remoteTypeCache={};this.remoteInstanceCache={};this.remoteFunctionCache={};this.localFunctionCache={};this.bridgeID=FABridge.nextBridgeID++;this.name=A;this.nextLocalFuncID=0;FABridge.instances[this.name]=this;FABridge.idMap[this.bridgeID]=this;return this;}FABridge.TYPE_ASINSTANCE=1;FABridge.TYPE_ASFUNCTION=2;FABridge.TYPE_JSFUNCTION=3;FABridge.TYPE_ANONYMOUS=4;FABridge.initCallbacks={};FABridge.userTypes={};FABridge.addToUserTypes=function(){for(var A=0;A<arguments.length;A++){FABridge.userTypes[arguments[A]]={typeName:arguments[A],enriched:false};}};FABridge.argsToArray=function(B){var A=[];for(var C=0;C<B.length;C++){A[C]=B[C];}return A;};function instanceFactory(A){this.fb_instance_id=A;return this;}function FABridge__invokeJSFunction(A){var C=A[0],B=A.concat();B.shift();var D=FABridge.extractBridgeFromID(C);return D.invokeLocalFunction(C,B);}FABridge.addInitializationCallback=function(B,D){var C=FABridge.instances[B];if(C!=undefined){D.call(C);return ;}var A=FABridge.initCallbacks[B];if(A==null){FABridge.initCallbacks[B]=A=[];}A.push(D);};function FABridge__bridgeInitialized(G){var A=document.getElementsByTagName("object"),F=A.length,D=[];if(F>0){for(var P=0;P<F;P++){if(typeof A[P].SetVariable!="undefined"){D[D.length]=A[P];}}}var I=document.getElementsByTagName("embed"),B=I.length,O=[];if(B>0){for(var M=0;M<B;M++){if(typeof I[M].SetVariable!="undefined"){O[O.length]=I[M];}}}var C=D.length,N=O.length,H="bridgeName="+G;if((C==1&&!N)||(C==1&&N==1)){FABridge.attachBridge(D[0],G);}else{if(N==1&&!C){FABridge.attachBridge(O[0],G);}else{var Q=false;if(C>1){for(var L=0;L<C;L++){var S=D[L].childNodes;for(var K=0;K<S.length;K++){var E=S[K];if(E.nodeType==1&&E.tagName.toLowerCase()=="param"&&E.name.toLowerCase()=="flashvars"&&E.value.indexOf(H)>=0){FABridge.attachBridge(D[L],G);Q=true;break;}}if(Q){break;}}}if(!Q&&N>1){for(var J=0;J<N;J++){var R=O[J].attributes.getNamedItem("flashVars").nodeValue;if(R.indexOf(H)>=0){FABridge.attachBridge(O[J],G);break;}}}}}return true;}FABridge.nextBridgeID=0;FABridge.instances={};FABridge.idMap={};FABridge.refCount=0;FABridge.extractBridgeFromID=function(B){var A=(B>>16);return FABridge.idMap[A];};FABridge.attachBridge=function(A,C){var B=new FABridge(A,C);FABridge[C]=B;var E=FABridge.initCallbacks[C];if(E==null){return ;}for(var D=0;D<E.length;D++){E[D].call(B);}delete FABridge.initCallbacks[C];};FABridge.blockedMethods={toString:true,get:true,set:true,call:true};FABridge.prototype={root:function(){return this.deserialize(this.target.getRoot());},releaseASObjects:function(){return this.target.releaseASObjects();},releaseNamedASObject:function(B){if(typeof (B)!="object"){return false;}else{var A=this.target.releaseNamedASObject(B.fb_instance_id);return A;}},create:function(A){return this.deserialize(this.target.create(A));},makeID:function(A){return(this.bridgeID<<16)+A;},getPropertyFromAS:function(B,A){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.");}else{FABridge.refCount++;retVal=this.target.getPropFromAS(B,A);retVal=this.handleError(retVal);FABridge.refCount--;return retVal;}},setPropertyInAS:function(C,B,A){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.");}else{FABridge.refCount++;retVal=this.target.setPropInAS(C,B,this.serialize(A));retVal=this.handleError(retVal);FABridge.refCount--;return retVal;}},callASFunction:function(B,A){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.");}else{FABridge.refCount++;retVal=this.target.invokeASFunction(B,this.serialize(A));
retVal=this.handleError(retVal);FABridge.refCount--;return retVal;}},callASMethod:function(B,C,A){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.");}else{FABridge.refCount++;A=this.serialize(A);retVal=this.target.invokeASMethod(B,C,A);retVal=this.handleError(retVal);FABridge.refCount--;return retVal;}},invokeLocalFunction:function(D,B){var A,C=this.localFunctionCache[D];if(C!=undefined){A=this.serialize(C.apply(null,this.deserialize(B)));}return A;},getTypeFromName:function(A){return this.remoteTypeCache[A];},createProxy:function(C,B){var D=this.getTypeFromName(B);instanceFactory.prototype=D;var A=new instanceFactory(C);this.remoteInstanceCache[C]=A;return A;},getProxy:function(A){return this.remoteInstanceCache[A];},addTypeDataToCache:function(D){newType=new ASProxy(this,D.name);var B=D.accessors;for(var C=0;C<B.length;C++){this.addPropertyToType(newType,B[C]);}var A=D.methods;for(var C=0;C<A.length;C++){if(FABridge.blockedMethods[A[C]]==undefined){this.addMethodToType(newType,A[C]);}}this.remoteTypeCache[newType.typeName]=newType;return newType;},addPropertyToType:function(A,D){var E=D.charAt(0);var B;var C;if(E>="a"&&E<="z"){C="get"+E.toUpperCase()+D.substr(1);B="set"+E.toUpperCase()+D.substr(1);}else{C="get"+D;B="set"+D;}A[B]=function(F){this.bridge.setPropertyInAS(this.fb_instance_id,D,F);};A[C]=function(){return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id,D));};},addMethodToType:function(A,B){A[B]=function(){return this.bridge.deserialize(this.bridge.callASMethod(this.fb_instance_id,B,FABridge.argsToArray(arguments)));};},getFunctionProxy:function(A){var B=this;if(this.remoteFunctionCache[A]==null){this.remoteFunctionCache[A]=function(){B.callASFunction(A,FABridge.argsToArray(arguments));};}return this.remoteFunctionCache[A];},getFunctionID:function(A){if(A.__bridge_id__==undefined){A.__bridge_id__=this.makeID(this.nextLocalFuncID++);this.localFunctionCache[A.__bridge_id__]=A;}return A.__bridge_id__;},serialize:function(D){var A={},C=typeof (D);if(C=="number"||C=="string"||C=="boolean"||C==null||C==undefined){A=D;}else{if(D instanceof Array){A=[];for(var B=0;B<D.length;B++){A[B]=this.serialize(D[B]);}}else{if(C=="function"){A.type=FABridge.TYPE_JSFUNCTION;A.value=this.getFunctionID(D);}else{if(D instanceof ASProxy){A.type=FABridge.TYPE_ASINSTANCE;A.value=D.fb_instance_id;}else{A.type=FABridge.TYPE_ANONYMOUS;A.value=D;}}}}return A;},deserialize:function(E){var A;var C=typeof (E);if(C=="number"||C=="string"||C=="boolean"||E==null||E==undefined){A=this.handleError(E);}else{if(E instanceof Array){A=[];for(var B=0;B<E.length;B++){A[B]=this.deserialize(E[B]);}}else{if(C=="object"){for(var B=0;B<E.newTypes.length;B++){this.addTypeDataToCache(E.newTypes[B]);}for(var D in E.newRefs){this.createProxy(D,E.newRefs[D]);}if(E.type==FABridge.TYPE_PRIMITIVE){A=E.value;}else{if(E.type==FABridge.TYPE_ASFUNCTION){A=this.getFunctionProxy(E.value);}else{if(E.type==FABridge.TYPE_ASINSTANCE){A=this.getProxy(E.value);}else{if(E.type==FABridge.TYPE_ANONYMOUS){A=E.value;}}}}}}}return A;},addRef:function(A){this.target.incRef(A.fb_instance_id);},release:function(A){this.target.releaseRef(A.fb_instance_id);},handleError:function(B){if(typeof (B)=="string"&&B.indexOf("__FLASHERROR")==0){var A=B.split("||");if(FABridge.refCount>0){FABridge.refCount--;}throw new Error(A[1]);return B;}else{return B;}}};ASProxy=function(B,A){this.bridge=B;this.typeName=A;return this;};ASProxy.prototype={get:function(A){return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id,A));},set:function(B,A){this.bridge.setPropertyInAS(this.fb_instance_id,B,A);},call:function(B,A){this.bridge.callASMethod(this.fb_instance_id,B,A);},addRef:function(){this.bridge.addRef(this);},release:function(){this.bridge.release(this);}};(function(){if(window.WebSocket){return ;}var B=window.console;
if(!B){B={log:function(){},error:function(){}};}function A(){if("navigator" in window&&"plugins" in navigator&&navigator.plugins["Shockwave Flash"]){return !!navigator.plugins["Shockwave Flash"].description;}if("ActiveXObject" in window){try{return !!new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version");}catch(D){}}return false;}if(!A()){return ;}if(location.protocol=="file:"){B.log("web-socket-js doesn't work in file:///... URL (without special configuration). Open the page via Web server i.e. http://...");}FlashSocket=function(F,I,E,H,G){var D=this;D.readyState=FlashSocket.CONNECTING;D.bufferedAmount=0;setTimeout(function(){FlashSocket.__addTask(function(){D.__createFlash(F,I,E,H,G);});},1);};FlashSocket.prototype.__createFlash=function(F,I,E,H,G){var D=this;D.__flash=FlashSocket.__flash.create(F,I,E||null,H||0,G||null);D.__flash.addEventListener("open",function(J){try{D.readyState=D.__flash.getReadyState();if(D.__timer){clearInterval(D.__timer);}if(window.opera){D.__timer=setInterval(function(){D.__handleMessages();},500);}if(D.onopen){D.onopen();}}catch(K){B.error(K.toString());}});D.__flash.addEventListener("close",function(J){try{D.readyState=D.__flash.getReadyState();if(D.__timer){clearInterval(D.__timer);}if(D.onclose){D.onclose();}}catch(K){B.error(K.toString());}});D.__flash.addEventListener("message",function(){try{D.__handleMessages();}catch(J){B.error(J.toString());}});D.__flash.addEventListener("error",function(J){try{if(D.__timer){clearInterval(D.__timer);}if(D.onerror){D.onerror();}}catch(K){B.error(K.toString());}});D.__flash.addEventListener("stateChange",function(J){try{D.readyState=D.__flash.getReadyState();D.bufferedAmount=J.getBufferedAmount();}catch(K){B.error(K.toString());}});};FlashSocket.prototype.send=function(E){if(this.__flash){this.readyState=this.__flash.getReadyState();}if(!this.__flash||this.readyState==FlashSocket.CONNECTING){throw"INVALID_STATE_ERR: Web Socket connection has not been established";}var D=this.__flash.send(encodeURIComponent(E));if(D<0){return true;}else{this.bufferedAmount=D;return false;}};FlashSocket.prototype.close=function(){if(!this.__flash){return ;}this.readyState=this.__flash.getReadyState();if(this.readyState!=FlashSocket.OPEN){return ;}this.__flash.close();this.readyState=FlashSocket.CLOSED;if(this.__timer){clearInterval(this.__timer);}if(this.onclose){this.onclose();}};FlashSocket.prototype.addEventListener=function(E,F,D){if(!("__events" in this)){this.__events={};}if(!(E in this.__events)){this.__events[E]=[];if("function"==typeof this["on"+E]){this.__events[E].defaultHandler=this["on"+E];this["on"+E]=this.__createEventHandler(this,E);}}this.__events[E].push(F);};FlashSocket.prototype.removeEventListener=function(F,G,D){if(!("__events" in this)){this.__events={};}if(!(F in this.__events)){return ;}for(var E=this.__events.length;E>-1;--E){if(G===this.__events[F][E]){this.__events[F].splice(E,1);break;}}};FlashSocket.prototype.dispatchEvent=function(F){if(!("__events" in this)){throw"UNSPECIFIED_EVENT_TYPE_ERR";}if(!(F.type in this.__events)){throw"UNSPECIFIED_EVENT_TYPE_ERR";}for(var E=0,D=this.__events[F.type].length;E<D;++E){this.__events[F.type][E](F);if(F.cancelBubble){break;}}if(false!==F.returnValue&&"function"==typeof this.__events[F.type].defaultHandler){this.__events[F.type].defaultHandler(F);}};FlashSocket.prototype.__handleMessages=function(){var D=this.__flash.readSocketData();for(var E=0;E<D.length;E++){var F=decodeURIComponent(D[E]);try{if(this.onmessage){var G;if(window.MessageEvent){G=document.createEvent("MessageEvent");G.initMessageEvent("message",false,false,F,null,null,window,null);}else{G={data:F};}this.onmessage(G);}}catch(G){B.error(G.toString());}}};FlashSocket.prototype.__createEventHandler=function(D,E){return function(H){var G=new C();G.initEvent(E,true,true);G.target=G.currentTarget=D;for(var F in H){G[F]=H[F];}D.dispatchEvent(G,arguments);};};function C(){}C.prototype.cancelable=true;C.prototype.cancelBubble=false;C.prototype.preventDefault=function(){if(this.cancelable){this.returnValue=false;
}};C.prototype.stopPropagation=function(){this.cancelBubble=true;};C.prototype.initEvent=function(D,F,E){this.type=D;this.cancelable=E;this.timeStamp=new Date();};FlashSocket.CONNECTING=0;FlashSocket.OPEN=1;FlashSocket.CLOSING=2;FlashSocket.CLOSED=3;FlashSocket.__tasks=[];FlashSocket.__initialize=function(){if(FlashSocket.__swfLocation){window.WEB_SOCKET_SWF_LOCATION=FlashSocket.__swfLocation;}if(!window.WEB_SOCKET_SWF_LOCATION){B.error("[FlashSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf");return ;}var D=document.createElement("div");D.id="FlashSocketContainer";D.style.position="absolute";D.style.left="-100px";D.style.top="-100px";var E=document.createElement("div");E.id="webSocketFlash";D.appendChild(E);document.body.appendChild(D);swfobject.embedSWF(WEB_SOCKET_SWF_LOCATION,"webSocketFlash","8","8","9.0.0",null,{bridgeName:"webSocket"},null,null,function(F){if(!F.success){B.error("[FlashSocket] swfobject.embedSWF failed");}});FABridge.addInitializationCallback("webSocket",function(){try{FlashSocket.__flash=FABridge.webSocket.root();FlashSocket.__flash.setCallerUrl(location.href);FlashSocket.__flash.setDebug(!!window.WEB_SOCKET_DEBUG);for(var F=0;F<FlashSocket.__tasks.length;++F){FlashSocket.__tasks[F]();}FlashSocket.__tasks=[];}catch(G){B.error("[FlashSocket] "+G.toString());}});};FlashSocket.__addTask=function(D){if(FlashSocket.__flash){D();}else{FlashSocket.__tasks.push(D);}};window.webSocketLog=function(D){B.log(decodeURIComponent(D));};window.webSocketError=function(D){B.error(decodeURIComponent(D));};if(!window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION){if(window.addEventListener){window.addEventListener("load",FlashSocket.__initialize,false);}else{window.attachEvent("onload",FlashSocket.__initialize);}}})();Planeto.Clock=Planeto.Clock||{};Planeto.Clock.View=BasicMVC.Base.extend({constructor:function(A){this.name="Planeto.Clock.View";if(!A){console.warn("No clock element supplied in constuct");return ;}this.timerRef=0;this.currentTime=0;this.roundTime=15000;this.currentClockStep=0;this.currentTimeLeft="";this.onTimerEnd=null;this.domClockElement=$(A);this.domClockPie=$(A).find(".pie");this.domClockNumber=$(A).find(".number");if(!this.domClockPie.attr("id")){this.domClockPie.attr("id","clockpie-"+Math.uuid(8));}},eventListeners:function(){return[];},eventHandlers:function(A){switch(A.name){}},resetTimer:function(A){this.currentTime=new Date();this.timeUntilNextEvent=A;this.roundTime=this.timeUntilNextEvent*20;if(this.roundTime<100){this.roundTime*=3;this.plotUpdate=6;}else{this.plotUpdate=2;}this.currentTimeLeft=this.timeUntilNextEvent;this.domClockNumber.html(this.currentTimeLeft);this.stopClockInterval();this.timerRef=setInterval(CallbackProxy(this,this.updateTimer),this.roundTime);},show:function(){this.domClockElement.show();},hide:function(){this.domClockElement.hide();},stopClockInterval:function(){clearInterval(this.timerRef);},closeTimer:function(){this.stopClockInterval();this.currentClockStep=0;this.domClockNumber.html("");this.domClockPie.html("");if(this.onTimerEnd&&$.isFunction(this.onTimerEnd)){this.onTimerEnd();}},addTimeToTimer:function(A){this.closeTimer();this.roundTime+=A*20;this.timerRef=setInterval(CallbackProxy(this,this.updateTimer),this.roundTime);},onTimeChangedEvent:function(A){this.addTimeToTimer(A.timeUntilNextEvent);},updateTimer:function(){var D=new Date(),B=this.timeUntilNextEvent;this.currentTimeLeft=Math.round(this.timeUntilNextEvent-(D.getTime()-this.currentTime.getTime())/1000);this.domClockNumber.html((this.currentTimeLeft>0?this.currentTimeLeft:""));this.currentClockStep=Math.round((D.getTime()-this.currentTime.getTime())/this.roundTime*this.plotUpdate);if(this.currentClockStep>=100){this.closeTimer();}else{if(B>10){var A=100,C=this.currentClockStep;Raphael.fn.pieChart=function(K){var M="#857364",L="#e57d1a",J="#cf1896",N=40+0.001,F=(N-0.001)/2,E=360-(360*K/A),I=-(E+90)*Math.PI/180,H=N+F*Math.cos(I),G=N+F*Math.sin(I);if(E<=90&&B>5){color=J;}else{if(E<=180&&B>5){color=L;
}else{color=M;}}return this.path(["M",N,N,"L",N,(N-F),"A",F,F,0,+(E>180),0,H,G]).attr({fill:color,stroke:color});};this.domClockPie.empty();if(C>=0&&C<A){Raphael(this.domClockPie.attr("id"),70,70).pieChart(C);}}else{this.domClockPie.html("");}}}});Planeto.Mastery=Planeto.Mastery||{};Planeto.Mastery.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.Mastery.View";this.waveReceived=false;this.masteryPoints={};this.baseMastery={};this.trObj=$("#dialogMastery tbody tr").clone();$(".requestMastery").toolTiper().live("click",this.localScopeFull(this.requestMastery));$(".showMastery").live("click",this.localScopeFull(this.showMastery));$("#dialogMastery").delegate(".increase:not(.disabledButton), .decrease","click",this.localScopeFull(this.changeMastery)).delegate(".closeModal","click",this.localScopeFull(this.closeMastery)).delegate(".saveMastery","click",this.localScopeFull(this.saveMastery));},eventListeners:function(){return[PlanetoEvents.GET_MASTERY_POINTS_RESPONSE,PlanetoEvents.WAVE_MESSAGE_RECEIVED_EVENT];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.GET_MASTERY_POINTS_RESPONSE:this.getMasteryPoints(A.data);break;case PlanetoEvents.WAVE_MESSAGE_RECEIVED_EVENT:this.waveReceived=true;break;}},requestMastery:function(){this.sendEvent(PlanetoService.GET_MASTERY_POINTS);this.showMastery();},showMastery:function(){$("#dialogMastery").modal();},getMasteryPoints:function(A){this.masteryPoints=A.masteryPoints.points;this.baseMastery=A.baseMastery;$("#dialogMastery .dialogHeader h2 span").html(A.masteryPoints.availablePoints);$("#dialogMastery tbody").html("");for(var B=0;B<this.masteryPoints.length;B++){var C=this.trObj.clone(),D=this.masteryPoints[B];C.attr({rel:D.category.id}).addClass("category_"+D.category.id);C.find(".category div").html(D.category.name);C.find(".points div").html(D.pointsForCategory);if(A.masteryPoints.availablePoints>0){C.find(".increase").removeClass("disabledButton");}else{C.find(".increase").addClass("disabledButton");}C.find(".decrease").hide();$("#dialogMastery tbody").append(C);}this.updateMasteryDiagram(this.baseMastery);},updateMasteryDiagram:function(C){var D=[],A=["dd40c3","5e9fef","d6b82b","986f2e","61ac28","d98f21"];for(var B=0;B<this.masteryPoints.length;B++){D.push({label:this.masteryPoints[B].category.name,data:C[B].pointsForCategory+50*Math.pow(this.masteryPoints[B].pointsForCategory,0.4),color:"#"+A[B]});}$.plot($("#dialogMasteryPointsPieChart"),D,{series:{pie:{show:true,stroke:{color:"#ccc",width:1},radius:1,label:{show:true,radius:4/6,formatter:function(E,F){return Math.round(F.percent)+"%";}}},},legend:{show:false}});},changeMastery:function(A){var C=$(A.target).is("td")?$(A.target):$(A.target).parents("td"),F=C.parent("tr").attr("rel"),I=C.hasClass("increase")?1:-1,H=C.siblings(".number"),B=H.children("input").val(),G=parseInt(B)+I,J=parseInt($("#dialogMastery .dialogHeader h2 span").html()),D=J-I;if(J>0||I<0){H.children("input").val(G);if(G>0){C.siblings(".decrease").show();}else{C.hide();}$("#dialogMastery .dialogHeader h2 span").html(D);for(var E=0;E<this.masteryPoints.length;E++){if(F==this.masteryPoints[E].category.id){this.masteryPoints[E].pointsForCategory+=I;this.updateMasteryDiagram(this.baseMastery);break;}}}if(D>0){$("#dialogMastery .increase").removeClass("disabledButton");}else{$("#dialogMastery .increase").addClass("disabledButton");}},closeMastery:function(){$("#dialogMastery").modalClose();if(totalQuestions==0&&this.waveReceived==false){$("#landingScreen").hide();this.sendEvent(PlanetoEvents.OPEN_INFINITE_STREAM_GAME);}},saveMastery:function(){this.sendEvent(PlanetoService.SET_MASTERY_POINTS,this.masteryPoints);this.closeMastery();}});BasicMVC.Facade.getInstance().register(new Planeto.Mastery.View());Planeto.QuizWave=Planeto.QuizWave||{};Planeto.QuizWave.View=BasicMVC.Base.extend({constructor:function(){this.name="Planeto.QuizWave.View";this.challengeObject=null;this.inputTimeout=400;this.inputTimer=null;this.wave=null;this.lastPassedToFacebookId=null;
this.questionSets=[];$("#dialogSendWaveToFriends .friendslist > div").live("click",this.localScopeFull(this.onFriendSelected));$("#dialogSendWaveToFriends .close").live("click",this.localScopeFull(this.closeSendWaveToFriendsDialog));$("#dialogSendWaveToFriends .showall").live("click",this.localScopeFull(this.renderAllFriends));$("#dialogSendWaveToFriends input.filter").live("keyup",this.localScopeFull(this.filterInputHandler));$("#createQuizWave input.filter").live("keyup",this.localScopeFull(this.questionSetFilterInputHandler));$("#createQuizWave ul.list").live("click",this.localScopeFull(this.questionSetSelectHandler));quizWaveUI=this;},eventListeners:function(){return[PlanetoService.STOP_GAME,PlanetoEvents.WAVE_MESSAGE_RECEIVED_EVENT,PlanetoService.PASS_WAVE_TO_FACEBOOK_USER_REQUEST,PlanetoEvents.PASS_WAVE_RESPONSE,PlanetoEvents.GET_COMPLETED_QUESTION_SETS_RESPONSE,PlanetoEvents.RECEIVE_BONUS_FOR_WAVE_RESPONSE,Planeto.QuizWave.SHOW_ALL_FRIENDS,Planeto.QuizWave.CREATE_WAVE,PlanetoEvents.GET_WAVES_RESPONSE,PlanetoEvents.SEARCH_QUESTION_SET_FOR_WAVE_RESPONSE,PlanetoEvents.CREATE_WAVE_RESPONSE,PlanetoEvents.CONVERT_LOGIN_RESULT_RESPONSE,ConnectionControl.CONVERTED_TO_FACEBOOK];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.WAVE_MESSAGE_RECEIVED_EVENT:this.wave=A.data;this.showWaveReceievedDialog(A.data);break;case Planeto.QuizWave.CREATE_WAVE:this.showCreateWave();this.renderTab();break;case Planeto.QuizWave.SHOW_ALL_FRIENDS:$(".friendfilter input").val("");this.renderAllFriends();break;case PlanetoEvents.GET_COMPLETED_QUESTION_SETS_RESPONSE:this.questionSets=A.data.questionSets;this.renderQuestionSets(this.questionSets);break;case PlanetoEvents.SEARCH_QUESTION_SET_FOR_WAVE_RESPONSE:this.questionSets=A.data.matches;this.renderQuestionSets(this.questionSets);break;case PlanetoEvents.GET_WAVES_RESPONSE:this.renderQuizWaves(A.data);break;case PlanetoEvents.PASS_WAVE_RESPONSE:this.onPassWaveResponse(A.data);break;case PlanetoEvents.RECEIVE_BONUS_FOR_WAVE_RESPONSE:this.onBonusResponse(A.data);break;case PlanetoService.STOP_GAME:this.resetUI();break;case PlanetoEvents.CREATE_WAVE_RESPONSE:this.showSendWaveToFriendsOnCreationDialog(A.data);break;case ConnectionControl.CONVERTED_TO_FACEBOOK:this.onConvertLoginResponse(A.data);break;case PlanetoService.PASS_WAVE_TO_FACEBOOK_USER_REQUEST:this.lastPassedToFacebookId=A.data.facebookId;break;}},onConvertLoginResponse:function(A){this.renderProperCreateButton();this.renderQuestionSets(this.questionSets);},onPassWaveResponse:function(A){if(A.successful==true){this.getQuizWaves();if(this.lastPassedToFacebookId!=null&&this.lastPassedToFacebookId!=""){this.wave.facebookFriendsAlreadyPartOfWaveOrPlayedQuestionSet.push(this.lastPassedToFacebookId);this.lastPassedToFacebookId=null;this.renderAllFriends();}}},onBonusResponse:function(B){if(this.receivedWave){this.sendEvent(PlanetoEvents.START_GAME_MODE);}else{var A=this.wave;var C=$("#dialogSuccessfullyCreatedWave");C.find("span").html("http://play.planeto.com/#uref=puid-"+user_id+"&wm="+this.wave.waveMessageId);C.modal();C.find(".close").unbind("click").bind("click",function(){$("#dialogSuccessfullyCreatedWave").modalClose();});}},showCreateWave:function(){this.initUI();this.getQuestionSets(20);this.getQuizWaves();this.receivedWave=false;},showWaveReceievedDialog:function(E){this.receivedWave=true;this.wave=E;var F=$("#dialogWaveReceived"),C=F.find("div.kill"),H=F.find("div.play"),I=F.find(".dialogHeader span"),G=F.find(".questionset-info img"),A=F.find(".questionset-info .name"),J=F.find(".questionset-info .description"),B=F.find(".questionset-info .creator"),D=this;A.html(E.questionSet.name);J.html(E.questionSet.description);G.attr("src","/img/plain/"+E.questionSet.imageUrl);I.html(E.sender.name);E.stats.formatedTimeSpan=this.getFormatedTimeSpan(E.stats.age,"in the last ","");F.find(".stats .total").html(E.stats.passedByTotalCount);F.find(".stats .friends").html(E.stats.passedByFriendsCount);F.find(".stats .age").html(E.stats.formatedTimeSpan);
if(E.questionSet.creatorName){B.show().find("span").html(E.questionSet.creatorName);}else{B.hide();}C.unbind("click").bind("click",function(){F.modalClose();D.showConfirmKillWave(E);});H.unbind("click").bind("click",function(){D.showSendWaveToFriendsDialog(E);});F.modal({alone:true});},showWaveEnded:function(B){var A=$("#dialogWaveEnded"),D=A.find("div.close"),C=this;D.unbind("click").bind("click",function(){A.modalClose();});A.modal();},showConfirmKillWave:function(D){var C=$("#dialogConfirmKillWave"),A=C.find("div.kill"),B=C.find("div.play"),E=this;D.stats.formatedTimeSpan=this.getFormatedTimeSpan(D.stats.age,"in the last ","");C.find(".stats .total").html(D.stats.passedByTotalCount);C.find(".stats .age").html(D.stats.formatedTimeSpan);A.unbind("click").bind("click",function(){C.modalClose();E.sendEvent(PlanetoService.REJECT_WAVE_REQUEST,D.waveMessageId);});B.unbind("click").bind("click",function(){E.showSendWaveToFriendsDialog(D);E.showWaveReceievedDialog(D);C.modalClose();});C.modal();},showSendWaveToFriendsOnCreationDialog:function(A){$("#dialogSendWaveToFriends .instruction .createWaveInstruction").show();$("#dialogSendWaveToFriends .instruction .passWaveInstruction").hide();this.showSendWaveToFriendsDialog(A);},showSendWaveToFriendsDialog:function(C){var B=$("#dialogSendWaveToFriends");this.wave=C;this.wave.stats.formatedTimeSpan=this.getFormatedTimeSpan(C.stats.age,"in the last ","");if(fb_friends.length>0){this.challengeObject=C;B.find(".qsName").html(C.questionSet.name);B.find("input.filter").val("");setTimeout(function(){B.modal();},500);setTimeout(this.localScopeFull(this.renderAllFriends),500);}else{var A=$("#dialogNeedFriendsToPlayWave");A.modal();$("#dialogNeedFriendsToPlayWave .close").unbind("click").bind("click",function(){$("#dialogNeedFriendsToPlayWave").modalClose();});}},closeSendWaveToFriendsDialog:function(){$("#dialogWaveReceived").modalClose();this.sendEvent(PlanetoService.RECEIVE_BONUS_FOR_WAVE_REQUEST,this.wave.waveMessageId);$("#dialogSendWaveToFriends .instruction .createWaveInstruction").hide();$("#dialogSendWaveToFriends .instruction .passWaveInstruction").show();$("#dialogSendWaveToFriends").modalClose();},createWave:function(A){this.sendEvent(PlanetoService.CREATE_WAVE_REQUEST,A);},initUI:function(){var A=$("#createQuizWave"),C=A.find("ul.list");A.show().siblings().hide();C.empty();var B=$("<li>");B.html("Loading question sets...");C.append(B);this.renderProperCreateButton();},renderProperCreateButton:function(){var B=$("#createQuizWave"),A=B.find(".startWave"),C=this;if(connectedToFB){$("#createQuizWave .facebookConnect").hide();A.show();A.unbind("click").bind("click",function(){var D=$("#createQuizWave li.selected").data("id");if(D){if(fb_friends.length>0){C.createWave(D);B.modalClose();}else{C.needMoreFriendsForCreateWave();}}else{console.log("please select a questionset");}});}else{$("#createQuizWave .facebookConnect").show();A.hide();}},resetUI:function(){$("#createQuizWave").hide();},getQuestionSets:function(A){this.sendEvent(PlanetoService.GET_COMPLETED_QUESTION_SETS_REQUEST,A);},getQuizWaves:function(){this.sendEvent(PlanetoService.GET_QUIZ_WAVES_REQUEST);},renderQuestionSets:function(A){var C=$("#createQuizWave"),G=C.find("ul.list"),E=$("#createQuizWave input.filter"),D=E.val().toLowerCase();$("#createQuizWave .startWave").addClass("disabledButton");G.empty();for(var B=0;B<A.length;B++){var F=$("<li>");F.html(A[B].name);F.data("id",A[B].identity);G.append(F);}if(A.length==0){var H="";if(D==""||D==E.attr("placeholder").toLowerCase()){H="You have not completed any question sets yet. Complete a question set to be able to send it in a quiz wave";}else{H="No result for search '"+D+"'...";}var F=$("<li>");F.html(H);G.append(F);}},renderAllFriends:function(){this.renderFriends(fb_friends);},renderFriends:function(D){var C=$("#dialogSendWaveToFriends"),E=C.find(".friendslist"),B=D.length;tmp=[];for(var A=0;A<B;A++){var G=D[A],H="";if(this.checkIfAlreadyPartOfWave(G.id)){H="not-available";}var F="<div class='friendItem "+H+"' id='challenge-friend-"+G.id+"' rel='"+G.id+"'><img src='http://graph.facebook.com/"+G.id+"/picture'/><h4>"+shortenString(G.name,8,"..",true)+"</h4></div>";
tmp.push(F);}E.html(tmp.join(""));},renderQuizWaves:function(A){console.log("renderQuizWaves ",A);var B=$("#multiplayerActiveQuizWaves"),D=$("#multiplayerCompletedQuizWaves");for(var C=0;C<A.ended.length;C++){A.ended[C].stats.ageFormatted=this.getFormatedTimeSpan(A.ended[C].stats.age,"Lived for ","");}for(var C=0;C<A.ongoing.length;C++){A.ongoing[C].stats.ageFormatted=this.getFormatedTimeSpan(A.ongoing[C].stats.age,"Started "," ago");}B.empty();D.empty();$.tmpl("multiplayer_quizwave_waveitem",A.ongoing).appendTo(B);$.tmpl("multiplayer_quizwave_waveitem",A.ended).appendTo(D);B.find("li img").each(function(){var E=$(this);E.attr("src","/img/42x42/"+E.attr("rel"));E.removeAttr("rel");});D.find("li img").each(function(){var E=$(this);E.attr("src","/img/42x42/"+E.attr("rel"));E.removeAttr("rel");});},renderTab:function(A){$("#quizArea").hide();$("#multiplayerArea").show();var B=$("#tabContent_5"),C=this;if(Planeto.FragmentLoader.templateExist("multiplayer_quizwave_tabcontent")){B.empty();$.tmpl("multiplayer_quizwave_tabcontent",A).appendTo(B);this.displayGameRoomsTab();}else{Planeto.FragmentLoader.loadTemplates(resource_multiplayer_templates,function(){C.renderTab(A);});}B.find(".tabSubMenu li").toolTiper();},displayGameRoomsTab:function(){$("#column3 li").removeClass("active");$("#tabContentContainer > .tabContent").addClass("hide").hide();$("#tab_5").removeAttr("class").addClass("QUIZ_WAVE");$("#tab_5, #tab_5_1").addClass("active");$("#column3, #tab_5, #tabContent_5, #tabContent_5_1").show();},displayActiveGameRoomTab:function(){$("#column3 li").removeClass("active");$("#tabContentContainer > .tabContent").addClass("hide").hide();$("#tabContent_5_1").addClass("hide").hide();$("#tab_5, #tab_5_2").addClass("active");$("#tab_5, #tabContent_5, #tabContent_5_2").show();},checkIfAlreadyPartOfWave:function(B){var A=false;for(var C=0;C<this.wave.facebookFriendsAlreadyPartOfWaveOrPlayedQuestionSet.length;C++){if(this.wave.facebookFriendsAlreadyPartOfWaveOrPlayedQuestionSet[C]==B){A=true;break;}}return A;},filterInputHandler:function(){clearTimeout(this.inputTimer);if(this.filtering){this.abortFilter=true;}this.inputTimer=setTimeout(this.localScopeFull(this.filterFriends),this.inputTimeout);},questionSetFilterInputHandler:function(){clearTimeout(this.inputTimer);if(this.filtering){this.abortFilter=true;}this.inputTimer=setTimeout(this.localScopeFull(this.searchQuestionSets),this.inputTimeout);},searchQuestionSets:function(){$("#createQuizWave .startWave").addClass("disabledButton");var B=$("#createQuizWave input.filter").val().toLowerCase();var A=$("<li>");A.html("Searching...");$("#createQuizWave ul.list").empty().append(A);this.sendEvent(PlanetoService.SEARCH_QUESTIONSET_FOR_WAVE_REQUEST,{searchStr:B,itemsLimit:20});},questionSetSelectHandler:function(B){var A=$(B.target),C=A.data("id");A.siblings().removeClass("selected");A.addClass("selected");if(typeof (C)!=="undefined"){$("#createQuizWave .startWave").removeClass("disabledButton");}},filterFriends:function(){var G=fb_friends.length,A=$("#dialogSendWaveToFriends input.filter").val().toLowerCase(),B=[];this.filtering=true;if(A==""){this.renderAllFriends();this.abortFilter=false;this.filtering=false;return ;}for(var D=0;D<G;D++){var C=fb_friends[D],H=C.name.split(" "),E=false,F=$("#challenge-friend-"+C.id);if(C.name.toLowerCase().startsWith(A)){E=true;}else{for(var I=0;I<H.length;I++){if(H[I].toLowerCase().startsWith(A)){E=true;}}}if(E){B.push(C);}if(this.abortFilter){this.abortFilter=false;return ;}}this.abortFilter=false;this.filtering=false;this.renderFriends(B);},onFriendSelected:function(B){var A=$(B.target);if(!A.hasClass("friendItem")){A=A.parent(".friendItem");}message=this.challengeObject;message.target_id=A.attr("rel");if(this.checkIfAlreadyPartOfWave(message.target_id)){this.friendAlreadyPartOfWave(message);}else{this.sendEvent(Planeto.Facebook.QuizFeed.Control.SEND_WAVE_TO_FRIEND,message);}},friendAlreadyPartOfWave:function(){var A=$("#dialogFriendAlreadyPartOfWave");A.modal();
$("#dialogFriendAlreadyPartOfWave .close").unbind("click").bind("click",function(){$("#dialogFriendAlreadyPartOfWave").modalClose();});},needMoreFriendsForCreateWave:function(){var A=$("#dialogNeedFriendsToCreateWave");A.modal();$("#dialogNeedFriendsToCreateWave .close").unbind("click").bind("click",function(){$("#dialogNeedFriendsToCreateWave").modalClose();});},filterQuestionSets:function(){var E=this.questionSets.length,F=$("#createQuizWave input.filter").val().toLowerCase(),H=[];this.filtering=true;if(F==""){this.renderQuestionSets(this.questionSets);this.abortFilter=false;this.filtering=false;return ;}for(var D=0;D<E;D++){var B=this.questionSets[D],G=B.name.split(" "),C=false;if(B.name.toLowerCase().startsWith(F)){C=true;}else{for(var A=0;A<G.length;A++){if(G[A].toLowerCase().startsWith(F)){C=true;}}}if(C){H.push(B);}if(this.abortFilter){this.abortFilter=false;return ;}}this.abortFilter=false;this.filtering=false;this.renderQuestionSets(this.questionSets);},getFormatedTimeSpan:function(D,B,C){var E=this.getTimeSpan(D),A=B;if(E.days>0){if(E.days==1){A+="1 day";}else{A+=E.days+" days";}if(E.hours>0){if(E.hours==1){A+=" and 1 hour";}else{A+=" and "+E.hours+" hours";}}}else{if(E.hours==1){A+=E.hours+" hour";}if(E.hours>1){A+=E.hours+" hours";}if(E.hours==0){if(E.minutes<1){A+="0 minutes";}else{if(E.minutes>1){A+=E.minutes+" minutes";}else{A+="1 minute";}}}}A+=C;return A;},getTimeSpan:function(E){var D=1000,A=60000,B=3600000,C=86400000;var F={};F.milliseconds=E%1000;F.seconds=Math.floor(E/D)%60;F.minutes=Math.floor(E/A)%60;F.hours=Math.floor(E/B)%24;F.days=Math.floor(E/C);return F;}});Planeto.QuizWave.CREATE_WAVE="Planeto.QuizWave.CREATE_WAVE";Planeto.QuizWave.SHOW_ALL_FRIENDS="Planeto.QuizWave.SHOW_ALL_FRIENDS";BasicMVC.Facade.getInstance().register(new Planeto.QuizWave.View());KissmetricsControl=BasicMVC.Base.extend({constructor:function(){this.name="KissmetricsControl";_kmq.push(["record","Visited Play"]);_kmq.push(["trackClickOnOutboundLink","kn_prof_link","Clicked My Knowledge Profile Btn"]);},eventListeners:function(){return[PlanetoEvents.NEW_QUIZ_RESPONSE,PlanetoEvents.LOGIN_RESPONSE];},eventHandlers:function(A){switch(A.name){case PlanetoEvents.LOGIN_RESPONSE:this.onLoginResponse(A.data);break;case PlanetoEvents.NEW_QUIZ_RESPONSE:this.onNewQuizSession(A.data);break;}},onLoginResponse:function(A){_kmq.push(["identify",A.account.user.id]);},onNewQuizSession:function(A){if(A.chosen==true&&A.newChosen==true){_kmq.push(["record","Selected user from game",{startDialogVersion:"v2.0"}]);}},});BasicMVC.Facade.getInstance().register(new KissmetricsControl());(function(X){var G=X.fn.domManip,U="_tmplitem",H=/^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,W={},S={},T,I={key:0,data:{}},P=0,V=0,M=[];function R(Z,b,Y,a){var f={data:a||(a===0||a===false)?a:b?b.data:{},_wrap:b?b._wrap:null,tmpl:null,parent:b||null,nodes:[],calls:D,nest:B,wrap:A,html:C,update:E};Z&&X.extend(f,Z,{nodes:[],parent:b});if(Y){f.tmpl=Y;f._ctnt=f._ctnt||f.tmpl(X,f);f.key=++P;(M.length?S:W)[P]=f;}return f;}X.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(Y,Z){X.fn[Y]=function(q){var p=[],f=X(q),d,o,a,b,e=this.length===1&&this[0].parentNode;T=W||{};if(e&&e.nodeType===11&&e.childNodes.length===1&&f.length===1){f[Z](this[0]);p=this;}else{for(o=0,a=f.length;o<a;o++){V=o;d=(o>0?this.clone(true):this).get();X(f[o])[Z](d);p=p.concat(d);}V=0;p=this.pushStack(p,Y,f.selector);}b=T;T=null;X.tmpl.complete(b);return p;};});X.fn.extend({tmpl:function(Z,a,Y){return X.tmpl(this[0],Z,a,Y);},tmplItem:function(){return X.tmplItem(this[0]);},template:function(Y){return X.template(Y,this[0]);},domManip:function(o,Y,Z){if(o[0]&&X.isArray(o[0])){var l=X.makeArray(arguments),e=o[0],a=e.length,b=0,n;while(b<a&&!(n=X.data(e[b++],"tmplItem"))){}if(n&&V){l[2]=function(d){X.tmpl.afterManip(this,d,Z);};}G.apply(this,l);}else{G.apply(this,arguments);}V=0;!T&&X.tmpl.complete(W);return this;}});X.extend({tmpl:function(f,a,b,g){var Z,Y=!g;
if(Y){g=I;f=X.template[f]||X.template(null,f);S={};}else{if(!f){f=g.tmpl;W[g.key]=g;g.nodes=[];g.wrapped&&K(g,g.wrapped);return X(O(g,null,g.tmpl(X,g)));}}if(!f){return[];}if(typeof a==="function"){a=a.call(g||{});}b&&b.wrapped&&K(b,b.wrapped);Z=X.isArray(a)?X.map(a,function(d){return d?R(b,g,f,d):null;}):[R(b,g,f,a)];return Y?X(O(g,null,Z)):Z;},tmplItem:function(Y){var Z;if(Y instanceof X){Y=Y[0];}while(Y&&Y.nodeType===1&&!(Z=X.data(Y,"tmplItem"))&&(Y=Y.parentNode)){}return Z||I;},template:function(Z,Y){if(Y){if(typeof Y==="string"){Y=J(Y);}else{if(Y instanceof X){Y=Y[0]||{};}}if(Y.nodeType){Y=X.data(Y,"tmpl")||X.data(Y,"tmpl",J(Y.innerHTML));}return typeof Z==="string"?(X.template[Z]=Y):Y;}return Z?typeof Z!=="string"?X.template(null,Z):X.template[Z]||X.template(null,H.test(Z)?Z:X(Z)):null;},encode:function(Y){return(""+Y).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;");}});X.extend(X.tmpl,{tag:{tmpl:{_default:{$2:"null"},open:"if($notnull_1){__=__.concat($item.nest($1,$2));}"},wrap:{_default:{$2:"null"},open:"$item.calls(__,$1,$2);__=[];",close:"call=$item.calls();__=call._.concat($item.wrap(call,__));"},each:{_default:{$2:"$index, $value"},open:"if($notnull_1){$.each($1a,function($2){with(this){",close:"}});}"},"if":{open:"if(($notnull_1) && $1a){",close:"}"},"else":{_default:{$1:"true"},open:"}else if(($notnull_1) && $1a){"},html:{open:"if($notnull_1){__.push($1a);}"},"=":{_default:{$1:"$data"},open:"if($notnull_1){__.push($.encode($1a));}"},"!":{open:""}},complete:function(){W={};},afterManip:function(Z,Y,g){var a=Y.nodeType===11?X.makeArray(Y.childNodes):Y.nodeType===1?[Y]:[];g.call(Z,Y);L(a);V++;}});function O(d,Z,a){var Y,h=a?X.map(a,function(b){return typeof b==="string"?d.key?b.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+U+'="'+d.key+'" $2'):b:O(b,d,b._ctnt);}):d;if(Z){return h;}h=h.join("");h.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/,function(b,k,g,j){Y=X(g).get();L(Y);if(k){Y=N(k).concat(Y);}if(j){Y=Y.concat(N(j));}});return Y?Y:N(h);}function N(Z){var Y=document.createElement("div");Y.innerHTML=Z;return X.makeArray(Y.childNodes);}function J(Y){return new Function("jQuery","$item","var $=jQuery,call,__=[],$data=$item.data;with($data){__.push('"+X.trim(Y).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,function(Z,a,h,p,u,t,s){var n=X.tmpl.tag[h],o,r,q;if(!n){throw"Unknown template tag: "+h;}o=n._default||[];if(t&&!/\w$/.test(u)){u+=t;t="";}if(u){u=Q(u);s=s?","+Q(s)+")":t?")":"";r=t?u.indexOf(".")>-1?u+Q(t):"("+u+").call($item"+s:u;q=t?r:"(typeof("+u+")==='function'?("+u+").call($item):("+u+"))";}else{q=r=o.$1||"null";}p=Q(p);return"');"+n[a?"close":"open"].split("$notnull_1").join(u?"typeof("+u+")!=='undefined' && ("+u+")!=null":"true").split("$1a").join(q).split("$1").join(r).split("$2").join(p||o.$2||"")+"__.push('";})+"');}return __;");}function K(Z,Y){Z._wrap=O(Z,true,X.isArray(Y)?Y:[H.test(Y)?Y:X(Y).html()]).join("");}function Q(Y){return Y?Y.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null;}function F(Y){var Z=document.createElement("div");Z.appendChild(Y.cloneNode(true));return Z.innerHTML;}function L(Z){var a="_"+V,f,g,d={},r,Y,q;for(r=0,Y=Z.length;r<Y;r++){if((f=Z[r]).nodeType!==1){continue;}g=f.getElementsByTagName("*");for(q=g.length-1;q>=0;q--){b(g[q]);}b(f);}function b(s){var v,t=s,n,u,l;if(l=s.getAttribute(U)){while(t.parentNode&&(t=t.parentNode).nodeType===1&&!(v=t.getAttribute(U))){}if(v!==l){t=t.parentNode?t.nodeType===11?0:t.getAttribute(U)||0:0;if(!(u=W[l])){u=S[l];u=R(u,W[t]||S[t]);u.key=++P;W[P]=u;}V&&w(l);}s.removeAttribute(U);}else{if(V&&(u=X.data(s,"tmplItem"))){w(u.key);W[u.key]=u;t=X.data(s.parentNode,"tmplItem");t=t?t.key:0;}}if(u){n=u;while(n&&n.key!=t){n.nodes.push(s);n=n.parent;}delete u._ctnt;delete u._wrap;X.data(s,"tmplItem",u);}function w(e){e=e+a;u=d[e]=d[e]||R(u,W[u.parent.key+a]||u.parent);
}}}function D(Z,e,f,Y){if(!Z){return M.pop();}M.push({_:Z,tmpl:e,item:this,data:f,options:Y});}function B(Z,a,Y){return X.tmpl(X.template(Z),a,Y,this);}function A(Y,Z){var a=Y.options||{};a.wrapped=Z;return X.tmpl(X.template(Y.tmpl),Y.data,a,Y.item);}function C(Z,a){var Y=this._wrap;return X.map(X(X.isArray(Y)?Y.join(""):Y).filter(Z||"*"),function(b){return a?b.innerText||b.textContent:b.outerHTML||F(b);});}function E(){var Y=this.nodes;X.tmpl(null,null,null,this).insertBefore(Y[0]);X(Y).remove();}})(jQuery);
