//<script>
var Page_ValidationVer = "125";
var Page_IsValid = true;
var Page_BlockSubmit = false;
var Page_ValidatingEntirePage = false;
var Unformat_Numbers = "";
var Unformat_Dates = "";
var Unformat_Times = "";
var FieldsToClear = "";
var Unformat_ExpressionFields = "";
var FormatFunctionName = "function RegularExpressionValidatorEvaluateIsValid";
var RequiredFunctionName = "function RequiredFieldValidatorEvaluateIsValid";
var PageValidationArray = null;

function ValidatorUpdateDisplay(val) {
	if (typeof(val.display) == "string") {    
        if (val.display == "None") {
        	  // Update the Field Label Text Color as well
    		  ValidatorChangeLabelText(val);	
            return;
        }
        if (val.display == "Dynamic") {
			var el = document.getElementById(val.id);
			if(el)
			{
				el.style.display = val.isvalid ? "none" : "inline";  
				el.style.padding = val.isvalid ? "0px" : "5px";   
			}
            // Update the Field Label Text Color as well
    		  ValidatorChangeLabelText(val);
            return;
        }
    }

	 val.style.visibility = val.isvalid ? "hidden" : "visible";
    // Update the Field Label Text Color as well
    ValidatorChangeLabelText(val);
}

function ValidatorReset() {
    for (var i = 0; i < PageValidationArray.length; i++) {
        PageValidationArray[i].isvalid = true;
        ValidatorUpdateDisplay(PageValidationArray[i]);
   }
   Page_IsValid = true;
}

function ValidatorUpdateIsValid() {
    var i;
    for (i = 0; i < PageValidationArray.length; i++) {
        if (!PageValidationArray[i].isvalid) {
            Page_IsValid = false;
            return;
        }
   }
   Page_IsValid = true;
}

function ValidatorHookupControlID(controlID, val) {
    if (typeof(controlID) != "string") {
        return;
    }
    var ctrl = document.getElementById(controlID);
    if (typeof(ctrl) != "undefined") {
        ValidatorHookupControl(ctrl, val);
    }
    else {
        val.isvalid = true;
        val.enabled = false;
    }
}

function ValidatorHookupControl(control, val) {
    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") {
                ValidatorHookupControl(inner, val);
            } 
        }
        return;
    }
    else if (control.tagName != "INPUT" && control.tagName != "TEXTAREA" && control.tagName != "SELECT") {
        var i;
        for (i = 0; i < control.children.length; i++) {
            ValidatorHookupControl(control.children[i], val);
        }
        return;
    }
    else {
        if (typeof(control.Validators) == "undefined") {
            control.Validators = new Array;
            var ev;
            if (control.type == "radio") {
                ev = control.onclick;
            } else {
                ev = control.onblur;
            }
            if (typeof(ev) == "function" ) {            
                ev = ev.toString();
                ev = ev.substring(ev.indexOf("{") + 1, ev.lastIndexOf("}"));
            }
            else {
                ev = "";
            }
            var func = new Function("ValidatorOnChange(); " + ev);
            /*
            if (control.type == "radio") {
                control.onclick = func;
            } else {            
                control.onblur = func;
            }
            */

        }
        control.Validators[control.Validators.length] = val;
    }    
}

function ValidatorGetValue(id) {
   var control;
    control = document.getElementById(id);
    if (typeof(control.value) == "string") {
        return control.value;
    }
    if (typeof(control.tagName) == "undefined" && typeof(control.length) == "number") {
        var j;
        for (j=0; j < control.length; j++) {
            var inner = control[j];
            if (typeof(inner.value) == "string" && (inner.type != "radio" || inner.status == true)) {                
                return inner.value;
            }
        }
    }
    else {
        return ValidatorGetValueRecursive(control);
    }
    return "";
}

function ValidatorGetValueRecursive(control)
{
   // JJM Defect: 79300
   // if (typeof(control.value) == "string" && (control.type != "radio" || control.status == true)) {
   //     return control.value;
   // }
   
      if (IsMac())
      {
         if (typeof(control.value) == "string" && (control.type != "radio" || control.status == true || control.checked == true)) 
         {
             return control.value;
      	 }   
      }
      else
      {
      	if (typeof(control.value) == "string" && (control.type != "radio" || control.status == true || control.checked == true)) 
      	 {
      	     return control.value;
      	 }
      }
   
    var i, val;
    for (i = 0; i<control.children.length; i++) {
        val = ValidatorGetValueRecursive(control.children[i]);
        if (val != "") return val;
    }
    return "";
}

