function setupCat1(all, formno) {
  i = -1;
  if (all) {
	  document.forms[formno].category1.options[0] = new Option("Alle", "-1", true);
	  i = 0;
  }
  document.forms[formno].category1.options[1+i] = new Option("Til hesten", "1", false);
  document.forms[formno].category1.options[2+i] = new Option("Til rytteren", "2", false);
  document.forms[formno].category1.options[3+i] = new Option("Til stalden", "3", false);
  document.forms[formno].category1.options[4+i] = new Option("Bøger/blade", "6", false);
  document.forms[formno].category1.options[5+i] = new Option("Til kørsel", "4", false);
  document.forms[formno].category1.options[6+i] = new Option("Til western", "5", false);
  document.forms[formno].category1.options[7+i] = new Option("Større samling af udstyr", "7", false); 
}

function setupCat2(all, formno) {
  document.forms[formno].category2.selectedIndex = -1;
  document.forms[formno].category2.options.length = 0;
  
  cat1_selection = document.forms[formno].category1.options[document.forms[formno].category1.selectedIndex].value;

  i = -1;
  if (all) {
	  document.forms[formno].category2.options[0] = new Option("Alle", "-1", true);
	  i = 0;
  }
  if (cat1_selection == "1") {
    document.forms[formno].category2.options[1+i] = new Option("Sadler og tilbehør", "10", false);
    document.forms[formno].category2.options[2+i] = new Option("Hovedtøj og tilbehør", "11", false);
    document.forms[formno].category2.options[3+i] = new Option("Longering og hjælpetøjler", "12", false);
    document.forms[formno].category2.options[4+i] = new Option("Dækkener og tilbehør", "13", false);
    document.forms[formno].category2.options[5+i] = new Option("Pleje af hest og udstyr", "14", false);
    document.forms[formno].category2.options[6+i] = new Option("Transport af hest", "15", false);
    document.forms[formno].category2.options[7+i] = new Option("Benbeskyttelse", "16", false);
    document.forms[formno].category2.options[8+i] = new Option("Grimer og træktove", "17", false);
    document.forms[formno].category2.style.visibility='visible';
  } else if (cat1_selection == "2") {
    document.forms[formno].category2.options[1+i] = new Option("Sikkerhedsudstyr", "20", false);
    document.forms[formno].category2.options[2+i] = new Option("Beklædning", "21", false);
    document.forms[formno].category2.options[3+i] = new Option("Piske og sporer", "22", false);
    document.forms[formno].category2.options[4+i] = new Option("Støvler og fodtøj", "23", false);
    document.forms[formno].category2.style.visibility='visible';
  } else if (cat1_selection == "3") {
    document.forms[formno].category2.options[1+i] = new Option("Krybber", "300", false);
    document.forms[formno].category2.options[2+i] = new Option("Opbinding", "301", false);
    document.forms[formno].category2.options[3+i] = new Option("Navneskilte", "302", false);
    document.forms[formno].category2.options[4+i] = new Option("Hønet og høhække", "303", false);
    document.forms[formno].category2.options[5+i] = new Option("Andet til stalden", "304", false);
    document.forms[formno].category2.style.visibility='visible';
  } else if (cat1_selection == "6") {
    document.forms[formno].category2.options[1+i] = new Option("Hestebøger", "320", false);
    document.forms[formno].category2.options[2+i] = new Option("Hesteblade", "321", false);
    document.forms[formno].category2.style.visibility='visible';
  } else {
    document.forms[formno].category2.style.visibility='hidden';
  }

  // Category 3 - Reset
  document.forms[formno].category3.options.length = 0;
  document.forms[formno].category3.style.visibility='hidden';
}

