
var ids=new Array();var hidecoex=false;document.getElementsByClassName=function(cl){var retnode=[];var myclass=new RegExp('\\b'+cl+'\\b');var elem=this.getElementsByTagName('*');for(var i=0;i<elem.length;i++){var classes=elem[i].className;if(myclass.test(classes))retnode.push(elem[i]);}
return retnode;};function QAinit(){if(document.getElementById){var tids=document.getElementsByClassName('sprite-expand');for(i=0;i<tids.length;i++)tids[i].onmouseup=setstate;tids=document.getElementsByClassName('sprite-unexpand');for(i=0;i<tids.length;i++)tids[i].onmouseup=setstate;}}
function setstate(){var d=this.parentNode.parentNode.getElementsByTagName('span')[0];var i=this;if(d.style.display=="inline"){d.style.display="none";this.setAttribute('class','sprite-expand');this.setAttribute('className','sprite-expand');}else{d.style.display="inline";this.setAttribute('class','sprite-unexpand');this.setAttribute('className','sprite-unexpand');}}
function expandall(){if(document.getElementById){for(i=0;i<ids.length;i++)ids[i].parentNode.getElementsByTagName('span')[1].style.display="block";}}
function collapseall(){if(document.getElementById){for(i=0;i<ids.length;i++)ids[i].parentNode.getElementsByTagName('span')[1].style.display="none";}}
function removelink(){if(document.getElementById('linkres')){document.getElementById('linkres').value='';}
if(document.getElementById('linkrow')){document.getElementById('linkrow').style.display='none';}}
function updatedictionary(book,offset){var node=document.getElementById("dic"+offset).value;var url="update.pl?data=dictionary,"+book+","+offset+","+node;request.open("GET",url,true);request.onreadystatechange=updatePage;request.send(null);}
function updatePage(){if(request.readyState==4){if(request.status==200){var response=request.responseText;if(response!='OK'){alert(response);}}}}
var request=false;try{request=new XMLHttpRequest();}catch(trymicrosoft){try{request=new ActiveXObject("Msxml2.XMLHTTP");}catch(othermicrosoft){try{request=new ActiveXObject("Microsoft.XMLHTTP");}catch(failed){request=false;}}}
if(!request)
alert("Error initializing XMLHttpRequest!");var depthreq=1;var namereq='';var showsub=0;function getData(name,depth){namereq=name;var node=document.getElementById("l"+name+depth).value;document.getElementById(name).value=node;if(node==''||node==0){document.getElementById("s"+name+(depth+1)).innerHTML='';}else{var iflang=document.getElementById("if").value;var url="nav.pl?node="+node+"&if="+iflang+"&sub="+showsub+"&name="+name;depthreq=depth;request.open("GET",url,true);request.onreadystatechange=updatePage;request.send(null);}}
function updatePage(){if(request.readyState==4){if(request.status==200){if(request.responseText.charAt(0)=="0"){}else{if(request.responseText!=''){var alltext="All";if(document.getElementById("if").value=='gb'){alltext="全部";}
document.getElementById("s"+namereq+(depthreq+1)).innerHTML='<select id="l'+namereq+(depthreq+1)+'" class="booklistbox" onChange="getData(\''+namereq+'\','+(depthreq+1)+');"><option value="">['+alltext+']</option>'+request.responseText+'</select><span id="s'+namereq+(depthreq+2)+'"></span>';}}}else
alert("status is "+request.status);}}
function addSearch(depth){document.getElementById("param"+depth).innerHTML='<br /><input type="text" name="search'+depth+'" id="search'+depth+'" size="20" class="searchbox" /><input type="radio" name="textonly'+depth+'" id="textonly'+depth+'" value="textonly" checked="checked" onclick="hideSemantics('+depth+');" />Text search<input type="radio" name="textonly'+depth+'" value="semantic"  onclick="matchword('+depth+');" />Dictionary match<span id="semantic'+(depth)+'"></span><br /><span id="param'+(depth+1)+'" name="param'+(depth+1)+'"><input type="submit" value="More..." onclick="addSearch('+(depth+1)+');" /></span>';}
function matchword(depth,hide){if(hide){hidecoex=true;}
var node=document.getElementById("search"+depth).value;if(node==''){alert('Please enter the word or character you wish to search on.\n請先輸入您想要查詢的字詞。');document.getElementById("textonly"+depth).checked="checked";return false;}else{var url="dic.pl?char="+escape(node)+"&if=en";depthreq=depth;request.open("GET",url,true);request.onreadystatechange=showSemantics;request.send(null);}}
function findResource(){var node=document.getElementById("searchres").value;document.getElementById("resourcechoice").innerHTML='';if(node==''){alert('Please enter the surname of an author or a word in the title to search on.\n請先輸入作者姓名或書名的關鍵詞。');return false;}else{var url="res.pl?search="+escape(node)+"&if=en";request.open("GET",url,true);request.onreadystatechange=showResources;request.send(null);}
return false;}
function showResources(){if(request.readyState==4){if(request.status==200){if(request.responseText.charAt(0)=="0"){alert('No matching entries found.');}else{document.getElementById("resourcechoice").innerHTML='<select name="resource" id="resource">'+request.responseText+'</select><input type="submit" value="Add" />';}}else
alert("status is "+request.status);}}
function showSemantics(){if(request.readyState==4){if(request.status==200){if(request.responseText.charAt(0)=="0"){alert('No matching entries in the CTP dictionary.');document.getElementById("textonly"+depthreq).checked="checked";}else{if(hidecoex){document.getElementById("semantic"+depthreq).innerHTML='<select name="semanticchoice'+depthreq+'" id="semanticchoice'+depthreq+'">'+request.responseText+'</select>';}else{document.getElementById("semantic"+depthreq).innerHTML='<select id="semanticchoice'+depthreq+'">'+request.responseText+'</select><br /><input type="checkbox" id="filterc'+depthreq+'" value="yes" />Include coextensive terms';}}}else
alert("status is "+request.status);}}
function hideSemantics(depth){document.getElementById("semantic"+depth).innerHTML="";}
function noSemantics(depth){document.getElementById("textonly"+depth).checked="checked";}
function enableParallel(){if(document.getElementById("enableparallel").checked){document.getElementById("lparallelsearch1").disabled='';document.getElementById("lparallelsearch2").disabled='';}else{document.getElementById("sparallelsearch3").innerHTML='';document.getElementById("lparallelsearch1").options[0].selected=true;document.getElementById("lparallelsearch1").disabled='disabled';document.getElementById("lparallelsearch2").options[0].selected=true;document.getElementById("lparallelsearch2").disabled='disabled';}}
function prepareSearch(){document.getElementById("node").value=3925;var i;for(i=1;i<10;i++){var thisCntrl=document.getElementById("lnode"+i);if(thisCntrl){if(thisCntrl.options[thisCntrl.selectedIndex].value){document.getElementById("node").value=thisCntrl.options[thisCntrl.selectedIndex].value;}}}
if(!document.getElementById("node").value){document.getElementById("node").value=3925;}
if(!document.getElementById("parallelsearch").value){document.getElementById("parallelsearch").value=3925;}
for(i=1;i<10;i++){var thisCntrl=document.getElementById("lparallelsearch"+i);if(thisCntrl){if(thisCntrl.options[thisCntrl.selectedIndex].value){document.getElementById("parallelsearch").value=thisCntrl.options[thisCntrl.selectedIndex].value;}}}
if(!document.getElementById("enableparallel").checked){document.getElementById("parallelsearch").value='';}
var searchstring='';var filterstring='';for(i=1;i<10;i++){if(document.getElementById("textonly"+i)){if(document.getElementById("textonly"+i).checked){if(document.getElementById("search"+i).value!=''){if(searchstring!=''){searchstring=searchstring+" ";}
if(document.getElementById("search"+i).value.indexOf(" ")>-1){searchstring=searchstring+'"'+document.getElementById("search"+i).value+'"';}else{searchstring=searchstring+document.getElementById("search"+i).value;}}}else{var ind=document.getElementById("semanticchoice"+i).selectedIndex;if(filterstring!=''){filterstring=filterstring+",";}
filterstring=filterstring+'d'+document.getElementById("semanticchoice"+i).options[ind].value;if(document.getElementById("filterc"+i).checked!=''){filterstring=filterstring+"c";}}}}
if(sellist){for(i=0;i<sellist.length;i++){if(filterstring!=''){filterstring=filterstring+",";}
filterstring=filterstring+"p"+sellist[i];}}
document.getElementById("filter").value=filterstring;document.getElementById("searchu").value=searchstring;document.getElementById("yearfrom").value=document.getElementById("yearfrom1").value;document.getElementById("yearto").value=document.getElementById("yearto1").value;if(document.getElementById("reqtype1").checked){document.getElementById("reqtype").value='stats';}else{document.getElementById("reqtype").value='';}
if(document.getElementById("matchtype1").checked){document.getElementById("matchtype").value='exact';}else if(document.getElementById("matchtype2").checked){document.getElementById("matchtype").value='binary';}else{document.getElementById("matchtype").value='';}
var propsearch="";var propsearchterms=0;for(i=0;i<sellist.length;i++){var thisterm=document.getElementById("propsearch"+sellist[i]).value;propsearch=propsearch+thisterm+"|";if(thisterm){propsearchterms++;}}
if(propsearchterms==0){propsearch="";}
document.getElementById("ps").value=propsearch;return true;}
function vote(message,voteval){var url="vote.pl?message="+message+"&vote="+voteval;request.open("GET",url,true);request.send(null);if(document.getElementById("vote"+message)){document.getElementById("vote"+message).style.display='none';}}
function setActiveStyleSheet(title){var i,a,main;for(i=0;(a=document.getElementsByTagName("link")[i]);i++){if(a.getAttribute("rel").indexOf("style")!=-1&&a.getAttribute("title")){a.disabled=true;if(a.getAttribute("title")==title)a.disabled=false;}}}
function getActiveStyleSheet(){var i,a;for(i=0;(a=document.getElementsByTagName("link")[i]);i++){if(a.getAttribute("rel").indexOf("style")!=-1&&a.getAttribute("title")&&!a.disabled)return a.getAttribute("title");}
return null;}
function getPreferredStyleSheet(){var i,a;for(i=0;(a=document.getElementsByTagName("link")[i]);i++){if(a.getAttribute("rel").indexOf("style")!=-1&&a.getAttribute("rel").indexOf("alt")==-1&&a.getAttribute("title"))return a.getAttribute("title");}
return null;}
function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else expires="";document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
window.onload=function(e){var cookie=readCookie("style");var title=cookie?cookie:getPreferredStyleSheet();setActiveStyleSheet(title);QAinit(e);initPopups();}
window.onunload=function(e){var title=getActiveStyleSheet();createCookie("style",title,365);}
var cookie=readCookie("style");var title=cookie?cookie:getPreferredStyleSheet();setActiveStyleSheet(title);function getElementsByClass(searchClass,domNode,tagNames){if(domNode==null)domNode=document;if(tagNames==null)tagNames='*';var el=new Array();var tags=domNode.getElementsByTagName(tagNames);var tcl=" "+searchClass+" ";for(i=0,j=0;i<tags.length;i++){var test=" "+tags[i].className+" ";if(test.indexOf(tcl)!=-1)
el[j++]=tags[i];}
return el;}
function initPopups(){var links=getElementsByClass('tn',document,'a');var n,i;for(n=0;n<links.length;n++){var popupcontent=links[n].getElementsByTagName('span')[0];var idnum=links[n].href.substr(links[n].href.indexOf('#')+1,10);var desc="";var source=document.getElementsByName(idnum);for(i=0;i<source.length;i++){if(source[i].parentNode.parentNode.cells){if(desc.indexOf(source[i].parentNode.parentNode.cells[4].innerHTML)==-1){if(desc!=""){desc=desc+"<br />";}
desc=desc+"<b>"+source[i].parentNode.parentNode.cells[3].innerHTML+"</b><br />"+source[i].parentNode.parentNode.cells[4].innerHTML;}}}
var newdiv=document.createElement("div");newdiv.innerHTML=desc;popupcontent.appendChild(newdiv);}}
function cite(title,url,author,editor){window.open("/cite.pl?title="+title+"&url="+url+"&author="+author+"&editor="+editor,"","menubar=1,resizable=1,width=700,height=400");}
function showRefs(){var targetdiv=document.getElementById("metaviewer");var targettext="";for(var i=0;i<arguments.length;i++){targettext+=document.getElementById("meta"+arguments[i]).innerHTML+'<br />';}
targetdiv.innerHTML=targettext;}
var lasthoverid;var segmentcolour=new Array();function highlightSegment(tgt,event){if(lasthoverid==tgt){return;}
lasthoverid=tgt;var target=document.getElementById(arguments[0]);segmentcolour[tgt]=target.style.backgroundColor;target.style.background='#FF8888';target.style.margin='0';document.getElementById('metaviewer').style.display='inline';document.getElementById('metaviewer').style.left=mouseX(event)-100+'px';document.getElementById('metaviewer').style.top=mouseY(event)+60+'px';}
function unhighlightSegment(){lasthoverid='';var target=document.getElementById(arguments[0]);target.style.background=segmentcolour[arguments[0]];document.getElementById('metaviewer').style.display='none';}
function mouseX(evt){if(evt.pageX)return evt.pageX;else if(evt.clientX)
return evt.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);else return null;}
function mouseY(evt){if(evt.pageY)return evt.pageY;else if(evt.clientY)
return evt.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);else return null;}
function updateAccepted()
{if(request.readyState==4){if(request.status==200){var response=request.responseText;var bits=response.split('|');document.getElementById('accept'+bits[0]).innerHTML=bits[1];}}}
function acceptProperty(propid,accept){var url="propaccept.pl";request.open("POST",url,true);request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");request.onreadystatechange=updateAccepted;var iflang=document.getElementById("if").value;request.send("id="+propid+"&accept="+accept+"&if="+iflang);}
function updatePublic()
{if(request.readyState==4){if(request.status==200){var response=request.responseText;var bits=response.split('|');if(bits[1]=='0'){document.getElementById('pub'+bits[0]).innerHTML=bits[2];}else{alert(bits[1]);}}}}
function setPublic(propid,setpub){var url="proppublic.pl";request.open("POST",url,true);request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");request.onreadystatechange=updatePublic;var iflang=document.getElementById("if").value;request.send("id="+propid+"&public="+setpub+"&if="+iflang);}
var detailid="";var commentaryid="";function getPropDetails(propid,target,node){detailid='info'+target;var existing=document.getElementById(detailid);if(existing){if(existing.style.display==''){existing.style.display='none';}else{existing.style.display='';}}else{var newel=document.createElement('div');newel.setAttribute('id','info'+target);newel.style.marginLeft='20px';newel.style.color='#000000';node.parentNode.parentNode.appendChild(newel);var url="propinfo.pl?prop="+propid+"&if="+document.getElementById('if').value;if(document.getElementById('remap')){url=url+"&remap="+document.getElementById('remap').value;}
request.open("GET",url,true);request.onreadystatechange=showPropDetails;request.send(null);}
return false;}
function showPropDetails()
{if(request.readyState==4){if(request.status==200){var response=request.responseText;if(response.charAt(0)=='0'){alert(response.substring(1));}else{document.getElementById(detailid).innerHTML=response.substring(1);}}}}
function getCommentary(node){commentaryid='comm'+node;var existing=(document.getElementById(commentaryid));if(existing.innerHTML!=''){if(existing.style.display==''){existing.style.display='none';}else{existing.style.display='';}}else{var url="commentary.pl?node="+node+"&if="+document.getElementById('if').value;if(document.getElementById('remap')){url=url+"&remap="+document.getElementById('remap').value;}
request.open("GET",url,true);request.onreadystatechange=showCommentary;request.send(null);}}
function showCommentary()
{if(request.readyState==4){if(request.status==200){var response=request.responseText;if(response.charAt(0)=='0'){alert(response.substring(1));}else{document.getElementById(commentaryid).innerHTML=response.substring(1);}}}}
function showpgorig(e){if(!e)var e=window.event;var relTarg=e.relatedTarget||e.fromElement;var tg=(window.event)?e.srcElement:e.target;var reltg=tg;if(reltg){while(reltg&&reltg.nodeName!='BODY')
{if(reltg.id.substring(0,2)=='pg')return true;reltg=reltg.parentNode}}
var i;for(i=0;i<wts.length;i++){for(j=0;j<wts[i].length;j++){var el=document.getElementById('orig'+i+'.'+j);if(el){el.innerHTML=orig[i][j];}}}
return true;}
function showpg(group,num)
{document.body.onmousedown=showpgorig;var i;var j;if(orig.length==0){for(i=0;i<wts.length;i++){orig[i]=new Array();for(j=0;j<wts[i].length;j++){var el=document.getElementById('orig'+i+'.'+j);if(el){orig[i][j]=el.innerHTML;}}}}
for(i=0;i<wts[group][num].length;i++){if(wts[group][num][i]){document.getElementById('par'+group+'.'+i).innerHTML=wts[group][num][i];}}}
if(String(top.location).substring(0,13)=='http://shuhai'&&top.location==self.location){top.location="http://shuhai.dsturgeon.net";}
