
Type.registerNamespace("Awc.WestOnline.Rules.UI.Controls");

Awc.WestOnline.Rules.UI.Controls.ErrorPanel = function (controlId, listControlId) {
    Awc.WestOnline.Rules.UI.Controls.ErrorPanel.initializeBase(this);

    this._errorSection;
    this._errorList;
    this._firstTime;
}

Awc.WestOnline.Rules.UI.Controls.ErrorPanel.prototype = {
	initialize: function() {
		this._firstTime = true;
		Awc.WestOnline.Rules.UI.Controls.ErrorPanel.callBaseMethod(this, 'initialize');
	},
	dispose: function() {
		return;
	},
	get_ErrorSection: function() {
		return this._errorSection;
	},
	set_ErrorSection: function(value) {
		this._errorSection = $get(value);
	},
	get_ErrorList: function() {
		return this._errorList;
	},
	set_ErrorList: function(value) {
		this._errorList = $get(value);
	},
	ClearList: function() {
		this._firstTime = true;
		this._errorSection.style.display = 'none';
		while (this._errorList.firstChild) {
			this._errorList.removeChild(this._errorList.firstChild);
		}
	},
	Reset: function(control) {
	    if (typeof (control) != 'undefined') {
	        var current = control.parentNode;
	        while (current.tagName.toLowerCase() != 'div') {
	            current = current.parentNode;
	        }
	        if (current != null && current.className.indexOf("error") != -1)
	            current.className = current.className.replace(/ error/, "");
	    }
	},
	Add: function(message, control) {
		if (this._firstTime) {
			this._firstTime = false;
			this._errorSection.style.display = 'block';
			window.scroll(this._errorSection.offsetLeft, this._errorSection.offsetTop);
		}
		var item = document.createElement('li');
		item.innerHTML = message;
		this._errorList.appendChild(item);

		if (typeof (control) != 'undefined') {
			var current = control.parentNode;
			while (current.tagName.toLowerCase() != 'div') {
				current = current.parentNode;
			}
			if (current != null && current.className.indexOf("error") == -1)
				current.className += " error";
		}
    },
	ValidateEmptyControl: function(control, message) {
		this.Reset(control);
		if (control.value == '') {
			this.Add(message, control);
			return false;
		}
		return true;
	},
	ValidateEmptyDobControl: function(dayControl, monthControl, yearControl, message) {
		this.Reset(dayControl);
		this.Reset(monthControl);
		this.Reset(yearControl);
		if (dayControl.value == '' || monthControl.value == '' || yearControl.value == '') {
			this.Add(message, dayControl);
			return false;
		}
		return true;
	}
}

// Register the class as derived from Sys.Component.
Awc.WestOnline.Rules.UI.Controls.ErrorPanel.registerClass('Awc.WestOnline.Rules.UI.Controls.ErrorPanel', Sys.Component);


if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();