var t;
var len;
var len2;
var lenCont0;
var lenCont1;
var strSearchCont0;
var strSearchCont1;
var wildcard;
var wildcardType;
var lenSrch;
var lenSrch2;
var strSrch;
var strSrch2;
var strSearch;
var strSearch2;
var strSndSurname="";
var xmlhttp=null;
var xmlhttpH=null;
var w=window;
var h=history;
var d=document;
var strLat=[];
var strLng=[];
var ltlg=[];
var strMrkrTtl=[];
var strMkrTtl=[];
var imgWin='';
var strOpenMapId="";
var strMapId, strStartId, strDrvId, strAddrQry;
var strStartAddr="", strStartAddrDefault="GPO Adelaide, 141 King William St, Adelaide SA 5000";
function dtaLoad(){
var e;
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');
      xmlhttpH=new ActiveXObject('Msxml2.XMLHTTP');
    }
    catch(e){
      try{
        xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
        xmlhttpH=new ActiveXObject('Microsoft.XMLHTTP');
      }
      catch(e){
        xmlhttp=false;
        xmlhttpH=false;
        alert(strErrMsg);
        if(w.h.length)w.h.back();
        return;
      }
    }
  }
  else if(w.XMLHttpRequest){
    try{
      xmlhttp=new XMLHttpRequest();
      xmlhttp.overrideMimeType('text/xml');
      xmlhttpH=new XMLHttpRequest();
      xmlhttpH.overrideMimeType('text/xml');
    }
    catch(e){
      xmlhttp=false;
      xmlhttpH=false;
      alert(strErrMsg);
      if(w.h.length)w.h.back();
      return;
    }
  }
  else{
    alert(strErrMsg);
    if(w.h.length)w.h.back();
    return;
  }
  if(xmlhttp && xmlhttpH){
    xmlhttp.open('GET','cemeteries.xml',true);
    xmlhttp.send(null);
    xmlhttpH.open('GET','../tbldb.xml',true);
    xmlhttpH.send(null);
    d.getElementById('dbType')[0].selected=true;
    d.getElementById('strQry').value="";
    d.getElementById('strQry2').value="";
    d.getElementById('btnGo').disabled=false;
  }
  else{
    alert(strErrMsg);
    if(w.h.length)w.h.back();
    return;
  }
}
function changeSelection(){
  if(d.getElementById('dbType').value=="c"){
    d.getElementById('strMain').innerHTML="suburb,&nbsp;town,&nbsp;locality&nbsp;or&nbsp;cemetery&#160;name";
    d.getElementById('strGiven').innerHTML="";
    d.getElementById('strQry').value="";
    d.getElementById('strQry').style.width="20em";
    d.getElementById('strQry2').value="";
    d.getElementById('strQry2').disabled="disabled";
    d.getElementById('strQry2').style.visibility='hidden';
    d.getElementById('blnSortAlpha').checked="checked";
    d.getElementById('blnSortDate').disabled="disabled";
    d.getElementById('blnSDL').disabled="disabled";
    d.getElementById('blnWildcards').checked="checked";
    d.getElementById('blnExact').disabled="disabled";
    d.getElementById('blnE').disabled="disabled";
    d.getElementById('blnSound').disabled="disabled";
    d.getElementById('blnS').disabled="disabled";
  }
  else{
    d.getElementById('strMain').innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;surname&nbsp;*";
    d.getElementById('strGiven').innerHTML="given&nbsp;name";
    d.getElementById('strQry').value="";
    d.getElementById('strQry').style.width="9.7em";
    d.getElementById('strQry2').disabled=false;
    d.getElementById('strQry2').value="";
    d.getElementById('strQry2').style.visibility='visible';
    d.getElementById('blnE').disabled=false;
    d.getElementById('blnExact').disabled=false;
    d.getElementById('blnSDL').disabled=false;
    d.getElementById('blnS').disabled=false;
    d.getElementById('blnSound').disabled=false;
    d.getElementById('blnSortDate').disabled=false;
  }
  d.getElementById('strQry').focus();
}
function findQuery(){
  var i;
  d.getElementById('btnGo').disabled='disabled';
  lenSrch=d.getElementById('strQry').value.length;
  if(lenSrch>28)lenSrch=28;
  lenSrch2=d.getElementById('strQry2').value.length;
  if(lenSrch2>24)lenSrch2=24;
  strSrch=d.getElementById('strQry').value.toUpperCase();
  strSrch2=d.getElementById('strQry2').value.toLowerCase();
  len=0;
  lenCont0=0;
  lenCont1=0;
  len2=0;
  strSearch="";
  strSearchCont0="";
  strSearchCont1="";
  strSearch2="";
  wildcard=0;
  wildcardType="";
  for(i=0;i<lenSrch;i++){
    if((strSrch.charAt(i)>='A' && strSrch.charAt(i)<='Z') || (strSrch.charAt(i)>='0' && strSrch.charAt(i)<='9') || strSrch.charAt(i)=="'" || strSrch.charAt(i)=="-" || 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)=="*" || strSearch.charAt(i)=="?")break;
        strSearchCont0 +=strSearch.charAt(i);
        lenCont0++;
        break;
      case 1:
        if(strSearch.charAt(i)=="*" || strSearch.charAt(i)=="?")break;
        strSearchCont1 +=strSearch.charAt(i);
        lenCont1++;
        break;
      default:
        if(strSearch.charAt(i)=="*" || strSearch.charAt(i)=="?")break;
        strSearchCont1 +=strSearch.charAt(i);
        lenCont1++;
        break;
    }
    if(strSearch.charAt(i)=="*"){
      wildcard++;
      wildcardType="*";
    }
    else if(strSearch.charAt(i)=="?"){
      wildcard++;
      wildcardType="?";
    }
  }
  len=lenCont0+lenCont1;
  for(i=0;i<lenSrch2;i++){
    if((strSrch2.charAt(i)>='a' && strSrch2.charAt(i)<='z') || strSrch2.charAt(i)==" " || strSrch2.charAt(i)=="-" || strSrch2.charAt(i)=="'"){
      strSearch2 +=strSrch2.charAt(i);
      len2++;
    }
  }
  if(len<2 && d.getElementById('dbType').value=="h"){
    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 2 characters of the name to be found.<br />";
    d.getElementById('btnGo').disabled=false;
    d.getElementById('strQry').focus();
    return;
  }
  else if(len<4 && d.getElementById('dbType').value=="c"){
    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>location</b> box with at least 4 characters of the place to be found.<br />";
    d.getElementById('btnGo').disabled=false;
    d.getElementById('strQry').focus();
    return;
  }
  else if(strSearchCont0=="AtoZ" && d.getElementById('dbType').value=="c"){
    xmlhttp.onreadystatechange=checkReadyState;
    xmlhttpH.onreadystatechange=checkReadyState;
    if(xmlhttp.readyState==4 && xmlhttpH.readyState==4 && xmlhttp.status=='200' && xmlhttpH.status=='200')runSearch();
  }
  else{
    d.getElementById('htmlProgress').innerHTML='Downloading the indexes ...';
    if(d.getElementById('blnSound').checked)strSearch=calculateSound(strSearch);
    xmlhttp.onreadystatechange=checkReadyState;
    xmlhttpH.onreadystatechange=checkReadyState;
    if(xmlhttp.readyState==4 && xmlhttpH.readyState==4 && xmlhttp.status=='200' && xmlhttpH.status=='200'){
      d.getElementById('htmlProgress').innerHTML='Searching ...';
      if(t)w.clearTimeout(t);
      t=w.setTimeout('runSearch()',200);
    }
  }
}
function checkReadyState(){
  if(xmlhttp.readyState==4 && xmlhttpH.readyState==4 && xmlhttp.status=='200' && xmlhttpH.status=='200'){
    d.getElementById('htmlProgress').innerHTML='Searching ...';
    if(t)w.clearTimeout(t);
    t=w.setTimeout('runSearch()',200);
  }
  else if(xmlhttp.readyState==4 && xmlhttpH.readyState==4 && (xmlhttp.status !='200' || xmlhttpH.status !='200')){
    alert('An error occurred while loading the index');
    if(w.h.length)w.h.back();
    return;
  }
}
function runSearch(){
var i;
var j;
var count=0;
var strName="";
var strName2="";
var strName3="";
var strName4="";
var strArray=[];
var strPrint="";
var cemDoc=xmlhttp.responseXML;
var rList=cemDoc.getElementsByTagName('r');
var nList=cemDoc.getElementsByTagName('n');
var lList=cemDoc.getElementsByTagName('l');
var lgList=cemDoc.getElementsByTagName('lg');
var mList=cemDoc.getElementsByTagName('m');
var pList=cemDoc.getElementsByTagName('lc');
var hList=cemDoc.getElementsByTagName('h');
var tList=cemDoc.getElementsByTagName('t');
var hlDoc=xmlhttpH.responseXML;
var nHList=hlDoc.getElementsByTagName('n');
var gHList=hlDoc.getElementsByTagName('g');
var dHList=hlDoc.getElementsByTagName('d');
var yHList=hlDoc.getElementsByTagName('a');
var rHList=hlDoc.getElementsByTagName('c');
var cemLen=nList.length;
var hlLen=nHList.length;
var strL=[];
var strLG=[];
var strLoc;
var s=d.getElementById('blnSortAlpha').checked;
var k,l,m,n,o,p;
var intSrchType;
  strOpenMapId="";
  rslt=0;
  if(d.getElementById('blnWildcards').checked)intSrchType=0;
  else if(d.getElementById('blnExact').checked)intSrchType=1;
  else if(d.getElementById('blnSound').checked)intSrchType=2;
  j=0;
  if(d.getElementById('dbType').value=='c'){
    while(j<cemLen){
      strL[j]=lList[j].firstChild.nodeValue;
      strLG[j]=lgList[j].firstChild.nodeValue;
      if(strL[j] !='-' && strLG[j] !='-'){
        if(strL[j].charAt(0) =='-' && strLG[j].charAt(strLG[j].length-1) !='?'){
          strLat[j]=strL[j];
          strLng[j]=strLG[j];
          strMkrTtl[j]=nList[j].firstChild.nodeValue;
        }
        else if(strL[j].charAt(0)=='~'){
          strLat[j]=strL[j].substr(1,strL[j].length-1);
          strLng[j]=strLG[j];
          strMkrTtl[j]=nList[j].firstChild.nodeValue+' (in this vicinity)';
        }
        else if(strL[j].charAt(0)!='-'){
          strLat[j]=strL[j].substr(1,strL[j].length-1);
          strLng[j]=strLG[j];
          strMkrTtl[j]=nList[j].firstChild.nodeValue+' (approximate location)';
        }
        else if(strLG[j].charAt(strLG[j].length-1)=='?'){
          strLat[j]=strL[j];
          strLng[j]=strLG[j].substr(0,strLG[j].length-1);
          strMkrTtl[j]=nList[j].firstChild.nodeValue+' (unconfirmed location)';
        }
      }
      else{strLat[j]='';strLng[j]='';}
      strName=nList[j].firstChild.nodeValue.toUpperCase();
      strName2=lList[j].firstChild.nodeValue+lgList[j].firstChild.nodeValue;
      strName3=pList[j].firstChild.nodeValue.toUpperCase();
      strName4=hList[j].firstChild.nodeValue.toUpperCase();
      if(strName2=='-')strName2="";
      if(strName3=='-' || strName3=='?')strName3="";
      if(strName4=='-')strName4="";
      l=0;
      m=strName.indexOf(strSearchCont0);
      n=strName2.indexOf(strSearchCont0);
      o=strName3.indexOf(strSearchCont0);
      p=strName4.indexOf(strSearchCont0);
      if((m>=0 && strName.indexOf(strSearchCont1,m+lenCont0-1)>=0)||(strName.substr(0,lenCont0)==strSearchCont0 && strName.substr(strName.length-lenCont1,lenCont1)==strSearchCont1)||(n>=0 && strName2.indexOf(strSearchCont1,n+lenCont0-1)>=0)||(o>=0 && strName3.indexOf(strSearchCont1,o+lenCont0-1)>=0)||(p>=0 && strName4.indexOf(strSearchCont1,p+lenCont0-1)>=0)||strSearchCont0=="ATOZ"){
        strArray[count]="<p><i>Cemetery:</i> <b>"+nList[j].firstChild.nodeValue+"</b>";
        strLoc=pList[j].firstChild.nodeValue;
        strMapId=rList[j].firstChild.nodeValue;
        strAddrQry=strMapId+'zx';
        strStartId=strMapId+'zy';
        strDrvId=strMapId+'zz';
        strScale=mList[j].firstChild.nodeValue;
        strMrkrTtl[j]=nList[j].firstChild.nodeValue;
        if(strScale=='-')strScale='14,"400px"';
        else if(strScale.length<3)strScale+=',"400px"';
        if(strLat[j] && strL[j].charAt(0) !='~'){
          strArray[count]+="<br/><i>Latitude, longitude:</i> "+strL[j]+", "+strLG[j]+" (<a href='javascript:;' onclick='dispDir(&#39;"+strMapId+"&#39;,"+strLat[j]+", "+strLng[j]+","+strScale+","+j+");'>directions</a>, <a href='javascript:;' onclick='dispMap(&#39;"+strMapId+"&#39;,"+strLat[j]+", "+strLng[j]+","+strScale+","+j+");'>road map</a>, <a href='javascript:;' onclick='dispMapPlus(&#39;"+strMapId+"&#39;,"+strLat[j]+", "+strLng[j]+","+strScale+","+cemLen+");'>nearby cemeteries</a>, <a href='javascript:;' onclick='dispSat(&#39;"+strMapId+"&#39;,"+strLat[j]+", "+strLng[j]+","+strScale+","+j+");'>satellite view</a>, <a href='javascript:;' onclick='clrMap(&#39;"+strMapId+"&#39;);'>clear</a>)";
        }
        else if(strLat[j]){
          strArray[count]+="<br/><i>Latitude, longitude:</i> "+strL[j]+", "+strLG[j]+" (<a href='javascript:;' onclick='dispMap(&#39;"+strMapId+"&#39;,"+strLat[j]+", "+strLng[j]+","+strScale+","+j+");'>road map - marker shows vicinity only</a>, <a href='javascript:;' onclick='dispMapPlus(&#39;"+strMapId+"&#39;,"+strLat[j]+", "+strLng[j]+","+strScale+","+cemLen+");'>nearby cemeteries</a>, <a href='javascript:;' onclick='clrMap(&#39;"+strMapId+"&#39;);'>clear</a>)";
        }
        if(strLoc !='?' && strLoc !='-')strArray[count]+="<br/><i>Location:</i> "+strLoc;
        if(hList[j].firstChild.nodeValue !='-')strArray[count]+="<br/><i>Notes:</i> "+hList[j].firstChild.nodeValue;
        l=tList[j].firstChild.nodeValue.length;
        if(tList[j].firstChild.nodeValue.charAt(0)!='-')strArray[count]+="<br/><i>Online data:</i> "+tList[j].firstChild.nodeValue;
        if(strLat[j]){
          strArray[count]+="<div id="+strMapId+" class='map' style='display:none;margin-bottom:1.2em;'></div>";
          if(strL[j].charAt(0) !='~'){strArray[count]+="<form id="+strStartId+" style='display:none;margin-bottom:0.5em;padding:0.5em 1em 0.8em 1em;'><div style='margin-bottom:0.4em;'><b>new start address for driving directions</b><br />(<b>eg</b> &#160;141 King William St, Adelaide SA &#160;<b><u>or</u></b>&#160; -34.93, 138.62)</div><input type='text' id="+strAddrQry+" placeholder='start address' value='' maxlength='64' style='width:25em;font-weight:normal;' onkeydown='if(event.keyCode==13)btnAddrGo.focus();' onkeyup='if(event.keyCode==13)dispDir(&#39;"+strMapId+"&#39;,"+strLat[j]+", "+strLng[j]+","+strScale+","+j+");' />&#160;<button type='button' id='btnAddrGo' onclick='dispDir(&#39;"+strMapId+"&#39;,"+strLat[j]+", "+strLng[j]+","+strScale+","+j+");' style='font-weight:bold;'>&#160;Go&#160;</button></form><div id="+strDrvId+" style='display:none;margin-bottom:0.8em;'></div>";}
        }
        strArray[count]+="</p>";
        count++;
      }
      j++;
    }
  }
  else{
    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;
      if(((!intSrchType && (!wildcard || wildcardType=='*') && m>=0 && n>=0) || (!intSrchType && wildcardType=='?' && (p==lenCont0+1 || lenCont0==0 || lenCont1==0) && m>=0 && n>=0) || (intSrchType==1 && (!wildcard || wildcardType=='*') && strName.substr(0,lenCont0)==strSearchCont0 && strName.substr(k-lenCont1,lenCont1)==strSearchCont1) || (intSrchType==1 && wildcardType=='?' && k==(lenCont0+1+lenCont1) && strName.substr(0,lenCont0)==strSearchCont0 && strName.substr(k-lenCont1, lenCont1)==strSearchCont1) || (intSrchType==2 && strName==strSearch)) && (len2==0 || (len2>1 && strName2.indexOf(strSearch2)>=0) || (len2==1 && strName2.charAt(0)==strSearch2.charAt(0)))){
        i=0;
        while(i<cemLen){
          if(rList[i].firstChild.nodeValue==rHList[j].firstChild.nodeValue){
            if(s){
              strArray[count]="<p>"+nHList[j].firstChild.nodeValue+" "+gHList[j].firstChild.nodeValue+" died "+dHList[j].firstChild.nodeValue+" aged "+yHList[j].firstChild.nodeValue+" buried &amp;/or memorialised at "+nList[i].firstChild.nodeValue;
            }
            else{
              strArray[count]="<p>"+dHList[j].firstChild.nodeValue+" death of "+nHList[j].firstChild.nodeValue+" "+gHList[j].firstChild.nodeValue+" aged "+yHList[j].firstChild.nodeValue+" buried &amp;/or memorialised at "+nList[i].firstChild.nodeValue;
            }
            if(nList[i].firstChild.nodeValue.toLowerCase().indexOf('lone grave')<0)strArray[count]+=" Cemetery</p>";
            else strArray[count]+="</p>";
            count++;
            break;
          }
          i++;
        }
      }
      j++;
    }
  }
  if(count){
    strArray.sort();
    strPrint='<h3>Search results <span class="xsml">(total of '+count+')</span></h3>';
    for(i=0;i<count;i++)strPrint +=strArray[i];
    d.getElementById('strResult').innerHTML=strPrint;
    d.getElementById('htmlProgress').innerHTML='View the results below...';
  }
  else{
    d.getElementById('strResult').innerHTML="<h3>Search results <span class='xsml'>(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. <a href='index.html'>Click here for a list of other sites with SA cemetery memorial inscriptions or burial registers.</a></p>";
    d.getElementById('htmlProgress').innerHTML='There are no results to view.';
  }
  if(!d.getElementById('strQry').disabled) d.getElementById('strQry').focus();
  d.getElementById('btnGo').disabled=false;
}
function calculateSound(strString){
var strModSound="";
var strSound="";
var i;
var intStrLen=strString.length;
  for(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 && (!(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 clrMap(mapId){
  d.getElementById(mapId).style.display="none";
  d.getElementById(mapId).innerHTML="";
  var startId=mapId+'zy';
  if(d.getElementById(startId))d.getElementById(startId).style.display="none";
  var drvId=mapId+'zz';
  if(d.getElementById(drvId)){
    d.getElementById(drvId).style.display="none";
    d.getElementById(drvId).innerHTML="";
  }
  strOpenMapId='';
  if(imgWin)imgWin.close();
}
function dispDir(mapId,lat,lng,mag,hgt,cnt){
  if(strOpenMapId)clrMap(strOpenMapId);
  d.getElementById(mapId).innerHTML="<br />&#160;loading map...";
  d.getElementById(mapId).style.height=hgt;
  d.getElementById(mapId).style.display="block";
  var latlng=new google.maps.LatLng(lat,lng);
  var mapOptions={mapTypeId:google.maps.MapTypeId.ROADMAP,navigationControl:true, mapTypeControl:false,scaleControl:true,streetViewControl:true};
  var map=new google.maps.Map(document.getElementById(mapId),mapOptions);
  var marker=new google.maps.Marker({position:latlng,map:map,flat:true,title:strMrkrTtl[cnt]});
  var directionsService=new google.maps.DirectionsService();
  var directionsDisplay=new google.maps.DirectionsRenderer({map:map});
  strAddrQry=mapId+'zx';
  strStartId=mapId+'zy';
  strDrvId=mapId+'zz';
  strStartAddr=d.getElementById(strAddrQry).value;
  if(!strStartAddr)strStartAddr=strStartAddrDefault;
  d.getElementById(strStartId).style.display="block";
  d.getElementById(strDrvId).style.display="block";
  directionsDisplay.setPanel(document.getElementById(strDrvId));
  var request={origin:strStartAddr,destination:latlng,travelMode:google.maps.DirectionsTravelMode.DRIVING,unitSystem:google.maps.DirectionsUnitSystem.METRIC,region:"au"};
  directionsService.route(request,function(response,status){
    if(status==google.maps.DirectionsStatus.OK)directionsDisplay.setDirections(response);
    else{
      d.getElementById(strStartId).style.display="none";
      d.getElementById(mapId).style.display="none";
      alert('No Google directions available for this location');
    }
  });
  strStartAddrDefault=strStartAddr;
  strOpenMapId=mapId;
}
function dispMap(mapId,lat,lng,mag,hgt,cnt){
  if(strOpenMapId)clrMap(strOpenMapId);
  d.getElementById(mapId).innerHTML="<br />&#160;loading map...";
  d.getElementById(mapId).style.height=hgt;
  d.getElementById(mapId).style.display="block";
  var latlng=new google.maps.LatLng(lat,lng);
  var mapOptions={zoom:mag,center:latlng,mapTypeId:google.maps.MapTypeId.ROADMAP,navigationControl:true,mapTypeControl:false,scaleControl:true,streetViewControl:true,overviewMapControl:true};
  var map=new google.maps.Map(document.getElementById(mapId),mapOptions);
  var marker=new google.maps.Marker({position:latlng,map:map,flat:true,title:strMrkrTtl[cnt]});
  strOpenMapId=mapId;
}
function dispSat(mapId,lat,lng,mag,hgt,cnt){
  if(strOpenMapId)clrMap(strOpenMapId);
  d.getElementById(mapId).style.height=hgt;
  d.getElementById(mapId).innerHTML="<br />&#160;loading map...";
  d.getElementById(mapId).style.display="block";
  var type=google.maps.MapTypeId.SATELLITE;
  var latlng=new google.maps.LatLng(lat,lng);
  var options={zoom:mag+2, center:latlng,mapTypeId:type,navigationControl:true,mapTypeControl:false,scaleControl:true,streetViewControl:true,overviewMapControl:true};
  var map=new google.maps.Map(document.getElementById(mapId),options);
  var marker=new google.maps.Marker({position:latlng,map:map,flat:true,title:strMkrTtl[cnt]});
  strOpenMapId=mapId;
}
function dispMapPlus(mapId,lat,lng,mag,hgt,cnt){
  if(strOpenMapId)clrMap(strOpenMapId);
  var ltlg=[];
  var mkr=[];
  var i;
  d.getElementById(mapId).style.height=hgt;
  d.getElementById(mapId).innerHTML="<br />&#160;loading map...";
  d.getElementById(mapId).style.display="block";
  var type=google.maps.MapTypeId.ROADMAP;
  var latlng=new google.maps.LatLng(lat,lng);
  var options={zoom:mag-2,center:latlng,mapTypeId:type,navigationControl:true,mapTypeControl:false,scaleControl:true,streetViewControl:true};
  var map=new google.maps.Map(document.getElementById(mapId),options);
  for(i=0;i<=cnt;i++){
    ltlg[i]=new google.maps.LatLng(strLat[i],strLng[i]);
    mkr[i]=new google.maps.Marker({position:ltlg[i],map:map,flat:true,title:strMkrTtl[i]});
  }
  strOpenMapId=mapId;
}
function wo(path){
  imgWin=window.open(path,'imgWin','width=720,height=600');
  imgWin.focus();
}//Copyright(c)2003-2012 B Leadbeater, Australia
