var processorDoclist;var processorDocOverview;var processorDocConcordance;var processorDocDetail;var processorDocPoints;var sortColumn="title";var sortOrder="ascending";var dataType="text";var concordancesortColumn="node";var concordancesortPosition="";var helpwindow="";var xmlDoc;var http=false;var map=false;var authoricon;var participanticon;var authorparticipanticon;function popuphelp(A){if(!helpwindow.closed&&helpwindow.location){helpwindow.focus()}else{helpwindow=window.open(A,"help","height=450, width=350");if(!helpwindow.opener){helpwindow.opener=self}}if(window.focus){helpwindow.focus()}}function displayoverview(){var B=processorDocOverview.transformToDocument(xmlDoc);var D=document.importNode(B.documentElement,true);var A=document.getElementById("overview").getElementsByTagName("div")[0];document.getElementById("overview").replaceChild(D,A);var C=document.getElementById("overview");C.style.display=""}function displayresults(B,F,G){var E=xmlDoc.getElementsByTagName("documentlist");if(E.length!==0){sortColumn=B;sortOrder=F;dataType=G;processorDoclist.setParameter(null,"sortColumn",sortColumn);processorDoclist.setParameter(null,"sortOrder",sortOrder);processorDoclist.setParameter(null,"dataType",dataType);var C=processorDoclist.transformToDocument(xmlDoc);var H=document.importNode(C.documentElement,true);var A=document.getElementById("doclist").getElementsByTagName("div")[0];document.getElementById("doclist").replaceChild(H,A);var D=document.getElementById("doclist");D.style.display=""}}function displayconcordance(C,E){var B=xmlDoc.getElementsByTagName("concordance");if(B.length!==0){concordancesortColumn=C;concordancesortPosition=E;processorDocConcordance.setParameter(null,"concordancesortColumn",concordancesortColumn);processorDocConcordance.setParameter(null,"concordancesortPosition",concordancesortPosition);var D=processorDocConcordance.transformToDocument(xmlDoc);var G=document.importNode(D.documentElement,true);var A=document.getElementById("concordance").getElementsByTagName("div")[0];document.getElementById("concordance").replaceChild(G,A);var F=document.getElementById("concordance");F.style.display=""}}function createMarker(A,D,C){var B=new GMarker(A,C);GEvent.addListener(B,"click",function(){B.openInfoWindow(D)});return B}function displaymap(){var K=xmlDoc.getElementsByTagName("points");if(K.length!==0){var N=document.createElement("div");N.appendChild(document.createTextNode("Click on a flag and select 'Show details' for more information"));var B=document.getElementById("detail").getElementsByTagName("div")[0];document.getElementById("detail").replaceChild(N,B);var L=document.getElementById("map");L.style.display="";if(!map){map=new GMap2(document.getElementById("gmap"));map.addControl(new GLargeMapControl());map.addControl(new GMapTypeControl());map.setCenter(new GLatLng(56,-4),5,G_SATELLITE_MAP)}else{map.clearOverlays()}var G=processorDocPoints.transformToDocument(xmlDoc);var M=G.getElementsByTagName("point");for(var F=0;F<M.length;F++){var A=M[F].getElementsByTagName("longitude")[0].childNodes[0].nodeValue;var I=M[F].getElementsByTagName("latitude")[0].childNodes[0].nodeValue;var E=M[F].getElementsByTagName("role")[0].childNodes[0].nodeValue;var H;if(E=="author"){H=authoricon}else{if(E=="participant"){H=participanticon}else{H=authorparticipanticon}}var C=M[F].getElementsByTagName("infowindow")[0].childNodes[0];N=document.importNode(C,true);var J=new GLatLng(I,A);var D=createMarker(J,N,H);map.addOverlay(D)}}}function handleResponse(){if(http.readyState==4){var M=document.getElementById("logoright").getElementsByTagName("img")[0];M.src="/common/corpus.gif";var P;var I;var C;if(http.status!=200){P=document.createElement("div");I=document.createElement("h2");I.appendChild(document.createTextNode("Error: The response was not received from the server"));P.appendChild(I);C=document.getElementById("message").getElementsByTagName("div")[0];document.getElementById("message").replaceChild(P,C)}else{if(!http.responseXML||http.responseXML.documentElement.nodeName=="parsererror"){P=document.createElement("div");I=document.createElement("h2");I.appendChild(document.createTextNode("Error: The response received from the server was invalid"));P.appendChild(I);C=document.getElementById("message").getElementsByTagName("div")[0];document.getElementById("message").replaceChild(P,C)}else{xmlDoc=http.responseXML;var Q=document.getElementById("selection");var H=Q.getElementsByTagName("tr");var J;var D;var N;for(var G=1;G<H.length;G++){J=H[G];D=J.getElementsByTagName("td");N=D[3];if(N.childNodes.length!==0){N.removeChild(N.childNodes[0])}}var K=xmlDoc.getElementsByTagName("error");if(K.length!==0){P=document.createElement("div");I=document.createElement("h2");I.appendChild(document.createTextNode("There is a problem with your criteria"));P.appendChild(I);C=document.getElementById("message").getElementsByTagName("div")[0];document.getElementById("message").replaceChild(P,C);var O;var E;for(var F=0;F<K.length;F++){var A=K[F].getAttribute("cause");var L=K[F].childNodes[0].nodeValue;A++;J=H[A];D=J.getElementsByTagName("td");N=D[3];O=document.createElement("strong");O.style.color="#FF6666";E=document.createTextNode("Problem: "+L);O.appendChild(E);N.appendChild(O)}}else{P=document.createElement("div");C=document.getElementById("message").getElementsByTagName("div")[0];document.getElementById("message").replaceChild(P,C);displayoverview();var B=document.getElementById("showme");B.style.display="";displaymap();displayconcordance(concordancesortColumn,concordancesortPosition);displayresults(sortColumn,sortOrder,dataType)}}}}}function sndReq(A){http=false;http=new XMLHttpRequest();if(!http){alert("Error: Your browser does not support Advanced search")}else{http.onreadystatechange=handleResponse;http.open("post","advancedrpc.php",true);http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");http.send(A)}}function collapse(){var A;for(A=1;A<=headings;A++){document.getElementById("heading"+A).className="hide";document.getElementById("xheading"+A).className="expand"}for(A=1;A<=sections;A++){document.getElementById("section"+A).className="hide";document.getElementById("xsection"+A).className="expand"}}function disable(A){var B;if(A=="audio"){B=document.getElementById("xheading2");B.className="disable";B.onclick=function(){return false}}else{if(A=="written"){B=document.getElementById("xheading3");B.className="disable";B.onclick=function(){return false}}}}function enable(A){var B;if(A=="audio"){B=document.getElementById("xheading2");B.className="expand";B.onclick=function(){toggle("heading2");return false}}else{if(A=="written"){B=document.getElementById("xheading3");B.className="expand";B.onclick=function(){toggle("heading3");return false}}}}function checkaudiowritten(){collapse();var O=document.getElementById("selection");var J=O.getElementsByTagName("tr");var H=true;var D=true;var Q=false;for(var N=1;N<J.length;N++){var B=J[N];var G=B.getElementsByTagName("td");var E=G[1];var I=E.getElementsByTagName("input");if(I.length===0){I=E.getElementsByTagName("select")}var F=I[0];var L=F.xtablename;var R=F.xfieldname;var M;if(F.type=="checkbox"){if(F.checked===true){M="true"}else{M="false"}}else{M=F.value}if(L=="audio"||L=="audiofootage"||L=="audiotranscription"||L=="participant"||L=="participant.contact"||L=="participant.demographics"){D=false}else{if(L=="text"){H=false}else{if(L=="special"&&R=="restrict"){if(M=="Spoken"){D=false}else{H=false}}}}if(L=="special"&&R=="concordance"){Q=true}}if(H){enable("audio")}else{disable("audio")}if(D){enable("written")}else{disable("written")}var C=document.getElementById("concordancespan");var A=document.getElementById("concordancecb");if(Q){C.className="";C.title="";A.disabled=""}else{C.className="disabled";C.title="Available for Word/phrase (concordance) only";A.disabled="disabled"}var K=document.getElementById("mappointsspan");var P=document.getElementById("mappoints");if(document.getElementById("mapcb").checked===true){K.className="";K.title="";P.disabled=""}else{K.className="disabled";K.title="Available for map display only";P.disabled="disabled"}}function action(){checkaudiowritten();var Q=document.getElementById("overview");Q.style.display="none";var C=document.getElementById("showme");C.style.display="none";var S=document.getElementById("map");S.style.display="none";var R=document.getElementById("doclist");R.style.display="none";var T=document.getElementById("concordance");T.style.display="none";var G=document.createElement("div");var N=document.createElement("h2");N.style.textAlign="center";var Z=document.createElement("img");Z.src="icons/spinner.gif";Z.width="80";Z.height="80";Z.alt="Please wait, query in progress";N.appendChild(Z);N.appendChild(document.createElement("br"));N.appendChild(document.createTextNode("Please wait"));N.appendChild(document.createElement("br"));N.appendChild(document.createTextNode("Query in progress"));G.appendChild(N);var B=document.getElementById("message").getElementsByTagName("div")[0];document.getElementById("message").replaceChild(G,B);var J=document.getElementById("logoright").getElementsByTagName("img")[0];J.src="icons/spinner.gif";var K=[];var X=document.getElementById("selection");var V=X.getElementsByTagName("tr");var W;for(W=1;W<V.length;W++){var E=V[W];var O=E.getElementsByTagName("td");var M=O[1];var U=M.getElementsByTagName("input");if(U.length===0){U=M.getElementsByTagName("select")}var L=U[0];var F=[];F[0]=L.xhumanname;F[1]=L.xtablename;F[2]=L.xfieldname;F[3]=L.xtype;if(L.type=="checkbox"){if(L.checked===true){F[5]="true"}else{F[5]="false"}}else{F[5]=L.value;if(L.xtype=="number"||L.xtype=="date"){var P=M.getElementsByTagName("select")[0];F[6]=P.value}}K.push(F)}var H="";for(W=0;W<K.length;W++){if(W>0){H+="&"}H+="xtablename["+W+"]";H+="=";H+=encodeURIComponent(K[W][1]);H+="&";H+="xfieldname["+W+"]";H+="=";H+=encodeURIComponent(K[W][2]);H+="&";H+="xvalue["+W+"]";H+="=";H+=encodeURIComponent(K[W][5]);if(K[W][3]=="number"||K[W][3]=="date"){H+="&";H+="xoperator["+W+"]";H+="=";H+=encodeURIComponent(K[W][6])}}var I=document.getElementById("mapcb");if(I.checked){H+="&map=y"}var Y=document.getElementById("mappoints");H+="&mappoints="+Y.value;var D=document.getElementById("doclistcb");if(D.checked){H+="&doclist=y"}var A=document.getElementById("concordancecb");if(A.checked){H+="&concordance=y"}sndReq(H)}function deletecriteria(A){var D=A.parentNode;var C=D.parentNode;var B=C.parentNode;B.removeChild(C);action()}function returnaction(B,A){if(event.keyCode==13){A.value=A.value;A.onchange()}}function addtoselection(L,R,P,D,C){var F;var J;var H;switch(D){case"checkbox":F=document.createElement("input");F.type="checkbox";F.defaultChecked="true";F.onclick=function(){action()};break;case"text":F=document.createElement("input");F.type="text";F.size=20;F.maxlength=C;F.value="Please specify";F.onchange=function(){action()};if(_SARISSA_IS_IE){F.onkeydown=function(T){returnaction(T,this)}}break;case"date":F=document.createElement("input");F.type="text";F.size=10;F.maxlength=20;F.value="2000-01-01";F.onchange=function(){action()};if(_SARISSA_IS_IE){F.onkeydown=function(T){returnaction(T,this)}}J=document.createElement("select");H=document.createElement("option");H.appendChild(document.createTextNode("="));H.value="=";J.appendChild(H);H=document.createElement("option");H.appendChild(document.createTextNode(">"));H.value=">";J.appendChild(H);H=document.createElement("option");H.appendChild(document.createTextNode(">="));H.value=">=";J.appendChild(H);H=document.createElement("option");H.appendChild(document.createTextNode("<"));H.value="<";J.appendChild(H);H=document.createElement("option");H.appendChild(document.createTextNode("<="));H.value="<=";J.appendChild(H);J.selectedIndex=0;J.onchange=function(){action()};break;case"number":F=document.createElement("input");F.type="text";F.size=10;F.maxlength=10;F.value="0";F.onchange=function(){action()};if(_SARISSA_IS_IE){F.onkeydown=function(T){returnaction(T,this)}}J=document.createElement("select");H=document.createElement("option");H.appendChild(document.createTextNode("="));H.value="=";J.appendChild(H);H=document.createElement("option");H.appendChild(document.createTextNode(">"));H.value=">";J.appendChild(H);H=document.createElement("option");H.appendChild(document.createTextNode(">="));H.value=">=";J.appendChild(H);H=document.createElement("option");H.appendChild(document.createTextNode("<"));H.value="<";J.appendChild(H);H=document.createElement("option");H.appendChild(document.createTextNode("<="));H.value="<=";J.appendChild(H);J.selectedIndex=0;J.onchange=function(){action()};break;case"select":F=document.createElement("select");var M=[];M=C.split(",");for(var N=0;N<M.length;N++){H=document.createElement("option");H.appendChild(document.createTextNode(M[N]));H.value=M[N];F.appendChild(H)}F.selectedIndex=0;F.onchange=function(){action()};break}F.xhumanname=L;F.xtablename=R;F.xfieldname=P;F.xtype=D;var O=document.getElementById("selection");var A=O.getElementsByTagName("tbody")[0];var E=document.createElement("tr");var B=document.createElement("td");B.appendChild(document.createTextNode(L));E.appendChild(B);var K=document.createElement("td");if(D=="number"||D=="date"){K.appendChild(J);K.appendChild(document.createTextNode(" "))}K.appendChild(F);E.appendChild(K);var I=document.createElement("td");var Q=document.createElement("a");Q.className="remove";Q.href="#";Q.onclick=function(){deletecriteria(this);return false};Q.title="Remove";var S=document.createElement("img");S.src="/common/remove.gif";S.width="16";S.height="16";S.alt="Remove";Q.appendChild(S);I.appendChild(Q);E.appendChild(I);var G=document.createElement("td");E.appendChild(G);A.appendChild(E);F.focus();action()}function detail(B){processorDocDetail.setParameter(null,"pid",B);var C=processorDocDetail.transformToDocument(xmlDoc);var D=document.importNode(C.documentElement,true);var A=document.getElementById("detail").getElementsByTagName("div")[0];document.getElementById("detail").replaceChild(D,A)}function initpage(){var F=new GIcon();F.iconSize=new GSize(24,32);F.image="icons/authorparticipant.png";F.iconAnchor=new GPoint(12,32);F.infoWindowAnchor=new GPoint(12,1);F.transparent="icons/trans.png";F.imageMap=[0,0,23,0,23,24,15,24,12,31,9,24,0,24];F.shadowSize=new GSize(40,32);F.shadow="icons/shadow.png";F.printImage="icons/authorparticipantie.gif";F.mozPrintImage="icons/authorparticipantff.gif";F.printShadow="icons/shadowprint.gif";authoricon=new GIcon(F);authoricon.image="icons/author.png";authoricon.printImage="icons/authorff.gif";authoricon.mozPrintImage="icons/authorff.gif";participanticon=new GIcon(F);participanticon.image="icons/participant.png";participanticon.printImage="icons/participantff.gif";participanticon.mozPrintImage="icons/participantff.gif";authorparticipanticon=new GIcon(F);authorparticipanticon.image="icons/authorparticipant.png";authorparticipanticon.printImage="icons/authorparticipantff.gif";authorparticipanticon.mozPrintImage="icons/authorparticipantff.gif";var C;C=document.getElementById("mapcb");C.onclick=function(){action()};C=document.getElementById("mappoints");C.onchange=function(){action()};C=document.getElementById("concordancecb");C.onclick=function(){action()};C=document.getElementById("doclistcb");C.onclick=function(){action()};var A=Sarissa.getDomDocument();A.async=false;A.load("doclist.xsl");processorDoclist=new XSLTProcessor();processorDoclist.importStylesheet(A);var B=Sarissa.getDomDocument();B.async=false;B.load("overview.xsl");processorDocOverview=new XSLTProcessor();processorDocOverview.importStylesheet(B);var G=Sarissa.getDomDocument();G.async=false;G.load("concordance.xsl");processorDocConcordance=new XSLTProcessor();processorDocConcordance.importStylesheet(G);var E=Sarissa.getDomDocument();E.async=false;E.load("detail.xsl");processorDocDetail=new XSLTProcessor();processorDocDetail.importStylesheet(E);var D=Sarissa.getDomDocument();D.async=false;D.load("points.xsl");processorDocPoints=new XSLTProcessor();processorDocPoints.importStylesheet(D)}function checkAllDownloads(){var C=document.getElementById("doclist");var A=C.getElementsByTagName("input");for(var B=0;B<A.length;B++){A[B].checked="true"}}function uncheckAllDownloads(){var C=document.getElementById("doclist");var A=C.getElementsByTagName("input");for(var B=0;B<A.length;B++){A[B].checked=""}}function startDownloads(){document.downloadcorpus.submit()}
