function api_call(h,g,d){h.open("POST",MAIN_URL+"json");h.setRequestHeader("Content-Type","application/json");h.withCredentials=!0;h.onreadystatechange=d;h.send(JSON.stringify(g))}function api_response(h){if(4==h.readyState)if(200==h.status)if(h=JSON.parse(h.responseText),void 0!=h.login)top.location.href=login_url;else return h;else alert("Server communication failed: "+h.status+" ("+h.responseText+")"),document.location+="";return!1} function number_format(h){return h.toString().replace(/\B(?=(\d{3})+(?!\d))/g," ")}var e=function(h){return document.getElementById(h)}; function Common(){function h(a,f,l){a=a.getElementsByTagName("DIV");f=["f2l"+f,"f2r"+f,"f4l"+f,"f4r"+f];var r=["f2l"+l,"f2r"+l,"f4l"+l,"f4r"+l];l="a"==l?"#0030CB":"#5C0D11";for(var n=0;n"+D+"
"+H+"
"+F+"
";G.style.visibility="visible"}};this.hide_popup_box=function(){e("popup_box").removeAttribute("style")};this.show_itemc_box=function(a,f,l,r,n,w){this.show_popup_box(a, f,398,75,l,r,n,dynjs_itemc[w].n,dynjs_itemc[w].q,"Consumable")};this.show_itemr_box=function(a,f,l,r,n,w,B,D){this.show_popup_box(a,f,398,85,l,r,n,w,B,D)};var g=void 0,d=0,m=0,q=0,u=function(){var a=g.scrollTop;g.scrollTop=0';l+=v[n]}return'
'+f+"
"};this.apply_select=function(a){h(a,"b","a");a.style.color="#0030CB"};this.apply_unselect=function(a){h(a,"a","b");a.removeAttribute("style")};var y=void 0; this.text_select=function(a){var f=y!=a;this.text_unselect();f&&(this.apply_select(a),y=a)};this.text_unselect=function(){void 0!=y&&(this.apply_unselect(y),y=void 0)}}var common=new Common; function ItemShop(){function h(){y=!0;1>d||1>m?y=!1:"shop_pane"==g&&m*u>current_credits&&(y=!1);e("accept_button").src=IMG_URL+"shops/accept"+(y?"":"_d")+".png";e("cost_field").value=u;e("sum_field").value=(m*u).toLocaleString("en")}var g=void 0,d=0,m=0,q=void 0,u=0,v=0,y=!1;this.set_item=function(a,f,l,r,n){f==d&&a==g&&(a=void 0,r=l=f=0,n=void 0);g=a;d=f;u=r;q=f&&!n?dynjs_itemc[f].n:n;v=l;this.set_count(0v&&this.set_count(v);h()};this.commit_transaction=function(){y&&confirm("Are you sure you wish to "+("shop_pane"==g?"purchase":"sell")+" "+m+' "'+q.replace("'","'")+'" for '+common.number_format(m*u)+" credits ?")&&(e("select_mode").value=g,e("select_item").value=d,e("select_count").value=m,e("shopform").submit())}} function Snowflake(){var h=e("shrine_info"),g=e("shrine_artifact"),d=e("shrine_trophy"),m=e("shrine_collectible"),q=e("shrine_offertext"),u=0,v=0,y=0,a="",f="",l=void 0,r=!1;this.set_shrine_item=function(n,w,B,D){n==u&&(B=w=n=0,D=void 0);u=n;v=w;y=B;l=D;r=!0;n=0;1>u?(e("accept_equip").style.display="none",r=!1,n=1):2E4<=u&&3E4>u?(r=!0,n=2):3E4<=u&&4E4>u?(r=y<=v,n=3):7E4<=u&&8E4>u&&(r=!0,n=4);if(3==n)for(e("accept_equip").style.display="",e("accept_reward").style.display="none",w=e("accept_equip").querySelectorAll(".accept_equip"), B=0;Bv?"You have "+v+" / "+y+" items required for this offering.":"Offer "+y+"x "+l+" for :"};this.submit_shrine_reward=function(n,w){a=n;f=w;this.commit_transaction()};this.commit_transaction= function(){r&&confirm("Are you sure you wish to offer Snowflake "+(1v?"0":"")+v;h.style.width=4*q+"px";m>=end_time&&(document.location= reload_to,clearInterval(d))},ticktime)} function ItemSelector(){var h=0,g=!1;this.set_item=function(q){h==q?this.commit_slot(0):h=q};var d=void 0,m=void 0;this.hover_slot=function(q){0!=h&&(void 0!=d&&this.unhover_slot(),common.suppress_popups=!0,d=q,m=q.innerHTML,q.innerHTML=dynjs_itemc[h].n,q.className="ss")};this.unhover_slot=function(){void 0!=d&&(d.innerHTML=m,d.removeAttribute("class"),d=void 0,common.suppress_popups=!1)};this.commit_slot=function(q){g||(g=!0,e("slot").value=q,e("item").value=h,e("selectionform").submit())}} function MonsterLab(){this.create_monster=function(h){e("selected_patk").value=h;e("create_form").submit()}} function Battle(){var h=e("infopane"),g=[void 0,void 0],d=[void 0,void 0],m="log",q=void 0,u=void 0,v=void 0,y=1,a=0,f=void 0,l=e("ta_monster_1"),r=e("ta_monster_2"),n=!1,w=function(b){void 0!=h&&(h.innerHTML=b)};this.set_infopane=function(b){switch(b){case "Attack":var k="Damages a single enemy. Depending on your equipped weapon, this can place certain status effects on the affected monster. To attack, click here, then click your target. Simply clicking an enemy will also perform a normal attack.";break; case "Skillbook":k="Use special skills and magic. To use offensive spells and skills, first click it, then click your target. To use it on yourself, click it twice.";break;case "Items":k="Use various consumable items that can replenish your vitals or augment your power in various ways.";break;case "Spirit":k="Toggle Spirit Channeling.";break;case "Defend":k="Increases your defensive capabilities for the next turn.";break;case "Focus":k="Reduces the chance that your next spell will be resisted. Your defenses and evade chances are lowered for the next turn."; break;default:k="Choose from the Battle Actions highlighted above, and use them to defeat your enemies listed to the right. When all enemies are reduced to zero Health, you win. If your Health reaches zero, you are defeated."}w('
'+b+"
"+k+"
")};this.set_infopane_spell=function(b,k,t,z,C,A){var E="";if(0'+ b+'
'+k+'
'+E+'
')}; this.set_infopane_effect=function(b,k,t){w('
'+b+'
'+k+'
'+("autocast"==t?"Expires if magic is depleted to below 10%":"permanent"==t?"Permanent until triggered":"decaying"==t?"Decays by 20% per turn":"Expires in "+t+" turn"+(1==t?"":"s"))+".
")};this.set_infopane_item=function(b){w('
'+dynjs_itemc[b].n+'
'+dynjs_itemc[b].q+"
")};this.lock_action= function(b,k,t,z){if(!n)if(d[k]==b&&"skill"!=t?(g[k]=void 0,d[k]=void 0):(g[k]=h.innerHTML,d[k]=b),0==k&&(g[1]=void 0,d[1]=void 0),1==k)q!=t&&(this.clear_actions(),q=t,b.src=IMG_URL+"battle/"+q+"_s.png",this.set_mode(t)),this.set_selected_subaction(b,z);else switch(q==t?"skill"==t?this.set_selected_subaction(void 0):q=void 0:(this.clear_actions(),q=t),b.src=IMG_URL+"battle/"+t+"_"+(void 0==q?"n":"s")+".png",this.set_mode(t),t){case "attack":this.toggle_default_pane();break;case "skill":this.toggle_magic_pane(); break;case "items":this.toggle_item_pane();break;default:this.touch_and_go()}};this.clear_actions=function(){if(void 0!=q){if("spirit"!=q){var b="magic"==q?"skill":q;e("ckey_"+b).src=IMG_URL+"battle/"+b+"_n.png"}q=void 0}};this.clear_infopane=function(){void 0!=g[1]?w(g[1]):void 0!=g[0]?w(g[0]):this.set_infopane("Battle Time")};var B=function(b){e("pane_"+b).style.display="none";m=void 0};this.toggle_pane=function(b){b==m?this.toggle_default_pane():(B(m),e("pane_"+b).style.display="",m=b)};this.toggle_default_pane= function(){"log"!=m&&(B(m),e("pane_log").style.display="",m=m="log")};this.toggle_magic_pane=function(){"skill"==m?this.toggle_pane("magic"):"magic"==m?this.toggle_pane("skill"):this.toggle_pane(default_magic_pane)};this.toggle_skill_pane=function(){this.toggle_pane("skill")};this.toggle_item_pane=function(){this.toggle_pane("item")};var D="attack",H=0,F=0;this.set_mode=function(b){D=D==b&&"magic"!=b?"attack":b};this.reset_skill=function(){F=H=0;this.set_selected_subaction(void 0)};this.set_hostile_skill= function(b){F=F==b?0:b};this.set_friendly_skill=function(b){F==b?(H=0,this.touch_and_go()):F=b};this.hover_target=function(b){if(void 0==v){var k=common.findPosWithScroll(b),t=common.findPosWithScroll(e("battle_right"));k[0]-=t[0];k[1]-=t[1];l.style.left=k[0]-7+"px";l.style.top=k[1]+b.offsetHeight/2-3+"px";r.style.left=k[0]+b.offsetWidth+2+"px";r.style.top=k[1]+b.offsetHeight/2-3+"px";l.style.visibility="visible";r.style.visibility="visible"}};this.unhover_target=function(){void 0==v&&(l.removeAttribute("style"), r.removeAttribute("style"))};this.commit_target=function(b){n||void 0!=v||(H=v=b,this.touch_and_go())};var G=void 0,J=void 0,I=void 0;this.touch_and_go=function(){n||void 0!=f||(G=D,J=H,I=F,f=new XMLHttpRequest,api_call(f,{type:"battle",method:"action",token:battle_token,mode:D,target:H,skill:F},this.process_action))};this.recast=function(){n||void 0==G||(D=G,H=J,F=I,this.touch_and_go())};for(var L=0,O=!1,M="pane_completion pane_effects pane_action pane_vitals pane_quickbar table_skills table_magic pane_item pane_monster".split(" "), Q=[],P=0;PA){0==A&&(A=10);E=!0;var K=e("qb"+A);K&&(K.onmouseover(),K.onclick())}}else{if(13==k||32==k)z="btcp";else if(-1=k||"G"==t||"P"==t)"item"!=m&&(z="ckey_items"),C="G"==t||"P"==t?"ikey_p":b.ctrlKey? "ikey_n"+(k-111):b.shiftKey?"ikey_s"+(k-111):"ikey_"+(k-111);else if(!b.ctrlKey&&!b.shiftKey)switch(t){case "Q":z="ckey_attack";break;case "W":z="ckey_skill";break;case "E":z="ckey_items";break;case "S":z="ckey_spirit";break;case "D":z="ckey_defend";break;case "F":z="ckey_focus";break;case "R":z="recast"}if(z||C)E=!0;if(z)if("recast"==z)battle.recast();else if(K=e(z))K.onclick();if(C&&(K=e(C)))K.onclick()}if(E)return b.cancelBubble=!0,b.returnValue=!1,b.stopPropagation&&(b.stopPropagation(),b.preventDefault()), !1}};this.clear_infopane();this.start_flash_loop();this.set_infopane("Battle Time")}function at_show_aux(h,g){h=e(h);g=e(g);for(var d="x"==g.at_position?h.offsetWidth+0:0;h;h=h.offsetParent)d+=h.offsetLeft;g.style.position="absolute";g.style.top="27px";g.style.left=d+"px";g.style.visibility="visible"}function at_show(){p=e(this.at_parent);c=e(this.at_child);at_show_aux(p.id,c.id)}function at_hide(){c=e(this.at_child);e(c.id).style.visibility="hidden"} function at_click(){p=e(this.at_parent);c=e(this.at_child);"visible"!=c.style.visibility?at_show_aux(p.id,c.id):c.style.visibility="hidden";return!1} function at_attach(h,g,d,m,q){p=e(h);c=e(g);p.at_parent=p.id;c.at_parent=p.id;p.at_child=c.id;c.at_child=c.id;p.at_position=m;c.at_position=m;c.style.position="absolute";c.style.visibility="hidden";switch(d){case "click":p.onclick=at_click;p.onmouseout=at_hide;c.onmouseover=at_show;c.onmouseout=at_hide;break;case "hover":p.onmouseover=at_show,p.onmouseout=at_hide,c.onmouseover=at_show,c.onmouseout=at_hide}};