  if (window.XMLHttpRequest)
  {
    var http = new XMLHttpRequest();
  }
  else if (window.ActiveXObject)
  {
    var http = new ActiveXObject("Microsoft.XMLHTTP");
  }

  function doBrowse()
  {
    var category = document.browse.category.value;
category = category.replace("%20", "-");    
category = category.replace(" ", "-");
    var brand = document.browse.brand.value;
brand = brand.replace("%20", "-");    
brand = brand.replace(" ", "-");
brand = brand.toLowerCase();
 if (brand){
    var url = "http://www.vieri.nl/"+brand+"/"+category+"/";
}
 else{
    var url = "http://www.vieri.nl/"+category+"/";
    
}

    window.location = url;
  }

  function updateCategory()
  {
    document.browse.brand.options[0].selected = true;
  }

  function updateProducts()
  {
    var category = document.browse.category.value;

    var brand = document.browse.brand.value;

    if (category == "") return;

    document.browse.category.disabled = true;

    document.browse.brand.disabled = true;

    document.browse.submit.disabled = true;

    document.browse.submit.value = "zoeken...";

    var url = "http://www.vieri.nl/browse.php?browse=1&browseCategory="+category+"&browseBrand="+brand;

    http.abort();

    http.onreadystatechange = browseResponse;

    http.open("GET", url, true);

    http.send(null);
  }

  function browseResponse()
  {
    if (http.readyState == 4)
    {
      var response = http.responseText;

      var lines = response.split("\n");

      var count = lines[0];

      document.browse.submit.value = count+" accommodaties";

      document.browse.submit.disabled = false;

      document.browse.category.disabled = false;

      if (lines[1] == "BRANDS")
      {
        document.browse.brand.options.length = 1;

        for(i=2;i<lines.length;i++)
        {
          if (lines[i] == "") break;

          document.browse.brand.options[(i-1)] = new Option(lines[i],lines[i]);
        }
      }
      if (document.browse.brand.options.length > 1)
      {
        document.browse.brand.disabled = false;
      }
    }
    else
    {
      document.browse.submit.value = document.browse.submit.value + ".";
    }
  }


