/*******
** vp  - Triodos independency script - (c) Indivirtual 2008-2009 - 0.6.9 **	
*******/


Element = function(oObj, sClassName, sPIndex, isElement, sOptionIndex) {
    this.sPIndex = sPIndex
    this.oObj = oObj;
    this.sClassName = sClassName;
    this.sOptionIndex = sOptionIndex;
    this.aChilds = new Array();
    this.isElement = isElement;
	
    if ( (this.sClassName != 'form') && (this.oObj.tagName.toLowerCase() != 'option') && (this.oObj.tagName.toLowerCase() != 'select')  && (this.oObj.tagName.toLowerCase() != 'div') ) {
        EventListener.addEvent(this.oObj, "click", this._setEvents, this);
    }
    if ( (this.sClassName != 'form') && (this.oObj.tagName.toLowerCase() == 'select') ) {
        EventListener.addEvent(this.oObj, "change", this._setEvents, this);
    }
    if ( (this.sClassName != 'form') && (this.sClassName.indexOf("example") != -1) ) {
        if ( (/</i.test(this.oObj.value)) && (/>/i.test(this.oObj.value))  ) {
            EventListener.addEvent(this.oObj, "focus", this._removePrefilled, this);
        }
        else {
            ClassName.remove(this.oObj, 'example');	
        }
    }
 	
 	if ( (this.sClassName != 'form') && (this.sClassName.indexOf("cQAS") != -1) ) {
		ClassName.add(this.oObj, 'disabled');
		this.oObj.disabled = true;
	}

	if ( (this.sClassName == 'form') && (this.oObj.id == 'FORMID') ) {
        ClassName.remove(this.oObj, 'pLoading');
    }

}


