function MsgBox (textstring) {
  alert (textstring);
}

function LoadURL (textstring) {
  window.location.href="http://" + textstring;
}

function PerformSiteSearch (terms, site) {
  // window.location.href="http://www.google.com/search?q=" + terms + "+site%3A" + site
  var theURL = "http://www.google.com/search?q=" + terms + "+site%3A" + site;
  window.open(theURL);
}

function UpdateSearchSite(){
  document.searchForm.searchsite.value = document.searchForm.freqsearchsites.value;
}

function PerformNakedSearch(searchterms, extensions){
  //note: "+" produces a space in the URL (i.e. "+%2B" = " +")
  // "%2B" = "+"
  // "%22" = quotes
  // "%3A" = ":"
  // "%28" = "("
  // "%29" = ")"
  // "%7C+ = "|"
  var theURL = "http://www.google.com/search?q=";
  //add: -inurl:(htm|html|php)
  theURL = theURL + "-inurl%3A%28htm%7Chtml%7Cphp%29";
  //add: intitle:
  theURL = theURL + "+intitle%3A";
  //add: "index of"
  theURL = theURL + "%22index+of%22";
  //add: +"last modified"
  theURL = theURL + "+%2B%22last+modified%22";
  //add: [space]+"parent directory"
  theURL = theURL + "+%2B%22parent+directory%22";
  //add: [space]+description
  theURL = theURL + "+%2Bdescription";
  //add: [space]+size
  theURL = theURL + "+%2Bsize";
  //add: [space]+([EXTENSIONS])
  theURL = theURL + "+%2B%28" + extensions + "%29";
  //add: [space]"[SEARCH TERMS]"
  theURL = theURL + "+%22" + searchterms + "%22";
  window.open(theURL);
  //http://www.google.com/search?q=-inurl%3A%28htm%7Chtml%7Cphp%29+intitle%3A%22index+of%22+%2B%22last+modified%22+%2B%22parent+directory%22+%2Bdescription+%2Bsize+%2B%28[EXTENSIONS]%29+%22[TERMS]%22
}

function UpdateFileExtensions(){
  document.nakedForm.nakedfileext.value = document.nakedForm.freqfileextensions.value;
}

function PerformMovieSearch(moviesearchterms, moviezipcode){
  // http://www.google.com/search?q=showtimes+84115
  // http://www.google.com/search?q=juno+showtimes+84115
  // var theURL = "http://www.google.com/movies?q=" + moviesearchterms + "+showtimes+" + moviezipcode;
  // window.open(theURL);
  
  if (moviesearchterms == "") {
    // http://www.google.com/movies?sc=1&near=84115&rl=1
    var theURL = "http://www.google.com/movies?sc=1&near=" + moviezipcode + "&rl=1"
  }
  else
  {
    // http://www.google.com/movies?q=juno&btnG=Search+Movies&sc=1&near=84115&rl=1
    var theURL = "http://www.google.com/movies?q=" + moviesearchterms + "&btnG=Search+Movies&sc=1&near=" + moviezipcode + "&rl=1"
  }
  
  window.open(theURL);
}

function submitmoviesenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   PerformMovieSearch(myfield.form.moviesearchterms.value, myfield.form.moviezipcode.value);
   //myfield.form.submit();
   return false;
   }
else
   return true;
}

function submitnakedenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   PerformNakedSearch(myfield.form.nakedsearchterms.value, myfield.form.nakedfileext.value);
   //myfield.form.submit();
   return false;
   }
else
   return true;
}

function submitsiteenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   PerformSiteSearch(myfield.form.searchterms.value, myfield.form.searchsite.value);
   //myfield.form.submit();
   return false;
   }
else
   return true;
}