// This is a handy function that empties a select dropdown's options
function clearOptions(selectObject)
{
    if(document.layers)
    {
        selectObject.options.length = 0;
    }
    else
    {
        selectObject.innerHTML = "";
    }
}

function opt(value, text)
{
    this.text = text;
    this.value = value;
}

var products = new Array();

products["Anchoring Systems"] = new Array();
products["Screws"] = new Array();
products["Nuts & Bolts"] = new Array();
products["Rivets"] = new Array();
products["Tools"] = new Array();
products["Silicone & Adhesives"] = new Array();
products["Nails"] = new Array();
products["Miscellaneous"] = new Array();
products["Framing Nails"] = new Array();

products["Anchoring Systems"].push(new opt("Select a Product", "Select a Product"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/anka_plug.php", "> Anka Plug"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/bettadrive_anchors.php", "> Bettadrive Anchors"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/chemical_anchors.php", "> Chemical Anchors"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/chemical_injections.php", "> Chemical Injections"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/christmas_trees.php", "> Christmas Trees"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/dbz_metal_pin_anchor.php", "> DBZ Metal Pin Anchor"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/drive_pins.php", "> Drive Pins"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/drop_in_anchors.php", "> Drop In Anchors"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/frame_anchors.php", "> Frame Anchors"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/high_load_safety_anchors.php", "> High Load Safety Anchors"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/hollow_wall_anchors.php", "> Hollow Wall Anchors"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/macdrive_anchors.php", "> Macdrive Anchors"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/Macloc_anchors.php", "> Macloc Anchors"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/macnuts.php", "> Macnuts"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/macplugs.php", "> Macplugs"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/masonbolts.php", "> Masonbolts"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/nail_in_plugs.php", "> Nail in Plugs"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/nails.php", "> Nails"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/plaster_anchor.php", "> Plaster Anchor"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/power_acuated_piston_tools.php", "> Power Acuated Piston Tools"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/power_loads.php", "> Power Loads"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/purlin_clips.php", "> Purlin Clips"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/screwbolts.php", "> Screwbolts"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/slug_plug.php", "> Slug Plug"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/splitz_anchors.php", "> Splitz Anchors"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/superplugs.php", "> Superplugs"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/suspension_anchors.php", "> Suspension Anchors"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/toggles.php", "> Toggles"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/universal_plugs.php", "> Universal Plugs"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/utility_hook.php", "> Utility Hook"));
products["Anchoring Systems"].push(new opt(".../../Products/Anchoring/wall_lok_anchors.php", "> Wall-lok Anchors"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/wallplugs.php", "> Wallplugs"));
products["Anchoring Systems"].push(new opt("../../Products/Anchoring/wedge_anchors.php", "> Wedge Anchors"));


products["Screws"].push(new opt("Select a Product", "Select a Product"));
products["Screws"].push(new opt("../../Products/Screws/cabinet_screws.php", "> Cabinet Screws"));
products["Screws"].push(new opt("../../Products/Screws/chipboard_screws.php", "> Chipboard Screws"));
products["Screws"].push(new opt("../../Products/Screws/collated_self_drilling_screws.php", "> Collated Self Drilling Screws"));
products["Screws"].push(new opt("../../Products/Screws/drywall_screws.php", "> Drywall Screws"));
products["Screws"].push(new opt("../../Products/Screws/fastdrive_collated_screws.php", "> Fastdrive Collated Screws"));
products["Screws"].push(new opt("../../Products/Screws/porous_material_screws.php", "> Porous Material Screws"));
products["Screws"].push(new opt("../../Products/Screws/screw_accessories.php", "> Screw Accessories"));
products["Screws"].push(new opt("../../Products/Screws/self_drilling_screws.php", "> Self Drilling Screws"));
products["Screws"].push(new opt("../../Products/Screws/self_tapping_screws.php", "> Self Tapping Screws"));
products["Screws"].push(new opt("../../Products/Screws/stainless_steel_screws.php", "> Stainless Steel Screws"));
products["Screws"].push(new opt("../../Products/Screws/stitching_screws.php", "> Stitching Screws"));
products["Screws"].push(new opt("../../Products/Screws/superchipboard_screws.php", "> Superchipboard Screws"));
products["Screws"].push(new opt("../../Products/Screws/timber_screws.php", "> Timber Screws"));
products["Screws"].push(new opt("../../Products/Screws/type_17_screws.php", "> Type 17 Screws"));
products["Screws"].push(new opt("../../Products/Screws/villaboard_screws.php", "> Villaboard Screws"));
products["Screws"].push(new opt("../../Products/Screws/woodscrews.php", "> Woodscrews"));

products["Nuts & Bolts"].push(new opt("Select a Product", "Select a Product"));
products["Nuts & Bolts"].push(new opt("../../Products/Nuts and Bolts/carriage_bolt_nut.php", "> Carriage Bolt & Nut"));
products["Nuts & Bolts"].push(new opt("../../Products/Nuts and Bolts/coach_screws.php", "> Coach Screws"));
products["Nuts & Bolts"].push(new opt("../../Products/Nuts and Bolts/hex_bolt_nut.php", "> Hex Bolt & Nut"));
products["Nuts & Bolts"].push(new opt("../../Products/Nuts and Bolts/hex_couplings.php", "> Hex Couplings"));
products["Nuts & Bolts"].push(new opt("../../Products/Nuts and Bolts/hex_ducting_nuts.php", "> Hex Ducting Nuts"));
products["Nuts & Bolts"].push(new opt("../../Products/Nuts and Bolts/hex_nut.php", "> Hex Nut"));
products["Nuts & Bolts"].push(new opt("../../Products/Nuts and Bolts/metalthreads.php", "> Metalthreads"));
products["Nuts & Bolts"].push(new opt("../../Products/Nuts and Bolts/roofing_bolts_nuts.php", "> Roofing Bolts & Nuts"));
products["Nuts & Bolts"].push(new opt("../../Products/Nuts and Bolts/set_screws.php", "> Set Screws"));
products["Nuts & Bolts"].push(new opt("../Products/Nuts and Bolts/spring_strut_nuts.php", "> Spring Strut Nuts"));
products["Nuts & Bolts"].push(new opt("../../Products/Nuts and Bolts/threaded_rod.php", "> Threaded Rod"));
products["Nuts & Bolts"].push(new opt("../../Products/Nuts and Bolts/washers.php", "> Washers"));
products["Nuts & Bolts"].push(new opt("../../Products/Nuts and Bolts/wedge_nuts.php", "> Wedge Nuts"));
products["Nuts & Bolts"].push(new opt("../../Products/Nuts and Bolts/wing_nut.php", "> Wing Nut"));

products["Rivets"].push(new opt("Select a Product", "Select a Product"));
products["Rivets"].push(new opt("../../Products/Rivets/aluminium_steel_rivets.php", "> Aluminium Steel Rivets"));
products["Rivets"].push(new opt("../../Products/Rivets/all_aluminium_rivets.php", "> All Aluminium Rivets"));
products["Rivets"].push(new opt("../../Products/Rivets/all_stainless_steel.php", "> All Stainless Steel"));
products["Rivets"].push(new opt("../../Products/Rivets/aluminium_sealed_rivets.php", "> Aluminium Sealed Rivets"));
products["Rivets"].push(new opt("../../Products/Rivets/aluminium_steel_coloured_rivets.php", "> Aluminium Steel Coloured Rivets"));
products["Rivets"].push(new opt("../../Products/Rivets/copper_sealed_plated_stem_rivets.php", "> Copper Sealed with Plated Stem Rivets"));
products["Rivets"].push(new opt("../../Products/Rivets/copper_plated_stem_rivets.php", "> Copper with Plated Stem Rivets"));
products["Rivets"].push(new opt("../../Products/Rivets/coppernickel_steel_rivets.php", "> Coppernickel/ Steel Rivets"));
products["Rivets"].push(new opt("../../Products/Rivets/multigrip_rivets.php", "> Multigrip Rivets"));
products["Rivets"].push(new opt("../../Products/Rivets/peel_rivets.php", "> Peel Rivets"));
products["Rivets"].push(new opt("../../Products/Rivets/riveting_tools.php", "> Riveting Tools"));
products["Rivets"].push(new opt("../../Products/Rivets/stainless_steel_steel_rivets.php", "> Stainless Steel/ Steel rivets"));
products["Rivets"].push(new opt("../../Products/Rivets/steel_steel_rivets.php", "> Steel/ Steel Rivets"));

products["Tools"].push(new opt("Select a Product", "Select a Product"));
products["Tools"].push(new opt("../../Products/Tools/auger_bits.php", "> Auger Bits"));
products["Tools"].push(new opt("../../Products/Tools/caulking_guns.php", "> Caulking Guns"));
products["Tools"].push(new opt("../../Products/Tools/cutting_wheels.php", "> Cutting Wheels"));
products["Tools"].push(new opt("../../Products/Tools/hacksaw_blades.php", "> Hacksaw Blades"));
products["Tools"].push(new opt("../../Products/Tools/hacksaw_frame.php", "> Hacksaw Frame"));
products["Tools"].push(new opt("../../Products/Tools/hss_drill_bits.php", "> HSS Drill Bits"));
products["Tools"].push(new opt("../../Products/Tools/kut_wise_arbors_accessories.php", "> Kut wise Arbors & Accessories"));
products["Tools"].push(new opt("../../Products/Tools/kut_wise_hss_holesaw_kits.php", "> Kut wise HSS Holesaw Kits"));
products["Tools"].push(new opt("../../Products/Tools/kut_wise_hss_holesaws.php", "> Kut wise HSS Holesaws"));
products["Tools"].push(new opt("../../Products/Tools/masonry_drill_bits.php", "> Masonry Drill Bits"));
products["Tools"].push(new opt("../../Products/Tools/retractable_utility_knife.php", "> Retractable Utility Knife"));
products["Tools"].push(new opt("../../Products/Tools/screw_driver_bits.php", "> Screw Driver Bits"));
products["Tools"].push(new opt("../../Products/Tools/sds_max_rotary_hammer_bits.php", "> SDS Max Rotary Hammer Bits"));
products["Tools"].push(new opt("../../Products/Tools/sds_multifit_rotary_hammer_bits.php", "> SDS Multifit Rotary Hammer Bits"));
products["Tools"].push(new opt("../../Products/Tools/smart_bit_drills.php", "> Smart Bit Drills"));
products["Tools"].push(new opt("../../Products/Tools/spade_bits.php", "> Spade Bits"));
products["Tools"].push(new opt("../../Products/Tools/tape_measure.php", "> Tape Measure"));
products["Tools"].push(new opt("../../Products/Tools/utility_knife.php", "> Utility Knife"));
products["Tools"].push(new opt("../../Products/Tools/utility_knife_blade.php", "> Utility Knife Blade"));

products["Silicone & Adhesives"].push(new opt("Select a Product", "Select a Product"));
products["Silicone & Adhesives"].push(new opt("../../Products/Silicone and Adhesives/construction_adhesive.php", "> Construction Adhesive"));
products["Silicone & Adhesives"].push(new opt("../../Products/Silicone and Adhesives/cool_room.php", "> Cool Room"));
products["Silicone & Adhesives"].push(new opt("../../Products/Silicone and Adhesives/expanding_foam.php", "> Expanding Foam"));
products["Silicone & Adhesives"].push(new opt("../../Products/Silicone and Adhesives/firerated_acrylic_sealant.php", "> Firerated Acrylic Sealant"));
products["Silicone & Adhesives"].push(new opt("../../Products/Silicone and Adhesives/fish_tank.php", "> Fish Tank"));
products["Silicone & Adhesives"].push(new opt("../../Products/Silicone and Adhesives/gap_filler.php", "> Gap Filler"));
products["Silicone & Adhesives"].push(new opt("../../Products/Silicone and Adhesives/never_nail.php", "> Never Nail"));
products["Silicone & Adhesives"].push(new opt("../../Products/Silicone and Adhesives/polyurethane_sealant.php", "> Polyurethane Sealant"));
products["Silicone & Adhesives"].push(new opt("../../Products/Silicone and Adhesives/roof_gutter_silicone.php", "> Roof and Gutter Silicone"));
products["Silicone & Adhesives"].push(new opt("../../Products/Silicone and Adhesives/sanitary_silicone.php", "> Sanitary Silicone"));
products["Silicone & Adhesives"].push(new opt("../../Products/Silicone and Adhesives/window_glass_silicone.php", "> Window and Glass Silicone"));

products["Nails"].push(new opt("Select a Product", "Select a Product"));
products["Nails"].push(new opt("../../Products/Nails/blued_cut_tacks.php", "> Blued Cut Tacks"));
products["Nails"].push(new opt("../../Products/Nails/bracket_nails.php", "> Bracket Nails"));
products["Nails"].push(new opt("../../Products/Nails/brads.php", "> Brads"));
products["Nails"].push(new opt("../../Products/Nails/bullet_head.php", "> Bullet Head"));
products["Nails"].push(new opt("../../Products/Nails/clouts.php", "> Clouts"));
products["Nails"].push(new opt("../../Products/Nails/concrete_nails.php", "> Concrete Nails"));
products["Nails"].push(new opt("../../Products/Nails/connector_plate_nails.php", "> Connector Plate Nails"));
products["Nails"].push(new opt("../../Products/Nails/corrugated_fasteners.php", "> Corrugated Fasteners"));
products["Nails"].push(new opt("../../Products/Nails/decking_nails.php", "> Decking Nails"));
products["Nails"].push(new opt("../../Products/Nails/deck_spikes.php", "> Deck Spikes"));
products["Nails"].push(new opt("../../Products/Nails/escutheon_pins.php", "> Escutheon Pins"));
products["Nails"].push(new opt("../../Products/Nails/fibre_cement_nails.php", "> Fibre Cement Nails"));
products["Nails"].push(new opt("../../Products/Nails/flat_head_nails.php", "> Flat Head Nails"));
products["Nails"].push(new opt("../../Products/Nails/hardboard_nails.php", "> Hardboard Nails"));
products["Nails"].push(new opt("../../Products/Nails/particle_board_nails.php", "> Particle Board Nails"));
products["Nails"].push(new opt("../../Products/Nails/plasterboard_nails.php", "> Plasterboard Nails"));
products["Nails"].push(new opt("../../Products/Nails/roofing_nails.php", "> Roofing Nails"));
products["Nails"].push(new opt("../../Products/Nails/soft_sheet_nails.php", "> Soft Sheet Nails"));
products["Nails"].push(new opt("../../Products/Nails/staples.php", "> Staples"));
products["Nails"].push(new opt("../../Products/Nails/underlay_nails.php", "> Underlay Nails"));
products["Nails"].push(new opt("../../Products/Nails/wallboard_nails.php", "> Wallboard Nails"));

products["Miscellaneous"].push(new opt("Select a Product", "Select a Product"));
products["Miscellaneous"].push(new opt("../../Products/Miscellaneous/duct_packaging_tape.php", "> Duct & Packaging Tape"));
products["Miscellaneous"].push(new opt("../../Products/Miscellaneous/dust_masks.php", "> Dust Masks"));
products["Miscellaneous"].push(new opt("../../Products/Miscellaneous/merchandise_stands.php", "> Merchandise Stands"));
products["Miscellaneous"].push(new opt("../../Products/Miscellaneous/safety_goggle.php", "> Safety Goggle"));
products["Miscellaneous"].push(new opt("../../Products/Miscellaneous/supra_bins.php", "> Supra Bins"));
products["Miscellaneous"].push(new opt("../../Products/Miscellaneous/tilit_bins.php", "> Tilit Bins"));
products["Miscellaneous"].push(new opt("../../Products/Miscellaneous/window_packers.php", "> Window Packers"));

products["Framing Nails"].push(new opt("Select a Product", "Select a Product"));
products["Framing Nails"].push(new opt("../../Products/Framing Nails/framing_nail_tool.php", "> Framing Nail Tool"));
products["Framing Nails"].push(new opt("../../Products/Framing Nails/gas_fuel_cells.php", "> Gas Fuel Cells"));
products["Framing Nails"].push(new opt("../../Products/Framing Nails/framing_nails.php", "> Framing Nails"));

// This is the function that will actually change the options list
// of the second dropdown based on the selected value of the first.
function sync_products(categorySelect, productSelect)
{
    var id   = categorySelect[categorySelect.selectedIndex].value;
    var name = categorySelect[categorySelect.selectedIndex].text;
    
    clearOptions(productSelect);

    if (id == 0)
    {
        productSelect.options[0] =  new Option('Select a Category First', 0);
        productSelect.disabled   = true;
        productSelect.size       = 1;
    }
    else
    {
        var categoryProducts = products[id];
        for (var i in categoryProducts)
        {
            productSelect.options[productSelect.options.length] = new Option(categoryProducts[i].text, categoryProducts[i].value);
        }
        productSelect.disabled = false;
    }
}