var maxResumeSession={};maxResumeSession.pageList=[];maxResumeSession.autoClose=false;$langDefaultSection="ResumeSession";maxResumeSession.init=function(){document.title=$lang("title");maxResumeSession.loadAutoClose();maxResumeSession.loadPageList();maxResumeSession.buildPageList()};maxResumeSession.loadAutoClose=function(){maxConfig.setActiveFile("$main");var A=maxConfig.ini.getValue("Settings","ResumeAutoClose");A=(A!="1")?false:true;maxResumeSession.autoClose=A;var B=$id("auto_close");if(!B){return}B.checked=A};maxResumeSession.toggleAutoClose=function(){var A=$id("auto_close");if(A.checked){maxResumeSession.autoClose=true}else{maxResumeSession.autoClose=false}maxConfig.setActiveFile("$main");maxConfig.ini.setValue("Settings","ResumeAutoClose",maxResumeSession.autoClose?"1":"0");maxConfig.save()};maxResumeSession.loadPageList=function(){maxConfig.setActiveFile("$session");var A=maxConfig.ini.getArray("LastURL",false);for(var B=0;B<A.length;B++){var C={};C.id=B;C.url=A[B][0];C.title=A[B][1];C.enabled=true;A[B]=C}maxResumeSession.pageList=A};maxResumeSession.buildPageList=function(){var A=$id("pageList");if(!A){alert("maxResumeSession.buildList : can not get obj 'pageList'")}var B="";for(var D=0;D<maxResumeSession.pageList.length;D++){var F=maxResumeSession.pageList[D];var C=F.url.$encodeHTML();var E=false;if(C.indexOf("file://")==0){E=true;C="javascript:maxResumeSession.openPage("+D+")"}B+='<div class="pageList-item"><img src="../_shared/images/btn_check_checked.png" id="check_'+F.id+'" class="checkButton" onclick="maxResumeSession.togglePageItem('+F.id+');" />&nbsp; <a id="link_'+F.id+'" href="'+C+'"'+(E?"":' target="_blank"')+" onclick=\"javascript:maxResumeSession.linkOpened('"+F.id+"');\">"+F.title.$cut(100).$encodeHTML()+"</a></div>"}A.innerHTML=B};maxResumeSession.togglePageItem=function(B){if(!maxResumeSession.pageList[B]){alert("maxResumeSession.togglePageItem :: invalid id "+B);return}var A=maxResumeSession.pageList[B];A.enabled=!A.enabled;maxResumeSession.updatePageItemCheck(A)};maxResumeSession.updatePageItemCheck=function(B){var A=$id("check_"+B.id);if(!A){alert("maxResumeSession.updatePageItemCheck : invalid id "+id);return}if(B.enabled){A.src="../_shared/images/btn_check_checked.png"}else{A.src="../_shared/images/btn_check.png"}};maxResumeSession.selectPages=function(C){for(var A=0;A<maxResumeSession.pageList.length;A++){var B=maxResumeSession.pageList[A];if(C==1){B.enabled=true}else{if(C==0){B.enabled=false}else{B.enabled=!B.enabled}}maxResumeSession.updatePageItemCheck(B)}};maxResumeSession.openPage=function(A){var B=maxResumeSession.pageList[A];if(!B){return}try{external.max_newTab("",B.url,"ignoreOpenNext;DelCurrentSession;")}catch(C){window.open(B.url)}B.enabled=false;B.opened=true;maxResumeSession.updatePageItemCheck(B);maxResumeSession.updatePageItemStatus(B)};maxResumeSession.openPages=function(){for(var A=0;A<maxResumeSession.pageList.length;A++){if(maxResumeSession.pageList[A].enabled){maxResumeSession.openPage(A)}}if(maxResumeSession.autoClose){external.max_closeTab("")}};maxResumeSession.updatePageItemStatus=function(B){var A=$id("link_"+B.id);if(!A){alert("maxResumeSession.updatePageItemStatus : invalid id "+B.id);return}A.className="openedPageLink"};maxResumeSession.linkOpened=function(C){if(!maxResumeSession.pageList[C]){alert("maxResumeSession.togglePageItem : invalid id "+C);return}var A=maxResumeSession.pageList[C];A.enabled=false;A.opened=true;maxResumeSession.updatePageItemCheck(A);try{external.max_invoke("DelCurrentSession",A.url)}catch(B){}};