function VocabWord_getTarget () {
  count = 0;
  result = new String();
  while (count < this.keyStr.length) {
    chr = this.keyStr.charAt(count);
    if ((chr == '\\') && (count != this.keyStr.length-1)) {
      result = result + this.keyStr.charAt(count+1);
      count += 2;
      continue;
    }
    if (chr == '#') {
      count++;
      while ((count < this.keyStr.length) && (this.keyStr.charAt(count) >= '0')
        && (this.keyStr.charAt(count) <= '9')) count++; 
    } 
    else if (chr == '~') {
      result = result + ' ';
      count++;
    } else {
      result = result + chr;
      count++;
    }
  }
  return result;
}

function VocabWord_keyMatch (key) {
   return (key.toLowerCase() == this.keyStr);
}

function VocabWord_getSoundURL () {
  return this.sndURL;
}

function VocabWord_getHostText() {
  return this.hostStr;
}

function VocabWord (keyStr, hostStr, sndURL, gramURL) {
  this.getTarget = VocabWord_getTarget;
  this.keyMatch = VocabWord_keyMatch;
  this.getSoundURL = VocabWord_getSoundURL;
  this.keyStr = keyStr.toLowerCase();
  this.getHostText = VocabWord_getHostText;
  this.targStr = this.getTarget();
  this.hostStr = hostStr;
  this.sndURL = sndURL;
  this.gramURL = gramURL;
}



function Vocabulary_addWord (word) {
  this.vocab[this.vocab.length] = word;
}

function Vocabulary_addEntry (keyStr, hostStr, sndURL) {
  word = new VocabWord (keyStr, hostStr, sndURL);
  this.addWord (word);
}

function Vocabulary_findKey (keyStr) {
  for (count = 0; count < this.vocab.length; count++) {
     entry = this.vocab[count];
     if (entry.keyMatch(keyStr)) {
       return entry;
     }
  }
  return null;
}

function Vocabulary () {
  this.addWord = Vocabulary_addWord;
  this.addEntry = Vocabulary_addEntry;
  this.findKey = Vocabulary_findKey;
  this.count = 0;
  this.vocab = new Array ();
}



