<!-- Ray's Vedant Health Search
var searchKeywords = "";

function triggersearch()
{
    document.location = "/resources/search-results/?" + searchKeywords;
}

function entersearch(e)
{
   if (window.event) // IE
   {
      keynum = e.keyCode
   }
   else if (e.which) // Netscape/Firefox/Opera
   {
      keynum = e.which
   }

   if (keynum == 13)
   {
      try
      {
        e.cancelBubble = true;
      }
      catch(e2)
      {
      }

      try
      {
        e.stopPropagation();
      }
      catch(e2)
      {
      }

      try
      {
        e.preventDefault();
      }
      catch(e2)
      {
      }

      if (searchsetvalue() == true)
      {
          // Submit the main search
          window.setTimeout("searchsubmit();", 100);
      } 

      return false;
   } 
   else
   {
      return true;
   }
}

function searchsubmit(tmpValue)
{
   if (searchsetvalue() == true)
   {
      // Submit the main search
      triggersearch();
   }
}

function searchsetvalue()
{
  // Get the value from the form...
  var myTextField = "";

  try
  {
      var myTextField = this.document.getElementById('searchvalue');
  }
  catch (e)
  {
      alert("Please enter the search keywords");
      return false;
  }

  try
  {
      if (myTextField.value == "")
      {
         alert("Please enter the search keywords");
         return false;
      }
  }
  catch (e)
  {
  }

  // Tidy up
  var txt = myTextField.value;
  var re = /[^a-zA-Z0-9 \-]/g;

  txt = txt.replace(re.value," ");
  txt = txt.replace(/[ ][ ]+/g," ");
  txt = txt.replace(/^[ ]+|[ ]*[ ]$/g,"");

  // Anything defined?
  if ((txt.length < 1) || (txt.match(/[^a-zA-Z0-9 \-]+/g)))
  {
    alert("Please enter valid search keywords");
    return false;
  }

  // Store the keywords for later use....
  //document.cookie = "VHsearch=" + txt;
  //this.document.cookie = "VHsearch=" + txt;

  searchKeywords = txt;

  //window.setTimeout("setsearchcookie();", 10);

  return true;
}

function setsearchcookie(thekeywords)
{
   document.cookie = "VHsearch=" + searchKeywords ;
}
// -->

