var dynamicOptionListCount=0;var dynamicOptionListObjects=new Array();function initDynamicOptionLists(){for(var n=0;n<dynamicOptionListObjects.length;n++){var h=dynamicOptionListObjects[n];if(h.formName!=null){h.form=document.forms[h.formName]}else{if(h.formIndex!=null){h.form=document.forms[h.formIndex]}else{var a=h.fieldNames[0][0];for(var o=0;o<document.forms.length;o++){if(typeof(document.forms[o][a])!="undefined"){h.form=document.forms[o];break}}if(h.form==null){alert("ERROR: Couldn't find form element "+a+" in any form on the page! Init aborted");return}}}for(var g=0;g<h.fieldNames.length;g++){for(var e=0;e<h.fieldNames[g].length-1;e++){var p=h.form[h.fieldNames[g][e]];if(typeof(p)=="undefined"){alert("Select box named "+h.fieldNames[g][e]+" could not be found in the form. Init aborted");return}if(e==0){if(p.options!=null){for(l=0;l<p.options.length;l++){var c=p.options[l];var d=h.findMatchingOptionInArray(h.options,c.text,c.value,false);if(d!=null){var b=c.selected;var q=new Option(c.text,c.value,c.defaultSelected,c.selected);q.selected=c.selected;q.defaultSelected=c.defaultSelected;q.DOLOption=d;p.options[l]=q;p.options[l].selected=b}}}}if(p.onchange==null){p.onchange=new Function("dynamicOptionListObjects["+h.index+"].change(this)")}}}}resetDynamicOptionLists()}function resetDynamicOptionLists(a){for(var c=0;c<dynamicOptionListObjects.length;c++){var d=dynamicOptionListObjects[c];if(typeof(a)=="undefined"||a==null||a==d.form){for(var b=0;b<d.fieldNames.length;b++){d.change(d.form[d.fieldNames[b][0]],true)}}}}function DOLOption(e,d,c,b,a){this.text=e;this.value=d;this.defaultSelected=c;this.selected=b;this.leftMargin=a;this.options=new Array();return this}function DynamicOptionList(){this.form=null;this.options=new Array();this.longestString=new Array();this.numberOfOptions=new Array();this.currentNode=null;this.currentField=null;this.currentNodeDepth=0;this.fieldNames=new Array();this.formIndex=null;this.formName=null;this.fieldListIndexes=new Object();this.fieldIndexes=new Object();this.selectFirstOption=true;this.numberOfOptions=new Array();this.longestString=new Array();this.values=new Object();this.forValue=DOL_forValue;this.forText=DOL_forText;this.forField=DOL_forField;this.forX=DOL_forX;this.addOptions=DOL_addOptions;this.addOptionsTextValue=DOL_addOptionsTextValue;this.setDefaultOptions=DOL_setDefaultOptions;this.setValues=DOL_setValues;this.setValue=DOL_setValues;this.setFormIndex=DOL_setFormIndex;this.setFormName=DOL_setFormName;this.printOptions=DOL_printOptions;this.addDependentFields=DOL_addDependentFields;this.change=DOL_change;this.child=DOL_child;this.selectChildOptions=DOL_selectChildOptions;this.populateChild=DOL_populateChild;this.change=DOL_change;this.addNewOptionToList=DOL_addNewOptionToList;this.findMatchingOptionInArray=DOL_findMatchingOptionInArray;if(arguments.length>0){for(var a=0;a<arguments.length;a++){this.fieldListIndexes[arguments[a].toString()]=this.fieldNames.length;this.fieldIndexes[arguments[a].toString()]=a}this.fieldNames[this.fieldNames.length]=arguments}this.index=window.dynamicOptionListCount++;window.dynamicOptionListObjects[this.index]=this}function DOL_findMatchingOptionInArray(b,f,e,j){if(b==null||typeof(b)=="undefined"){return null}var h=null;var g=null;for(var d=0;d<b.length;d++){var c=b[d];if(c.value==e&&c.text==f){return c}if(!j){if(h==null&&e!=null&&c.value==e){h=c}if(g==null&&f!=null&&c.text==f){g=c}}}return(h!=null)?h:g}function DOL_forX(c,b){if(this.currentNode==null){this.currentNodeDepth=0}var a=(this.currentNode==null)?this:this.currentNode;var d=this.findMatchingOptionInArray(a.options,(b=="text")?c:null,(b=="value")?c:null,false);if(d==null){d=new DOLOption(null,null,false,false,false);d[b]=c;a.options[a.options.length]=d}this.currentNode=d;this.currentNodeDepth++;return this}function DOL_forValue(a){return this.forX(a,"value")}function DOL_forText(a){return this.forX(a,"text")}function DOL_forField(a){this.currentField=a;return this}function DOL_addNewOptionToList(b,h,f,e,d){var g=new DOLOption(h,f,e,false,d);if(b==null){b=new Array()}for(var c=0;c<b.length;c++){if(b[c].text==g.text&&b[c].value==g.value){if(g.selected){b[c].selected=true}if(g.defaultSelected){b[c].defaultSelected=true}return b}}b[b.length]=g}function DOL_addOptions(){if(this.currentNode==null){this.currentNode=this}if(this.currentNode.options==null){this.currentNode.options=new Array()}for(var a=0;a<arguments.length;a++){var b=arguments[a];this.addNewOptionToList(this.currentNode.options,b,b,false,false);if(typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined"){this.numberOfOptions[this.currentNodeDepth]=0}if(this.currentNode.options.length>this.numberOfOptions[this.currentNodeDepth]){this.numberOfOptions[this.currentNodeDepth]=this.currentNode.options.length}if(typeof(this.longestString[this.currentNodeDepth])=="undefined"||(b.length>this.longestString[this.currentNodeDepth].length)){this.longestString[this.currentNodeDepth]=b}}this.currentNode=null;this.currentNodeDepth=0}function DOL_addOptionsTextValue(){if(this.currentNode==null){this.currentNode=this}if(this.currentNode.options==null){this.currentNode.options=new Array()}if(typeof(arguments[0])=="boolean"){var b=true;var a=1}else{var b=false;var a=0}for(a;a<arguments.length;a++){var d=arguments[a++];var c=arguments[a];this.addNewOptionToList(this.currentNode.options,d,c,false,b);if(typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined"){this.numberOfOptions[this.currentNodeDepth]=0}if(this.currentNode.options.length>this.numberOfOptions[this.currentNodeDepth]){this.numberOfOptions[this.currentNodeDepth]=this.currentNode.options.length}if(typeof(this.longestString[this.currentNodeDepth])=="undefined"||(d.length>this.longestString[this.currentNodeDepth].length)){this.longestString[this.currentNodeDepth]=d}}this.currentNode=null;this.currentNodeDepth=0}function DOL_child(c){var b=this.fieldListIndexes[c.name];var a=this.fieldIndexes[c.name];if(a<(this.fieldNames[b].length-1)){return this.form[this.fieldNames[b][a+1]]}return null}function DOL_setDefaultOptions(){if(this.currentNode==null){this.currentNode=this}for(var a=0;a<arguments.length;a++){var b=this.findMatchingOptionInArray(this.currentNode.options,null,arguments[a],false);if(b!=null){b.defaultSelected=true}}this.currentNode=null}function DOL_setValues(){if(this.currentField==null){alert("Can't call setValues() without using forField() first!");return}if(typeof(this.values[this.currentField])=="undefined"){this.values[this.currentField]=new Object()}for(var a=0;a<arguments.length;a++){this.values[this.currentField][arguments[a]]=true}this.currentField=null}function DOL_setFormIndex(a){this.formIndex=a}function DOL_setFormName(a){this.formName=a}function DOL_printOptions(c){if((navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)<=4)){var b=this.fieldIndexes[c];var a="";if(typeof(this.numberOfOptions[b])!="undefined"){for(var d=0;d<this.numberOfOptions[b];d++){a+="<OPTION>"}}a+="<OPTION>";if(typeof(this.longestString[b])!="undefined"){for(var d=0;d<this.longestString[b].length;d++){a+="_"}}document.writeln(a)}}function DOL_addDependentFields(){for(var a=0;a<arguments.length;a++){this.fieldListIndexes[arguments[a].toString()]=this.fieldNames.length;this.fieldIndexes[arguments[a].toString()]=a}this.fieldNames[this.fieldNames.length]=arguments}function DOL_change(e,g){if(g==null||typeof(g)=="undefined"){g=false}var n=this.fieldListIndexes[e.name];var d=this.fieldIndexes[e.name];var a=this.child(e);if(a==null){return}if(e.type=="select-one"){if(a.options!=null){a.options.length=0}if(e.options!=null&&e.options.length>0&&e.selectedIndex>=0){var b=e.options[e.selectedIndex];this.populateChild(b.DOLOption,a,g);this.selectChildOptions(a,g)}}else{if(e.type=="select-multiple"){var h=new Array();if(!g){for(var f=0;f<a.options.length;f++){var k=a.options[f];if(k.selected){this.addNewOptionToList(h,k.text,k.value,k.defaultSelected,k.leftMargin)}}}a.options.length=0;if(e.options!=null){var p=e.options;for(var f=0;f<p.length;f++){if(p[f].selected){this.populateChild(p[f].DOLOption,a,g)}}var j=false;if(!g){for(var f=0;f<a.options.length;f++){var c=this.findMatchingOptionInArray(h,a.options[f].text,a.options[f].value,true);if(c!=null){a.options[f].selected=true;j=true}}}if(!j){this.selectChildOptions(a,g)}}}}this.change(a,g)}function DOL_populateChild(g,c,h){if(g!=null&&g.options!=null){var n="";for(var e=0;e<g.options.length;e++){var i=g.options[e];if(c.options==null){c.options=new Array()}var f=false;var b=false;for(var d=0;d<c.options.length;d++){var m=c.options[d];if(m.text==i.text&&m.value==i.value){f=true;break}}if(!f){var a=new Option(i.text,i.value,false,false);a.selected=false;a.defaultSelected=false;if(typeof(i.value)=="undefined"){if(Browser.ie){a.style.color="#AAAAAA"}a.disabled=true}else{if(i.leftMargin){if(Browser.firefox){a.style.marginLeft="10px"}else{a.text="- "+a.text}}}a.DOLOption=i;c.options[c.options.length]=a}}if(Browser.ie){c.onclick=function(){if(c.options[c.selectedIndex].disabled){c.selectedIndex=-1}return true}}}}function DOL_selectChildOptions(e,h){var b=this.values[e.name];var d=false;if(h&&b!=null&&typeof(b)!="undefined"){for(var c=0;c<e.options.length;c++){var a=e.options[c].value;if(a!=null&&b[a]!=null&&typeof(b[a])!="undefined"){d=true;break}}}var g=false;for(var c=0;c<e.options.length;c++){var f=e.options[c];if(d&&f.value!=null&&b[f.value]!=null&&typeof(b[f.value])!="undefined"){f.selected=true;g=true}else{if(!d&&f.DOLOption!=null&&f.DOLOption.defaultSelected){f.selected=true;g=true}else{f.selected=false}}}if(this.selectFirstOption&&!g&&e.options.length>0){for(var c=0;c<e.options.length;c++){var f=e.options[c];if(f.disabled){continue}f.selected=true;break}}else{if(!g&&e.type=="select-one"){e.selectedIndex=-1}}};
