var maxOptions={};$langDefaultSection="Options";maxOptions.init=function(){maxConfig.setActiveFile("$main");document.title=$lang("maxthon_options");maxOptions.adjustHeight();window.onresize=maxOptions.adjustHeight;var B=$cookies("mxOption_activePage");var A=$parseQueryString();if(A.page){if(maxOptions.pages[A.page]){B=A.page}}if(maxOptions.pages[B]){maxOptions.activePage=B}maxOptions.ui.buildPageLinks();maxOptions.action.activatePage(maxOptions.activePage)};maxOptions.destroy=function(){};maxOptions.adjustHeight=function(){var B=$id("sidebar");var A=document.documentElement.clientHeight-B.offsetTop;B.style.height=A;var B=$id("contentBlock");A=document.documentElement.clientHeight-B.offsetTop-22;$id("pageContent").style.height=A};maxOptions.action={};maxOptions.action.activatePage=function(targetPage){var obj=$id("pageLink_"+maxOptions.activePage);if(obj){obj.className=""}obj=$id("pageLink_"+targetPage);if(obj){obj.className="active"}maxOptions.ui.setPageHeader(targetPage);maxOptions.ui.buildPage(targetPage);try{eval("maxOptions.pages."+maxOptions.activePage+".destroy()")}catch(e){if(!((e.number&65535)==438)){alert("maxOptions.pages."+targetPage+".destroy()\n"+(e.number&65535)+" : "+e.message);throw (e)}}try{maxOptions.pages[targetPage].init()}catch(e){if(!((e.number&65535)==438)){alert("maxOptions.pages["+targetPage+"].init()\n"+(e.number&65535)+" : "+e.message);throw (e)}}maxOptions.activePage=targetPage;$cookies("mxOption_activePage",targetPage)};maxOptions.action.applyChanges=function(){maxConfig.save();external.max_Invoke("ReloadConfig");maxOptions.ui.showMessage($lang("config_saved"),3000)};maxOptions.action.restoreDefault=function(){if(confirm("["+$lang("maxthon_options")+"]\n\n"+$lang("confirm_restore_default"))){external.max_Invoke("DefaultConfig","All");maxConfig.load();maxOptions.action.activatePage(maxOptions.activePage);maxOptions.ui.showMessage($lang("config_restored"),3000)}};maxOptions.action.close=function(A){if(maxConfig.files["$main"].modified&&confirm("["+$lang("maxthon_options")+"]\n\n"+$lang("config_not_saved_confirm"))){maxOptions.action.applyChanges()}else{maxConfig.files["$main"].modified=false}maxOptions.destroy();if(!A){external.max_closeTab("")}};maxOptions.ui={};maxOptions.ui.showMessage=function(C,A){var B=$id("msgBox");if(B){B.innerHTML=C;B.style.display="block";window.setTimeout(maxOptions.ui.clearMessage,A)}};maxOptions.ui.clearMessage=function(){var A=$id("msgBox");if(A){A.innerHTML="";A.style.display="none"}};maxOptions.ui.toggleSidebar=function(){var B=$id("sidebarWrapper");var A=$id("btnSidebar");if($toggleElement("sidebar")){B.style.width="";A.src="../_shared/images/btn_hide_sidebar.png"}else{B.style.width="8";A.src="../_shared/images/btn_show_sidebar.png"}};maxOptions.ui.setPageHeader=function(A){var B=$lang("page_"+A);$write(B,"pageHeader",false)};maxOptions.ui.buildPageLinks=function(){var A="";for(label in maxOptions.pages){if(maxOptions.pages[label].type=="separator"){A+="<hr/>"}else{A+='<a id="pageLink_'+label+'" class="pageLink" href="javascript:;" onclick="this.blur();maxOptions.action.activatePage(\''+label+'\');"><img src="images/page_'+label+'.png"/> '+$lang("page_"+label)+"</a>\n"}}$write(A,"pageLinks",false)};maxOptions.ui.buildPage=function(C){var B=$id("pageContent");if(!B){alert("maxOptions.ui.buildPage :: missing 'pageContent' object")}var A=maxConfig.ui.buildItems(maxOptions.pages[C].items);A+="<br/><br/><br/><br/><br/><br/>";B.innerHTML=A};maxOptions.getLangCode=function(){var B;try{B=external.max_language_id}catch(A){}if(B=="0x0804"){B="cn"}else{B="en"}return B};maxOptions.getURL=function(A){var B=maxOptions.getLangCode();switch(A){case"addons":if(B=="cn"){return"http://addons.maxthon.cn"}else{return"http://addons.maxthon.com"}break;case"go":if(B=="cn"){return"http://gocn.maxthon.com"}else{return"http://go.maxthon.com"}break;case"web":if(B=="cn"){return"http://www.maxthon.cn"}else{return"http://www.maxthon.com"}break;case"forum":if(B=="cn"){return"http://bbs.maxthon.cn"}else{return"http://forum.maxthon.com"}break}};