var oError = new ckErrorObj();

function ckErrorObj() {
var oDate = new Date();
     this.uniqueId = oDate.getMonth() + '' + oDate.getDate() + '' + oDate.getTime() + '';
	//this.uniqueID = this.__getUniqueID(); //since more than one ajax object can be declared on a page, need a way to uniquely identify each
	this.aValidationElements = Array();
	this.aErrorDisplays = Array();
	
	this.bFWDeclared = false;
	this.bTabsDeclared = false;
	this.bStandardContainersAvail = false;
	this.bAutoDisplayErrors = true; //when true, will automatically display after auto-validate. For custom error handling after auto-validate call, set to false

	return this;
}

ckErrorObj.prototype.anyErrors = function() {
	var count = 0;
	for (var key in this.aErrorDisplays) count++;

	return (count > 0);
}

/*----- Add Message -------------------------------------------------------------------------------------------*/

ckErrorObj.prototype.addBlankMsg = function(sDesc) {
	this.__addBlankOrInvalidMsg(sDesc,"blank");
}
ckErrorObj.prototype.addInvalidMsg = function(sDesc) {
	this.__addBlankOrInvalidMsg(sDesc,"invalid");
}
ckErrorObj.prototype.__addBlankOrInvalidMsg = function(sDesc,sStyle) {
	//Messages are not tied to individual validation elements, and therefore are not linked to a tab or displayID. They will always
	//	display in the default container. This works well for floating window errors since the default container is the floating window itself

	var oParams = new Object(); 
	
	if (sStyle=="blank") oParams.bBlankMsg = true;  
	else if (sStyle=="invalid") oParams.bInvalidMsg=true;

	this.add(sDesc,oParams);
}

/*----- Add Error -------------------------------------------------------------------------------------------*/

ckErrorObj.prototype.addBlankErr = function(sDesc) {
	var oParams = (arguments.length==2 ? arguments[1] : null);
	this.__addBlankOrInvalidErr(sDesc,oParams,"blank");
}
ckErrorObj.prototype.addInvalidErr = function(sDesc) {
	var oParams = (arguments.length==2 ? arguments[1] : null);
	this.__addBlankOrInvalidErr(sDesc,oParams,"invalid");
}
ckErrorObj.prototype.__addBlankOrInvalidErr = function(sDesc,oParams,sStyle) {
	//If this is called from checkBlank() or checkInvalid(), we'll already have the oParams object.  If not, attempt to retrieve the 
	//	validation element by searching for sDesc=failtext since that's the most common addBlankError type of call. This
	//	is just so we can mark the fields on the screen with errors even after a server side validation. If
	//	still not found, create a dummy oParams object with that property set to pass in to add()
	
	//Validation elements array will only be empty if auto-validate not performed before adding an error. Always call before attempting to search 
	if (this.aValidationElements.length==0) this.__buildValidationElements(); 
	
	if (!oParams) oParams = this.__getValidationElementParamsByFailtext(sDesc);

	if (!oParams) oParams = new Object(); 
	
	if (sStyle=="blank") oParams.bBlank = true;  //Always mark oParams.bBlank/bValid even though checkBlank/checkValid may already have since this can be called directly by the client without going through those functions
	else if (sStyle=="invalid") oParams.bValid=false;

	this.add(sDesc,oParams);
}

