var menu1_disp = new Object();
var menu2_disp = new Object();
var menu1_length = 13;
var menu2_length = 0;
		
menu1_disp['Bath'] = "Bath"
menu1_disp['Cosmetic'] = "Cosmetic"
menu1_disp['Extract'] = "Extract"
menu1_disp['Gift/Accessory'] = "Gift/Accessory"
menu1_disp['Herb'] = "Herb"
menu1_disp['Incense'] = "Incense"
menu1_disp['Miscellaneous'] = "Miscellaneous"
menu1_disp['Oil'] = "Oil"
menu1_disp['Pet'] = "Pet"
menu1_disp['Potpourri'] = "Potpourri"
menu1_disp['Spice'] = "Spice"
menu1_disp['Tea'] = "Tea"

//Create a double-dimensional Array
for (var i in menu1_disp) {
	menu2_disp[i] = new Object();
}

menu2_disp['Bath']['Herbal'] = "Herbal"
menu2_disp['Bath']['Soap'] = "Soap"
menu2_disp['Bath']['Waters'] = "Waters"
menu2_disp['Cosmetic']['Clay'] = "Clay"
menu2_disp['Cosmetic']['Creams'] = "Creams"
menu2_disp['Cosmetic']['Henna'] = "Henna"
menu2_disp['Extract']['Chinese'] = "Chinese"
menu2_disp['Extract']['Herbal'] = "Herbal"
menu2_disp['Extract']['Japan'] = "Japan"
menu2_disp['Herb']['Accessories'] = "Accessories"
menu2_disp['Herb']['Chinese'] = "Chinese"
menu2_disp['Herb']['Crafts'] = "Crafts"
menu2_disp['Herb']['Gums/Resins'] = "Gums/Resins"
menu2_disp['Herb']['India'] = "India"
menu2_disp['Herb']['Japan'] = "Japan"
menu2_disp['Herb']['Medicinal'] = "Medicinal"
menu2_disp['Herb']['Resin/Gum'] = "Resin/Gum"
menu2_disp['Herb']['Resins/Gum'] = "Resins/Gum"
menu2_disp['Herb']['Resins/Gums'] = "Resins/Gums"
menu2_disp['Incense']['Accessories'] = "Accessories"
menu2_disp['Incense']['Cones'] = "Cones"
menu2_disp['Incense']['Native Amer'] = "Native Amer"
menu2_disp['Incense']['Powder Blend'] = "Powder Blend"
menu2_disp['Incense']['Resin'] = "Resin"
menu2_disp['Incense']['Resin/Gum'] = "Resin/Gum"
menu2_disp['Incense']['Stick'] = "Stick"
menu2_disp['Miscellaneous']['Accessories'] = "Accessories"
menu2_disp['Miscellaneous']['Creams'] = "Creams"
menu2_disp['Miscellaneous']['Gift'] = "Gift"
menu2_disp['Oil']['Base'] = "Base"
menu2_disp['Oil']['Essential'] = "Essential"
menu2_disp['Oil']['Fragrance'] = "Fragrance"
menu2_disp['Pet']['Cat'] = "Cat"
menu2_disp['Pet']['Dog'] = "Dog"
menu2_disp['Tea']['Black'] = "Black"
menu2_disp['Tea']['Blend'] = "Blend"
menu2_disp['Tea']['Green'] = "Green"
menu2_disp['Tea']['Herbal'] = "Herbal"

function createMenus () {
	//CREATE ALIASES TO MENUS IN FORM
    var category = document.frm1.maincategory;
    var subcategory = document.frm1.subcategory;

    //category.length = menu1.length + 1;
	category.length = menu1_length
	
	for (var y in menu2_disp[0]) {
			menu2_length++;
	}


    subcategory.length = menu2_length + 1; 
	
	//INITIALIZES THE MENUS TO USE FIRST RECORD
	cnt1 = 0;
    for (var y in menu1_disp) {
		 category.options[cnt1+1].text = menu1_disp[y];
         category.options[cnt1+1].value  = y;
   		 cnt1++;         
    }
    
	category.options[0].selected = true;
	subcategory.options[0].selected = true;
    
}

/******************************************************************************************************/

function updateMenus ( what ) {
    var sel = what.selectedIndex;
	var sel_value = what.form.maincategory.options[sel].value
	var sel_name = what.form.maincategory.options[sel].text

	if ( sel >= 0 && sel < menu1_length )  {
		menu2_length = 0;
		
		for (var y in menu2_disp[sel_value]) {
				menu2_length++;
		}
			    
		what.form.subcategory.length = menu2_length + 1;
		
		//CREAT SUB MENU
			cnt1 = 0;
		    for (var y in menu2_disp[sel_value]) {
				 what.form.subcategory.options[cnt1+1].text = menu2_disp[sel_value][y];
		         what.form.subcategory.options[cnt1+1].value  = y;
		   		 cnt1++;         
		    }
	} 
	what.form.subcategory.options[0].selected=true;

}

function initialize_menu(menu_val1, menu_val2, menu_val3) {
	var i;
	
		for (i=0; i< document.frm2.maincategory.length; i++) {
		  if (document.frm2.maincategory.options[i].value == menu_val1) {
		   document.frm2.maincategory.options[i].selected = true
		   updateSubCategoryId(i, document.frm2.maincategory.options[i].value, menu_val2)
		  }
		}
		
		for (i=0; i< document.frm2.req_Tier.length; i++) {
		  if (document.frm2.req_Tier.options[i].value == menu_val3) {
		   document.frm2.req_Tier.options[i].selected = true
		  }
		}

}

function updateSubCategoryId (indexnum, indexvalue, menu_val ) {
	var sel = indexnum
    var sel_value = indexvalue;
	var i;
	
	if ( sel >= 0 && sel < menu1_length )  {
		menu2_length = 0;
		
		
		for (var y in menu2_disp[sel_value]) {
				menu2_length++;
		}
	    
		document.frm2.subcategory.length = menu2_length + 1;

		//CREAT SUB MENU
			cnt1 = 0;
		    for (var y in menu2_disp[sel_value]) {
				 document.frm2.subcategory.options[cnt1+1].text = menu2_disp[sel_value][y];
		         document.frm2.subcategory.options[cnt1+1].value  = y;
		   		 cnt1++;         
		    }
	}
	
	// SET THE subcategory TO SELECTED
	for (i=0; i< document.frm2.subcategory.length; i++) {
	  if (document.frm2.subcategory.options[i].value == menu_val) {
	   document.frm2.subcategory.options[i].selected = true
	  }
	} 
	//document.frm2.subcategory.options[0].selected=true;

}
// end of hiding -->