function replaceString (fullS, oldS, newS) {
// Replaces substring oldS with newS in fullS
  for (var i=0; i<fullS.length; i++) {
   if (fullS.substring(i,i+oldS.length) == oldS) {
   fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length)
    }
  }
  return fullS;
}

function search () {
  var team = document.formsearch.teamName.value.toString();
 {
 var oldS = "University of ";
 var newS = "";
 team = replaceString (team, oldS, newS);
 oldS = " University";
 team = replaceString (team, oldS, newS);
 oldS = " & ";
 newS = " and ";
 team = replaceString (team, oldS, newS);
 oldS = "&";
 team = replaceString (team, oldS, newS);
  var fullAddress= "http://www.1122productions.com/fightsongs/";
  var firstLetter = team.charAt(0).toLowerCase();
  if (firstLetter == "x" || firstLetter == "y") {
    firstLetter = "xy";
  }
  fullAddress = fullAddress + firstLetter + ".html#" + team;
  oldS = " ";
  newS = "_";
  fullAddress = replaceString (fullAddress, oldS, newS);
  location.href = fullAddress;
 }}