ckErrorObj.prototype.add = function(sDesc) {
	var oParams = ((arguments.length==2 && arguments[1]) ? arguments[1] : null);
	
	var uniqueID=""; //need any unique id to separate the different places errors will be displayed;
	if (oParams) uniqueID = (oParams.hasOwnProperty("tab") ? oParams.tab : (oParams.hasOwnProperty("displayID") ? oParams.displayID : ""));
	if (uniqueID=="") uniqueID = "default";	

	var oDisplay = this.aErrorDisplays[uniqueID]; //all information needed to display properly
	//alert(objectDebugStr(this,2))

	if (!oDisplay) {
		oDisplay = eval({"displayID":"","tab":"","aError":Array(),"aBlank":Array(),"aBlankMsgs":Array(),"aInvalid":Array(),"aInvalidMsgs":Array()});
		if ((oParams) && (oParams.hasOwnProperty("tab"))) oDisplay.tab = oParams.tab;
		else if ((oParams) && (oParams.hasOwnProperty("displayID"))) oDisplay.displayID = oParams.displayID;
		else oDisplay.displayID="default";
	} 

	if ((sDesc) && (sDesc != "")) { //possible no failtext and just need element highlighted
		if (!oParams) {
			oDisplay.aError[oDisplay.aError.length] = sDesc; //if no error container identifier, add as regular error to standard container
		} else {
			if ((oParams.hasOwnProperty("bBlank")) && (oParams.bBlank)) oDisplay.aBlank[oDisplay.aBlank.length] = sDesc;
			else if ((oParams.hasOwnProperty("bBlankMsg")) && (oParams.bBlankMsg)) oDisplay.aBlankMsgs[oDisplay.aBlankMsgs.length] = sDesc;
			else if ((oParams.hasOwnProperty("bValid")) && (!oParams.bValid)) oDisplay.aInvalid[oDisplay.aInvalid.length] = sDesc;
			else if ((oParams.hasOwnProperty("bInvalidMsg")) && (oParams.bInvalidMsg)) oDisplay.aInvalidMsgs[oDisplay.aInvalidMsgs.length] = sDesc;
			else oDisplay.aError[oDisplay.aError.length] = sDesc; //Regular errors will come in like this when an error container set
			
		}

		this.aErrorDisplays[uniqueID]=oDisplay;
	}
	
	//alert("aErrorDisplay[" + uniqueID + "]\n" + objectDebugStr(this.aErrorDisplays[uniqueID],2));
}


/*------------------------------------------------------------------------------------------------
checkBlank
	-This procedure should be the centralized place to mark the oParams object with the bBlank property.
	-Single incoming parameter can be a form element or a string. If coming from auto-validate process
		then we already have the string value. If called from another script, oEl is probably most
		useful since we also retrieve the validation element parameters automatically for the element.
	-If calling from auto-validate, we'll have oParams to pass in. If called from outside auto-validate
		during custom error handling then retrieve it.  This means that even if an element is not going to 
		take part in auto-validation ("v" attribute is empty) they still need to have a ckValidate tag if
		any custom validation occurring
	-The auto-validate function must be called before any direct calls to checkBlank so that the validation elements are built.
		Otherwise, calls to getValidationElementParams() will fail
------------------------------------------------------------------------------------------------*/
ckErrorObj.prototype.checkBlank = function(variant) {
	var oEl = (typeof(variant)=="object" ? variant : null);
	var sValue = (typeof(variant=="string") ? variant : (oEl ? oEl.value : ""));
	
	var oParams = (arguments.length==2 ? arguments[1] : this.__getValidationElementParams(oEl)); 

	//it's useless to call this function without having a validation element declared on the page, so err out if none found
	if (!oParams) throwConsoleError("ckErrorObj.checkBlank","Called checkBlank() on an element that does not have a corresponding ckValidate tag.\n" + objectDebugStr(oEl));

	//Might have been blank on a previous call, so we always need to set here even though forced bBlank=true in addBlankErr()
	//For server side validation when auto-validate is not called, we're not going through this function so this
	//	flag will not be toggled back since server validation only tells you who IS blank, not who is not. So it's important
	//	to make sure ALL error indications are stripped in __reset()

	if (oEl) oParams.bBlank = oValidation.isBlank(oEl);
	else oParams.bBlank = (sValue=="");

	if (oParams.bBlank) this.addBlankErr(oParams.failtext,oParams); 
	
	return oParams.bBlank;
}
/*------------------------------------------------------------------------------------------------
checkValid
	-Single incoming parameter can be a form element or a string. If coming from auto-validate process
		then we already have the string value. If called from another script, oEl is probably most
		useful since we also retrieve the validation element parameters automatically for the element.
------------------------------------------------------------------------------------------------*/
ckErrorObj.prototype.checkValid = function(variant) {
	var oEl = (typeof(variant)=="object" ? variant : null);
	var sValue = (typeof(variant=="string") ? variant : (oEl ? oEl.value : ""));
	
	var sValidation = (arguments.length >=2 && arguments[1]!="" ? arguments[1] : "auto");
	var oParams = (arguments.length == 3 && arguments[2] ? arguments[2] : this.__getValidationElementParams(oEl)); 

	//unless specific validation passed, auto-validates based on element's "fieldname" or "name" attribute	
	switch (sValidation) {
		case "email" :
			var aReturn = oValidation.validateEmail(sValue);
			oParams.bValid = aReturn[0];

			if (!oParams.bValid) oParams.failtext += ". " + aReturn[1];

			break;
		case "url" : oParams.bValid = oValidation.isValidURL(sValue);	break;
		case "date" : oParams.bValid = oValidation.isValidDate(sValue);	break;
		case "time" : oParams.bValid = oValidation.isValidTime(sValue); break;
		case "phone" : oParams.bValid = oValidation.isValidPhoneNumber(sValue);break;
	}
	
	if (!oParams.bValid) this.addInvalidErr(oParams.failtext,oParams);
	return oParams.bValid;
}

