var dynamicOptionListCount=0;var dynamicOptionListObjects=new Array();function initDynamicOptionLists(){for(var A=0;A<dynamicOptionListObjects.length;A++){var I=dynamicOptionListObjects[A];if(I.formName!=null){I.form=document.forms[I.formName]}else{if(I.formIndex!=null){I.form=document.forms[I.formIndex]}else{var H=I.fieldNames[0][0];for(var J=0;J<document.forms.length;J++){if(typeof(document.forms[J][H])!="undefined"){I.form=document.forms[J];break}}if(I.form==null){alert("ERROR: Couldn't find form element "+H+" in any form on the page! Init aborted");return}}}for(var B=0;B<I.fieldNames.length;B++){for(var C=0;C<I.fieldNames[B].length-1;C++){var G=I.form[I.fieldNames[B][C]];if(typeof(G)=="undefined"){alert("Select box named "+I.fieldNames[B][C]+" could not be found in the form. Init aborted");return}if(C==0){if(G.options!=null){for(l=0;l<G.options.length;l++){var K=G.options[l];var D=I.findMatchingOptionInArray(I.options,K.text,K.value,false);if(D!=null){var F=K.selected;var E=new Option(K.text,K.value,K.defaultSelected,K.selected);E.selected=K.selected;E.defaultSelected=K.defaultSelected;E.DOLOption=D;G.options[l]=E;G.options[l].selected=F}}}}if(G.onchange==null){G.onchange=new Function("dynamicOptionListObjects["+I.index+"].change(this)")}}}}resetDynamicOptionLists()}function resetDynamicOptionLists(D){for(var C=0;C<dynamicOptionListObjects.length;C++){var B=dynamicOptionListObjects[C];if(typeof(D)=="undefined"||D==null||D==B.form){for(var A=0;A<B.fieldNames.length;A++){B.change(B.form[B.fieldNames[A][0]],true)}}}}function DOLOption(D,A,B,C){this.text=D;this.value=A;this.defaultSelected=B;this.selected=C;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(D,G,E,H){if(D==null||typeof(D)=="undefined"){return null}var C=null;var B=null;for(var A=0;A<D.length;A++){var F=D[A];if(F.value==E&&F.text==G){return F}if(!H){if(C==null&&E!=null&&F.value==E){C=F}if(B==null&&G!=null&&F.text==G){B=F}}}return(C!=null)?C:B}function DOL_forX(A,C){if(this.currentNode==null){this.currentNodeDepth=0}var D=(this.currentNode==null)?this:this.currentNode;var B=this.findMatchingOptionInArray(D["options"],(C=="text")?A:null,(C=="value")?A:null,false);if(B==null){B=new DOLOption(null,null,false,false);B[C]=A;D.options[D.options.length]=B}this.currentNode=B;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(C,F,A,D){var B=new DOLOption(F,A,D,false);if(C==null){C=new Array()}for(var E=0;E<C.length;E++){if(C[E].text==B.text&&C[E].value==B.value){if(B.selected){C[E].selected=true}if(B.defaultSelected){C[E].defaultSelected=true}return C}}C[C.length]=B}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);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()}for(var B=0;B<arguments.length;B++){var C=arguments[B++];var A=arguments[B];this.addNewOptionToList(this.currentNode.options,C,A,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"||(C.length>this.longestString[this.currentNodeDepth].length)){this.longestString[this.currentNodeDepth]=C}}this.currentNode=null;this.currentNodeDepth=0}function DOL_child(C){var A=this.fieldListIndexes[C.id];var B=this.fieldIndexes[C.id];if(B<(this.fieldNames[A].length-1)){return this.form[this.fieldNames[A][B+1]]}return null}function DOL_setDefaultOptions(){if(this.currentNode==null){this.currentNode=this}for(var B=0;B<arguments.length;B++){var A=this.findMatchingOptionInArray(this.currentNode.options,null,arguments[B],false);if(A!=null){A.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(A){if((navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)<=4)){var C=this.fieldIndexes[A];var D="";if(typeof(this.numberOfOptions[C])!="undefined"){for(var B=0;B<this.numberOfOptions[C];B++){D+="<OPTION>"}}D+="<OPTION>";if(typeof(this.longestString[C])!="undefined"){for(var B=0;B<this.longestString[C].length;B++){D+="_"}}document.writeln(D)}}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(A,G){if(G==null||typeof(G)=="undefined"){G=false}var I=this.fieldListIndexes[A.id];var E=this.fieldIndexes[A.id];var L=this.child(A);if(L==null){return}if(A.type=="select-one"){if(L.options!=null){L.options.length=0}if(A.options!=null&&A.options.length>0&&A.selectedIndex>=0){var D=A.options[A.selectedIndex];this.populateChild(D.DOLOption,L,G);if(window.dynamicOptionListCount==1&&E==1){ecf_PurchaseModule_PurchaseOptionChanged1(D.DOLOption)}this.selectChildOptions(L,G)}}else{if(A.type=="select-multiple"){var J=new Array();if(!G){for(var K=0;K<L.options.length;K++){var H=L.options[K];if(H.selected){this.addNewOptionToList(J,H.text,H.value,H.defaultSelected)}}}L.options.length=0;if(A.options!=null){var F=A.options;for(var K=0;K<F.length;K++){if(F[K].selected){this.populateChild(F[K].DOLOption,L,G)}}var B=false;if(!G){for(var K=0;K<L.options.length;K++){var C=this.findMatchingOptionInArray(J,L.options[K].text,L.options[K].value,true);if(C!=null){L.options[K].selected=true;B=true}}}if(!B){this.selectChildOptions(L,G)}}}}this.change(L,G)}function DOL_populateChild(C,I,E){if(C!=null&&C.options!=null){for(var A=0;A<C.options.length;A++){var J=C.options[A];if(I.options==null){I.options=new Array()}var D=false;var H=false;for(var B=0;B<I.options.length;B++){var F=I.options[B];if(F.text==J.text&&F.value==J.value){D=true;break}}if(!D){var G=new Option(J.text,J.value,false,false);G.selected=false;G.defaultSelected=false;G.DOLOption=J;I.options[I.options.length]=G}}}}function DOL_selectChildOptions(A,E){var F=this.values[A.id];var C=false;if(E&&F!=null&&typeof(F)!="undefined"){for(var G=0;G<A.options.length;G++){var H=A.options[G].value;if(H!=null&&F[H]!=null&&typeof(F[H])!="undefined"){C=true;break}}}var B=false;for(var G=0;G<A.options.length;G++){var D=A.options[G];if(C&&D.value!=null&&F[D.value]!=null&&typeof(F[D.value])!="undefined"){D.selected=true;B=true}else{if(!C&&D.DOLOption!=null&&D.DOLOption.defaultSelected){D.selected=true;B=true}else{D.selected=false}}}if(this.selectFirstOption&&!B&&A.options.length>0){A.options[0].selected=true}else{if(!B&&A.type=="select-one"){A.selectedIndex=-1}}};