Element.prototype = {
	
    _addChild:function(elX) {
        if(this.aChilds == null) {
            this.aChilds = new Array();
        }
        this.aChilds.push(elX);
    },
	
    fillParents:function(parent, els) {
        for (var x=0; x<els.length; x++) {
			
            /*  select */
            if (/select/i.test(els[x].tagName.toLowerCase()) ) {
                var elParent = new Element(els[x], '', '', els[x].tagName.toLowerCase(), '');
                parent._addChild(elParent);
                this._fillOptions(elParent, els[x].options, els)
            }
            /*  input (example class) */
            else if ( (els[x].className.indexOf("pState") != -1 ) && (els[x].tagName.toLowerCase() != 'option') || (els[x].className.indexOf("example") != -1 ) ) { 
                var pStateIndex = this._stripeClass(els[x].className, 'pState', 6, 8);
                var onloadStateVar = this._preloadState(els[x].className); // check for onload state variable "formActHide"
				
                if ( /radio/i.test(els[x].type) ) {
                    var radioGroup = document.getElementsByName(els[x].name);
                    for (var i=0; i<radioGroup.length; i++) {
                        if (radioGroup[i].className.indexOf('pState' + pStateIndex) == -1) {
                            var elParentGroup = new Element(radioGroup[i], radioGroup[i].className += ' resetPreviousSetRadioStates' + pStateIndex, pStateIndex);
                            parent._addChild(elParentGroup);
                        }
                    }
                }
				
                if ( /false/i.test(els[x].checked) ) {
                    onloadState = (onloadStateVar == true) ? false : true;  /** disabled = false : enabled = true **/
                }
                else {
                    if (els[x].className.indexOf("disabled") != -1 ) {
                        onloadState = (onloadStateVar == true) ? false : true;  /** disabled = false : enabled = true **/
                    }
                    else {
                        onloadState = (onloadStateVar == true) ? true : false;  /** disabled = false : enabled = true **/
                    }
                }
                var elParent = new Element(els[x], els[x].className, pStateIndex)
                parent._addChild(elParent);
                this._fillChilds(elParent, els, onloadState)
            }
			else if (els[x].className.indexOf("cQAS") != -1) {
				var elementX = new Element(els[x], els[x].className);
				parent._addChild(elementX);
			}
        }
        return parent;
    },
	
    _fillOptions:function(parent, options, els) {
        /**  reset loop  **/
		for (var x=0; x<options.length; x++) {
            if ( (options[x].className.indexOf('pState') != -1) && (/false/i.test(options[x].selected)) ) {
				var pStateIndex = this._stripeClass(options[x].className, 'pState', 6, 8);
                var onloadStateVar = this._preloadState(options[x].className); // check for onload state variable "formActHide"
                var elementX = new Element(options[x], options[x].className, pStateIndex, '', x);
                parent._addChild(elementX);
				onloadState = (onloadStateVar == true) ? false : true;  /** disabled = false : enabled = true **/
                this._fillChilds(elementX, els, onloadState);
            }
        }
        /**  set Selected loop  **/
        for (var x=0; x<options.length; x++) {
            if ( (options[x].className.indexOf('pState') != -1) && (/true/i.test(options[x].selected)) ) {
				var pStateIndex = this._stripeClass(options[x].className, 'pState', 6, 8);
                var onloadStateVar = this._preloadState(options[x].className); // check for onload state variable "formActHide"
                var elementX = new Element(options[x], options[x].className, pStateIndex, '', x);
                parent._addChild(elementX);
				if (options[x].parentNode.className.indexOf("disabled") != -1 ) {
					onloadState = (onloadStateVar == true) ? false : true;  /** disabled = false : enabled = true **/
				}
				else {
					onloadState = (onloadStateVar == true) ? true : false;  /** disabled = false : enabled = true **/
				}
                this._fillChilds(elementX, els, onloadState);
            }
        }
	},

    _fillChilds:function(parent, els, onloadState) {
        if (/div/i.test(parent.oObj.tagName.toLowerCase())) {
            for (var w=0; w<els.length; w++) {
                if ( (/select/i.test(els[w].tagName)) || (/input/i.test(els[w].tagName)) ) {
                    if (els[w].className.indexOf('cState') == -1) {
                        if (onloadState == false) {
							if (!/cQAS/i.test(els[w].className) ) {
	                            els[w].disabled = true;
							}
                        }

                        /* onloadStateVar == true means > onload = hidden */
                        else {
 							if (!/cQAS/i.test(els[w].className) ) {
 	                          els[w].disabled = false;	
							}
                        }
	
                        var elementDivChild = new Element(els[w], 'noClass', '', '', '');
                        parent._addChild(elementDivChild);
                    }

                    //alert(els[w].className + " " +  onloadState + ' jajaja ');
                    //this._fillChilds(elementDivChild, els[w], onloadState);
                }
            }
        }
        else {
            for (var x=0; x<els.length; x++) {
                if(els[x].className.indexOf("cState" + parent.sPIndex) != -1) {
                    if (onloadState == false) {
						if (!/cQAS/i.test(els[x].className) ) {
							ClassName.add(els[x], "disabled");
							els[x].disabled = true;
						}
                     }
                    else if (onloadState == true) {
						if (!/cQAS/i.test(els[x].className) ) {
							ClassName.remove(els[x], "disabled");
							els[x].disabled = false;
						}
                    }
					
                    if (/div/i.test(els[x].tagName)) {
                        var elementDiv = new Element(els[x], els[x].className);
                        parent._addChild(elementDiv);
	
                        var elements = getElementsByAttributeValue('class', els[x].className);
                        for (var u=0; u<elements.length; u++) {
                            var elsD = elements[u].getElementsByTagName('*');
                            this._fillChilds(elementDiv, elsD, onloadState);
                        }
                    }

                    /* onloadStateVar == true means > onload = hidden */
                    else {
                        var elementX = new Element(els[x], els[x].className);
                        parent._addChild(elementX);
                    }
	
                    if (els[x].className.indexOf('pState') != -1) {
                        this._fillChilds(elementX, els);
                    }
                }
            }
        }
    },

    _preloadState:function(className) {
        var _onloadStateVar = (/formActHide/i.test(className)) ? true : false;
        return _onloadStateVar
    },

    _stripeClass:function(sClass, sString, nFirstEndPos, nLastEndPos) {
        var firstPos = sClass.indexOf(sString);
        sClass = sClass.slice((firstPos + nFirstEndPos), firstPos + nLastEndPos);
       // if (/00/i.test(sClass)) alert ("Please don't use change pState00.");
        return sClass;
    },

    _setEvents:function(e) {
        if (this.sClassName.indexOf("resetPreviousSetRadioStates") != -1) {
            this._resetPreviousSetRadioStatesAction();
        }
        if (this.oObj.tagName.toLowerCase() == 'select') {
            this._doAction();
        }
        if(this.sClassName.indexOf("pState") != -1) {
            this._doAction();
        }
    },
	
	
	
    _resetPreviousSetRadioStatesAction:function() {

        /**   <input type="radio" class="resetPreviousSetRadioStates" />
		---------------------------------------------- **/
        // This is only to clear the setted radiostates. !! This is not the regualar set functionality. !!
		
		
        /**  GET: All Childs from the form (every element).  **/
        for (var x=0; x<window.thisPageForm.aChilds.length; x++) {
			
            /**  CHECK: if Child == parent == PIndex  **/
            if ( window.thisPageForm.aChilds[x].sClassName.indexOf('pState'+ this.sPIndex) != -1) {

                /**  GET: onloadStateVar form the Child (Objected <options />) of the <select />[0]  **/
                var onloadStateVar = (/formActHide/i.test(window.thisPageForm.aChilds[x].oObj.className)) ? true : false; // check for onload state variable "formActHide"
                for (var a=0; a<window.thisPageForm.aChilds[x].aChilds.length; a++) {

                    /* if Child = <div />  */
                    if (/div/i.test(window.thisPageForm.aChilds[x].aChilds[a].oObj.tagName.toLowerCase())){
						
                        /* Loop thru Childs of <div /> */
                        for (var y=0; y<window.thisPageForm.aChilds[x].aChilds[a].aChilds.length; y++) {
							
                            /* onloadStateVar == true means > onload = hidden */
                            if (onloadStateVar == true) {
							
								if (!/cQAS/i.test(window.thisPageForm.aChilds[x].aChilds[a].aChilds[y].oObj.className) ) {
									window.thisPageForm.aChilds[x].aChilds[a].aChilds[y].oObj.disabled = true;
								}

								if (window.thisPageForm.aChilds[x].aChilds[a].aChilds[y].sClassName.indexOf("pState") != -1) {
									var pStateIndex = this._stripeClass(window.thisPageForm.aChilds[x].aChilds[a].aChilds[y].sClassName, 'pState', 6, 8);
									this._setNextLevels(pStateIndex, true);
								}
                            }

                            /* onloadStateVar == false means > onload = visible */
                            else {
							
								if (!/cQAS/i.test(window.thisPageForm.aChilds[x].aChilds[a].aChilds[y].oObj.className) ) {
									window.thisPageForm.aChilds[x].aChilds[a].aChilds[y].oObj.disabled = false;
								}

                                if (window.thisPageForm.aChilds[x].aChilds[a].aChilds[y].sClassName.indexOf("pState") != -1) {
                                    var pStateIndex = this._stripeClass(window.thisPageForm.aChilds[x].aChilds[a].aChilds[y].sClassName, 'pState', 6, 8);
                                    this._setNextLevels(pStateIndex, false);
                                }
                            }
                        }
                    }

                    if (onloadStateVar == true) {
							
						if (!/cQAS/i.test(window.thisPageForm.aChilds[x].aChilds[a].oObj.className) ) {
							/**  SET: everything disabled  **/
							ClassName.add(window.thisPageForm.aChilds[x].aChilds[a].oObj, "disabled");
							window.thisPageForm.aChilds[x].aChilds[a].oObj.disabled = true;
						}
						
                        /**  CHECK: Child == parent or <select />[1]  **/
                        if ( (window.thisPageForm.aChilds[x].aChilds[a].sClassName.indexOf("pState") != -1) || ( /select/i.test(window.thisPageForm.aChilds[x].aChilds[a].oObj.tagName.toLowerCase())) ) {
                            var pStateIndex = this._stripeClass(window.thisPageForm.aChilds[x].aChilds[a].sClassName, 'pState', 6, 8);
                            this._setNextLevels(pStateIndex, true);

                            if (/select/i.test(window.thisPageForm.aChilds[x].aChilds[a].oObj.tagName.toLowerCase())) {
                                for (var v=0; v<window.thisPageForm.aChilds[x].aChilds[a].oObj.options.length; v++) {
                                    if (window.thisPageForm.aChilds[x].aChilds[a].oObj.options[v].className.indexOf('pState') != -1) {
                                        if (window.thisPageForm.aChilds[x].aChilds[a].oObj.options[v].selected == true) {
                                            var pStateIndex = this._stripeClass(window.thisPageForm.aChilds[x].aChilds[a].oObj.options[v].className, 'pState', 6, 8);
                                            this._setNextLevels(pStateIndex, true);
                                        }
                                    }
                                }
                            }
                            else {
                                var pStateIndex = this._stripeClass(window.thisPageForm.aChilds[x].aChilds[a].sClassName, 'pState', 6, 8);
                                this._setNextLevels(pStateIndex, true);
                            }
                        }
                    }

                    /* onloadStateVar == false means > onload = visible */
                    else {
							
						if (!/cQAS/i.test(window.thisPageForm.aChilds[x].aChilds[a].oObj.className) ) {
						   /**  SET: everything enabled  **/
							ClassName.remove(window.thisPageForm.aChilds[x].aChilds[a].oObj, "disabled");
							window.thisPageForm.aChilds[x].aChilds[a].oObj.disabled = false;
						}
						
                         /**  CHECK: Child == parent or <select />[1]  **/
                        if ( (window.thisPageForm.aChilds[x].aChilds[a].sClassName.indexOf("pState") != -1) || ( /select/i.test(window.thisPageForm.aChilds[x].aChilds[a].oObj.tagName.toLowerCase())) ) {
                            var pStateIndex = this._stripeClass(this.aChilds[x].sClassName, 'pState', 6, 8);
                            this._setNextLevels(pStateIndex, true);
							
                            if (/select/i.test(this.aChilds[x].oObj.tagName.toLowerCase())) {
                                for (var v=0; v<this.aChilds[x].oObj.options.length; v++) {
                                    if (this.aChilds[x].oObj.options[v].className.indexOf('pState') != -1) {
                                        if (this.aChilds[x].oObj.options[v].selected == true) {
                                            var pStateIndex = this._stripeClass(this.aChilds[x].oObj.options[v].className, 'pState', 6, 8);
                                            this._setNextLevels(pStateIndex, true);
                                        }
                                    }
                                }
                            }
                            else {
                                var pStateIndex = this._stripeClass(window.thisPageForm.aChilds[x].aChilds[a].sClassName, 'pState', 6, 8);
                                this._setNextLevels(pStateIndex, true);
                            }
                        }

                    }
                }
            }
        }
    },

    _doAction:function() {

        /**   <select />
		---------------------------------------------- **/
        if ( (/select/i.test(this.oObj.tagName)) ) {
			
            /**  GET: selected index of the  <select />[0]<options /> collection  **/
            var selectedI = this.oObj.options.selectedIndex;
		
            /**  LOOP:  all Childern (Objected <options />) of the <select />[0]  **/
            for (var x=0; x<this.aChilds.length; x++) {
				
                /**  GET: onloadStateVar form the Child (Objected <options />) of the <select />[0]  **/
                var onloadStateVar = this._preloadState(this.aChilds[x].sClassName); 
				
                /**  RESET: all Childern from the Child (Objected <options />) of the <select />[0]  **/
                for (var y=0; y<this.aChilds[x].aChilds.length; y++) {

                    /**  CHECK:  onloadStateVar == true means > onload = hidden  **/
                    if (onloadStateVar == true) {
							
						if (!/cQAS/i.test(this.aChilds[x].aChilds[y].oObj.className) ) {
							/**  SET: everything disabled  **/
							ClassName.add(this.aChilds[x].aChilds[y].oObj, "disabled");
							this.aChilds[x].aChilds[y].oObj.disabled = true;
						}
						
                        /**  CHECK: Childern from the Child (Objected <options />) of the <select />[0] == parent or <select />[1]  **/
                        if ( (this.aChilds[x].aChilds[y].sClassName.indexOf("pState") != -1) || ( /select/i.test(this.aChilds[x].aChilds[y].oObj.tagName.toLowerCase())) ) {
							
                            /**  CHECK: Childern from the Child (Objected <options />) of the <select />[0] == <select />[1]  **/
                            if (/select/i.test(this.aChilds[x].aChilds[y].oObj.tagName.toLowerCase())) {
								
                                /**  LOOP: Options from <select />[1] of the the Child (Objected <options />) of the <select />[0]  **/
                                for (var v=0; v<this.aChilds[x].aChilds[y].oObj.options.length; v++) {
									
                                    /**  CHECK: Options from <select />[1] of the the Child (Objected <options />) of the <select />[0] == parent   **/
                                    if (this.aChilds[x].aChilds[y].oObj.options[v].className.indexOf('pState') != -1) {
										
                                        /**  GET and SET: Next Parent **/
                                        var pStateIndex = this._stripeClass(this.aChilds[x].aChilds[y].oObj.options[v].className, 'pState', 6, 8);
                                        this._setNextLevels(pStateIndex, true);
                                    }
                                }
                            }
							
                            /**  Childern from the Child (Objected <options />) of the <select /> == parent  **/
                            else {
								
                                /**  GET and SET: Next Parent **/
                                var pStateIndex = this._stripeClass(this.aChilds[x].aChilds[y].sClassName, 'pState', 6, 8);
                                this._setNextLevels(pStateIndex, true);
                            }
                        }
                    }

                    /* onloadStateVar == false means > onload = visible */
                    else {
							
						if (!/cQAS/i.test(this.aChilds[x].aChilds[y].oObj.className) ) {
							/**  SET: everything enabled  **/
							ClassName.remove(this.aChilds[x].aChilds[y].oObj, "disabled");
							this.aChilds[x].aChilds[y].oObj.disabled = false;
						}
                    }
                }
            }

            for (var x=0; x<this.aChilds.length; x++) {

                /**  CHECK: Child (Objected <options />) of the <select />[0] == selectedIndex  **/
                if (this.aChilds[x].sOptionIndex == selectedI) {
					
                    /**  SET: Childern from the Child (Objected <options />) of the <select />[0]  **/
                    for (var y=0; y<this.aChilds[x].aChilds.length; y++) {

                        /* onloadStateVar == true means > onload = hidden */
                        if (onloadStateVar == true) {
							
							if (!/cQAS/i.test(this.aChilds[x].aChilds[y].oObj.className) ) {
								/**  SET: everything enabled  **/
								ClassName.remove(this.aChilds[x].aChilds[y].oObj, "disabled");
								this.aChilds[x].aChilds[y].oObj.disabled = false;
							}
							
                            /**  CHECK: Childern from the Child (Objected <options />) of the <select />[0] == parent or <select />[1]  **/
                            if ( (this.aChilds[x].aChilds[y].sClassName.indexOf("pState") != -1) || ( /select/i.test(this.aChilds[x].aChilds[y].oObj.tagName.toLowerCase())) ) {

                                if (/select/i.test(this.aChilds[x].aChilds[y].oObj.tagName.toLowerCase())) {
                                    for (var v=0; v<this.aChilds[x].aChilds[y].oObj.options.length; v++) {
                                        if (this.aChilds[x].aChilds[y].oObj.options[v].className.indexOf('pState') != -1) {
                                            if (this.aChilds[x].aChilds[y].oObj.options[v].selected == true) {
                                                var pStateIndex = this._stripeClass(this.aChilds[x].aChilds[y].oObj.options[v].className, 'pState', 6, 8);
                                                this._setNextLevels(pStateIndex, false);
                                            }
                                        }
                                    }
                                }
                                else {
                                    if (this.aChilds[x].aChilds[y].oObj.checked == true) {
                                        var pStateIndex = this._stripeClass(this.aChilds[x].aChilds[y].sClassName, 'pState', 6, 8);
                                        this._setNextLevels(pStateIndex, false);
                                    }
                                }
                            }
                        }
						
                        /* onloadStateVar == false means > onload = visible */
                        else {

                      
							if (!/cQAS/i.test(this.aChilds[x].aChilds[y].oObj.className) ) {
								/**  SET: everything disabled  **/
								ClassName.add(this.aChilds[x].aChilds[y].oObj, "disabled");
								this.aChilds[x].aChilds[y].oObj.disabled = true;
							}
		
                            if ( (this.aChilds[x].aChilds[y].sClassName.indexOf("pState") != -1) || ( /select/i.test(this.aChilds[x].aChilds[y].oObj.tagName.toLowerCase())) ) {
                                if (/select/i.test(this.aChilds[x].aChilds[y].oObj.tagName.toLowerCase())) {
                                    for (var v=0; v<this.aChilds[x].aChilds[y].oObj.options.length; v++) {
                                        if (this.aChilds[x].aChilds[y].oObj.options[v].className.indexOf('pState') != -1) {
                                            var pStateIndex = this._stripeClass(this.aChilds[x].aChilds[y].oObj.options[v].className, 'pState', 6, 8);
                                            this._setNextLevels(pStateIndex, true);
                                        }
                                    }
                                }
                                else {
                                    var pStateIndex = this._stripeClass(this.aChilds[x].aChilds[y].sClassName, 'pState', 6, 8);
                                    this._setNextLevels(pStateIndex, true);
                                }
                            }
                        }
                    }
                }
            }
        }


        /*   <input type="checkbox" /> ||  <input type="radio" />
		---------------------------------------------- */
        else {
			
            /* GET defaultloadstate */
            var onloadStateVar = this._preloadState(this.sClassName);
			
            /* not checked */
            if (/false/i.test(this.oObj.checked)) {
				
                /* loop thru all Child from checkbox */
                for (var x=0; x<this.aChilds.length; x++) {
					
                    /* if Child = <div />  */
                    if (/div/i.test(this.aChilds[x].oObj.tagName.toLowerCase())){
						
                        /* Loop thru Childs of <div /> */
                        for (var y=0; y<this.aChilds[x].aChilds.length; y++) {
							
                            /* onloadStateVar == true means > onload = hidden */
                            if (onloadStateVar == true) {

								ClassName.add(this.aChilds[x].oObj, "disabled");
								if (!/cQAS/i.test(this.aChilds[x].aChilds[y].oObj.className) ) {
									this.aChilds[x].aChilds[y].oObj.disabled = true;
								}

                                if (this.aChilds[x].aChilds[y].sClassName.indexOf("pState") != -1) {
                                    var pStateIndex = this._stripeClass(this.aChilds[x].aChilds[y].sClassName, 'pState', 6, 8);
                                    this._setNextLevels(pStateIndex, true);
                                }
                            }

                            /* onloadStateVar == false means > onload = visible */
                            else {
								if (!/cQAS/i.test(this.aChilds[x].aChilds[y].oObj.className) ) {
	                                this.aChilds[x].aChilds[y].oObj.disabled = false;
								}
                            }
                        }
                    }

                    /* onloadStateVar == true means > onload = hidden */
                    if (onloadStateVar == true) {

						if (!/cQAS/i.test(this.aChilds[x].oObj.className) ) {
						   /**  SET: everything disabled  **/
							ClassName.add(this.aChilds[x].oObj, "disabled");
							this.aChilds[x].oObj.disabled = true;
						
						}
						
                         /**  CHECK: Child == parent or <select />[1]  **/
                        if ( (this.aChilds[x].sClassName.indexOf("pState") != -1) || ( /select/i.test(this.aChilds[x].oObj.tagName.toLowerCase())) ) {
 
 							if (/select/i.test(this.aChilds[x].oObj.tagName.toLowerCase())) {
                                for (var v=0; v<this.aChilds[x].oObj.options.length; v++) {
                                    if (this.aChilds[x].oObj.options[v].className.indexOf('pState') != -1) {
                                        if (this.aChilds[x].oObj.options[v].selected == true) {
                                            var pStateIndex = this._stripeClass(this.aChilds[x].oObj.options[v].className, 'pState', 6, 8);
                                            this._setNextLevels(pStateIndex, true);
                                        }
                                    }
                                }
                            }
                            else {
                                var pStateIndex = this._stripeClass(this.aChilds[x].sClassName, 'pState', 6, 8);
                                this._setNextLevels(pStateIndex, true);
                            }
                        }
                    }
			
                    /* onloadStateVar == false means > onload = visible */
                    else {

						if (!/cQAS/i.test(this.aChilds[x].oObj.className) ) {
							/**  SET: everything enabled  **/
							ClassName.remove(this.aChilds[x].oObj, "disabled");
							this.aChilds[x].oObj.disabled = false;
						}
						
                        /**  CHECK: Childern parent == parent or <select />[1]  **/
                        if ( (this.aChilds[x].sClassName.indexOf("pState") != -1) || ( /select/i.test(this.aChilds[x].oObj.tagName.toLowerCase())) ) {

                            if (/select/i.test(this.aChilds[x].oObj.tagName.toLowerCase())) {
                                for (var v=0; v<this.aChilds[x].oObj.options.length; v++) {
                                    if (this.aChilds[x].oObj.options[v].className.indexOf('pState') != -1) {
                                        if (this.aChilds[x].oObj.options[v].selected == true) {
                                            var pStateIndex = this._stripeClass(this.aChilds[x].oObj.options[v].className, 'pState', 6, 8);
                                            this._setNextLevels(pStateIndex, false);
                                        }
                                    }
                                }
                            }
                            else {
                                if (this.aChilds[x].oObj.checked == true) {
                                    var pStateIndex = this._stripeClass(this.aChilds[x].sClassName, 'pState', 6, 8);
                                    this._setNextLevels(pStateIndex, false);
                                }
                            }
                        }
                    }
                }
            }


			/**  checked  **/
			else {
                for (var x=0; x<this.aChilds.length; x++) {
					/**  CHECK : Div  **/
                    if (/div/i.test(this.aChilds[x].oObj.tagName.toLowerCase())){
                        for (var y=0; y<this.aChilds[x].aChilds.length; y++) {

                            /* onloadStateVar == true means > onload = hidden */
                            if (onloadStateVar == true) {
							  
								if (!/cQAS/i.test(this.aChilds[x].aChilds[y].oObj.className) ) {
	                                this.aChilds[x].aChilds[y].oObj.disabled = false;
								}

                                if (this.aChilds[x].aChilds[y].sClassName.indexOf("pState") != -1) {
                                    if ( (this.aChilds[x].aChilds[y].oObj.selected == true) || (this.aChilds[x].aChilds[y].oObj.checked == true) ) {
                                        var pStateIndex = this._stripeClass(this.aChilds[x].aChilds[y].sClassName, 'pState', 6, 8);
                                        this._setNextLevels(pStateIndex, false);
                                    }
                                }
                            }
							
                            /* onloadStateVar == false means > onload = visible */
                            else {
								if (!/cQAS/i.test(this.aChilds[x].aChilds[y].oObj.className) ) {
									this.aChilds[x].aChilds[y].oObj.disabled = true;
								}
                            }
                        }
                    }

                    /* onloadStateVar == true means > onload = hidden */
                    if (onloadStateVar == true) {
                      
						if (!/cQAS/i.test(this.aChilds[x].oObj.className) ) {
							ClassName.remove(this.aChilds[x].oObj, "disabled");
							this.aChilds[x].oObj.disabled = false;
						}
						
                        /**  CHECK: Child == parent or <select />[1]  **/
                        if ( (this.aChilds[x].sClassName.indexOf("pState") != -1) || ( /select/i.test(this.aChilds[x].oObj.tagName.toLowerCase())) ) {
                            var pStateIndex = this._stripeClass(this.aChilds[x].sClassName, 'pState', 6, 8);
                            this._setNextLevels(pStateIndex, true);

                            if (/select/i.test(this.aChilds[x].oObj.tagName.toLowerCase())) {
                                for (var v=0; v<this.aChilds[x].oObj.options.length; v++) {
                                    if (this.aChilds[x].oObj.options[v].className.indexOf('pState') != -1) {
                                        if (this.aChilds[x].oObj.options[v].selected == true) {
                                            var pStateIndex = this._stripeClass(this.aChilds[x].oObj.options[v].className, 'pState', 6, 8);
                                            this._setNextLevels(pStateIndex, false);
                                        }
                                    }
                                }
                            }
                            else {
                                if (this.aChilds[x].oObj.checked == true) {
                                    var pStateIndex = this._stripeClass(this.aChilds[x].sClassName, 'pState', 6, 8);
                                    this._setNextLevels(pStateIndex, false);
                                }
                            }
                        }
                    }
					
                    /* onloadStateVar == false means > onload = visible */
                    else {

						if (!/cQAS/i.test(this.aChilds[x].oObj.className) ) {
							/**  SET: everything disabled  **/
							ClassName.add(this.aChilds[x].oObj, "disabled");
							this.aChilds[x].oObj.disabled = true;
						}
						
                        /**  CHECK: Child == parent or <select />[1]  **/
                        if ( (this.aChilds[x].sClassName.indexOf("pState") != -1) || ( /select/i.test(this.aChilds[x].oObj.tagName.toLowerCase())) ) {
                            var pStateIndex = this._stripeClass(this.aChilds[x].sClassName, 'pState', 6, 8);
                            this._setNextLevels(pStateIndex, true);
							
                            if (/select/i.test(this.aChilds[x].oObj.tagName.toLowerCase())) {
                                for (var v=0; v<this.aChilds[x].oObj.options.length; v++) {
                                    if (this.aChilds[x].oObj.options[v].className.indexOf('pState') != -1) {
                                        if (this.aChilds[x].oObj.options[v].selected == true) {
                                            var pStateIndex = this._stripeClass(this.aChilds[x].oObj.options[v].className, 'pState', 6, 8);
                                            this._setNextLevels(pStateIndex, true);
                                        }
                                    }
                                }
                            }
                            else {
                                var pStateIndex = this._stripeClass(this.aChilds[x].sClassName, 'pState', 6, 8);
                                this._setNextLevels(pStateIndex, true);
                            }
                        }
                    }
                }
            }
        }
    },
	
    _setNextLevels:function(pindex, state) {
        for (var i=0; i<window.thisPageForm.aChilds.length; i++){
            if ( /select/i.test(window.thisPageForm.aChilds[i].oObj.tagName.toLowerCase())) {
                for (var w=0; w<window.thisPageForm.aChilds[i].aChilds.length; w++){
                    if (window.thisPageForm.aChilds[i].aChilds[w].sClassName.indexOf('pState' + pindex) != -1) {
                        for (var q=0; q<window.thisPageForm.aChilds[i].aChilds[w].aChilds.length; q++) {
                            if (state == true) {
								if (!/cQAS/i.test(window.thisPageForm.aChilds[i].aChilds[w].aChilds[q].oObj.className) ) {
									ClassName.add(window.thisPageForm.aChilds[i].aChilds[w].aChilds[q].oObj, "disabled");
									window.thisPageForm.aChilds[i].aChilds[w].aChilds[q].oObj.disabled = true;
								}
                            }
                            else {
								if (!/cQAS/i.test(window.thisPageForm.aChilds[i].aChilds[w].aChilds[q].oObj.className) ) {
									ClassName.remove(window.thisPageForm.aChilds[i].aChilds[w].aChilds[q].oObj, "disabled");
									window.thisPageForm.aChilds[i].aChilds[w].aChilds[q].oObj.disabled = false;
								}
                            }


                            /*
							if ( (window.thisPageForm.aChilds[i].aChilds[w].aChilds[q].sClassName.indexOf("pState") != -1) || ( /select/i.test(window.thisPageForm.aChilds[i].aChilds[w].aChilds[q].oObj.tagName.toLowerCase())) ) {
								if (/select/i.test(window.thisPageForm.aChilds[i].aChilds[w].aChilds[q].oObj.tagName.toLowerCase())) {
									for (var v=0; v<window.thisPageForm.aChilds[i].aChilds[w].aChilds[q].oObj.options.length; v++) {
										if (window.thisPageForm.aChilds[i].aChilds[w].aChilds[q].oObj.options[v].className.indexOf('pState') != -1) {
											if (window.thisPageForm.aChilds[i].aChilds[w].aChilds[q].oObj.options[v].selected == true) {
												var pStateIndex = this._stripeClass(window.thisPageForm.aChilds[i].aChilds[w].aChilds[q].oObj.options[v].className, 'pState', 6, 8);
												this._setNextLevels(pStateIndex, true);
											}
										}
									}
								}
								else {
                             */
                            var pStateIndex = this._stripeClass(window.thisPageForm.aChilds[i].aChilds[w].aChilds[q].sClassName, 'pState', 6, 8);
                            this._setNextLevels(pStateIndex, state);
                            /*
								}
							} */
                        }
                    }
                }
            }
            else if (window.thisPageForm.aChilds[i].sClassName.indexOf('pState' + pindex) != -1) {
                for (var q=0; q<window.thisPageForm.aChilds[i].aChilds.length; q++) {
                    if (state == true) {
						if (!/cQAS/i.test(window.thisPageForm.aChilds[i].aChilds[q].oObj.className) ) {
							ClassName.add(window.thisPageForm.aChilds[i].aChilds[q].oObj, "disabled");
							window.thisPageForm.aChilds[i].aChilds[q].oObj.disabled = true;
						}
                    }
                    else {
						if (!/cQAS/i.test(window.thisPageForm.aChilds[i].aChilds[q].oObj.className) ) {
							ClassName.remove(window.thisPageForm.aChilds[i].aChilds[q].oObj, "disabled");
							window.thisPageForm.aChilds[i].aChilds[q].oObj.disabled = false;
						}
                    }

                    /*
					if ( (window.thisPageForm.aChilds[i].aChilds[q].sClassName.indexOf("pState") != -1) || ( /select/i.test(window.thisPageForm.aChilds[i].aChilds[q].oObj.tagName.toLowerCase())) ) {
						if (/select/i.test(window.thisPageForm.aChilds[i].aChilds[q].oObj.tagName.toLowerCase())) {
							for (var v=0; v<window.thisPageForm.aChilds[i].aChilds[q].oObj.options.length; v++) {
								if (window.thisPageForm.aChilds[i].aChilds[q].oObj.options[v].className.indexOf('pState') != -1) {
									if (window.thisPageForm.aChilds[i].aChilds[q].oObj.options[v].selected == true) {
										var pStateIndex = this._stripeClass(window.thisPageForm.aChilds[i].aChilds[q].oObj.options[v].className, 'pState', 6, 8);
										this._setNextLevels(pStateIndex, true);
									}
								}
							}
						}
						else {
                     */
                    var pStateIndex = this._stripeClass(window.thisPageForm.aChilds[i].aChilds[q].sClassName, 'pState', 6, 8);
                    this._setNextLevels(pStateIndex, state);
                    /*						}
					}*/
                }
            }
        }
    },

    _removePrefilled:function() {
        ClassName.remove(this.oObj, 'example');
        if ( (/</i.test(this.oObj.value)) && (/>/i.test(this.oObj.value))  ) {
            this.oObj.value = '';
        }
    }
}


