var Kf;if(Kf==undefined){Kf={}}if(Kf.Lib==undefined){Kf.Lib={}}if(Kf.Lib.Basic==undefined){Kf.Lib.Basic={}}String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")};String.prototype.ltrim=function(){return this.replace(/^\s+/g,"")};String.prototype.rtrim=function(){return this.replace(/\s+$/g,"")};Array.prototype.add=function(b,a){if(a==null){return}if(a<0||this.length<a){return}if(a<this.length){this.splice(a,0,b)}else{this.push(b)}};Array.prototype.addSorted=function(d,b){b=b||function(f,e){return Kf.Lib.Basic.compare(f,e)};var a=-1;for(var c=0;c<this.length;++c){if(b(d,this[c])<0){a=c;break}}this.add(d,a)};Array.prototype.lastIndexOf=function(c){var a=function(d){if(c instanceof Function){return c(d)}else{return d==c}};for(var b=this.length-1;0<=b;--b){if(a(this[b])){return b}}return -1};Array.prototype.remove=function(a){if(0<=a&&a<this.length){this.splice(a,1)}};Array.prototype.clear=function(a){while(this.length!=0){this.shift()}};Array.prototype.sortNum=function(){return this.sort(function(d,c){return d-c})};Array.prototype.map=function(a){var b=[];for(i=0;i<this.length;i++){b.push(a(this[i]))}return b};Array.prototype.indexOf=function(c){var a=function(d){if(c instanceof Function){return c(d)}else{return d==c}};for(var b=0;b<this.length;++b){if(a(this[b])){return b}}return -1};Array.prototype.contains=function(a){return this.indexOf(a)!=-1};Array.prototype.find=function(a){var b=false;for(i=0;i<this.length;i++){if(typeof(a)=="function"){if(a.test(this[i])){if(!b){b=[]}b.push(i)}}else{if(this[i]===a){if(!b){b=[]}b.push(i)}}}return b};Date.prototype.getYearEx=function(){var a=this.getYear();if(a<1900){a+=1900}return a};Date.prototype.getMonthEx=function(){return this.getMonth()+1};Date.prototype.getThisDay=function(){return new Date(this.getYearEx(),this.getMonth(),this.getDate())};Date.prototype.isSunday=function(){return this.getDay()==0};Date.prototype.getLatestSunday=function(){var a=this.getDay();var b=this.getTime();return new Date(b-a*24*60*60*1000)};Date.prototype.getYmdString=function(){var b=this.getYearEx();var c=this.getMonthEx();if(c<10){c="0"+c}var a=this.getDate();if(a<10){a="0"+a}return b+"/"+c+"/"+a};Date.prototype.getMdString=function(){var b=this.getMonth()+1;var a=this.getDate();return b+"/"+a};Date.prototype.getHmsString=function(){var a=this.getHours();if(a<10){a="0"+a}var b=this.getMinutes();if(b<10){b="0"+b}var c=this.getSeconds();if(c<10){c="0"+c}return a+":"+b+":"+c};Date.prototype.getHmString=function(){var a=this.getHours();var b=this.getMinutes();if(b<10){b="0"+b}return a+":"+b};Date.prototype.isToday=function(){var a=new Date();return this.getYear()==a.getYear()&&this.getMonth()==a.getMonth()&&this.getDate()==a.getDate()};Kf.Lib.Basic.sprintf=function(){var b=Kf.Lib.Basic.sprintf.arguments;if(b.length==0){return""}var a=b[0].length;var j=1,d=false,g="",h,f;for(var e=0;e<a;e++){h=b[0].charAt(e);if(d==false){if(h=="%"){d=true}else{g+=h}}else{if(h=="%"){g+="%"}else{if(h=="s"){f=b[j++];if(f!=null){g+=f.toString()}else{g+="%s"}}else{g+="%"+h}}d=false}}if(d){g+="%"}return g};Kf.Lib.Basic.escapeHtmlString=function(a){if(a==null){return null}a=a.replace(/&/g,"&amp;");a=a.replace(/\</g,"&lt;");a=a.replace(/\>/g,"&gt;");a=a.replace(/"/g,"&quot;");return a};Kf.Lib.Basic.replaceLinkString=function(c,b,d){var a;if(b==null){a=""}else{a=" target='"+b+"'"}if(d==null){d=""}else{d=d+"?"}c=c.replace(/((http|https):\/\/[0-9a-z-\/._?=&%\[\]~;]+)/gi,"<a href='"+d+"$1'"+a+">$1</a>");return c};Kf.Lib.Basic.equals=function(c,b){if((!(c instanceof Object))||(!(b instanceof Object))){return c==b}for(var a in c){if(c[a]!=b[a]){return false}}for(var a in b){if(c[a]!=b[a]){return false}}return true};Kf.Lib.Basic.compare=function(b,a){if(b==a){return 0}else{if(b<a){return -1}else{return 1}}};Kf.Lib.Basic.toJson=function(b){if(b===null){return"null"}if(b===undefined){return undefined}var e=typeof(b);if(e=="boolean"){return String(b)}if(e=="number"){return isFinite(b)?String(b):undefined}if(e=="string"){return'"'+Kf.Lib.Basic.toSafeStr(b)+'"'}if(b instanceof Function){return undefined}if(b instanceof Array){var a=[];for(var d=0;d<b.length;++d){var f=Kf.Lib.Basic.toJson(b[d]);if(f!==undefined){a.push(f)}}return"["+a.join(", ")+"]"}else{if(b instanceof Object){var a=[];for(var c in b){var f=Kf.Lib.Basic.toJson(b[c]);if(f!==undefined){a.push('"'+c+'":'+f)}}return"{"+a.join(", ")+"}"}else{return undefined}}};Kf.Lib.Basic.parseJson=function(str){return eval("("+str+")")};Kf.Lib.Basic.toJsonObj=function(b){if(b===null||b===undefined){return b}var e=typeof(b);if(e=="boolean"){return b}if(e=="number"){return isFinite(b)?b:undefined}if(e=="string"){return Kf.Lib.Basic.toSafeStr(b)}if(b instanceof Function){return undefined}if(b instanceof Array){var a=[];for(var d=0;d<b.length;++d){var f=Kf.Lib.Basic.toJsonObj(b[d]);if(f!==undefined){a.push(f)}}return a}else{if(b instanceof Object){var a={};for(var c in b){var f=Kf.Lib.Basic.toJsonObj(b[c]);if(f!==undefined){a[c]=f}}return a}else{return undefined}}};Kf.Lib.Basic.toSafeStr=function(a){return function(b){if(/["\\\x00-\x1f]/.test(b)){return b.replace(/[\x00-\x1f\\"]/g,function(d){var e=a[d];if(e){return e}e=d.charCodeAt();return"\\u00"+Math.floor(e/16).toString(16)+(e%16).toString(16)})}return b}}({"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"});Kf.Lib.Basic.inBaseType=function(a){var b=typeof a;if(b=="boolean"||b=="number"||b=="string"){return true}return false};Kf.Lib.Basic.toStringEx=function(a){if(a===null){return"null"}else{if(a===undefined){return"undefined"}}if(Kf.Lib.Basic.inBaseType(a)){return""+a}if(a instanceof Function){var e=arguments[1];if(e){return"function"}else{return a.toString()}}if(a instanceof Array){var d=[];for(var c=0;c<a.length;++c){var f=Kf.Lib.Basic.toStringEx(a[c],true);d.push(f)}return"["+d.join(", ")+"]"}else{if(a instanceof Object){var d=[];for(var b in a){var f=Kf.Lib.Basic.toStringEx(a[b],true);d.push(b+":"+f)}return"{"+d.join(", ")+"}"}else{return"error in toStringEx()"}}};myalert=function(b,a){var c;if(a!=null){c=a+":"+Kf.Lib.Basic.toJson(b)}else{c=Kf.Lib.Basic.toJson(b)}alert(c)};mylog=function(b,a){if(console==null||console.log==null){return}console.log(b)};var Kf;if(Kf==undefined){Kf={}}if(Kf.Lib==undefined){Kf.Lib={}}if(Kf.Lib.Basic==undefined){Kf.Lib.Basic={}}Kf.Lib.Basic.id2ElmCache={};function $(b){var a=Kf.Lib.Basic.id2ElmCache[b];if(a==null){a=document.getElementById(b);Kf.Lib.Basic.id2ElmCache[b]=a}return a}Kf.Lib.Basic.removeAllChildren=function(a){while(a.hasChildNodes()){a.removeChild(a.firstChild)}};Kf.Lib.Basic.insertChildAt=function(e,d,b){var a=e.childNodes;if(b<0||a.length<b){return}if(a.length==b){e.appendChild(d)}else{var c=a[b];e.insertBefore(d,c)}};Kf.Lib.Basic.removeChildAt=function(d,b){var a=d.childNodes;if(b<0||a.length<=b){return}var c=d.childNodes[b];if(c!=null){d.removeChild(c)}};Kf.Lib.Basic.addEventListener=function(c,a,b){if(c.addEventListener){c.addEventListener(a,b,false)}else{if(c.attachEvent){c.attachEvent("on"+a,b)}}};Kf.Lib.Basic.createElm=function(f,d,h,c,e,a){var g=document.createElement(f);if(h!=null){g.id=h}if(c!=null){g.className=c}if(e!=null){for(var b in e){g.style[b]=e[b]}}if(a!=null){for(var b in a){g.setAttribute(b,a[b])}}if(d!=null){d.appendChild(g)}return g};var Kf;if(Kf==undefined){Kf={}}if(Kf.Lib==undefined){Kf.Lib={}}Kf.Lib.Jsonp=function(){this._counter=0;this._id2TimeoutCallback={}};Kf.Lib.Jsonp.prototype.execute=function(c,e){var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","utf-8");if(c.indexOf("?")==-1){c=c+"?noCacheIE="+(new Date()).getTime()}else{c=c+"&noCacheIE="+(new Date()).getTime()}b.setAttribute("src",c);var f=this._nextId();b.setAttribute("id",f);Kf.Lib.Jsonp.Internal.headLoc.appendChild(b);var d=this._id2TimeoutCallback;d[f]=e;setTimeout(a,Kf.Lib.Jsonp.VALUE_TIMEOUT);function a(){Kf.Lib.Jsonp.Internal.headLoc.removeChild(b);var g=d[f];if(g!=null){delete d[f];g(c)}}return f};Kf.Lib.Jsonp.prototype.clearTimeoutCallback=function(a){delete this._id2TimeoutCallback[a]};Kf.Lib.Jsonp.prototype._nextId=function(){return""+(this._counter++)};Kf.Lib.Jsonp.VALUE_TIMEOUT=20000;Kf.Lib.Jsonp.Internal={};Kf.Lib.Jsonp.Internal.headLoc=document.getElementsByTagName("head").item(0);var Kf;if(Kf==undefined){Kf={}}if(Kf.Lib==undefined){Kf.Lib={}}Kf.Lib.Task={};Kf.Lib.Task.SeqExecutor=function(a){this.terminated=false;this._taskList=[];this._executing=false};Kf.Lib.Task.SeqExecutor.prototype.addTask=function(a){if(this.terminated){return}this._taskList.push(a);if(this._executing){return}this._executing=true;var b=this._taskList.shift();if(typeof(b)=="function"){b(this)}else{if(typeof(b.execute)=="function"){b.execute(this)}}};Kf.Lib.Task.SeqExecutor.prototype.notifyTaskDone=function(){if(this.terminated){return}if(this._taskList.length==0){this._executing=false;return}this._executing=true;var a=this._taskList.shift();if(typeof(a)=="function"){a(this)}else{if(typeof(a.execute)=="function"){a.execute(this)}}};Kf.Lib.Task.SeqExecutor.prototype.terminate=function(){this.terminated=true;this._taskList=[]};var Kf;if(Kf==undefined){Kf={}}if(Kf.Lib==undefined){Kf.Lib={}}Kf.Lib.Browser={};Kf.Lib.Browser.getClientSize=function(){var a={width:0,height:0};if(window.self&&self.innerHTML){a.width=self.innerWidth();a.height=self.innerHeight();return a}if(document.compatMode=="CSS1Compat"){if(document.documentElement&&document.documentElement.clientHeight){a.width=document.documentElement.clientWidth;a.height=document.documentElement.clientHeight;return a}else{a.width=document.body.clientWidth;a.height=document.body.clientHeight;return a}}else{if(document.body.clientWidth&&document.body.clientHeight){a.width=document.body.clientWidth;a.height=document.body.clientHeight;return a}else{a.width=document.documentElement.clientWidth;a.height=document.documentElement.clientHeight;return a}}};Kf.Lib.Browser.getClientWidth=function(){return Kf.Lib.Browser.getClientSize().width};Kf.Lib.Browser.getClientHeight=function(){return Kf.Lib.Browser.getClientSize().height};Kf.Lib.Browser.getDocumentSize=function(){var b=Math.max(Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),document.body.offsetWidth);var a=Math.max(Math.max(document.body.scrollHeight,document.documentElement.scrollHeight),document.body.offsetHeight);return{width:b,height:a}};Kf.Lib.Browser.getDocumentWidth=function(){Kf.Lib.Browser.getDocumentSize().width};Kf.Lib.Browser.getDocumentHeight=function(){Kf.Lib.Browser.getDocumentSize().height};Kf.Lib.Browser.getScrollPosition=function(){var b=document.documentElement.scrollLeft||document.body.scrollLeft;var a=document.documentElement.scrollTop||document.body.scrollTop;return{left:parseInt(b),top:parseInt(a)}};Kf.Lib.Browser.getScrollLeft=function(){return Kf.Lib.Browser.getScrollPosition().left};Kf.Lib.Browser.getScrollTop=function(){return Kf.Lib.Browser.getScrollPosition().top};Kf.Lib.Browser.getMousePosition=function(b){b=b||window.event;var a={};a.x=b.pageX||b.clientX+document.body.scrollLeft;a.y=b.pageY||b.clientY+document.body.scrollTop;return a};Kf.Lib.Browser.showAndMoveToCenter=function(e){var a=Kf.Lib.Browser.getScrollPosition();e.style.display="block";var b=Kf.Lib.Browser.getClientSize();var d=(b.width-e.offsetWidth)/2+a.left+"px";var c=(b.height-e.offsetHeight)/2+a.top+"px";e.style.left=d;e.style.top=c};var Kf=Kf||{};Kf.Pca={};Kf.Pca.divBackground=null;Kf.Pca.divInput=null;Kf.Pca.divInputText=null;Kf.Pca.divMessage=null;Kf.Pca.divMessageMessage=null;Kf.Pca.joinProcessing=false;Kf.Pca.key=null;Kf.Pca.chatTitle=null;Kf.Pca.jsonp=new Kf.Lib.Jsonp();Kf.Pca.lastJsonpId=null;Kf.Pca.taskQueueJsonp=new Kf.Lib.Task.SeqExecutor();Kf.Pca.urlAjax="http://pubchat-alter.net/join/start";Kf.Pca.doJoin=function(a){if(Kf.Pca.joinProcessing){Kf.Pca.showMessageDialog("参加処理中です。しばらくお待ちください。");return}Kf.Pca.joinProcessing=true;Kf.Pca.key=a;Kf.Pca.getConfig()};Kf.Pca.getConfig=function(){if(Kf.Pca.chatTitle!=null){Kf.Pca.showInputDialog(Kf.Pca.chatTitle)}else{Kf.Pca.taskQueueJsonp.addTask(Kf.Pca.taskGetConfig)}};Kf.Pca.taskGetConfig=function(){var a=Kf.Pca.urlAjax+"?method=get_config&callback=Kf.Pca.onGetConfig&key="+Kf.Pca.key;Kf.Pca.lastJsonpId=Kf.Pca.jsonp.execute(a,Kf.Pca.onJoinRequestError)};Kf.Pca.onGetConfig=function(a){Kf.Pca.jsonp.clearTimeoutCallback(Kf.Pca.lastJsonpId);if(a.status!="success"){Kf.Pca.onJoinRequestError();return}if(a.need_permission!=null){var b="このチャットに参加するためには管理者の許可が必要です。<br /><a href='skype:"+a.need_permission+"?chat'>管理者に参加申請を送る</a>";Kf.Pca.showMessageDialog(b);Kf.Pca.joinProcessing=false;if(Kf.Pca.joinCompleted!=null){Kf.Pca.joinCompleted()}}else{Kf.Pca.chatTitle=a.chat_title;Kf.Pca.showInputDialog(Kf.Pca.chatTitle)}Kf.Pca.taskQueueJsonp.notifyTaskDone()};Kf.Pca.startJoinRequest=function(){Kf.Pca.taskQueueJsonp.addTask(Kf.Pca.taskGetRequestId)};Kf.Pca.startJoinRequest=function(){Kf.Pca.taskQueueJsonp.addTask(Kf.Pca.taskGetRequestId)};Kf.Pca.taskGetRequestId=function(){var a=Kf.Pca.urlAjax+"?method=get_request_id&callback=Kf.Pca.onGetRequestId";Kf.Pca.lastJsonpId=Kf.Pca.jsonp.execute(a,Kf.Pca.onJoinRequestError)};Kf.Pca.onGetRequestId=function(b){Kf.Pca.jsonp.clearTimeoutCallback(Kf.Pca.lastJsonpId);if(b.status!="success"){Kf.Pca.onJoinRequestError();return}var a=new Kf.Pca.TaskJoinRequest(b.rid);Kf.Pca.taskQueueJsonp.addTask(a);Kf.Pca.taskQueueJsonp.notifyTaskDone()};Kf.Pca.TaskJoinRequest=function(a){this.requestId=a};Kf.Pca.TaskJoinRequest.prototype.execute=function(){var b=encodeURIComponent(Kf.Pca.divInputText.value);var a=Kf.Pca.urlAjax+"?method=join_request&rid="+this.requestId+"&callback=Kf.Pca.onJoinRequest&key="+Kf.Pca.key+"&skype_id="+b;Kf.Pca.lastJsonpId=Kf.Pca.jsonp.execute(a,Kf.Pca.onJoinRequestError)};Kf.Pca.onJoinRequest=function(b){Kf.Pca.jsonp.clearTimeoutCallback(Kf.Pca.lastJsonpId);var c;var a=b.status;if(a=="failure_rebooting"){c="サーバを再起動中です。しばらくしてからもう一度参加を実行してください。"}else{if(a=="failure_no_chat"){c="チャットに参加できませんでした。理由：チャットが存在しません"}else{if(a=="failure_join_already"){c="すでに参加中です。"}else{if(a=="failure_send_chat"){c="チャットに参加するためのURLを、あなたのスカイプチャットに送信できませんでした。入力したスカイプIDを確認してください。"}else{if(b.status!="success"){c="チャットに参加できませんでした。しばらくしてからもう一度参加を実行してください。"}else{c="チャットに参加するためのURLを、あなたのスカイプチャットに送信しました。<br /><br />メッセージが届かない場合は、「pubchat_alter」をあたなのスカイプコンタクトリストに追加してください。（<a href='skype:pubchat_alter?add'>コンタクトリストに追加</a>）"}}}}}Kf.Pca.showMessageDialog(c);Kf.Pca.taskQueueJsonp.notifyTaskDone();Kf.Pca.joinProcessing=false;if(Kf.Pca.joinCompleted!=null){Kf.Pca.joinCompleted()}};Kf.Pca.onJoinRequestError=function(){Kf.Pca.showMessageDialog("チャットに参加できませんでした。しばらくしてからもう一度参加を実行してください。");Kf.Pca.taskQueueJsonp.notifyTaskDone();Kf.Pca.joinProcessing=false;if(Kf.Pca.joinCompleted!=null){Kf.Pca.joinCompleted()}};Kf.Pca.checkAndDoJoinRequest=function(){var a=Kf.Pca.divInputText.value;if(a==null||a==""){Kf.Pca.showMessageDialog("スカイプIDが入力されていません。");return}if(255<a.length){Kf.Pca.showMessageDialog("スカイプIDが長すぎます。");return}Kf.Pca.hideInputDialog();Kf.Pca.startJoinRequest()};Kf.Pca.showInputDialog=function(f){Kf.Pca.showBackground();if(Kf.Pca.divInput==null){var a=document.getElementsByTagName("body").item(0);Kf.Pca.divInput=Kf.Lib.Basic.createElm("div",a,null,null,{padding:"2px",margin:"0px",border:"1px solid gray",width:"300px",backgroundColor:"#ccccff",position:"absolute",zIndex:"110",display:"none",textAlign:"left"});var c=Kf.Lib.Basic.createElm("div",Kf.Pca.divInput,null,null,{padding:"0px",margin:"0px",backgroundColor:"#ccccff",font:"normal normal bold 10pt/ 130% sans-serif",textAlign:"left"});inputHeader1="スカイプチャット「"+f+"」に参加します";c.innerHTML=inputHeader1;var b=Kf.Lib.Basic.createElm("div",Kf.Pca.divInput,null,null,{padding:"0px",margin:"0px",backgroundColor:"#ccccff",font:"normal normal 10pt/ 130% sans-serif",textAlign:"left"});b.innerHTML="あなたのスカイプIDを入力してください";Kf.Pca.divInputText=Kf.Lib.Basic.createElm("input",Kf.Pca.divInput,null,null,{padding:"0px",width:"296px",margin:"0px",font:"normal normal 10pt/ 130% sans-serif",textAlign:"left"},{type:"text"});var e=Kf.Lib.Basic.createElm("input",Kf.Pca.divInput,null,null,{padding:"0px",margin:"2px",font:"normal normal 10pt/ 130% sans-serif",textAlign:"left"},{type:"button",value:"キャンセル"});var d=Kf.Lib.Basic.createElm("input",Kf.Pca.divInput,null,null,{padding:"0px",margin:"2px",font:"normal normal 10pt/ 130% sans-serif",textAlign:"left"},{type:"button",value:"OK"});Kf.Lib.Basic.addEventListener(e,"click",function(){Kf.Pca.hideInputDialog();Kf.Pca.joinProcessing=false;if(Kf.Pca.joinCompleted!=null){Kf.Pca.joinCompleted()}});Kf.Lib.Basic.addEventListener(d,"click",Kf.Pca.checkAndDoJoinRequest)}Kf.Lib.Browser.showAndMoveToCenter(Kf.Pca.divInput);Kf.Pca.divInputText.focus()};Kf.Pca.hideInputDialog=function(){Kf.Pca.divInput.style.display="none";Kf.Pca.divBackground.style.display="none"};Kf.Pca.showBackground=function(){if(Kf.Pca.divBackground==null){var a=document.getElementsByTagName("body").item(0);Kf.Pca.divBackground=Kf.Lib.Basic.createElm("div",a,null,null,{padding:"0px",margin:"0px",backgroundColor:"#cccccc",position:"absolute",zIndex:"100",display:"none",filter:"alpha(opacity = '50')",MozOpacity:"0.5",opacity:"0.5"})}var b=Kf.Lib.Browser.getDocumentSize();Kf.Pca.divBackground.style.width=b.width+"px";Kf.Pca.divBackground.style.height=b.height+"px";Kf.Pca.divBackground.style.left="0px";Kf.Pca.divBackground.style.top="0px";Kf.Pca.divBackground.style.display="block"};Kf.Pca.showMessageDialog=function(b){Kf.Pca.showBackground();if(Kf.Pca.divMessage==null){var a=document.getElementsByTagName("body").item(0);Kf.Pca.divMessage=Kf.Lib.Basic.createElm("div",a,null,null,{padding:"2px",margin:"0px",border:"1px solid gray",width:"200px",backgroundColor:"#ffffcc",position:"absolute",zIndex:"120",display:"none",textAlign:"left"});Kf.Pca.divMessageMessage=Kf.Lib.Basic.createElm("div",Kf.Pca.divMessage,null,null,{padding:"0px",margin:"0px",backgroundColor:"#ffffcc",font:"normal normal bold 10pt/ 130% sans-serif",textAlign:"left"});var c=Kf.Lib.Basic.createElm("input",Kf.Pca.divMessage,null,null,{padding:"0px",margin:"2px",font:"normal normal 10pt/ 130% sans-serif",textAlign:"left"},{type:"button",value:"閉じる"});Kf.Lib.Basic.addEventListener(c,"click",function(){Kf.Pca.divMessage.style.display="none";if(Kf.Pca.divInput==null||Kf.Pca.divInput.style!="block"){Kf.Pca.divBackground.style.display="none"}})}Kf.Pca.divMessageMessage.innerHTML=b;Kf.Lib.Browser.showAndMoveToCenter(Kf.Pca.divMessage)};