function Page_ClientValidate() 
{
    var i;
    var firstFailedField = "";
    Page_ValidatingEntirePage = true;
    Page_IsValid = true;
    ClearUnformatOptions();    
    if (window.PageValidationArray)
    {
    	for (i = 0; i < PageValidationArray.length; i++) 
    	{
		    var val = PageValidationArray[i];
		    if(val)
		    {
				ValidatorValidate(val);	        
				if (!val.isvalid && firstFailedField == "") 
				{
        			//If this validator has a specfic JSO, use it
        			if(val.ControlID != null && val.ControlID != "")
        				firstFailedField = val.ControlID;
        			else
        				firstFailedField = val.controltovalidate;
				}
			}//else
			//	alert("PageValidationArray[" + i + "] is not found on the page");
		}
		Page_ValidatingEntirePage = false;
		ValidatorUpdateIsValid();    
		ValidationSummaryOnSubmit();
    }
    
    if (Page_IsValid == true)
    {
	    //Call the validatepage function if it exists to perform any further validation steps
		if (window.validatepage != null) {
			Page_IsValid = validatepage();
			if (Page_IsValid == false) {
				return false;
			}
		}
	}
		
    Page_BlockSubmit = !Page_IsValid;
    if (Page_IsValid == true) {
    		UnformatData();	
    } else {
    		//alert(JSResourceID542);	
    		alert(GetReplacementString(542));
    		if (firstFailedField != "") {
    			//Check to see if the field is linked to a JSO
    			var Control = null;
    			
    			if (window.ObjectManager)
    				ObjectManager.GetObject(firstFailedField);
    				
    			if(Control != null && Control.SetFocus)
    				Control.SetFocus();
    			else 
    			{
    				field = document.getElementById(firstFailedField);
    				if(field && !IsHidden(field) && !IsDisabled(field))
    					field.focus();    			
    			}
    		}
    }
    return Page_IsValid;
}

function ClearUnformatOptions() {
	Unformat_Numbers = "";
	Unformat_Dates = "";
	Unformat_Times = "";
	Unformat_ExpressionFields = "";
	FieldsToClear = "";
}

function UnformatData() {
	// Go through and unformat the numeric, date, and time fields
	var i = 0;
	var ids = FieldsToClear.split(",");
	var field = null;
	
	// Clear out the values of the hidden fields
	for (i = 0; i < ids.length-1; i++) {
		field = document.getElementById(ids[i]);
		if (field != null)
		{
			if (field.type == "text" || field.type == "textarea") {
				field.value = "";
			}
		}
	}
	
	ids = Unformat_Numbers.split(",");
	// Ignore the last item, it's empty (the string has the format of <id>,<id>,<id>, )
	for (i = 0; i < ids.length-1; i++) {
		document.getElementById(ids[i]).value = Number_Unformat(document.getElementById(ids[i]).value, document.getElementById(ids[i]).getAttribute("NumberFormat"));
	}
	
	ids = Unformat_Dates.split(",");
	for (i = 0; i < ids.length-1; i++) {
		document.getElementById(ids[i]).value = Date_Unformat(document.getElementById(ids[i]).value);	
	}
	
	ids = Unformat_Times.split(",");
	for (i = 0; i < ids.length-1; i++) {
		document.getElementById(ids[i]).value = Time_Unformat(document.getElementById(ids[i]).value);
	}
	
	ids = Unformat_ExpressionFields.split(",");
	for (i = 0; i < ids.length-1; i++) {
		document.getElementById(ids[i]).value = Expression_Unformat(document.getElementById(ids[i]).value, document.getElementById(ids[i]).getAttribute("NumberFormat"));
	}
}

function ValidatorCommonOnSubmit() {    

    if(event)
    {
        event.returnValue = !Page_BlockSubmit;
        Page_BlockSubmit = false;
    }
}

function ValidatorEnable(val, enable) {
    val.enabled = (enable != false);
    ValidatorValidate(val);
    ValidatorUpdateIsValid();
}

function ValidatorOnChange() {    
    
    var vals = event.srcElement.Validators;
    var i;
    if (vals != null) {
	    for (i = 0; i < vals.length; i++) {
	        ValidatorValidate(vals[i]);
	    }
    }
    ValidatorUpdateIsValid();    
}

