var oStdContainer = new stdContainerObj();
function stdContainerObj() {
	return this;
}

stdContainerObj.prototype.clearAll = function() {
	this.clearError();
	this.clearWarning();
	this.clearInfo();
	this.clearSuccess();
}

stdContainerObj.prototype.displayInfo = function(sHTML) {	this.__displayStandardContainer("info",sHTML); } 
stdContainerObj.prototype.clearInfo = function() {	this.__clearStandardContainer("info"); }  

stdContainerObj.prototype.displayWaiting = function(sHTML) {	this.__displayStandardContainer("waiting",sHTML); }
stdContainerObj.prototype.clearWaiting = function() {	this.__clearStandardContainer("waiting"); }

stdContainerObj.prototype.displayWarning = function(sHTML) {	this.__displayStandardContainer("warning",sHTML); }
stdContainerObj.prototype.clearWarning = function() {	this.__clearStandardContainer("warning"); }

stdContainerObj.prototype.displaySuccess = function(sHTML) {	this.__displayStandardContainer("success",sHTML); } 
stdContainerObj.prototype.clearSuccess = function() {	this.__clearStandardContainer("success"); } 


stdContainerObj.prototype.clearError = function() {	this.__clearStandardContainer("error"); }
stdContainerObj.prototype.displayError = function(sHTML) {
	var section = (arguments.length==2 ? arguments[1] : "") //could be element or string id
	var container,containerText;
	
	if ((typeof(section)=="object") && (section != null)) {
		//Element to display error within passed. Common functionality is to have a container
		//	for ajax calls that displays a waiting message. That container also used to display resulting errors, so
		//	apply the errorDisplay class to the container as well as putting the error in it.
		section.innerHTML = sHTML;
		section.className="errorDisplay"
		section.display="block";
	} else if (section=="") {  //show error in standardContainers section
		this.__displayStandardContainer("error",sHTML)
		
		//close out info container if it's open so any previous success message doesn't confuse the users
		this.clearSuccess();
	} else {
		//the old sectionID error format
		var oRow = document.getElementById("errorRow_"+ section);
		var containerText = document.getElementById("errors_"+section);
	
		containerText.innerHTML = sHTML;
		oRow.style.display="";
	}
}

stdContainerObj.prototype.__displayStandardContainer = function(containerCode,sHTML) {
	var oEl, oWrapperEl;
	var oContainer = document.getElementById("standardContainer." + containerCode);
	if (!oContainer) {
		if (oWrapperEl = document.getElementById("standardContainers")) {
			var oDiv = document.createElement("DIV")
			oDiv.id="standardContainer." + containerCode;
			oDiv.className=containerCode + "Display standardContainer";
			oContainer = oWrapperEl.appendChild(oDiv)
		}
	}
	if (oContainer) {
		oContainer.innerHTML = sHTML;
		oContainer.style.display="block";
		window.scrollTo(0,0); //TODO:scroll to position of standard container wrapper
	}
}
stdContainerObj.prototype.__clearStandardContainer = function(containerCode) {
	var oContainer = document.getElementById("standardContainer." + containerCode);
	if (oContainer) {
		oContainer.innerHTML = "";
		oContainer.style.display="none";
	}
}

//need to retain until all occurrences wiped out
function clearSectionError(sectionID) {
	var oRow = document.getElementById('errorRow_'+ sectionID);
	var containerText = document.getElementById('errors_'+sectionID);
	
	if (oRow) oRow.style.display='none';
	if (containerText) containerText.innerHTML = "";
}
