﻿function RemoveAll(listBox)
{
    if (listBox != null)
    {
	    listBox.style.display = "block";
	    listBox.selectedIndex = -1;
	    
	    for (var i = 0; i < listBox.options.length; i++)
	        listBox.options[i] = null;
	}
}

function AddItems(listBox, oValue)
{
	if (listBox != null)
	{
        var objOption = document.createElement("option");
	    listBox.options.add(objOption);  
	    objOption.value = oValue;
	    objOption.text = oValue;
	}
}

function UpdateDDL(ddlValue, opType1, opType2)
{
    document.getElementById('opt2').style.display = "none";
    document.getElementById(opType2).style.display = "none";
    document.getElementById('opt1').style.display = "block";
    
    var listBox = document.getElementById(opType1);
    RemoveAll(listBox);
   
    switch (ddlValue)
    {
        case 'K-12-School': 
        {
            AddItems(listBox, 'District');
            AddItems(listBox, 'Elementary');
            AddItems(listBox, 'Middle School/Jr. High');
            AddItems(listBox, 'High School');
            break;
        }
        case 'College and University':
        {
            AddItems(listBox, 'Meal Plans');
            AddItems(listBox, 'Campus Eating');
            AddItems(listBox, 'C&U - C-Store');
            AddItems(listBox, 'Fraternity/Sorority');
            break;
        }
        case 'Healthcare':
        {
            AddItems(listBox, 'Hospital');
            AddItems(listBox, 'CCRC');
            AddItems(listBox, 'Assisted Living');
            AddItems(listBox, 'Nursing Home');
            break;
        }
        case 'Lodging':
        {
            AddItems(listBox, 'Limited Service');
            AddItems(listBox, 'Full Service');
            break;
        }
        case 'Commercial and Restaurant':
        {
            AddItems(listBox, 'Casual/Bistro/Grill/Dinner House');
            AddItems(listBox, 'Family/Buffet/Salad Soup');
            AddItems(listBox, 'Limited Service');
            AddItems(listBox, 'QSR/Specialty/Chain');
            document.getElementById('opt2').style.display = "block";
            document.getElementById(opType2).style.display = "block";
            break;
        }
        case 'Travel & Leisure':
        {
            AddItems(listBox, 'Casinos');
            AddItems(listBox, 'Camps');
            AddItems(listBox, 'Cruise Lines');
            AddItems(listBox, 'Recreation');
            AddItems(listBox, 'Catering');
            AddItems(listBox, 'Airlines');
            break;
        }
        case 'Military' :
        {
            AddItems(listBox, 'Air Force');
            AddItems(listBox, 'JSPV');
            AddItems(listBox, 'NAPA');
            break;
        }
        case 'Bakery' :
        {
            AddItems(listBox, 'In-Store Supermarket');
            AddItems(listBox, 'Traditional Retail Bakery');
            AddItems(listBox, 'Wholesale');
            break;
        }
        case 'Other' :
        {
            AddItems(listBox, 'Correctional');
            AddItems(listBox, 'Daycare/Preschool');
            AddItems(listBox, 'Government');
            break;
        }
        default:
        {
            document.getElementById('opt1').style.display = "none";
            document.getElementById(opType1).style.display = "none";
            break;
        }
    }
}
