//<script>

var Page_IndicatorsVer = "100";
var Page_IndicatorCurrent;

function IndicatorOnLoad() {
    if (typeof(Page_Indicators) == "undefined")
        return;

    var i, ind;
    for (i = 0; i < Page_Indicators.length; i++) {
        ind = Page_Indicators[i];
        if (typeof(ind)=="undefined") 
			continue;
        
        if (typeof(ind.evaluationfunction) == "string") {
            eval("ind.evaluationfunction = " + val.evaluationfunction + ";");
        }
        
        if (typeof(ind.isvalid) == "string") {
            if (ind.isvalid == "False") {
                ind.isvalid = false;                                
            } 
            else {
                ind.isvalid = true;
            }
        } else {
            ind.isvalid = false;
        }

        if (typeof(ind.enabled) == "string") {
            ind.enabled = (ind.enabled != "False");
        }
        
        if (i==0) Page_IndicatorCurrent = ind;
        
        IndicatorHookupControlID(ind.controltoguard, ind);
        IndicatorUpdateDisplay(ind);
    }
    Page_IndicatorsActive = true;
}


function IndicatorHookupControlID(controlID, ind) {
    if (typeof(controlID) != "string") {
        return;
    }
    var ctrl = document.all[controlID];
    if (typeof(ctrl) != "undefined") {
        IndicatorHookupControl(ctrl, ind);
    }
    else {
        ind.isvalid = true;
        ind.enabled = false;
    }
}

function IndicatorHookupControl(control, ind) {


    if (typeof(control.tagName) == "undefined" && typeof(control.length) == "number") {
        var i;
        for (i = 0; i < control.length; i++) {
            var inner = control[i];
            if (typeof(inner.value) == "string") {
               IndicatorHookupControl(inner, ind);
            } 
        }
        return;
    }
    else if (control.tagName != "INPUT" && control.tagName != "TEXTAREA" && control.tagName != "SELECT") {
        var i;
        for (i = 0; i < control.children.length; i++) {
            IndicatorHookupControl(control.children[i], val);
        }
        return;
    }
    else {
        if (typeof(control.Indicators) == "undefined") {
            control.Indicators = new Array;
            var ev;
            /*
            if (control.type == "radio") {
                ev = control.onclick;
            } else {
                ev = control.onchange;
            }
            if (typeof(ev) == "function" ) {            
                ev = ev.toString();
                ev = ev.substring(ev.indexOf("{") + 1, ev.lastIndexOf("}"));
            }
            else {
                ev = "";
            }
            var func = new Function("IndicatorOnChange(); " + ev);
            if (control.type == "radio") {
                control.onclick = func;
            } else {            
                control.onchange = func;
            }
            */
            if (control.type == "radio") {
                control.attachEvent('onclick',IndicatorOnChange);
            } else {
                control.attachEvent('onchange',IndicatorOnChange);
            }
            // OPTIONAL add property to turn it off
           if (control.type == "text" || control.type == "password") 
           {
				control.attachEvent('onfocus',IndicatorShowFocus);
				control.attachEvent('onblur',IndicatorHideFocus);
            }
       

        }
        control.Indicators[control.Indicators.length] = ind;
    }    
}

function IndicatorOnChange() {
    var inds = event.srcElement.Indicators;
    var i;
    for (i = 0; i < inds.length; i++) {
		inds[i].isvalid = true;
        IndicatorUpdate(inds[i]);
    }
 //   ValidatorUpdateIsValid();    
}

function IndicatorUpdate(ind) {   
	if (Page_IndicatorCurrent==ind) {
		if (ind.enabled == false) {
			Page_IndicatorCurrent=next;
			IndicatorUpdateDisplay(next);
			IndicatorUpdate(next);
		} else {
			if (ind.isvalid == true) {
				Page_IndicatorCurrent=null;
				if (typeof(ind.nextindicator) == "string") {
					var next = document.all[ind.nextindicator];
					if (typeof(next) != "undefined") {
						// check if the name is on the list (i.e. it has connected target);
						Page_IndicatorCurrent=next;
						IndicatorUpdateDisplay(next);
						IndicatorUpdate(next);
					}
				}
			}
		}
		IndicatorUpdateDisplay(ind);
	}
}


function IndicatorUpdateDisplay(ind) {
    if (typeof(ind.display) == "string") {    
        if (ind.display == "None") {
            return;
        }
        if (ind.display == "Dynamic") {
            ind.style.display = (Page_IndicatorCurrent==ind) ?  "inline" : "none";
            return;
        }
    }
    ind.style.visibility = (Page_IndicatorCurrent==ind) ? "visible" : "hidden";
}

function IndicatorShowFocus() {
	control = event.srcElement;
	control.lastBackgroundColor = control.style.backgroundColor;
	control.style.backgroundColor = '#FFFF99';
}

function IndicatorHideFocus() {
	control = event.srcElement;
	if (typeof(control.lastBackgroundColor)!=undefined) 
		control.style.backgroundColor = control.lastBackgroundColor;
	else 
		control.style.backgroundColor = 'transparent';
}

//</script>