function DoValidate(val) {
	if (val.clientvalidationfunction && val.clientvalidationfunction.indexOf("ValidateOneBoxChecked") >= 0)
		return true;
	else if(val.getAttribute("ControlID"))
	{
		//Check for the Custom Validator that denotes the JSO
		var Control = ObjectManager.GetObject(val.getAttribute("ControlID"));
		if(Control && Control.DoValidate)
			return Control.DoValidate();
		else
			return true;
	}
	else
		return (!IsHidden(document.getElementById(val.controltovalidate)) && !document.getElementById(val.controltovalidate).disabled)
}

function ValidatorValidate(val) {
    val.isvalid = true;
	if (val.enabled != false && document.getElementById(val.controltovalidate) != null) {
		if (DoValidate(val)) {		
	        if (typeof(val.evaluationfunction) == "function" || val.getAttribute("ControlID")) 
	        {
	            if(val.getAttribute("ControlID"))
	            {
					//Check for the Custom Validator that denotes the JSO
					var Control = ObjectManager.GetObject(val.getAttribute("ControlID"));
					if(Control && Control.Validate)
						val.isvalid = Control.Validate();
					else
						val.isvalid = true;				
				}
	            else
					val.isvalid = val.evaluationfunction(val); 
	            
	            if (val.isvalid && Page_ValidatingEntirePage && val.evaluationfunction &&
	                val.evaluationfunction.toString().substring(0,FormatFunctionName.length) == FormatFunctionName) {            	
	            	// Add this ID to the correct list
	            	switch (document.getElementById(val.controltovalidate).getAttribute("DataType")) //Defect:218412, 218500 
	            	{
	            		case "dtIntegerLong":
	            		case "dtSingleDouble":
	            			// Don't do it twice (for dynamic rows)
	            			if (Unformat_Numbers.indexOf(val.controltovalidate + ",") < 0)
	            				Unformat_Numbers = Unformat_Numbers + val.controltovalidate + ",";
	            			break;
	            		
	            		case "dtDateTime": 
	            		
	            			//the AIM CH step allows some non-datetime values in a datetime control. Check for this and allow it.
	            			if(document.getElementById(val.controltovalidate).value == "<<process_date>>" ||document.getElementById(val.controltovalidate).value == "<<process_time>>" || 
	            			   document.getElementById(val.controltovalidate).value == "<<700:process_date>>" ||document.getElementById(val.controltovalidate).value == "<<700:process_time>>") break;
	            			
	            			if (document.getElementById(val.controltovalidate).getAttribute("FormatType") == "atDateOnly") { //Defect:218412, 218500 
	            				// Don't do it twice (for dynamic rows)
		            			if (Unformat_Dates.indexOf(val.controltovalidate + ",") < 0)
		            				Unformat_Dates = Unformat_Dates + val.controltovalidate + ",";
	            			} else if (document.getElementById(val.controltovalidate).getAttribute("FormatType") == "atTimeOnly") { //Defect:218412, 218500 
	            				// Don't do it twice (for dynamic rows)
	            				if (Unformat_Times.indexOf(val.controltovalidate + ",") < 0)
	            					Unformat_Times = Unformat_Times + val.controltovalidate + ",";
	            			}
	            			break;	
	            	}
	            }
	        }
	   	} else {
	   		// If we're validating the entire page, clear the value of the field
	   		// If the field is just disabled, don't clear it
	   		if (Page_ValidatingEntirePage) {
	   			var field = document.getElementById(val.controltovalidate);
	   			if (!field.disabled) {
	   				FieldsToClear = FieldsToClear + val.controltovalidate + ",";
	   			} else if (field.hasExpression == "true") {
	   				// If this is an expression field, unformat the expression field
	   				if (Unformat_ExpressionFields.indexOf(val.controltovalidate + ",") < 0) {
	   					Unformat_ExpressionFields = Unformat_ExpressionFields + val.controltovalidate + ",";
	   				}	
	   			}		
	   		}		
	   	}	     
    }    
    ValidatorUpdateDisplay(val);
}

function LoadValidator(val) {
   if (typeof(val.evaluationfunction) == "string") {
       eval("val.evaluationfunction = " + val.evaluationfunction + ";");
   }

   
   if (typeof(val.isvalid) == "string") {
       if (val.isvalid == "False") {
           val.isvalid = false;                                
           Page_IsValid = false;
       } 
       else {
           val.isvalid = true;
       }
   } else {
       val.isvalid = true;
   }
   if (typeof(val.enabled) == "string") {
       val.enabled = (val.enabled != "False");
   }
   ValidatorHookupControlID(val.controltovalidate, val);
   ValidatorHookupControlID(val.controlhookup, val);
}