/*------------------------------------------------------------------------------------------------
autoValidate

	Required attributes
		v:validation	: blank | validURL...
		failtext		: what text to display as the error
		fieldname		: name or id of the form field element as it will be submitted. Must be unique. If a form object passed in, search on oForm[fieldname] is done first. If not found, element retrieved by combo of "elName" and "fieldname"
		
	Conditional required
		form			: id of form being validated. Required only when calling autoValidate with a FORM object. Provides link between ckValidate element and the form to ensure we only validate elements belonging to that form
		elName			: name attribute of elements being validated. Required only when calling autoValidate using name attr. Ensures we only validate elements belonging to elements with that name
				
	Optional attributes
		tab				: name (exact name of tab, not smallTalkVar) of tab to display errors in. Exact name used so error string can be built identifying what tabs have errors.
		displayID		: name of container to display errors in.
	
	Auto-added attributes
		tabID			: smallTalkVar of tab. Added only if tab is present
		
		If neither "tab" nor "errDisplay" are set, the error is displayed in the standardContainers elements. They
		are mutually exclusive, so both should not appear at the same time, however, any setting
		for "tab" takes precedence over "errDisplay"
-----------------------------------------------------------------------------------------------*/
ckErrorObj.prototype.autoValidateAndSubmit = function(oForm) {
	//only a FORM object is valid since we'd need a URL and return handler param for forms built from an ajax call and submitted back via ajax
	this.autoValidate(oForm);
	if (!this.anyErrors()) oForm.submit();
}
ckErrorObj.prototype.autoValidateAndAjaxSubmit = function(oForm,returnHandler) {
	//only a FORM object is valid since we'd need a URL and return handler param for forms built from an ajax call and submitted back via ajax
	this.autoValidate(oForm);
	if (!this.anyErrors()) {
		(new ckAjaxObj()).postForm(oForm,returnHandler)
	}
}

