function FindWord() {
  varWord = document.dictionary_form.dictionary_word.value;
  if(varWord.length<2) {
    alert("You need to enter a word.");
    document.dictionary_form.dictionary_word.focus();
    return false;
  }
  varURL = "http://www.webster.com/cgi-bin/dictionary?va=" + varWord;
  document.location = varURL;
  return false;
}
function FindGoogle() {
  varSearch = document.google_form.Google_Text.value;
  if(varSearch.length<2) {
    alert("You need to enter search text.");
    document.google_form.Google_Text.focus();
    return false;
  }
  varURL = "http://www.google.com/search?hl=en&q=" + varSearch;
  document.location = varURL;
  return false;
}
function FindMap() {
  var varMap = document.mapquest_form;
  var varURL = '';
  var strStreet = '';var strCity = '';var strState = '';var strZip = '';
  if(varMap.Map_City.value.length==0){alert('You need to enter a city.');varMap.Map_City.focus();return false;}
  strCity = CleanMapElements(varMap.Map_City.value);
  strCity = replaceSubstring(strCity, ' ', '+');
  if(varMap.Map_State.value.length==0){alert('You need to enter a state.');varMap.Map_State.focus();return false;}
  if(varMap.Map_State.value.length==1){alert('You need to enter two letters in your state.');varMap.Map_State.focus();return false;}
  strState = CleanMapElements(varMap.Map_State.value);
  strState = replaceSubstring(strState, ' ','');
  if(varMap.Map_Street.value.length>0){
    var strStreet = CleanMapElements(varMap.Map_Street.value);strStreet = replaceSubstring(strStreet, ' ', '+');}
  strZip = replaceSubstring(varMap.Map_Zip.value,' ','');
  if(strZip.length!=5){strZip = '';}else{strZip = CleanMapElements(strZip);}
  varURL = "http://www.mapquest.com/maps/map.adp?city="+strCity+"&state="+strState+"&address="+strStreet+"&zip=";
  varURL = varURL+strZip+"&country=us&zoom=8";
  document.location = varURL;
  return false;
}
function CleanMapElements(x) {
  var strReturn;
  strReturn = replaceSubstring(x, "%", "%%25");
  strReturn = replaceSubstring(strReturn, '&', '%%26');
  strReturn = replaceSubstring(strReturn, '+', '%%30');
  return strReturn;
}
function replaceSubstring(inputString, fromString, toString) {
var temp = inputString;
if (fromString == "") {return inputString;}
if (toString.indexOf(fromString) == -1) {
  while (temp.indexOf(fromString) != -1) {
    var toTheLeft = temp.substring(0, temp.indexOf(fromString));
    var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
    temp = toTheLeft + toString + toTheRight;
  }
} else {
  var midStrings = new Array("~", "`", "_", "^", "#");
  var midStringLen = 1;
  var midString = "";
  while (midString == "") {
    for (var i=0; i < midStrings.length; i++) {
      var tempMidString = "";
      for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
        if (fromString.indexOf(tempMidString) == -1) {midString = tempMidString; i = midStrings.length + 1;}
      }
    }
    while (temp.indexOf(fromString) != -1) {
      var toTheLeft = temp.substring(0, temp.indexOf(fromString));
      var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
      temp = toTheLeft + midString + toTheRight;
    }
    while (temp.indexOf(midString) != -1) {
      var toTheLeft = temp.substring(0, temp.indexOf(midString));
      var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
      temp = toTheLeft + toString + toTheRight;
    }
  }
  return temp;
}