function ValidatorOnLoad() {
	var i, val;		
    if (typeof(Page_Validators) == "undefined")
        return;
        
    PageValidationArray = Page_Validators;	
    for (i = 0; i < PageValidationArray.length; i++) {
        val = PageValidationArray[i];
        LoadValidator(val);
    }
    Page_ValidationActive = true;    
}

function ValidatorConvert(op, dataType, val) {
    function GetFullYear(year) {
        return (year + parseInt(val.century)) - ((year < val.cutoffyear) ? 0 : 100);
    }
    var num, cleanInput, m, exp;
    
    if (dataType == "Integer") {
        exp = /^\s*[-\+]?\d+\s*$/;
        if (op.match(exp) == null) 
            return null;
        num = parseInt(op, 10);
        return (isNaN(num) ? null : num);
    }
    else if(dataType == "Double") {
    		if (document.getElementById(val.controltovalidate).getAttribute("NumberFormat")) {
	    		var numFormat = document.getElementById(val.controltovalidate).getAttribute("NumberFormat");
	        
	        	//Identify the format's decimal character
			for (i=0; i < numFormat.length; i++) {
				if ((numFormat.charAt(i) != "-") && 
					(numFormat.charAt(i) != "+") && 
					(isNaN(numFormat.charAt(i)))) {
						val.decimalchar = numFormat.charAt(i);
						break;
				}
			}
		}
		
        exp = new RegExp("^\\s*([-\\+])?(\\d+)?(\\" + val.decimalchar + "(\\d+))?\\s*$");
        m = op.match(exp);
        if (m == null) {
            return null;
         }  
          if(IsMac())
        {
	         
	        cleanInput =(m[2].length>0 ? m[2] : "0");
	    	if(typeof(m[1]) != "undefined")
	    	{
		    	cleanInput = m[1] + cleanInput;
	    	}    
	    	
	    	if(typeof(m[4]) != "undefined")
	    	{
		    	cleanInput = cleanInput + "." + m[4];
	    	}
	    	else
	    	{
		    	cleanInput = cleanInput + ".";
	    	}
      	}	
        else
        { 
       	 cleanInput = m[1] + (m[2].length>0 ? m[2] : "0") + "." + m[4];
    	}
        num = parseFloat(cleanInput);
        return (isNaN(num) ? null : num);            
    } 
    else if (dataType == "Currency") {
        exp = new RegExp("^\\s*([-\\+])?(((\\d+)\\" + val.groupchar + ")*)(\\d+)"
                        + ((val.digits > 0) ? "(\\" + val.decimalchar + "(\\d{1," + val.digits + "}))?" : "")
                        + "\\s*$");
        m = op.match(exp);
        if (m == null)
            return null;
        var intermed = m[2] + m[5] ;
        cleanInput = m[1] + intermed.replace(new RegExp("(\\" + val.groupchar + ")", "g"), "") + ((val.digits > 0) ? "." + m[7] : 0);
        num = parseFloat(cleanInput);
        return (isNaN(num) ? null : num);            
    }
    else if (dataType == "Date") {
        var yearFirstExp = new RegExp("^\\s*((\\d{4})|(\\d{2}))([-./])(\\d{1,2})\\4(\\d{1,2})\\s*$");
        m = op.match(yearFirstExp);
        var day, month, year;
        
        //Set the date order appropriately
        switch(userDateFormat) {
        	case "MM/DD/YYYY":
        		val.dateorder = "mdy";	
        		break;
        	case "DD/MM/YYYY":
        		val.dateorder = "dmy";	
        		break;
        	case "YYYY/MM/DD":
        		val.dateorder = "ymd";	
        		break;	
        }
        
        if (m != null && (m[2].length == 4 || val.dateorder == "ymd")) {
            day = m[6];
            month = m[5];
            year = (m[2].length == 4) ? m[2] : GetFullYear(parseInt(m[3], 10))
        }
        else {
            if (val.dateorder == "ymd"){
                return null;		
            }						
            var yearLastExp = new RegExp("^\\s*(\\d{1,2})([-./])(\\d{1,2})\\2((\\d{4})|(\\d{2}))\\s*$");
            m = op.match(yearLastExp);
            if (m == null) {
                return null;
            }
            if (val.dateorder == "mdy") {
                day = m[3];
                month = m[1];
            }
            else {
                day = m[1];
                month = m[3];
            }
            year = (m[5].length == 4) ? m[5] : GetFullYear(parseInt(m[6], 10))
        }
        month -= 1;
        var date = new Date(year, month, day);
        return (typeof(date) == "object" && year == date.getFullYear() && month == date.getMonth() && day == date.getDate()) ? date.valueOf() : null;
    }
    else {
        return op.toString();
    }
}