ckErrorObj.prototype.autoValidate = function(variant) {
	//variant will either be a FORM object or the name attribute of all the form fields

	var oParams;
	var bError, bShortCircuit;
	var oEl;
	
	this.__reset();
	this.__buildValidationElements(variant);

	for (var index=0; index < this.aValidationElements.length; index++) {
		oValEl = this.aValidationElements[index];
		oParams = oValEl.oParams;
		//oEl = oValEl.oEl;

		if ((oParams.v) && (oParams.v != "")) {
			aValidation = oParams.v.split(","); //i.e. blank,validURL. Errors always short-circuit
			bShortCircuit = false;
				
			for (var vIndex=0; vIndex < aValidation.length && !bShortCircuit; vIndex++) {
				//sequence short circuits on first failed error. So checkBlank,validURL will not call validURL if value is blank. This is important so the updateElementsDisplay works as intended
				if (aValidation[vIndex]=="blank") {
					bShortCircuit = this.checkBlank(oValEl.value,oParams); 
				} else {
					if (oValEl.value != "") { //do not validate blank entries. Allows us to validate without also throwing errors on blanks
						switch (aValidation[vIndex]) {
							case "url" :
							case "email" :
							case "date" :
							case "phone" :
							case "time" :
								bShortCircuit = !(this.checkValid(oValEl.value,aValidation[vIndex],oParams));
								break;
							default :
								throwConsoleError("ckError.autoValidate","Unknown validation type requested (" + aValidation[vIndex] + ")");
						}
					}
					oParams.bValid=!bShortCircuit;			
				}					
						
			}	
			//alert(objectDebugStr(oParams,2));		
		}
		
	}
	
	if (this.bAutoDisplayErrors) this.displayErrors();
} 
/*------------------------------------------------------------------------------------------------
Display Errors
------------------------------------------------------------------------------------------------*/
ckErrorObj.prototype.displayErrors = function() {
	var sErrHTML = "";
	var aErrTabs = Array();
	var bOnlyBlankInvalid;
	var numTabErrors=0;
	var oParams,oDisplay,oEl;

	this.__evalCommonObjects();
	this.__updateElementsDisplay();	

	//There are potentially going to be errors identified for each tab, custom containers, and the default (standardContainer or floatingWindow)
	//If any tabs have errors, generate a generic message to display in the standardContainers area indicating which tabs have errors
	for (var index=0; index < this.aValidationElements.length; index++) {
		oParams = this.aValidationElements[index].oParams;
		if ((oParams.bBlank || !oParams.bValid) && (oParams.tab)){
			if (!aErrTabs[oParams.tab]) numTabErrors++; //do not count duplicates
			aErrTabs[oParams.tab] = "anything";
		}
	}

	if (numTabErrors != 0) {
		for (var key in aErrTabs) sErrHTML += (sErrHTML=="" ? "" : ", ") + key;
		sErrHTML = (numTabErrors > 1 ? "These tabs have" : "This tab has") + " <b>errors</b>: " + sErrHTML + ". Specific descriptions appear within the tab.";
		this.add(sErrHTML); //TODO: make sure this error is always the first displayed?
	}

	//show error containers	
	for (var uniqueID in this.aErrorDisplays) {  //array of oDisplay objects
		oDisplay = this.aErrorDisplays[uniqueID];

		sErrHTML = this.__getErrorHTML(oDisplay);
		
		if ((this.bFWDeclared) && (oFloatingWindow.bShowingWait)) oFloatingWindow.hideWait();
		
		if (oDisplay.tab != "") {
			if (!this.bTabsDeclared) throwConsoleError("ckErrorobj.displayErrors","Error display identified for tabs, however tabs object is not declared");
			tabID = smallTalkVar(oDisplay.tab); //waited until last possible moment to convert to tabID
			oTabs.displayError(tabID,sErrHTML);
		} else {
			if ((this.bFWDeclared) && (oFloatingWindow.bShowing || oDisplay.displayID=="floatingWindow")){
				oFloatingWindow.showError(sErrHTML);
			} else if (oDisplay.displayID=="default") {
				if ((this.bFWDeclared) && (oFloatingWindow.bShowingWait)) oFloatingWindow.hide();
				
				if (this.bStandardContainersAvail) oStdContainer.displayError(sErrHTML);
				else if (this.bFWDeclared) oFloatingWindow.showError(sErrHTML);
				else throwConsoleError("ckErrorObj.displayErrors","Attempting to display error, but neither standardContainers area nor floating window are available");
			} else {
				//Custom element to display error within. Common functionality is to have a container
				//	for ajax calls that displays a waiting message. That container also used to display resulting errors, so
				//	build the same way as the wait container where the error container is a div within the specified container
				//  and do not change the class of the parent container.
				var oEl = document.getElementById(oDisplay.displayID);
				if (oEl) {
					oEl.innerHTML = '<div class="errorDisplay">' + sErrHTML + '</div>';
					//oEl.className="errorDisplay"
					oEl.style.display="block";
				} else throwConsoleError("ckErrorObj.displayErrors","Request to show error in container '" + oDisplay.displayID + "' but container was not found. Error text is:" + sErrHTML);
			}	
		}
	}

	this.bAutoDisplayErrors = true; //need to reset each time since there may be other calls to validate on the same page without a refresh
}

