// Author: Paul Berry - PBerry@CirrusSoftware.com   

var iArrayMax = 8
var aDropdown = new Array(iArrayMax)

// As the page loads - first thing to do is to load the dropdown array
var bOk = LoadArrays()

function LoadArrays() {
// This can be thought of as an object array, each element can be identified as a property of the array position.
Array[0] = new sElement('Steel Blue','S','S')
Array[1] = new sElement('Steel Blue','M','M')
Array[2] = new sElement('Steel Blue','XL','XL')
Array[3] = new sElement('White','S','S')
Array[4] = new sElement('White','M','M')
Array[5] = new sElement('White','L','L')
Array[6] = new sElement('Light Blue','S','S')
Array[7] = new sElement('Light Blue','M','M')
Array[8] = new sElement('Light Blue','L','L')

return true
}

function sElement(sParentId,sValue,sDescription) {	
// Elements that will be loaded into the array structure and persistent. Think of it as an object.
this.ParentId = sParentId
this.Id = sValue
this.Description = sDescription
}

function bCascadeDrop(oDDsource,oDDdest) {
//function to enable cascading dropdowns
//called as the parent dropdown changes.
var iX
var sText
var iY= 0
var sOptionId
var sOptionDesc
var iStartPos
		
// Find the value of the item currently selected		
sText = oDDsource.options[oDDsource.selectedIndex].value 
if (sText != '0') {
//clear down the destination list box
oDDdest.options.length = 0                

// Loop through the elements that are in the array
// If they match the parent if then they should be displayed.

for (iX=0; iX<=iArrayMax; iX++) {		
if (sText == Array[iX].ParentId) {
// Grab the values out of the element (Netscape is not happy doing too many things in a function call!)
sOptionId = Array[iX].Id
sOptionDesc= Array[iX].Description
// alert (sOptionDesc)
			
// Write the element into the dripdown box.		
oDDdest.options[iY] = new Option (sOptionDesc,sOptionId)	
iY = iY +1		
}	
}	
}	
}