function ValidatorCompare(operand1, operand2, operator, val) {
    var dataType = val.type;
    var op1, op2;
    if ((op1 = ValidatorConvert(operand1, dataType, val)) == null)
        return false;    
    if (operator == "DataTypeCheck")
        return true;
    if ((op2 = ValidatorConvert(operand2, dataType, val)) == null)
        return true;
    
    switch (operator) {
        case "NotEqual":
            return (op1 != op2);
        case "GreaterThan":
            return (op1 > op2);
        case "GreaterThanEqual":
            return (op1 >= op2);
        case "LessThan":
            return (op1 < op2);
        case "LessThanEqual":
            return (op1 <= op2);
        default:
            return (op1 == op2);            
    }
}

function CompareValidatorEvaluateIsValid(val) {
    var value = ValidatorGetValue(val.controltovalidate);
    if (ValidatorTrim(value).length == 0)
        return true;
        
    var compareTo = "";
    if (null == document.getElementById(val.controltocompare)) {
        if (typeof(val.valuetocompare) == "string") {
            compareTo = val.valuetocompare;
        }
    }
    else {
        compareTo = ValidatorGetValue(val.controltocompare);
    }
    
    return ValidatorCompare(value, compareTo, val.operator, val);
}

function CustomValidatorEvaluateIsValid(val) {
    var value = "";
    /*
    if (typeof(val.controltovalidate) == "string") {
        value = ValidatorGetValue(val.controltovalidate);
        if (ValidatorTrim(value).length == 0)
        {
            return true;
        }    
    }
    */
    var args = { Value:value, IsValid:true };
    var blnValid = true;
    if (IsMac()) {
	    if (typeof(val.clientvalidationfunction) == "string") {
	        blnValid = eval(val.clientvalidationfunction + "(val, args) ;");
	        
	        if (blnValid == true || blnValid == false)
	        	args.IsValid = blnValid;
	        else {
	    		args.IsValid = true;	
	    	}	
	    } else {
	    		args.IsValid = true;
	    }       
    } else {
   			eval(val.clientvalidationfunction + "(val, args) ;");
    }
    return args.IsValid;
}

function RegularExpressionValidatorEvaluateIsValid(val) {
    var value = ValidatorGetValue(val.controltovalidate);        
    if (ValidatorTrim(value).length == 0)
        return true; 
    var rx = new RegExp(val.validationexpression);
    var matches = rx.exec(value);
    
    var valid = (matches != null && value == matches[0]);
    
    // if it's valid, do one further check for dates
    if (valid) {    	
    		if (document.getElementById(val.controltovalidate).getAttribute("DataType") == "dtDateTime" && 
    			document.getElementById(val.controltovalidate).getAttribute("FormatType") == "atDateOnly") { //Defect:218412, 218500    		
    			// This is a date, validate the days in the month
    			valid = validateDaysInMonth(value);	    	
    		}
    }
    else if(value == '<<process_date>>' || value == '<<process_time>>')
    {
		//this condition will only be true for the inteaction contact history step
		//shen the user uses the current process time or date buttons
		valid = true;
    }
    return valid;
}

function ValidatorTrim(s) {
	if(typeof s == "undefined")
		return "";
		
    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
	return (m == null) ? "" : m[1];
}