/*------------------------------------------------------------------------------------------------*/
ckErrorObj.prototype.__updateElementsDisplay = function() {
	var oValEl,oEl, oParams;
	var sLabelID,bError;
	
	for (var index=0; index < this.aValidationElements.length; index++) {
		oValEl = this.aValidationElements[index];
		oParams = oValEl.oParams;
		bError = (oParams.bBlank || !oParams.bValid);
		
		for (var elIndex = 0; elIndex < oValEl.aEl.length; elIndex++) {
			if (oEl = oValEl.aEl[elIndex]) {
				oEl.className = (bError ? "inputError" : "");
			}
		}
		
		var sClass;
		if (oParams) {
			sLabelID = (oParams.elName ? oParams.elName + "." : "");
			sLabelID += oParams.fieldname + ".label";
			var oLabel = document.getElementById(sLabelID);
			if (oLabel) {
				if (bError) {
					if (!oLabel.getAttribute("class-orig")) oLabel.setAttribute("class-orig",oLabel.className);
					sOrigClass=oLabel.getAttribute("class-orig"); 
					oLabel.className=sOrigClass +" inputErrorLabel";
				} else {
					sOrigClass=oLabel.getAttribute("class-orig");
					if (sOrigClass != null) oLabel.className = sOrigClass; //sOrigClass could be a blank string (no class) so must directly check for null
				}
			}
		}
	}
}