InitFill = function(ID) {
    elArr = $(ID);
    if (elArr) {
        this.elements = elArr.getElementsByTagName('*');	
        var formElement = new Element(document.forms[ID], "form");
        formElement = formElement.fillParents(formElement, elements);
        return formElement;
    }
}



function WriteOut(elementX, index) {
    var bla = '';
    
    for (var i=0; i < index; i++){   
        bla += " - ";
    }
    
    document.getElementById("test").innerHTML += bla + elementX.sClassName + ' - ' + elementX.oObj.tagName + ' - ' + elementX.oObj.disabled + '<br />';

    index++;
    
    for (var x=0; x < elementX.aChilds.length; x++) {
        WriteOut(elementX.aChilds[x], index);
    }
}



EventListener.addEvent(window, 'load', function() {										
    window.thisPageForm  = InitFill('FORMID');
	
	
});

var NAW1eAanvrager_Rekeningnummer = 0;
var NAW1eAanvrager_Rekeningnummer1 = 0;

function advance(currentField,nextField) {

    if (currentField.value.length == 3) {
        if (currentField.name == 'NAW1eAanvrager_Rekeningnummer') {
            if(NAW1eAanvrager_Rekeningnummer != 7) {
                document.ba[nextField].focus();
            }
        }
        else if(NAW1eAanvrager_Rekeningnummer1 != 3) {
            document.ba[nextField].focus();
        }
    }
    if (currentField.name == 'NAW1eAanvrager_Rekeningnummer') {
        NAW1eAanvrager_Rekeningnummer = currentField.value.length;
    }
    else {
        NAW1eAanvrager_Rekeningnummer1 = currentField.value.length;
    }
}

