	function MyclearErrorLabelsXHTML(form) {
	    // set all labels back to the normal class
	    var elements = form.elements;
	    for (var i = 0; i < elements.length; i++) {

	        var parentEl = elements[i];
	        // search for the parent table row, abort if the form is reached
	        // the form may contain "non-wrapped" inputs inserted by Dojo
	        while (parentEl.nodeName.toUpperCase() != "TR" && parentEl.nodeName.toUpperCase() != "FORM") {
	            parentEl = parentEl.parentNode;
	        }
	        if (parentEl.nodeName.toUpperCase() == "FORM") {
	            parentEl = null;
	        }

	         //if labelposition is 'top' the label is on the row above
	        if(parentEl && parentEl.cells) {
	          var labelRow = parentEl.cells.length > 1 ? parentEl : StrutsUtils.previousElement(parentEl, "tr");
	          if (labelRow) {
	              var cells = labelRow.cells;
	              if (cells && cells.length >= 1) {
	                  var label = cells[0].getElementsByTagName("label")[0];
	                  if (label) {
	                      label.setAttribute("class", "label");
	                      label.setAttribute("className", "label"); //ie hack cause ie does not support setAttribute
	                  }
	              }
	          }
	        }
	    }

	}
	
	function MyclearErrorLabels(form) {
	    MyclearErrorLabelsXHTML(form);
	}

	
	function MyaddErrorXHTML(e, errorText,up) {
	    try {
	        var row = (e.type ? e : e[0]);
	        if(up) {
		        i = up;
		        while(i>0){
		        	row = row.parentNode;
		        	i--;
		        }
	        }
	        while(row.nodeName.toUpperCase() != "TR") {
	            row = row.parentNode;
	        }
	        var table = row.parentNode;
	        var error = document.createTextNode(errorText);
	        var tr = document.createElement("tr");
	        var td = document.createElement("td");
	        var span = document.createElement("span");
	        td.align = "center";
	        td.valign = "top";
	        td.colSpan = 2;
	        span.setAttribute("class", "errorMessage");
	        span.setAttribute("className", "errorMessage"); //ie hack cause ie does not support setAttribute
	        span.appendChild(error);
	        td.appendChild(span);
	        tr.appendChild(td);
	        tr.setAttribute("errorFor", e.id);
	        table.insertBefore(tr, row);

	        // update the label too
	        //if labelposition is 'top' the label is on the row above
	        var labelRow = row.cells.length > 1 ? row : StrutsUtils.previousElement(tr, "tr");
	        var label = labelRow.cells[0].getElementsByTagName("label")[0];
	        if(label){
	        	label.setAttribute("class", "errorLabel");
	        	label.setAttribute("className", "errorLabel"); //ie hack cause ie does not support setAttribute
	        }
	    } catch (e) {
	        alert(e);
	    }
	}

	function MyaddError(e, errorText,up) {
	    MyaddErrorXHTML(e, errorText,up);
	}
	function getTables(form){
	    var table;
	    var tables = new Array();
	    for (var i = 0; i < form.childNodes.length; i++) {
	    	if (form.childNodes[i].tagName != null && form.childNodes[i].tagName.toLowerCase() == 'table') {
	    		table = form.childNodes[i];
	    		break;
	    	}
	    }	
        if (table == null) {
                return tables;
        }
        tables.push(table);
        for(var s = 0; s < table.rows.length; s++){
        	var row = table.rows[s];
	        for (var k = 0; k < row.childNodes.length; k++) {
	        	if (row.childNodes[k].tagName != null && row.childNodes[k].tagName.toLowerCase() == 'td') {
	        		td = row.childNodes[k];
	        		for (var j = 0; j < td.childNodes.length; j++) {
	        			if (td.childNodes[j].tagName != null && td.childNodes[j].tagName.toLowerCase() == 'table') {
	            			tables.push(td.childNodes[j]);
	        			}
	        		}
	        	}    
	       }
        }
        return tables;
	}
	function MyclearErrorMessages(form) {
		var tables = getTables(form);
	    MyclearErrorMessagesXHTML(form,tables);
	}
	function MyclearErrorMessagesXHTML(form,tables) {
        for (var i = 0; i < tables.length; i++) {
	            var rows = tables[i].rows;
	            if (rows == null){
	                continue;
	            }
	    	    var rowsToDelete = new Array();
	            for(var j = 0; j < rows.length; j++) {
	                var r = rows[j];
	                if (r.getAttribute("errorfor") != null) {
	                    rowsToDelete.push(r);
	                }
	            }
	    	    for (var k = 0; k < rowsToDelete.length; k++) {
	    	        var l = rowsToDelete[k];
	    	        tables[i].deleteRow(l.rowIndex);
	    	    }
	    }
	}