/*------------------------------------------------------------------------------------------------
Error HTML
------------------------------------------------------------------------------------------------*/
ckErrorObj.prototype.__getErrorHTML = function(oDisplay) {
	var sErrHTML = "";
	var sBlankHTML = "";
	var sInvalidHTML = "";
	
	if (oDisplay) {
		for (var index=0; index < oDisplay.aError.length; index++) sErrHTML += oDisplay.aError[index] + '<br>';
		sBlankHTML += this.__getBlankErrorHTML(oDisplay.aBlank, oDisplay.aBlankMsgs)
		sInvalidHTML += this.__getInvalidErrorHTML(oDisplay.aInvalid, oDisplay.aInvalidMsgs);
	}
	
	if (sBlankHTML != '' || sInvalidHTML !='') {
		bOnlyBlankInvalid = (sErrHTML=="");
		if (!bOnlyBlankInvalid) {
			sErrHTML += '<ul style="list-style-type:none">';
			if (sBlankHTML != '') sErrHTML += '<li>' + sBlankHTML + (sInvalidHTML != "" ? "<br/>" : "") + '</li>';
			if (sInvalidHTML != '') sErrHTML += '<li>' + sInvalidHTML + '</li>';
			sErrHTML += '</ul>';
		} else {
			if (sBlankHTML != '') sErrHTML = sBlankHTML + (sInvalidHTML != "" ? "<br/>" : "");
			if (sInvalidHTML != '') sErrHTML += sInvalidHTML
		}
	}
	
	return sErrHTML;
}
/*------------------------------------------------------------------------------------------------
Validation Element 
------------------------------------------------------------------------------------------------*/
ckErrorObj.prototype.__buildValidationElements = function(variant) {
	//If called from auto validate, this will get all ckvalidate elements on the page, but only save the ones required
	//	to process the auto-validate parameters. 
	//If we're in displayError and the validation elements array hasn't been built yet, this will save all the
	//	elements found on the page because we don't know what form or name attribute to validate
	//It's possible there are no validation elements when returning a general blank or invalid error from an ajax call, so do
	//  NOT call __reset() in here each time since this method is called from addBlankOrInvalid()
	var oForm = (typeof(variant)=="object" ? variant : null);
	var sNameAttr = (typeof(variant)=="string" ? variant : "");
	
	var aEl,oEl;
	var sParams,oParams;

//	this.__reset();

	var aFormObjects = formObjectsArray(oForm||sNameAttr);  //TODO: ckAjax stores lastGetFormDataVariant to pass into this func
	var oFormObj;

	//if both oForm and sNameAttr are null/empty then most likely a server side validation return from a direct call to postFormData
	//	instead of postForm or postFormDataByName since those store a "lastGetFormDataVariant" that is passed into here. If so,
	//	no need to process ckValidate tags since we're not validating based on any elements on the page
	if (!(oForm==null && sNameAttr=="")) {
		var aEl = document.getElementsByTagName("ckValidate");
		for (var index=0; index < aEl.length; index++) {
			if (sParams = aEl[index].getAttribute("params")) oParams=eval(sParams);

			//only required attribute is "el". If validation being handled server side, we may just want to mark as required
			if (!oParams) throwConsoleError("ckErrorObj.__buildValidationElements","ckValidate tag missing all parameters");
			if ((!oParams.fieldname) || (oParams.fieldname=="")) throwConsoleError("ckErrorObj.__buildValidationElements","ckValidate tag missing fieldname attribute. " + sParams)
	
			
			if (((oForm) && (oForm.id==oParams.form))  ||  ((sNameAttr != "") && (sNameAttr==oParams.elName)) ) {
				//Reference element by either the form (default) or id (required for certain ajax style forms that do not have FORM tags)
				//Any reason to add even if element not found on screen?? Maybe. For now, throw error.
			
				oFormObj = aFormObjects[oParams.fieldname];
				
				oParams.bBlank = false;
				oParams.bValid = true;
				
				//the object in aValidationElements contains an array of all the elements for the formfield, the field value and an object containing the validation params on the ckvalidate tag
				if (oFormObj) this.aValidationElements[this.aValidationElements.length] = ({"aEl":oFormObj.aEl,"value":oFormObj.value,"oParams":oParams});
				else throwConsoleError("ckError.__buildValidationElements","Request to validate '" + oParams.fieldname + "' but element was not found");
				//alert(objectDebugStr(this.aValidationElements,1));
			}
						
		}
	}
}

ckErrorObj.prototype.__getValidationElementParams = function(oEl) {
	//Client may be performing custom validation and needs this validation element to properly set.  Since we're only checking
	//	the first index of the element array, this isn't useful for radio buttons and checkboxes. The would never call
	//	the "isValid()" function (which calls this one) anyway.	
	var oValEl = null;
	for (var index=0; index < this.aValidationElements.length; index++) {
		if (this.aValidationElements[index].aEl[0]==oEl) { oValEl = this.aValidationElements[index];break;}
	}
	if (oValEl) return (oValEl.oParams)
	else return null;
}
ckErrorObj.prototype.__getValidationElementParamsByFailtext = function(sFailtext) {
	//used when addBlankErr called without passing in a oParams object. Happens when addBlankErr() or addInvalidErr called directly by client
	//	or for server side validation returning. If failtext has " - " then only search for text that appears before the dash because
	//	server side validation frequently used for complex validation rules and a failure explanation is frequently added to the failtext
	var oValEl = null;
	
	var sSearchFailtext = sFailtext;
	if (sFailtext.indexOf(" - ") > 0) sSearchFailtext = sFailtext.slice(0,sFailtext.indexOf(" - "))

	for (var index=0; index < this.aValidationElements.length; index++) {
		if (this.aValidationElements[index].oParams.failtext==sSearchFailtext) {oValEl = this.aValidationElements[index];break;}
	}
	if (oValEl) return (oValEl.oParams)
	else return null;
}