//---------- Feedback Belgie

var selectFeedback;

function setFeedbackChange()
{
    selectFeedback = document.getElementsByName('Feedback_Feedback')[0];
    addEvent(selectFeedback, 'change', changeFeedbackSub);
    changeFeedbackSub();
}

function changeFeedbackSub()
{
    var selectedValue = selectFeedback.options[selectFeedback.selectedIndex].value;
    var feedbackSubSelects = document.getElementsByTagName("select");
    var feedbackSub = document.getElementById(selectedValue);
    for (i=0; i<feedbackSubSelects.length; i++)
    {
	if (feedbackSubSelects[i] == feedbackSub)
	{
	    feedbackSubSelects[i].disabled = false;
	    feedbackSubSelects[i].parentNode.parentNode.className = '';
	}
	else
	{
	    if (feedbackSubSelects[i] != selectFeedback && feedbackSubSelects[i].name.indexOf("Feedback_Feedback") != -1)
	    {
		feedbackSubSelects[i].parentNode.parentNode.className = 'feedbackSub';
		feedbackSubSelects[i].disabled = true;
	    }
	}
    }

    var feedbackSubInputs = document.getElementsByTagName("input");
    for (i=0; i<feedbackSubInputs.length; i++)
    {
	if (feedbackSubInputs[i] == feedbackSub)
	{
	    feedbackSubInputs[i].disabled = false;
	    feedbackSubInputs[i].parentNode.parentNode.className = '';
	}
	else
	{
	    if (feedbackSubInputs[i] != selectFeedback && feedbackSubInputs[i].name.indexOf("Feedback_Feedback") != -1)
	    {
		feedbackSubInputs[i].parentNode.parentNode.className = 'feedbackSub';
		feedbackSubInputs[i].disabled = true;
	    }
	}
    }

}
