var items = new Array(
  new Array("Songs","","Best.Indie.Bands.asp"),
  new Array("Bio","","Singer.Songwriter.asp"), 
  new Array("About Monty","","Singer.Songwriter.asp"),  
  new Array("Monty's Bio","","Singer.Songwriter.asp"),
  new Array("Buy Music","","Best.Indie.Bands.asp"),
  new Array("Interviews","","Monty.Radio.Interviews.asp"),
  new Array("Email Monty","","Contact.Monty.asp"),
  new Array("Contact Monty","","Contact.Monty.asp"),
  new Array("Purchase Songs","","Best.Indie.Bands.asp"),
  new Array("Free Songs","","Free.Song.Download-MP3.Of.The.Day.asp"),  
  new Array("Free Music","","Free.Song.Download-MP3.Of.The.Day.asp"), 
  new Array("Music Downloads","","Free.Song.Download-MP3.Of.The.Day.asp"),  
  new Array("Photos","","Photos.Of.Monty.The.SpacePoet.asp"),
  new Array("Pictures","","Photos.Of.Monty.The.SpacePoet.asp"),
  new Array("Song Lyrics","","Monty.Poetry.And.Prose.asp#SongLyrics"),
  new Array("Novella","","Monty.Poetry.And.Prose.asp#Novella"),
  new Array("Lyrics","","Monty.Poetry.And.Prose.asp#SongLyrics"),
  new Array("Internet Radio Stations","","Internet.Radio.Stations.asp"),
  new Array("Radio Stations","","Internet.Radio.Stations.asp"),
  new Array("Poetry","","Monty.Poetry.And.Prose.asp"),
  new Array("Prose","","Monty.Poetry.And.Prose.asp"),
  new Array("Poems","","Monty.Poetry.And.Prose.asp")
  );

var URL = null;
var MatchCount = 0;
var matchesDiv = null;


function getMatch( search )
{
    search = search.replace(/^\s+/,"");
    var mtext = "";
    MatchCount = 0;
    if ( search != "" )
    {
        for ( var i = 0; i < items.length; ++i )
        {
            var re = new RegExp("(^" + search + "| " + search + ")", "gi");
            var item = items[i];
            if ( re.test(item[0]) || re.test(item[1]) )
            {
                mtext += '<div id=MYDIV><a class=MATCH href="' + item[2] + '">'
                      + item[0].replace( re, "<span>$1</span>")
                      + ""
                      + item[1].replace( re, "<span>$1</span>")
                      + '</a></div>';
                ++MatchCount;
                URL = item[2];
            }
        }
    }
    matchesDiv = document.getElementById("MATCHES");
    matchesDiv.style.visibility = "visible";
    document.getElementById("MATCHES").innerHTML = mtext;
}

function checkSingleMatch( search )
{
    getMatch( search );
    if ( MatchCount != 1 ) return false;

    // If using this for real, UNCOMMENT next line:
      location.href = URL;

    // but for debug we'll show this instead:
    alert("If this weren't debug mode, we'd jump to URL\n" + URL);
    return false;
}
