
ISLOnline_JSON={hextable:['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'],encode:function(obj){var i;var ret;var ch;if(obj.constructor==Array){ret='[';for(i=0;i<obj.length;++i){if(i>=1)ret+=',';ret+=this.encode(obj[i]);}
return ret+']';}else if(obj.constructor==String){ret='"';for(i=0;i<obj.length;++i){ch=obj.charCodeAt(i);if(ch!=34&&ch!=39&&ch!=92&&ch>=32&&ch<=126){ret+=obj.charAt(i);}else{ret+='\\u'+this.hextable[(ch>>12)&0xf]+this.hextable[(ch>>8)&0xf]+this.hextable[(ch>>4)&0xf]+this.hextable[ch&0xf];}}
return ret+'"';}else if(obj.constructor==Number&&(''+obj)==(''+Math.round(obj))){return''+obj;}else if(obj.constructor==Object){ret='{';for(i in obj){if(ret.length>1)ret+=',';ret+=this.encode(i)+':'+this.encode(obj[i]);}
ret+='}';return ret;}else{throw"unsupported type";}},decode:function(str){return eval('('+str+')');}};ISLOnline={CONNECTION_FAILED:'/connection-failed',makeError:function(err,desc){return{getError:function(){return err;},getDescription:function(){return desc;}};},calls_:{},reply_:function(call_id,data){if(ISLOnline.calls_[call_id]!=null)
ISLOnline.calls_[call_id].reply(data);},call:function(name,data,fnok,fnerror){data=ISLOnline_JSON.encode({"fn":name,"args":data,"lang":'en'});var encoded=[''];var ch;for(var i=0;i<data.length;++i){if(encoded[encoded.length-1].length>=300)
encoded[encoded.length]='';ch=data.charCodeAt(i);encoded[encoded.length-1]+=ISLOnline_JSON.hextable[(ch>>4)&0xf];encoded[encoded.length-1]+=ISLOnline_JSON.hextable[ch&0xf];encoded[encoded.length-1]+=ISLOnline_JSON.hextable[(ch>>12)&0xf];encoded[encoded.length-1]+=ISLOnline_JSON.hextable[(ch>>8)&0xf];}
var el=document.getElementsByTagName('head')[0];var call_id=''+Math.random()+'/'+(new Date()).getTime();ISLOnline.calls_[call_id]={reply:function(recv){delete ISLOnline.calls_[call_id];for(var i=0;i<this.elements.length;++i)
this.elements[i].parentNode.removeChild(this.elements[i]);if(recv==null){fnerror(ISLOnline.makeError(ISLOnline.CONNECTION_FAILED,'Connection to the server failed.'));}else if(recv.constructor==Object&&typeof(recv.error)=='string'&&typeof(recv.description)=='string'){fnerror(ISLOnline.makeError(recv.error,recv.description));}else{fnok(recv);}},elements:[]};setTimeout(function(){ISLOnline.reply_(call_id,null);},30000);var elements=ISLOnline.calls_[call_id].elements;for(var i=0;i<encoded.length;++i){var script=document.createElement('script');script.src='https://www.islonline.net/__webcall__'+'?ns=ISLOnline&call_id='+call_id+'&part='+i+'&all_parts='+encoded.length+'&data='+encoded[i];elements[elements.length]=script;el.appendChild(script);}}};ISLOnline['Join']={INVALID_SESSION_CODE:'/Join/invalid-session-code',SESSION_NOT_FOUND:'/Join/session-not-found',getSessionInfoByCode_:function(raw,fnok,fnerror){ISLOnline.call('Join.getSessionInfoByCode',raw,function(data){fnok({getAttribute:function(a){var ret=data[a];return ret==null?'':ret;},getAttributes:function(){var ret=[];for(var p in data)
if(data[p].length)
ret[ret.length]=p;return ret;},getInnerHTML:function(){return this.getAttribute('innerHTML');},join:function(){var js=this.getAttribute('joinJavascript');if(js.length){eval(js);return;}
var link=this.getAttribute('joinLink');if(link.length)
window.location.href=link;}});},fnerror);},getSessionInfoByCode:function(code,fnok,fnerror){ISLOnline.Join.getSessionInfoByCode_(''+code,fnok,fnerror);},getSessionInfoByCodeWithProgramQuery:function(code,pq,fnok,fnerror){ISLOnline.Join.getSessionInfoByCode_({'code':''+code,'programQuery':pq},fnok,fnerror);}};
