// JavaScript Document

function updateDD(ele, target){
	var optID = Number(ele.value);
	//erases the currently displayed options in the target dropdown menu
	for(var z=target.options.length-1; z>-1; z--){
		target.options[z] = null;
	}
	//if (optID > 0){
		//alert(typeof(this.opts));
		target.options[0] = new Option("---Please Select---", "");
		//populates the target dropdown menu
		for(var j=0; j<this.opts.length; j++){		
			if(this.opts[j].id == optID){					
				for(var d=0; d<this.opts[j].opts.length; d++){					
					target.options[d+1] = new Option(this.opts[j].opts[d].text, this.opts[j].opts[d].value); 
				}
				break;
			}
		}
		target.options[0].selected = true;//selects the first index as a default
	//}	
}

function optionData(text, value){
	this.text = text;
	this.value = value;
}

function addDD2option(text, value){
	this.opts[this.dd2Index] = new optionData(text, value);	
	this.dd2Index++;
}

function dd1Option(id, name){
	this.name = (name == null) ? '' : name;
	this.id = id;
	this.opts = new Array();
	this.dd2Index = 0;
	
	this.addDD2Option = addDD2option;
}

function addDD1option(id, name){
	this.dd1Index++;
	this.opts[this.dd1Index] = new dd1Option(id, name);	
}

function dropdownGroup(name){
	this.name = (name == null) ? '' : name;
	this.opts = new Array();
	this.dd1Index = -1;
	
	this.addDD1Option = addDD1option;
	this.update = updateDD;
}