var t;
var len;
var len2;
var wildcard;
var lenSrch;
var lenSrch2;
var strSrch;
var strSrch2;
var strSearch;
var strSearch2;
var strSndSurname;
var lenCont0;
var lenCont1;
var strSearchCont0;
var strSearchCont1;
var xmlhttpS=null;
var xmlhttpP=null;
var xmlhttpM=null;
var xmlhttpH=null;
var xmlhttpB=null;
var results=false;
var w=window;
var h=history;
var d=document;
var strErrMsg='Your internet browser is unable to search this database. Suitable browsers include recent versions of Internet Explorer, Firefox and Safari.';
var strPrint="";
var combCount=0;
var strCombArray=new Array();
function dtaLoad(){
  if(w.ActiveXObject){
    try{
      xmlhttpS=new ActiveXObject('Msxml2.XMLHTTP');
      xmlhttpP=new ActiveXObject('Msxml2.XMLHTTP');
      xmlhttpM=new ActiveXObject('Msxml2.xmlhttp');
      xmlhttpH=new ActiveXObject('Msxml2.xmlhttp');
      xmlhttpB=new ActiveXObject('Msxml2.xmlhttp');
    }
    catch(e){
      try{
        xmlhttpS=new ActiveXObject('Microsoft.XMLHTTP');
        xmlhttpP=new ActiveXObject('Microsoft.XMLHTTP');
        xmlhttpM=new ActiveXObject('Microsoft.xmlhttp');
        xmlhttpH=new ActiveXObject('Microsoft.xmlhttp');
        xmlhttpB=new ActiveXObject('Microsoft.xmlhttp');
      }
      catch(e){
        xmlhttpS=false;
        xmlhttpP=false;
        xmlhttpM=false;
        xmlhttpH=false;
        alert(strErrMsg);
        if(w.h.length)w.h.back();
        return;
      }
    }
  }
  else if(w.XMLHttpRequest){
    try{
      xmlhttpS=new XMLHttpRequest();
      xmlhttpS.overrideMimeType('text/xml');
      xmlhttpP=new XMLHttpRequest();
      xmlhttpP.overrideMimeType('text/xml');
      xmlhttpM=new XMLHttpRequest();
      xmlhttpM.overrideMimeType('text/xml');
      xmlhttpH=new XMLHttpRequest();
      xmlhttpH.overrideMimeType('text/xml');
      xmlhttpB=new XMLHttpRequest();
      xmlhttpB.overrideMimeType('text/xml');
    }
    catch(e){
      xmlhttpS=false;
      xmlhttpP=false;
      xmlhttpM=false;
      xmlhttpH=false;
      xmlhttpB=false;
      alert(strErrMsg);
      if(w.h.length)w.h.back();
      return;
    }
  }
  else{
    alert(strErrMsg);
    if(w.h.length)w.h.back();
    return;
  }
  if(xmlhttpS && xmlhttpP && xmlhttpM){
    xmlhttpP.open('GET','../shipping/tblp.xml',true);
    xmlhttpP.send(null);
    xmlhttpS.open('GET','../shipping/shipping.xml',true);
    xmlhttpS.send(null);
    d.getElementById('strQry').value="";
    xmlhttpM.open('GET','../births-marriages-deaths/tblm.xml',true);
    xmlhttpM.send(null);
    d.getElementById('strQry2').value="";
    xmlhttpB.open('GET','../births-marriages-deaths/tblb-small.xml',true);
    xmlhttpB.send(null);
    d.getElementById('strQry').focus();
    xmlhttpH.open('GET','../births-marriages-deaths/cemeteries/tblwt.xml',true);
    xmlhttpH.send(null);
    d.getElementById('btnGo').disabled=false;
  }
  else{
    alert(strErrMsg);
    if(w.h.length)w.h.back();
    return;
  }
}
function findQry(){
var i;
var lenSrch=d.getElementById('strQry').value.length;
  if(lenSrch>28)lenSrch=28;
var lenSrch2=d.getElementById('strQry2').value.length;
  if(lenSrch2>24)lenSrch2=24;
var strSrch=d.getElementById('strQry').value.toUpperCase();
var strSrch2=d.getElementById('strQry2').value.toLowerCase();
  d.getElementById('btnGo').disabled='disabled';
  d.body.style.cursor='default';
  d.getElementById('htmlProgress').innerHTML="";
  len=0;
  lenCont0=0;
  lenCont1=0;
  len2=0;
  strSearch="";
  strSearchCont0="";
  strSearchCont1="";
  strSearch2="";
  wildcard=0;
  for(i=0;i<lenSrch;i++){
    if((strSrch.charAt(i)>='A' && strSrch.charAt(i)<='Z') || strSrch.charAt(i)=="'" || strSrch.charAt(i)=="-" || strSrch.charAt(i)==" " || strSrch.charAt(i)=="*"){
      strSearch+=strSrch.charAt(i);
      len++;
    }
  }
  for(i=0;i<len;i++){
    switch(wildcard){
      case 0:
        if(strSearch.charAt(i)=="*")break;
        strSearchCont0+=strSearch.charAt(i);
        lenCont0++;
        break;
      case 1:
        if(strSearch.charAt(i)=="*")break;
        strSearchCont1+=strSearch.charAt(i);
        lenCont1++;
        break;
      default:
        if(strSearch.charAt(i)=="*")break;
        strSearchCont1+=strSearch.charAt(i);
        lenCont1++;
        break;
    }
    if(strSearch.charAt(i)=="*")wildcard++;
  }
  len=lenCont0+lenCont1;
  for(i=0;i<lenSrch2;i++){
    if((strSrch2.charAt(i)>='a' && strSrch2.charAt(i)<='z')||(strSrch2.charAt(i)>='0' && strSrch2.charAt(i)<='9') || strSrch2.charAt(i)==" " || strSrch2.charAt(i)=="-" || strSrch2.charAt(i)=="'"){
      strSearch2+=strSrch2.charAt(i);
      len2++;
    }
  }
  if((len<3) || len2==1 || len2==2){
    d.getElementById('strResult').innerHTML="<table border='0' cellspacing='0'><tr><th class='error'>Data Entry Error</th></tr><tr><td class='error'>Fill in the <b>surname</b> box with at least 3 characters of the name to be found. If using the <b>given name</b> box, at least 3 characters are required. If only initials are known, leave the given name box blank.<br/>";
    d.getElementById('btnGo').disabled=false;
    d.getElementById('strQry').focus();
    return;
  }
  else{
    d.getElementById('htmlProgress').innerHTML='Downloading the indexes <span class="bl">...</span>';
    if(d.getElementById('blnSound').checked)strSearch=calculateSound(strSearch);
    xmlhttpS.onreadystatechange=checkReadyState;
    xmlhttpP.onreadystatechange=checkReadyState;
    xmlhttpM.onreadystatechange=checkReadyState;
    xmlhttpH.onreadystatechange=checkReadyState;
    xmlhttpB.onreadystatechange=checkReadyState;
    if(xmlhttpS.readyState==4 && xmlhttpP.readyState==4 && xmlhttpM.readyState==4 && xmlhttpH.readyState==4 && xmlhttpB.readyState==4 && xmlhttpS.status=='200' && xmlhttpP.status=='200' && xmlhttpM.status=='200' && xmlhttpH.status=='200' && xmlhttpB.status=='200'){
      d.body.style.cursor='progress';
      d.getElementById('htmlProgress').innerHTML='Searching <span class="bl">...</span>';
      if(t)w.clearTimeout(t);
      t=w.setTimeout('runSearch()',200);
    }
  }
}
function checkReadyState(){
  if(xmlhttpS.readyState==4 && xmlhttpP.readyState==4 && xmlhttpM.readyState==4 && xmlhttpH.readyState==4 && xmlhttpB.readyState==4 && xmlhttpS.status=='200' && xmlhttpP.status=='200' && xmlhttpM.status=='200' && xmlhttpH.status=='200' && xmlhttpB.status=='200'){
    d.getElementById('htmlProgress').innerHTML='Searching <span class="bl">...</span>';
    if(t)w.clearTimeout(t);
    t=w.setTimeout('runSearch()',200);
  }
  else if(xmlhttpS.readyState==4 && xmlhttpP.readyState==4 && xmlhttpM.readyState==4 && xmlhttpH.readyState==4 && xmlhttpB.readyState==4 && (xmlhttpS.status!='200' || xmlhttpP.status!='200' || xmlhttpM.status!='200' || xmlhttpB.status!='200' || xmlhttpH.status!='200')){
    alert('An error occurred while loading the indexes');
    if(w.h.length)w.h.back();
    return;
  }
}
function runSearch(){
  var count=0;
  var strName="";
  var strName2="";
  var strNameW="";
  var strNameW2="";
  var strArray=new Array();
  var marDoc=xmlhttpM.responseXML;
  var sList=marDoc.getElementsByTagName('s');
  var gList=marDoc.getElementsByTagName('g');
  var wsList=marDoc.getElementsByTagName('w');
  var wgList=marDoc.getElementsByTagName('c');
  var dList=marDoc.getElementsByTagName('d');
  var aList=marDoc.getElementsByTagName('a');
  var waList=marDoc.getElementsByTagName('b');
  var pList=marDoc.getElementsByTagName('p');
  var listLen=sList.length;
  var s=d.getElementById('blnSortAlpha').checked;
  var intSrchType;
  combCount=0;
  strPrint="";
  if(d.getElementById('blnWildcards').checked)intSrchType=0;
  else if(d.getElementById('blnSound').checked)intSrchType=2;
  var i=0; var j; var k;var m; var mW;
  while(i<listLen){
    strName=sList[i].firstChild.nodeValue;
    strName2=gList[i].firstChild.nodeValue.toLowerCase();
    strNameW=wsList[i].firstChild.nodeValue;
    strNameW2=wgList[i].firstChild.nodeValue.toLowerCase();
    j=0;
    while(strName.charAt(j) !=' ' && strName.charAt(j) != '/' && strName.charAt(j))j++;
    k=0;
    while(strNameW.charAt(k) !=' ' && strNameW.charAt(k) !='/' && strNameW.charAt(k))k++;
    if(intSrchType==2){
      strName=calculateSound(strName.substr(0,j));
      strNameW=calculateSound(strNameW.substr(0,k));
    }
    if(!wildcard){
      if(j>k)lenCont0=j;
      else lenCont0=k;
    }
    m=strName.indexOf(strSearchCont0);
    mW=strNameW.indexOf(strSearchCont0);
    if((((!intSrchType && m>=0 && strName.indexOf(strSearchCont1,m+lenCont0-1)>=0) || (intSrchType==2 && strName==strSearch)) && (len2==0 || (len2>1 && strName2.indexOf(strSearch2)>=0) || (len2==1 && strName2.charAt(0)==strSearch2.charAt(0)))) || (((!intSrchType && mW>=0 && strNameW.indexOf(strSearchCont1,mW+lenCont0-1)>=0) || (intSrchType==2 && strNameW==strSearch)) && (len2==0 || (len2>1 && strNameW2.indexOf(strSearch2)>=0) || (len2==1 && strNameW2.charAt(0)==strSearch2.charAt(0))))){
      if(s){
        strArray[count]=sList[i].firstChild.nodeValue+" "+gList[i].firstChild.nodeValue;
        if(aList[i].firstChild.nodeValue!='-'){
          if(aList[i].firstChild.nodeValue!='a')strArray[count]+=", "+aList[i].firstChild.nodeValue+",";
          else strArray[count]+=", adult,";}
        strArray[count]+=" married "+wsList[i].firstChild.nodeValue+" "+ wgList[i].firstChild.nodeValue;
        if(waList[i].firstChild.nodeValue!='-'){
          if(waList[i].firstChild.nodeValue!='a')strArray[count]+=", "+waList[i].firstChild.nodeValue+",";
          else strArray[count]+=", adult,";}
        strArray[count]+=" on "+dList[i].firstChild.nodeValue;
        if(pList[i].firstChild.nodeValue!='-')strArray[count]+=" at "+pList[i].firstChild.nodeValue;
        strArray[count]+="<br />";
      }
      else{
        strArray[count]=dList[i].firstChild.nodeValue+" marriage of "+sList[i].firstChild.nodeValue+" "+gList[i].firstChild.nodeValue+" and "+wsList[i].firstChild.nodeValue+" "+ wgList[i].firstChild.nodeValue;
        if(pList[i].firstChild.nodeValue!='-')strArray[count]+=" at "+pList[i].firstChild.nodeValue;
        strArray[count]+="<br />";
      }
      count++;
    }
    i++;
  }
  if(count){
    results=true;
    combCount=count;
    strCombArray=strArray;
  }
  runSrch();
}
function runSrch(){
  var count=0;
  var c=0;
  var lenR=len+1;
  var strName="";
  var strName2="";
  var strNameLower="";
  var strSndSurname;
  var strArray=new Array();
  var sDoc=xmlhttpS.responseXML;
  var rLst=sDoc.getElementsByTagName('r');
  var nLst=sDoc.getElementsByTagName('n');
  var dLst=sDoc.getElementsByTagName('d');
  var fLst=sDoc.getElementsByTagName('f');
  var sLen=nLst.length;
  var pDoc=xmlhttpP.responseXML;
  var nPLst=pDoc.getElementsByTagName('n');
  var rPLst=pDoc.getElementsByTagName('r');
  var pLen=nPLst.length;
  var s=d.getElementById('blnSortAlpha').checked;
  var intSrchType;
  if(d.getElementById('blnWildcards').checked)intSrchType=0;
  else if(d.getElementById('blnSound').checked)intSrchType=2;
  if(len==2){
    if(!intSrchType)c=1;
    else c=2;
  }
  var i; var j=0; var k; var m;
  while(j<pLen){
    strName=nPLst[j].firstChild.nodeValue;
    strNameLower=strName.toLowerCase();
    m=strName.indexOf(strSearchCont0);
    if(!intSrchType){
      if(m>=0 && strName.indexOf(strSearchCont1,m+lenCont0-1)>=0 && strNameLower.indexOf(strSearch2,lenR)>=0){
        i=0;
        while(i<sLen){
          if(rLst[i].firstChild.nodeValue==rPLst[j].firstChild.nodeValue){
            if(s){
              strArray[count]=strName;
              if(nLst[i].firstChild.nodeValue != '-'){
                strArray[count]+=" arrived "+dLst[i].firstChild.nodeValue+" on <i>"+nLst[i].firstChild.nodeValue+"</i>";
                if(fLst[i].firstChild.nodeValue != '-')strArray[count]+=" from "+fLst[i].firstChild.nodeValue +"<br/>";
                else strArray [count]+="<br/>";
              }
              else strArray[count]+=" arrived by "+dLst[i].firstChild.nodeValue+"<br/>";
            }
            else{
              if(nLst[i].firstChild.nodeValue != '-'){
                strArray [count]=dLst[i].firstChild.nodeValue+" arrival of "+strName+" on <i>"+nLst[i].firstChild.nodeValue+"</i>";
                if(fLst[i].firstChild.nodeValue != '-')strArray[count]+=" from "+fLst[i].firstChild.nodeValue +"<br/>";
                else strArray[count]+="<br/>";
              }
              else strArray[count]=dLst[i].firstChild.nodeValue+" or earlier arrival of "+strName+"<br/>";
            }
            count++;
            break;
          }
          i++;
        }
      }
    }
    else if(intSrchType==2){
      k=0;
      var l=strName.charAt(0);
      while(l && l !=' ' && l !=',' && l !='/'){
        k++;
        l=strName.charAt(k);
      }
      strSndSurname=calculateSound(strName.substr(0,k));
      if((strSndSurname==strSearch)&&(strNameLower.indexOf(strSearch2,lenR)>=0)){
        var i=0;
        while(i<sLen){
          if(rLst[i].firstChild.nodeValue==rPLst[j].firstChild.nodeValue){
            if(s){
              strArray[count]=strName;
              if(nLst[i].firstChild.nodeValue != '-'){
                strArray[count]+=" arrived "+dLst[i].firstChild.nodeValue+" on <i>"+nLst[i].firstChild.nodeValue+"</i>";
                if(fLst[i].firstChild.nodeValue != '-') strArray[count]+=" from "+fLst[i].firstChild.nodeValue +"<br/>";
                else strArray[count]+="<br/>";
              }
              else strArray[count]+=" arrived by "+dLst[i].firstChild.nodeValue+"<br/>";
            }
            else{
              if(nLst[i].firstChild.nodeValue != '-'){
                strArray[count]=dLst[i].firstChild.nodeValue+" arrival of "+strName+" on <i>"+nLst[i].firstChild.nodeValue+"</i>";
                if(fLst[i].firstChild.nodeValue != '-')strArray[count]+=" from "+fLst[i].firstChild.nodeValue +"<br/>";
                else strArray[count]+="<br/>";
              }
              else strArray[count]=dLst[i].firstChild.nodeValue+" or earlier arrival of "+strName+"<br/>";
            }
            count++;
            break;
          }
          i++;
        }
      }
    }
    j++;
  }
  if(count){
    results=true;
    for(i=0;i<count;i++)strCombArray[combCount+i]=strArray[i];
    combCount+=count;
  }
  runSch();
}
function runSch(){
  var count=0;
  var strName="";
  var strName2="";
  var strName3="";
  var strArray=new Array();
  var strPrint="";
  var hlDoc=xmlhttpH.responseXML;
  var nHList=hlDoc.getElementsByTagName('n');
  var gHList=hlDoc.getElementsByTagName('g');
  var dHList=hlDoc.getElementsByTagName('d');
  var yHList=hlDoc.getElementsByTagName('y');
  var rHList=hlDoc.getElementsByTagName('r');
  var hlLen=nHList.length;
  var strLoc;
  var s=d.getElementById('blnSortAlpha').checked;
  var intSrchType;
  if(d.getElementById('blnWildcards').checked)intSrchType=0;
  else if(d.getElementById('blnSound').checked)intSrchType=2;
  var i; j=0; var k; var m; var n; var p; var q;
  while(j<hlLen){
    strName=nHList[j].firstChild.nodeValue;
    if(intSrchType==2)strName=calculateSound(strName);
    strName2=gHList[j].firstChild.nodeValue.toLowerCase();
    k=strName.length;
    m=strName.indexOf(strSearchCont0);
    n=strName.indexOf(strSearchCont1, m+lenCont0-1);
    p=n-m;
    q=" aged "+yHList[j].firstChild.nodeValue+" and was buried at Adelaide West Terrace Cemetery<br />";
    if(((!intSrchType && m >= 0 && n >= 0) || (intSrchType==2 && strName==strSearch)) && (len2==0 || (len2 > 1 && strName2.indexOf(strSearch2) >= 0) || (len2==1 && strName2.charAt(0)==strSearch2.charAt(0)))){
      if(s){
        strArray[count]=nHList[j].firstChild.nodeValue+" "+gHList[j].firstChild.nodeValue+" died "+dHList[j].firstChild.nodeValue+q;
      }
      else{
        strArray[count]=dHList[j].firstChild.nodeValue+" death of "+nHList[j].firstChild.nodeValue+q;
      }
      count++;
    }
    j++;
  }
  if(count){
    results=true;
    for(i=0;i<count;i++)strCombArray[combCount+i]=strArray[i];
    combCount+=count;
  }
  runSh();
}
function runSh(){
  var count=0;
  var strName="";
  var strName2="";
  var strArray=new Array();
  var strPrint="";
  var birDoc=xmlhttpB.responseXML;
  var sList=birDoc.getElementsByTagName('s');
  var gList=birDoc.getElementsByTagName('g');
  var dList=birDoc.getElementsByTagName('d');
  var pList=birDoc.getElementsByTagName('p');
  var fList=birDoc.getElementsByTagName('f');
  var hList=birDoc.getElementsByTagName('h');
  var mList=birDoc.getElementsByTagName('m');
  var nList=birDoc.getElementsByTagName('n');
  var listLen=sList.length;
  var s=d.getElementById('blnSortAlpha').checked;
  var intSrchType;
  if(d.getElementById('blnWildcards').checked)intSrchType=0;
  else if(d.getElementById('blnSound').checked)intSrchType=2;
  var i=0;
  while(i<listLen){
    strName=sList[i].firstChild.nodeValue;
    strName2=gList[i].firstChild.nodeValue.toLowerCase();
    var j=0;
    while(strName.charAt(j) !=' ' && strName.charAt(j) != '/' && strName.charAt(j))j++;
    if(intSrchType==2)strName=calculateSound(strName.substr(0,j));
    if(!wildcard)lenCont0=j;
    var m=strName.indexOf(strSearchCont0);
    if(((!intSrchType && m>=0 && strName.indexOf(strSearchCont1,m+lenCont0-1)>=0) || (intSrchType==2 && strName==strSearch)) && (len2==0 || (len2>1 && strName2.indexOf(strSearch2)>=0) || (len2==1 && strName2.charAt(0)==strSearch2.charAt(0)))){
      if(s){
        strArray[count]=sList[i].firstChild.nodeValue+" "+gList[i].firstChild.nodeValue;
        strArray[count]+=" born "+dList[i].firstChild.nodeValue+" at "+ pList[i].firstChild.nodeValue+", father "+fList[i].firstChild.nodeValue+" "+hList[i].firstChild.nodeValue+", mother "+mList[i].firstChild.nodeValue+" "+nList[i].firstChild.nodeValue;
        strArray[count]+="<br />";
      }
      else{
        strArray[count]=dList[i].firstChild.nodeValue+" birth of "+sList[i].firstChild.nodeValue+" "+gList[i].firstChild.nodeValue;
        if(pList[i].firstChild.nodeValue!='-')strArray[count]+=" at "+pList[i].firstChild.nodeValue+", father "+fList[i].firstChild.nodeValue+" "+hList[i].firstChild.nodeValue+", mother "+mList[i].firstChild.nodeValue+" "+nList[i].firstChild.nodeValue;
        strArray[count]+="<br />";
      }
      count++;
    }
    i++;
  }
  if(count){
    results=true;
    for(i=0;i<count;i++)strCombArray[combCount+i]=strArray[i];
    combCount+=count;
  }
  if(combCount){
    strCombArray.sort();
    strPrint='<h3 class="results">Search results <span style="font-size:13px; font-weight:normal;">(total of '+combCount+')</span></h3>';
    for(i=0;i<combCount;i++)strPrint+=strCombArray[i];
    d.getElementById('strResult').innerHTML=strPrint+'<br /><h3 class="results">Abbreviations used in the results</h3><p>If there is no given name or title, Mr is implied.<br/>aft = soon after, arr = arrived / arrival, dep&nbsp;=&nbsp;departed / departure<br/>b = born, m = married / male, d = died, f = female, fmly = formerly<br/>Alf = Alfred, Art = Arthur, Ben = Benjamin, Bgt = Bridget, Crln&nbsp;=&nbsp;Caroline, Cath&nbsp;=&nbsp;Catherine, Chas&nbsp;=&nbsp;Charles, Chlt&nbsp;=&nbsp;Charlotte<br/>ch = children, dau&nbsp;=&nbsp;daughter(s)<br/>Dan = Daniel, Ed = Edward, Elis = Elisabeth, Eliz&nbsp;=&nbsp;Elizabeth, Em&nbsp;=&nbsp;Emma<br />Fdk = Frederick, Fried&nbsp;=&nbsp;Friedrich, Geo&nbsp;=&nbsp;George, Hrt&nbsp;=&nbsp;Harriet, Hein&nbsp;=&nbsp;Heinrich, Hy&nbsp;=&nbsp;Henry<br/>Jas = James, J = Johann, Ja&nbsp;=&nbsp;Johanna, Je&nbsp;=&nbsp;Johanne, Kath&nbsp;=&nbsp;Katherine<br/>inc = including, jnr&nbsp;=&nbsp;junior, snr&nbsp;=&nbsp;senior, Nat&nbsp;=&nbsp;Naturalisation, n&nbsp;=&nbsp;nee<br/>Mgt = Margaret, Mtn&nbsp;=&nbsp;Martin, My = Mary, Ptk&nbsp;=&nbsp;Patrick, Rd&nbsp;=&nbsp;Richard, Rbt&nbsp;=&nbsp;Robert<br />prev = previous, prob&nbsp;=&nbsp;probably; svnt = servant(s);<br/>Sam = Samuel, Thos&nbsp;=&nbsp;Thomas, Whm&nbsp;=&nbsp;Wilhelm, Wm&nbsp;=&nbsp;William<br/>(w) = widowed - lower case w. Note that (W) is a doubtful given name initial W</p>';
    d.getElementById('htmlProgress').innerHTML='View the results below ...';
    for(var i=0;i<combCount;i++)strCombArray[i]=null;
  }
  else{
    d.getElementById('strResult').innerHTML="<h3 class='results'>Search results <span style='font-size:13px; font-weight:normal;'>(total of 0)</span></h3><p>The data you entered, <b><i>"+d.getElementById('strQry').value+" "+d.getElementById('strQry2').value+"</i></b>, is not in this database.</p>";
    d.getElementById('htmlProgress').innerHTML='There are no results to view.';
  }
  if(!d.getElementById('strQry').disabled) d.getElementById('strQry').focus();
  d.body.style.cursor='default';
  d.getElementById('btnGo').disabled=false;
}
function calculateSound(strString){
  var i;
  var strModSound="";
  var strSound="";
  var intStrLen=strString.length;
  var strChar;
  for(i=0;i<intStrLen;i++){
    strChar=strString.charAt(i);
    if(strChar=='P' || strChar=='F' || strChar=='V')strSound +='1';
    else if(strChar=='B'){
      if(strString.substr(intStrLen-2,2)!='MB' && strString.substr(intStrLen-3,3)!='MBE' && strString.substr(intStrLen-4,4)!='MBES' && strString.substr(intStrLen-3,3)!='MBS')strSound +='1';
    }
    else if(strChar=='C' || strChar=='S' || strChar=='K' || (strChar=='G' && i != intStrLen-1 && (!(i==intStrLen-2 && strString.charAt(intStrLen-1)=='N'))) || strChar=='J' || strChar=='Q' || strChar=='X' || strChar=='Z') strSound +='2';
    else if(strChar=='D' || strChar=='T')strSound +='3';
    else if(strChar=='L') strSound +='4';
    else if(strChar=='M' || strChar=='N'){
      if(i==1 && strChar=='N' && (strString.charAt(0)=='G' || strString.charAt(0)=='K' || strString.charAt(0)=='P'))strSound='5';
      else strSound +='5';
      if(i==0 && strString.charAt(1)=='C' && strChar=='M')strSound+='0';
    }
    else if(strChar=='R')strSound +='6';
    else if(strChar=='H'){
      if(i>1 && strString.charAt(i-1)=='G' && (strString.charAt(i-2)=='A' || strString.charAt(i-2)=='I' || strString.charAt(i-2)=='O' || strString.charAt(i-2)=='U')){
        strSound=strSound.substring(0,strSound.length-1);
      }
    }
    else if(strChar=='W' || strChar=='Y'){
      if(i==0 && ((strChar=='W' && strString.charAt(1)!='R') || strChar=='Y')) strSound +='9';
      else if(strChar=='Y')strSound +='0';
    }
    else if(((strChar=='A' || strChar=='I' || strChar=='O') && (i>0 || (i==0 && strString.charAt(1)!="'"))) || (i != intStrLen-1 && strChar=='E') || strChar=='I' || strChar=='U')strSound +='0';
  }
  strModSound=strSound.charAt(0);
  strSoundLen=strSound.length;
  for(i=1;i<strSoundLen;i++){
    if(strSound.charAt(i)!=strSound.charAt(i-1))strModSound+=strSound.charAt(i);
  }
  return strModSound;
}
function clearForm(){
  d.getElementById('htmlProgress').innerHTML="";
  d.getElementById('strResult').innerHTML="";
}
function displayHelp(){
  var htmlResults="";
  if(results) htmlResults=d.getElementById('strResult').innerHTML;
  else htmlResults="";
  d.getElementById('strResult').innerHTML="<h3 class='results'>Help on searching for Colonial South Australians</h3><p>Enter the person&#39;s name into the boxes.<br />A given name is optional. If only initials are known, leave the given name box blank.<br />Click the [&#160;<b>Go</b>&#160] button or press  the [Enter] key to begin the search.</p><h4>Text entry</h4><p>At least 3 allowed characters must be entered into the surname box before a search can proceed.<br />A given name is optional. If only given name initials are known, leave the given name box blank.<br />The search is not case sensitive.<br />The only characters allowed are letters of the alphabet, hyphens, spaces, apostrophes and no more than one <b>*</b> wildcard. Any other entered characters are ignored. In particular, the ? wildcard and the logical operators (and, or, not, &, |, &lt;, >, +, -) cannot be used.</p><h4>Searching for a name</h4><p>The default (and generally most satisfactory) method of searching for a name is the <b><i>containing</i></b> method. Select [containing] by clicking it, if necessary. Then enter into the surname box, sufficient letters to define the name to be found. Optionally, enter a given name. Click the [&#160;<b>Go</b>&#160] button or press the [Enter] key to begin the search. If the name you wish to find is not in the database, take into account possible spelling variations, as the people and the officials recording their information were often illiterate or semiliterate.<br />It is advisable to omit surname prefixes such as O' and Mac so that the usual variations of spelling these names are all found. <br />The search behaves as though you have entered a <b>*</b> wildcard at each end of your search text. That is, the search engine looks for the exact text you have entered anywhere within the name. For example, if you search for <b>hill</b>, several different names will be found, including <b>hill</b>, <b>hill</b>man, up<b>hill</b> and p<b>hill</b>ips, amongst others. This feature has the annoyance of giving some unwanted names but can be very useful. For example, searching for <b>phil</b> will give philp, philip and phillips, amongst others. This allows you to take into account some likely mis-spellings or variations of the name of interest. If required, one * wildcard can be inserted within the text to replace zero or more unknown or doubtful characters. For example, searching for r<b>e*</b>d will give r<b>ea</b>d, r<b>ee</b>d and r<b>ei</b>d. Searching for sm<b>*</b>th will give sm<b>i</b>th, sm<b>y</b>th and sm<b>y</b>the, amongst others.<br />The [Clear] button clears both boxes and places the cursor in the left hand box, ready for your next search. It also clears any displayed results and this help.</p><h4>Using the <i>'sounds like'</i> method</h4><p>If the above method fails, you may wish to try the <i>sounds like</i> method. This will allow you to find more variations of spelling and also take into account the pronunciation of the surname. For example, searching on the name <b>smith</b> will find the names smith, smyth, smythe and schmidt. The method used here is a heavily modified version of Soundex code matching which doesn't require the 1st letter of the name to be known and takes into account such pronunciation variations as dropped h's and g's. You must be prepared to scan the results and reject those which are poor matches. For some shorter names, ones with mainly vowels, and names containing spaces, all the results may be unsatisfactory.<br />To use the <i>sounds like</i> method, select [sounds like] before clicking [&#160;<b>Go</b>&#160] or pressing [Enter]. You <b>must enter the full surname</b> required. <b>Wildcards are not permitted</b>. Sound matching of given names is not available. Any entered given name will be matched by the <i>containing</i> method.</p>"+htmlResults;
  if(!d.getElementById('strQry').disabled)d.getElementById('strQry').focus();
}//Copyright(c)2003-2010 B Leadbeater, Australia