function ValidatorChangeLabelText(val) {
	// See if we can change the text of the field label
    var pos = -1;
    if (val.controltovalidate != null) 
    	val.controltovalidate.indexOf("field");
    	
    if (pos > -1)
    {
	    var strFieldID = val.controltovalidate.substring(pos + 5);
	    var strCellID = "";
	    var character = "";
	    
	    for (var i = 0; i < strFieldID.length; i++) {
	    		if (i == strFieldID.length - 1) {
	    			character = strFieldID.substring(i);
	    		} else {
	    			character = strFieldID.substring(i, i+1);
	    		}
	    		
	    		if (isNaN(character) && character != "-") {
	    			break;	
	    		} else {
	    			strCellID += character;
	    		}		
	    }	
		
		if (document.getElementById(FormFieldPrefix() + "tdLabel" + strCellID)) {
		    if (val.isvalid == false) {
		    		document.getElementById(FormFieldPrefix() + "tdLabel" + strCellID).className = "TDDetItemError";
		    } else {
		    		// Loop through all the validators for this field.  If all of them are valid, use the normal text font.
		    		// If at least one is invalid, use the error text font
		    		var blnValid = true;
				for (i = 0; i < PageValidationArray.length; i++) {
			     	if (val.controltovalidate == PageValidationArray[i].controltovalidate) {
			          	if (!PageValidationArray[i].isvalid) {
			          		blnValid = false;
			          		break;
			          	}
			          }		
			     }
		    		if (blnValid) {
		    			document.getElementById(FormFieldPrefix() + "tdLabel" + strCellID).className = "TDDetItem";
		    		} else {
		    			document.getElementById(FormFieldPrefix() + "tdLabel" + strCellID).className = "TDDetItemError";
		    		}	
		    }
		}	    
    }	
}	

function RequiredFieldValidatorEvaluateIsValid(val) {        
    var isValid = true;
    
    var formField = document.getElementById(val.controltovalidate);
    if (formField.getAttribute('required').toString() == "true") {
    		isValid = false;
    		if ((formField.getAttribute('multiple') == "multiple" || formField.getAttribute('multiple')) &&
         		formField.getAttribute('APType') == "DualSelect") {
        			isValid = (formField.options.length > 0);    				
    		} else {
    			isValid = ValidatorTrim(ValidatorGetValue(val.controltovalidate)) != ValidatorTrim(val.initialvalue);
    		}	
    }	
    return isValid;	
}

function RangeValidatorEvaluateIsValid(val) {
    var value = ValidatorGetValue(val.controltovalidate);
    if (ValidatorTrim(value).length == 0) 
        return true;
    return (ValidatorCompare(value, val.minimumvalue, "GreaterThanEqual", val) &&
            ValidatorCompare(value, val.maximumvalue, "LessThanEqual", val));
}

function ValidationSummaryOnSubmit() {
    if (typeof(Page_ValidationSummaries) == "undefined") 
        return;
    
    var summary, sums, s;
    for (sums = 0; sums < Page_ValidationSummaries.length; sums++) {
        summary = Page_ValidationSummaries[sums];
        summary.style.display = "none";
        if (!Page_IsValid) {
            if (summary.showsummary != "False") {
                summary.style.display = "";
                if (typeof(summary.displaymode) != "string") {
                    summary.displaymode = "BulletList";
                }
                switch (summary.displaymode) {
                    case "List":
                        headerSep = "<br>";
                        first = "";
                        pre = "";
                        post = "<br>";
                        strfinal = "";
                        break;
                        
                    case "BulletList":
                    default: 
                        headerSep = "";
                        first = "<ul>";
                        pre = "<li>";
                        post = "</li>";
                        strfinal = "</ul>";
                        break;
                        
                    case "SingleParagraph":
                        headerSep = " ";
                        first = "";
                        pre = "";
                        post = " ";
                        strfinal = "<br>";
                        break;
                }
                s = "";
                if (typeof(summary.headertext) == "string") {
                    s += summary.headertext + headerSep;
                }
                s += first;
                for (i=0; i<PageValidationArray.length; i++) {
                    if (!PageValidationArray[i].isvalid && typeof(PageValidationArray[i].errormessage) == "string") {
                        s += pre + PageValidationArray[i].errormessage + post;
                    }
                }   
                s += strfinal;
                summary.innerHTML = s; 
                window.scrollTo(0,0);
            }
            if (summary.showmessagebox == "True") {
                s = "";
                if (typeof(summary.headertext) == "string") {
                    s += summary.headertext + "<BR>";
                }
                for (i=0; i<PageValidationArray.length; i++) {
                    if (!PageValidationArray[i].isvalid && typeof(PageValidationArray[i].errormessage) == "string") {
                        switch (summary.displaymode) {
                            case "List":
                                s += PageValidationArray[i].errormessage + "<BR>";
                                break;
                                
                            case "BulletList":
                            default: 
                                s += "  - " + PageValidationArray[i].errormessage + "<BR>";
                                break;
                                
                            case "SingleParagraph":
                                s += PageValidationArray[i].errormessage + " ";
                                break;
                        }
                    }
                }
                span = document.createElement("SPAN");
                span.innerHTML = s;
                s = span.innerText;                
            }
        }
    }
}

