  function startMenu()
  {
    self.window.name="RIGHTSIDE";
    aWindow = window.open("http://www.statechamp.com/window.htm", "MenuWindow",
         "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,width=290,height=500");
  }

  function findCity( city, state, categ )
  {
     var i = city.indexOf(";");
     var real_city = city;
     if (i>0)
        real_city = city.substring(0, i) + "'" + city.substring(i+1, city.length);
     var real_categ = categ.substring( 0, categ.length-1 );
     window.location = "http://www.statechamp.com/cgi-bin/test.pl?TextField=" + real_city + "&What=" + real_categ + "&Index=0&State="  + state + "&SearchType=City";
  }

  function say(s)
  {
    alert(s);
  }

  function getState()
  {
     return window.parent.topwin.stateList.options[ stateList.selectedIndex ].value;
  }

  function changeState(s)
  {
    state = s;
  }

  function setCateg()
  {
     var s = getCookie("CategIdx");
     if (s != null)
         document.forms[0].CategList.selectedIndex = s;
  }

  function letsDoIt3(idx, s)
  {
     setCookie("CategIdx", idx);
     if (idx == 1)
       c = "newspapers";
     if (idx == 2)
       c = "schools";
     letsDoIt(c, s);
  }
  function letsDoIt2(s)
  {
     var i = document.forms[0].CategList.selectedIndex;
     var c = document.forms[0].CategList.options[i].value;
     setCookie("CategIdx", i);
     letsDoIt( c, s);
  }

  function loadPage(c, s)
  {
     window.location = "http://www.statechamp.com/html/bystate/pages/" + c + "/"  + s + ".html";
     saveCookie();
  }

  function letsDoIt(c, s)
  {
     window.location = "http://www.statechamp.com/cgi-statechamp/statechampMain?" +
          "statechamp_category=" + c + "?" + "state=" + s;
     saveCookie();
     //setCookie("State", s);
     //setCookie("Categ", c);
  }
    
  var win = self.parent.opener;
  function loadIt2( name, state_name, categ )
  {
     if (name != "main")
        window.location = "http://www.statechamp.com/cgi-statechamp/t.sh?" +
           name + "," +
           state_name + "," + categ;
  }

  function loadIt3( state_name, categ )
  {
     categSelect( categ );
     stateSelect( state_name );
  }

  function loadIt( addr )
  {
     if (addr != "main")
     {
         window.parent.location = addr;
     }
  }

  function setState()
  {
    var idx = getCookie("State");
    if (idx != null)
    {
       document.forms[0].homeList.selectedIndex = idx;
    }
  }
  function launch()
  {
     var idx = document.forms[0].homeList.selectedIndex;
     if (idx > 0)
     {
        setCookie("State", idx-1);
        startMenu();
     }
  }
  function func()
  {
     var state = "";
     var categ = "";
     var stateidx = document.forms[0].stateList.selectedIndex;
     var categidx = document.forms[0].categList.selectedIndex;
     state = document.forms[0].stateList.options[ stateidx ].value;
     categ = document.forms[0].categList.options[ categidx ].value;
     window.open("http://www.statechamp.com/html/bystate/" + categ + state + ".htm", "results");
     saveCookie();
  }
  function search(val)
  {
    // var categidx = document.forms[0].categList.selectedIndex;
    // var name = document.forms[0].categList.options[ categidx ].text;
    // var val = document.forms[0].categList.options[ categidx ].value;
    aWindow = window.open("", "SearchWindow",
         "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=yes,width=280,height=150");
    aWindow.document.open();
    aWindow.document.writeln("<HTML><HEAD>");
    aWindow.document.writeln("<TITLE>State Champ Search</TITLE></HEAD>");
    aWindow.document.writeln("<BODY BGCOLOR=\"#00066\"><FORM>");
    aWindow.document.writeln("<APPLET CODE=\"erocks.applets.searchApplet\"");
    aWindow.document.writeln("        CODEBASE=\"/\"");
    aWindow.document.writeln("  width=250 height=100>");
    aWindow.document.writeln("<PARAM NAME=\"what\" VALUE=\"" + val + "\">");
    aWindow.document.writeln("<PARAM NAME=\"11ROCKS_WINDOW\" VALUE=\"1\">");
    aWindow.document.writeln("</APPLET>");
    aWindow.document.writeln("<CENTER><INPUT TYPE=\"button\" NAME=\"Close\" VALUE=\"Close\" onClick=\"window.close()\"></CENTER>");
    aWindow.document.writeln("</FORM></BODY></HTML>");
    aWindow.document.close();
  }
  var the_cookie = document.cookie;
  function getCookieVal (offset)
  {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
    endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
  }
  function getCookie(name)
  {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen)
    {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) 
      break; 
    }
    return null;
  }
  function setCookie(name, value)
  {
    var today = new Date();
  //  var expires = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000);
    var path = null;
    var domain = null;
    var secure = false;
    document.cookie = name + "=" + escape (value) +
  //      "; expires=" + expires.toGMTString() +
        "; domain=www.statechamp.com";
  //  ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  //  ((path == null) ? "" : ("; path=" + path)) +
  //  ((domain == null) ? "" : ("; domain=" + domain)) +
  //  ((secure == true) ? "; secure" : "");
  }
  function initState()
  {
    var n = getCookie("State");
    if (n != null)
    {
       document.forms[0].stateList.selectedIndex = parseInt(n);
       n = getCookie("Categ");
       if (n != null)
       {
          document.forms[0].categList.selectedIndex = parseInt(n);
          // func();
       }
    }
  }
  function saveCookie()
  {
     setCookie("State", document.forms[0].stateList.selectedIndex);
     setCookie("Categ", document.forms[0].categList.selectedIndex);
  }

  function categSelect(categ)
  {
     for (i=0; i<51; i++)
       if (document.forms[0].categList.options[i].value == categ)
       {
          document.forms[0].categList.selectedIndex = i;
          break;
       }
  }

  function stateSelect(state)
  {
     setCookie("State", state);
     for (i=0; i<51; i++)
       if (document.forms[0].stateList.options[i].value == state)
       {
          document.forms[0].stateList.selectedIndex = i;
          break;
       }
  }

