var t;
var len;
var len2;
var lenCont0;
var lenCont1;
var wildcard;
var strSearch;
var strSearchCont0;
var strSearchCont1;
var strSearch2;
var xmlhttp=null;
var xmlhttpP=null;
var w=window;
var h=history;
var d=document;
function dtaLoad(){
var strErrMsg='Your internet browser is unable to search this database. Suitable browsers include recent versions of Internet Explorer, Firefox and Safari.';
  if(w.ActiveXObject){
    try{
      xmlhttp=new ActiveXObject('Msxml2.XMLHTTP');
      xmlhttpP=new ActiveXObject('Msxml2.XMLHTTP');
    }
    catch(e){
      try{
        xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
        xmlhttpP=new ActiveXObject('Microsoft.XMLHTTP');
      }
      catch(e){
        xmlhttp=false;
        xmlhttpP=false;
        d.body.style.cursor='default';
        alert(strErrMsg);
        if(w.h.length)w.h.back();
        return;
      }
    }
  }
  else if(w.XMLHttpRequest){
    try{
      xmlhttp=new XMLHttpRequest();
      xmlhttp.overrideMimeType('text/xml');
      xmlhttpP=new XMLHttpRequest();
      xmlhttpP.overrideMimeType('text/xml');
    }
    catch(e){
      xmlhttp=false;
      xmlhttpP=false;
      d.body.style.cursor='default';
      alert(strErrMsg);
      if(w.h.length)w.h.back();
      return;
    }
  }
  else{
    d.body.style.cursor='default';
    alert(strErrMsg);
    if(w.h.length)w.h.back();
    return;
  }
  if(xmlhttp && xmlhttpP){
    xmlhttpP.open('GET','tblp.xml',true);
    xmlhttpP.send(null);
    d.getElementById('strQry').value="";
    d.getElementById('strQry2').value="";
    d.getElementById('dbType')[0].selected=true;
    xmlhttp.open('GET','shipping.xml',true);
    xmlhttp.send(null);
    d.getElementById('btnGo').disabled=false;
  }
  else{
    d.body.style.cursor='default';
    alert(strErrMsg);
    if(w.h.length)w.h.back();
    return;
  }
}
function changeSelection(){
  if(d.getElementById('dbType').value=="v"){
    d.getElementById('strMain').innerHTML="&nbsp;&nbsp;&nbsp;ship&nbsp;name";
    d.getElementById('strOr').innerHTML="<b><u>or</u></b>";
    d.getElementById('strGiven').innerHTML="&nbsp;arrival&nbsp;date<sup>&nbsp;yyyy&minus;mm&minus;dd</sup>";
    d.getElementById('blnSortDate').disabled=false;
    d.getElementById('blnSDL').disabled=false;
    d.getElementById('blnSortDateDec').disabled=false;
    d.getElementById('blnSDLD').disabled=false;
  }
  else if(d.getElementById('dbType').value=="pl"){
    d.getElementById('strMain').innerHTML="ship&nbsp;name *";
    d.getElementById('strOr').innerHTML="";
    d.getElementById('strGiven').innerHTML="arrival&nbsp;date&nbsp;<sup>yyyy&minus;mm&minus;dd</sup>";
    d.getElementById('blnSortAlpha').checked="checked";
    d.getElementById('blnSortDate').disabled="disabled";
    d.getElementById('blnSDL').disabled="disabled";
    d.getElementById('blnSortDateDec').disabled="disabled";
    d.getElementById('blnSDLD').disabled="disabled";
  }
  else{
    d.getElementById('strMain').innerHTML="surname *";
    d.getElementById('strOr').innerHTML="";
    d.getElementById('strGiven').innerHTML="&nbsp;&nbsp;&nbsp;given&nbsp;name";
    d.getElementById('blnSortDate').disabled=false;
    d.getElementById('blnSDL').disabled=false;
    d.getElementById('blnSortDateDec').disabled=false;
    d.getElementById('blnSDLD').disabled=false;
  }
  d.getElementById('strQry').value="";
  d.getElementById('strQry2').value="";
  d.getElementById('strQry').focus();
}
function findQuery(){
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(var 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)==" " || strSrch.charAt(i)=="*"){
      strSearch+=strSrch.charAt(i);
      len++;
    }
  }
  for(var 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(var 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(d.getElementById('dbType').value=='p' && ((len<3 && strSearch!='EY') || 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 if(d.getElementById('dbType').value=='pl' && (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>ship name</b> box with at least 3 characters of the name to be found. If using the <b>arrival date</b> box, at least 3 characters are required.</td></tr></table><br/>";
    d.getElementById('btnGo').disabled=false;
    d.getElementById('strQry').focus();
    return;
  }
  else if(d.getElementById('dbType').value=='v' && ((len<3 && len2==0) || (len2<3 && len==0) || (len<3 && len2<3))){
    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>ship name</b> box with at least 3 characters of the name to be found and/or the <b>arrival date</b> box with at least 3 characters of the date to be found.</td></tr></table><br/>";
    d.getElementById('btnGo').disabled=false;
    d.getElementById('strQry').focus();
    return;
  }
  else{
    d.getElementById('htmlProgress').innerHTML='<span class="warn">Downloading the indexes ...</span>';
    if(d.getElementById('blnSound').checked)strSearch=calculateSound(strSearch);
    xmlhttp.onreadystatechange=checkReadyState;
    xmlhttpP.onreadystatechange=checkReadyState;
    if(xmlhttp.readyState==4 && xmlhttpP.readyState==4 && xmlhttp.status=='200' && xmlhttpP.status=='200'){
      d.body.style.cursor='progress';
      d.getElementById('htmlProgress').innerHTML='<span class="notify">Searching ...</span>';
      if(t)w.clearTimeout(t);
      t=w.setTimeout('runSearch()',250);
    }
  }
}
function checkReadyState(){
  if(xmlhttp.readyState==4 && xmlhttpP.readyState==4 && xmlhttp.status=='200' && xmlhttpP.status=='200'){
    d.body.style.cursor='progress';
    d.getElementById('htmlProgress').innerHTML='<span class="notify">Searching ...</span>';
    if(t)w.clearTimeout(t);
    t=w.setTimeout('runSearch()',250);
  }
  else if(xmlhttp.readyState==4 && xmlhttpP.readyState==4 && (xmlhttp.status !='200' || xmlhttpP.status !='200')){
    d.body.style.cursor='default';
    alert('A fatal error occurred while loading the index. Please contact us to report this error.');
    if(w.h.length)w.h.back();
    return;
  }
}
function runSearch(){
var i, j, k, l, m, n;
var count=0;
var c=0;
var lenR=len+1;
var strName="";
var strName2="";
var strNameLower="";
var strNameSrc="";
var strShip, strDate, strPort, strCapt, strDesc;
var strArray=[];
var strPrint="";
var sDoc=xmlhttp.responseXML;
var rLst=sDoc.getElementsByTagName('r');
var nLst=sDoc.getElementsByTagName('n');
var dLst=sDoc.getElementsByTagName('d');
var fLst=sDoc.getElementsByTagName('f');
var mLst=sDoc.getElementsByTagName('m');
var tLst=sDoc.getElementsByTagName('t');
var sLen=nLst.length;
var pDoc=xmlhttpP.responseXML;
var nPLst=pDoc.getElementsByTagName('n');
var sPLst=pDoc.getElementsByTagName('s');
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('blnExact').checked)intSrchType=1;
  else if(d.getElementById('blnSound').checked)intSrchType=2;
  if(strSearch=='EY')intSrchType=1;
  if(d.getElementById('dbType').value=='v'){//ship
    i=0;
    while(i<sLen){
      strName=nLst[i].firstChild.nodeValue.toUpperCase();
      strName2=dLst[i].firstChild.nodeValue.toLowerCase();
      if(intSrchType){
        j=0;
        var l=strName.charAt(0);
        while(l && l !=' ' && l !=',' && l !='/'){
          j++;
          l=strName.charAt(j);
        }
        if(intSrchType==2)strName=calculateSound(strName.substr(0,j));
        else strName=strName.substr(0,j);
        if(!wildcard)lenCont0=j;
        if(!len)strName="";
      }
      m=strName.indexOf(strSearchCont0);
      if((((!intSrchType && m>=0 && strName.indexOf(strSearchCont1, m+lenCont0-1)>=0)||(intSrchType==1 && strName.substr(0, lenCont0)==strSearchCont0 && strName.substr(strName.length-lenCont1, lenCont1)==strSearchCont1)||(intSrchType==2 && strName==strSearch)) && strName2.indexOf(strSearch2)>=0)){
        if(nLst[i].firstChild.nodeValue != '-'){
          if(s){
            strArray[count]="<p><b><i>"+nLst[i].firstChild.nodeValue+"</i></b> ";
            if(tLst[i].firstChild.nodeValue != '-')strArray[count]+="("+tLst[i].firstChild.nodeValue+") ";
            strArray[count]+= "arrived in SA "+dLst[i].firstChild.nodeValue;
            if(fLst[i].firstChild.nodeValue !='-')strArray[count]+=" from "+fLst[i].firstChild.nodeValue;
            if(mLst[i].firstChild.nodeValue !='-')strArray[count]+=", Captain "+mLst[i].firstChild.nodeValue;
            strArray[count]+="</p>";
          }
          else{
            strArray[count]="<p>"+dLst[i].firstChild.nodeValue+" arrival in SA of <b><i>"+nLst[i].firstChild.nodeValue+"</i></b> ";
            if(tLst[i].firstChild.nodeValue !='-')strArray[count]+="("+tLst[i].firstChild.nodeValue+") ";
            if(fLst[i].firstChild.nodeValue !='-')strArray[count]+="from "+fLst[i].firstChild.nodeValue;
            if(mLst[i].firstChild.nodeValue !='-')strArray[count]+=", Captain "+mLst[i].firstChild.nodeValue;
            strArray[count]+="</p>";
          }
          count++;
        }
      }
      i++;
    }
  }
  else if(d.getElementById('dbType').value=='p'){//pass
    if(len==2){
      if(!intSrchType)c=1;
      else if(intSrchType==2)c=2;
      d.getElementById('blnExact').checked='checked';
    }
    j=0;
    while(j<pLen){
      strName=nPLst[j].firstChild.nodeValue;
      strNameLower=strName.toLowerCase();
      strNameSrc=sPLst[j].firstChild.nodeValue;
      m=strName.indexOf(strSearchCont0);
      n=strNameSrc.indexOf(strSearchCont0);
      if(!intSrchType){
        if(((m>=0 && strName.indexOf(strSearchCont1, m+lenCont0-1)>=0)||(n>=0 && strNameSrc.indexOf(strSearchCont1, n+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]="<p>"+strName;
                if(nLst[i].firstChild.nodeValue != '-'){
                  strArray[count]+=" arrived in SA "+dLst[i].firstChild.nodeValue+" aboard <i>"+nLst[i].firstChild.nodeValue+"</i>";
                  if(fLst[i].firstChild.nodeValue != '-')strArray[count]+=" from "+fLst[i].firstChild.nodeValue +" [Source:"+sPLst[j].firstChild.nodeValue+"]<br/>";
                  else strArray [count]+=" [Source:"+sPLst[j].firstChild.nodeValue+"]</p>";
                }
                else strArray[count]+=" arrived in SA by "+dLst[i].firstChild.nodeValue+" [Source:"+sPLst[j].firstChild.nodeValue+"]</p>";
              }
              else{
                if(nLst[i].firstChild.nodeValue != '-'){
                  strArray [count]="<p>"+dLst[i].firstChild.nodeValue+" arrival in SA of "+strName+" aboard <i>"+nLst[i].firstChild.nodeValue+"</i>";
                  if(fLst[i].firstChild.nodeValue != '-')strArray[count]+=" from "+fLst[i].firstChild.nodeValue +" [Source:"+sPLst[j].firstChild.nodeValue+"]<br/>";
                  else strArray[count]+=" [Source:"+sPLst[j].firstChild.nodeValue+"]</p>";
                }
                else strArray[count]="<p>"+dLst[i].firstChild.nodeValue+" or earlier arrival in SA of "+strName+" [Source:"+sPLst[j].firstChild.nodeValue+"]</p>";
              }
              count++;
              break;
            }
            i++;
          }
        }
      }
      else if(intSrchType==2){
        k=0;
        l=strName.charAt(0);
        while(l && l !=' ' && l !=',' && l !='/'){
          k++;
          l=strName.charAt(k);
        }
        var strSndSurname=calculateSound(strName.substr(0,k));
        if((strSndSurname==strSearch)&&(strNameLower.indexOf(strSearch2,lenR)>=0)){
          i=0;
          while(i<sLen){
            if(rLst[i].firstChild.nodeValue==rPLst[j].firstChild.nodeValue){
              if(s){
                strArray[count]="<p>"+strName;
                if(nLst[i].firstChild.nodeValue != '-'){
                  strArray[count]+=" arrived in SA "+dLst[i].firstChild.nodeValue+" aboard <i>"+nLst[i].firstChild.nodeValue+"</i>";
                  if(fLst[i].firstChild.nodeValue != '-') strArray[count]+=" from "+fLst[i].firstChild.nodeValue +" [Source:"+sPLst[j].firstChild.nodeValue+"]<br/>";
                  else strArray[count]+=" [Source:"+sPLst[j].firstChild.nodeValue+"]</p>";
                }
                else strArray[count]+=" arrived in SA by "+dLst[i].firstChild.nodeValue+" [Source:"+sPLst[j].firstChild.nodeValue+"]</p>";
              }
              else{
                if(nLst[i].firstChild.nodeValue != '-'){
                  strArray[count]="<p>"+dLst[i].firstChild.nodeValue+" arrival in SA of "+strName+" aboard <i>"+nLst[i].firstChild.nodeValue+"</i>";
                  if(fLst[i].firstChild.nodeValue != '-')strArray[count]+=" from "+fLst[i].firstChild.nodeValue +" [Source:"+sPLst[j].firstChild.nodeValue+"]<br/>";
                  else strArray[count]+=" [Source:"+sPLst[j].firstChild.nodeValue+"]</p>";
                }
                else strArray[count]="<p>"+dLst[i].firstChild.nodeValue+" or earlier arrival in SA of "+strName+" [Source:"+sPLst[j].firstChild.nodeValue+"]</p>";
              }
              count++;
              break;
            }
            i++;
          }
        }
      }
      else if(intSrchType==1){
        k=0;
        l=strName.charAt(0);
        while(l && l !=' ' && l !=',' && l !='/'){
          k++;
          l=strName.charAt(k);
        }
        if(!wildcard) lenCont0=k;
        if(strName.substr(0, lenCont0)==strSearchCont0 && strName.substr(k-lenCont1, lenCont1)==strSearchCont1 && strNameLower.indexOf(strSearch2, lenR)>=0){
          i=0;
          while(i<sLen){
            if(rLst[i].firstChild.nodeValue==rPLst[j].firstChild.nodeValue){
              if(s){
                strArray[count]="<p>"+strName;
                if(nLst[i].firstChild.nodeValue != '-'){
                  strArray[count]+=" arrived in SA "+dLst[i].firstChild.nodeValue+" aboard <i>"+nLst[i].firstChild.nodeValue+"</i>";
                  if(fLst[i].firstChild.nodeValue != '-') strArray[count]+=" from "+fLst[i].firstChild.nodeValue +" [Source:"+sPLst[j].firstChild.nodeValue+"]</p>";
                  else strArray[count]+=" [Source:"+sPLst[j].firstChild.nodeValue+"]</p>";
                }
                else strArray[count]+=" arrived in SA by "+dLst[i].firstChild.nodeValue+" [Source:"+sPLst[j].firstChild.nodeValue+"]</p>";
              }
              else{
                if(nLst[i].firstChild.nodeValue != '-'){
                  strArray[count]="<p>"+dLst[i].firstChild.nodeValue+" arrival in SA of "+strName+" aboard <i>"+nLst[i].firstChild.nodeValue+"</i>";
                  if(fLst[i].firstChild.nodeValue != '-')strArray [count]+=" from "+fLst[i].firstChild.nodeValue +" [Source:"+sPLst[j].firstChild.nodeValue+"]</p>";
                  else strArray[count]+=" [Source:"+sPLst[j].firstChild.nodeValue+"]</p>";
                }
                else strArray[count]="<p>"+dLst[i].firstChild.nodeValue+" or earlier arrival of "+strName+" [Source:"+sPLst[j].firstChild.nodeValue+"]</p>";
              }
              count++;
              break;
            }
            i++;
          }
        }
      }
      j++;
    }
    if(c==1)d.getElementById('blnWildcards').checked='checked';
    else if(c==2)d.getElementById('blnSound').checked='checked';
  }
  else if(d.getElementById('dbType').value=='pl'){//pass list
    i=0;
    while(i<sLen){
      strName=nLst[i].firstChild.nodeValue.toUpperCase();
      strName2=dLst[i].firstChild.nodeValue.toLowerCase();
      var n=strName.length;
      if(!wildcard)lenCont0=n;
      if(intSrchType){
        k=0;
        l=strName.charAt(0);
        while(l && l !=' ' && l !=',' && l !='/'){
          k++;
          l=strName.charAt(k);
        }
        if(intSrchType==2)strName=calculateSound(strName.substr(0,k));
        else strName=strName.substr(0,k);
      }
      m=strName.indexOf(strSearchCont0);
      if(((!intSrchType && m>=0 && strName.indexOf(strSearchCont1, m+lenCont0-1)>=0)||(intSrchType==1 && strName.substr(0, lenCont0)==strSearchCont0 && strName.substr(k - lenCont1, lenCont1)==strSearchCont1)||(intSrchType==2 && strName==strSearch)) && strName2.indexOf(strSearch2)>=0){
        strShip=nLst[i].firstChild.nodeValue;
        strDate=dLst[i].firstChild.nodeValue;
        strPort=fLst[i].firstChild.nodeValue;
        strCapt=mLst[i].firstChild.nodeValue;
        strDesc=tLst[i].firstChild.nodeValue;
        j=0;
        while(j<pLen){
          if(rLst[i].firstChild.nodeValue==rPLst[j].firstChild.nodeValue){
            strArray[count]="<p>"+nPLst[j].firstChild.nodeValue+" [Source:"+sPLst[j].firstChild.nodeValue+"]</p>";
            count++;
          }
          j++;
        }
        if(count)break;
      }
      i++;
    }
  }
  else{
    d.body.style.cursor='default';
    if(w.h.length)w.h.back();
    return;
  }
  if(count){
    if(d.getElementById('dbType').value !='pl'){
      strArray.sort();
      if(d.getElementById('blnSortDateDec').checked)strArray.reverse();
    }
    strPrint='<h3>Search results <span class="xsml">(total of '+count+')</span></h3>';
    if(d.getElementById('dbType').value=='pl'){
      strPrint='<h3>Passengers arriving '+strDate+' in SA aboard the <i><b>'+strShip+'</b></i></h3><p>';
      if(strDesc != '-')strPrint+=' ('+strDesc+')';
      if(strPort != '-')strPrint+=' from '+strPort;
      if(strCapt != '-')strPrint+=', Captain '+strCapt;
      strPrint+='</p>';
    }
    for(i=0;i<count;i++)strPrint+=strArray[i];
    d.getElementById('strResult').innerHTML=strPrint+'<h3>Abbreviations used in the results</h3><p>If there is no given name or title, Mr is implied.<br/>[Source:1,2, ...]&nbsp;=&nbsp;sources of the information as listed separately below<br/>aft = soon after, arr = arrived / arrival, dep&nbsp;=&nbsp;departed / departure<br/>brq = barque, schn = schooner, ot = old tons, t = tons<br/>b = born, bap = baptised, 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<br/>Mgt = Margaret, Mtn&nbsp;=&nbsp;Martin, My = Mary, Nic&nbsp;=&nbsp;Nicholas, Ptk&nbsp;=&nbsp;Patrick, Ptr&nbsp;=&nbsp;Peter, Rd&nbsp;=&nbsp;Richard, Rbt&nbsp;=&nbsp;Robert<br />poss = possibly, 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...';
  }
  else{
    d.getElementById('strResult').innerHTML="<h3>Search results <span class='xsml'>(total of 0)</span></h3><br />";
    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 strModSound="";
var strSound="";
var intStrLen=strString.length;
  for(var i=0;i<intStrLen;i++){
    var 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 && strString.charAt(intStrLen-2)=='N'))&&(!(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="";
}//Copyright(c)2003-2011 B Leadbeater, Australia