/*------------------------------------------------------------------------------------------------
PRIVATE Utilities
------------------------------------------------------------------------------------------------*/
ckErrorObj.prototype.__getBlankErrorHTML = function(aBlank,aBlankMsgs) {
	var sHTML="";
	if (aBlankMsgs.length > 0) for (var index=0; index < aBlankMsgs.length; index++) sHTML += aBlankMsgs[index] + "<br>";
	if (aBlank.length > 0) {
		if (sHTML !="") sHTML += "<br/>";
		sHTML += 'The following may not be <b>blank</b>: ';
		for (var index=0; index < aBlank.length; index++) {
			sHTML += (index > 0 ? ", " : "") + aBlank[index];
		}
		sHTML += "<br/>";
	}
	return sHTML;
}
ckErrorObj.prototype.__getInvalidErrorHTML = function(aInvalid,aInvalidMsgs) {
	var sHTML="";
	if (aInvalidMsgs.length > 0) for (var index=0; index < aInvalidMsgs.length; index++) sHTML += aInvalidMsgs[index] + "<br>";
	if (aInvalid.length > 0) {
		if (sHTML !="") sHTML += "<br/>";
		sHTML += 'The following are <b>not valid</b>:<ul style="list-style-type:square;margin-top:1px">'
		for (var index=0; index < aInvalid.length; index++) {
			sHTML += '<li>' + aInvalid[index] + '</li>';
		}
		sHTML += '</ul>'
	}
	return sHTML;
}


ckErrorObj.prototype.__reset = function(sDesc) {
	//before clearing existing data, hide any errors currently showing. This is the only time before clearing
	// data that we know about custom error containers that may be showing since they will not be added to errors on next
	// auto-validate if errors have been fixed.
	
	this.__evalCommonObjects();

	//each element needs to be stripped of error markings so each call to auto-validate or new server trip starts with a fresh interface
	for (var index=0; index < this.aValidationElements.length; index++) {
		this.aValidationElements[index].oParams.bBlank = false;
		this.aValidationElements[index].oParams.bValid = true;
	}
	this.__updateElementsDisplay()

			
	if (this.bStandardContainersAvail) oStdContainer.clearError(); 
	if (this.bFWDeclared) oFloatingWindow.hideErrWarnSuccess();
	if (this.bTabsDeclared) oTabs.clearErrors();
	
	var oDisplay, oEl;
	for (var uniqueID in this.aErrorDisplays) {
		oDisplay = this.aErrorDisplays[uniqueID]
		if ((oDisplay.displayID != "default") && (oEl = document.getElementById(oDisplay.displayID))) oEl.style.display="none";
	}
	
	this.aValidationElements = Array();
	this.aErrorDisplays = Array();
}
ckErrorObj.prototype.__evalCommonObjects = function(sDesc) {
	//need to do this more often than just onload since the objects may be created after page loads or after this onload event would fire
	try { this.bFWDeclared = (oFloatingWindow != null); } catch(err) { this.bFWDeclared=false; }
	try { this.bTabsDeclared = (oTabs != null); } catch(err) { this.bTabsDeclared=false; } 
	this.bStandardContainersAvail = (document.getElementById("standardContainers") != null);
}
ckErrorObj.prototype.__getUniqueID = function () {
     var oDate = new Date();
     var uniqueId = oDate.getMonth() + '' + oDate.getDate() + '' + oDate.getTime() + '';

     return uniqueId;
}

