//############# begin smartSelect class definitions  ###################//
	
	function smartSelect(p_varRef,p_name,p_data,p_optionSelected,p_rules){
		this.optionData = p_data; // a simple array of default options
		this.optionSelected = p_optionSelected;  // (by value reference)
		this.name = p_name;
		this.varRef = p_varRef;
		this.rules = p_rules;
		return this;
	}
	
	
	function selectRender(){
		if(this.optionData != null){
			var tmpHTML = '<select id="' + this.name + '" name="' + this.name + '" onChange="' + this.varRef + '.setChildren();" class="general">\n'
			for(nn = 0;nn < this.optionData.length;nn++){
				if(this.optionData[nn].val == this.optionSelected){
					tmpHTML += '<option value="' + this.optionData[nn].val + '" SELECTED>' + this.optionData[nn].label;
				}else{
					tmpHTML += '<option value="' + this.optionData[nn].val + '">' + this.optionData[nn].label;
				}
			}
			tmpHTML += '<' + '/select>';
		}else{
			var tmpHTML = '<select id="' + this.name + '" name="' + this.name + '" onChange="' + this.varRef + '.setChildren();" DISABLED>\n'
			tmpHTML += '<option>---------------<' + '/select>';
		}
		document.write(tmpHTML);
	}
	
	function setSelectChildren(){
		//var objRef = eval('document.forms[0].' + this.name); // convert to an object
		if(this.rules != null){
			// we need to loop through the rules structure
			var parentObj = eval('document.forms[0].' + this.name)
			var parentVal = parentObj.options[parentObj.selectedIndex].value;
			//alert("debug:" + parentVal);
			for(ss=0;ss<this.rules.length;ss++){  // for each select that is a child
				var objRef = eval('document.forms[0].' + this.rules[ss].target); // convert to an object
				//alert("test parent:" + parentObj.name)
				for(oo=0;oo < this.rules[ss].ruleData.length;oo++){  // for each country in the rules list
					//alert("dedbug: " + this.rules[ss].ruleData[oo].val +" : " +  parentVal);
					if((this.rules[ss].ruleData[oo].val == parentVal) || (oo == this.rules[ss].ruleData.length - 1)){ // matches the select in the data
						objRef.options.length=0;
						for(rr=0;rr < this.rules[ss].ruleData[oo].options.length;rr++){
							objRef.options[objRef.options.length] = new Option(this.rules[ss].ruleData[oo].options[rr].label,this.rules[ss].ruleData[oo].options[rr].val,(this.rules[ss].ruleData[oo].options[rr].selected==true) ? true:false);
						}
						objRef.disabled = false
						break;
					}//else{
						//objRef.options.length=0;
						//objRef.options[objRef.options.length] = new Option('----------','zz',true);
						//objRef.disabled = true
					//}
				}
			}
		}	
	}
	

	function ruleClass(p_target,p_ruleData){
		this.target= p_target;
		this.ruleData = p_ruleData;
		return this;
	}
	
	function ruleDataClass(p_val,p_options){
		this.val=p_val;
		this.options=p_options;
		return this;
	}
	
	function optionClass(p_val,p_label,p_selected){
		this.val = p_val;
		this.label = p_label;
		this.selected = p_selected;
		return this;
	}
	
	smartSelect.prototype.render = selectRender;
	smartSelect.prototype.setChildren = setSelectChildren;
	
	// #########  end smartSelect definitions  ###################//