function setupCat3(all, formno) {
  document.forms[formno].category3.selectedIndex = -1;
  document.forms[formno].category3.options.length = 0;
  
  cat1_selection = document.forms[formno].category1.options[document.forms[formno].category1.selectedIndex].value;
  cat2_selection = document.forms[formno].category2.options[document.forms[formno].category2.selectedIndex].value;

  i = -1;
  if (all) {
     document.forms[formno].category3.options[0] = new Option("Alle", "-1", true);
	 i = 0;
  }
  if (cat1_selection == "1" && cat2_selection == "10") {
    document.forms[formno].category3.options[1+i] = new Option("Sadler", "30", false);
    document.forms[formno].category3.options[2+i] = new Option("Sadelunderlag", "31", false);
    document.forms[formno].category3.options[3+i] = new Option("Sadelgjorde", "32", false);
    document.forms[formno].category3.options[4+i] = new Option("Geleunderlag og sadelpads", "33", false);
    document.forms[formno].category3.options[5+i] = new Option("Stigbøjler og stigremme", "34", false);
    document.forms[formno].category3.options[6+i] = new Option("Andet tilbehør til sadler", "35", false);
    document.forms[formno].category3.style.visibility='visible';
  } else
   if (cat1_selection == "1" && cat2_selection == "11") {
    document.forms[formno].category3.options[1+i] = new Option("Trenser", "40", false);
    document.forms[formno].category3.options[2+i] = new Option("Kandar", "41", false);
    document.forms[formno].category3.options[3+i] = new Option("Pandebånd", "42", false);
    document.forms[formno].category3.options[4+i] = new Option("Næsebånd", "43", false);
    document.forms[formno].category3.options[5+i] = new Option("Tøjler", "44", false);
    document.forms[formno].category3.options[6+i] = new Option("Bid", "45", false);
    document.forms[formno].category3.options[7+i] = new Option("Andet tilbehør til hovedtøj", "46", false);
    document.forms[formno].category3.style.visibility='visible';
  } else
  if (cat1_selection == "1" && cat2_selection == "12") {
    document.forms[formno].category3.options[1+i] = new Option("Longer og køreliner", "50", false);
    document.forms[formno].category3.options[2+i] = new Option("Indspændinger og hjælpetøjler", "51", false);
    document.forms[formno].category3.options[3+i] = new Option("Longepiske", "52", false);
    document.forms[formno].category3.options[4+i] = new Option("Andet tilbehør til longering", "53", false);
    document.forms[formno].category3.style.visibility='visible';
  } else
  if (cat1_selection == "1" && cat2_selection == "13") {
    document.forms[formno].category3.options[1+i] = new Option("Stald og udedækkener", "60", false);
    document.forms[formno].category3.options[2+i] = new Option("Sveddækkener", "61", false);
    document.forms[formno].category3.options[3+i] = new Option("Dækkengjorde", "62", false);
    document.forms[formno].category3.options[4+i] = new Option("Skridtdækkener og tæpper", "63", false);
    document.forms[formno].category3.options[5+i] = new Option("Andet tilbehør til dækkener", "64", false);
    document.forms[formno].category3.style.visibility='visible';
  } else
  if (cat1_selection == "1" && cat2_selection == "14") {
    document.forms[formno].category3.options[1+i] = new Option("Plejemidler til hest", "70", false);
    document.forms[formno].category3.options[2+i] = new Option("Plejemidler til udstyr", "71", false);
    document.forms[formno].category3.options[3+i] = new Option("Strigler", "72", false);
    document.forms[formno].category3.options[4+i] = new Option("Klippere og tilbehør", "74", false);
    document.forms[formno].category3.options[5+i] = new Option("Andet tilbehør til pleje", "73", false);
    document.forms[formno].category3.style.visibility='visible';
  } else
  if (cat1_selection == "1" && cat2_selection == "15") {
    document.forms[formno].category3.options[1+i] = new Option("Transportgamacher", "80", false);
    document.forms[formno].category3.options[2+i] = new Option("Andet tilbehør til transport", "81", false);
    document.forms[formno].category3.style.visibility='visible';
  } else
  if (cat1_selection == "1" && cat2_selection =="16") {
    document.forms[formno].category3.options[1+i] = new Option("Gamacher", "90", false);
    document.forms[formno].category3.options[2+i] = new Option("Elastikbandager og underlag", "91", false);
    document.forms[formno].category3.options[3+i] = new Option("Staldbandager og underlag", "92", false);
    document.forms[formno].category3.options[4+i] = new Option("Klokker", "93", false);
    document.forms[formno].category3.options[5+i] = new Option("Andet tilbehør til benbeskyttelse", "94", false);
    document.forms[formno].category3.style.visibility='visible';
  } else
  if (cat1_selection == "1" && cat2_selection == "17") {
    document.forms[formno].category3.options[1+i] = new Option("Grimer", "100", false);
    document.forms[formno].category3.options[2+i] = new Option("Træktove", "101", false);
    document.forms[formno].category3.options[3+i] = new Option("Tilbehør til grimer og træktove", "102", false);
    document.forms[formno].category3.style.visibility='visible';
  } else
  if (cat1_selection == "2" && cat2_selection == "20") {
    document.forms[formno].category3.options[1+i] = new Option("Ridehjelme", "200", false);
    document.forms[formno].category3.options[2+i] = new Option("Sikkervedsveste", "201", false);
    document.forms[formno].category3.options[3+i] = new Option("Andet sikkerhedsudstyr", "202", false);
    document.forms[formno].category3.style.visibility='visible';
  } else
  if (cat1_selection == "2" && cat2_selection == "21") {
    document.forms[formno].category3.options[1+i] = new Option("Ridebukser", "210", false);
    document.forms[formno].category3.options[2+i] = new Option("Strømper", "211", false);
    document.forms[formno].category3.options[3+i] = new Option("Handsker", "212", false);
    document.forms[formno].category3.options[4+i] = new Option("Jakker og veste", "213", false);
    document.forms[formno].category3.options[5+i] = new Option("Chaps", "214", false);
    document.forms[formno].category3.options[6+i] = new Option("Stævnebeklædning", "215", false);
    document.forms[formno].category3.options[7+i] = new Option("Anden beklædning", "216", false);
    document.forms[formno].category3.style.visibility='visible';
  } else
  if (cat1_selection == "2" && cat2_selection == "22") {
    document.forms[formno].category3.options[1+i] = new Option("Piske", "220", false);
    document.forms[formno].category3.options[2+i] = new Option("Sporer og sporeremme", "221", false);
    document.forms[formno].category3.style.visibility='visible';
  } else
  if (cat1_selection == "2" && cat2_selection == "23") {
    document.forms[formno].category3.options[1+i] = new Option("Ridestøvler", "230", false);
    document.forms[formno].category3.options[2+i] = new Option("Leggings", "231", false);
    document.forms[formno].category3.options[3+i] = new Option("Staldstøvler og fodtøj", "232", false);
    document.forms[formno].category3.style.visibility='visible';
  } else {
    document.forms[formno].category3.style.visibility='hidden';
  }
}

function validateSelection(formno) {
 if (document.forms[formno].category1.selectedIndex == -1) {
   document.forms[formno].category1.focus();
   return false;
 } else {
   cat1_selection = document.forms[formno].category1.options[document.forms[formno].category1.selectedIndex].value;
   idx2 = document.forms[formno].category2.selectedIndex;

   if (cat1_selection == "1" || cat1_selection == "2") {
     if (idx2 == -1) {
       document.forms[formno].category2.focus();
	   return false;
     }
     idx3 = document.forms[formno].category3.selectedIndex;
     if (idx3 == -1) {
       document.forms[formno].category3.focus();
	   return false;
     }
   } else if (cat1_selection == "3" || cat1_selection == "6") {
     if (idx2 == -1) {
       document.forms[formno].category2.focus();
	   return false;
     }
   }
 }
 return true;
}

function resetCat(formno) {
  setupCat1(false, formno);
  document.forms[formno].category2.options.length = 0;
  document.forms[formno].category2.style.visibility='hidden';
  document.forms[formno].category3.options.length = 0;
  document.forms[formno].category3.style.visibility='hidden';
}
