﻿LeadingMIS.Error = function(){}

LeadingMIS.Error.Number = 0;
LeadingMIS.Error.Message = "";
LeadingMIS.Error.HelpLink = "";
LeadingMIS.Error.Object = null;
LeadingMIS.Error.Source = "";
LeadingMIS.Error.Item = new Array();

LeadingMIS.Error.DictionarySource = "/Common/SystemDictionary/ErrorDictionary.xml";
LeadingMIS.Error.Dictionary = new ActiveXObject("MSXML2.DOMDocument");
LeadingMIS.Error.Dictionary.async = false;
LeadingMIS.Error.Dictionary.load(LeadingMIS.Error.DictionarySource);

LeadingMIS.Error.setInfo = function(Number,Object,Message,Source,HelpLink)
{
	this.Number		= Number;
	this.Object		= Object;
	this.Message	= Message;
	this.Source		= Source;
	this.HelpLink	= HelpLink;
}

LeadingMIS.Error.clear = function()
{
	this.Number		= 0;
	this.Object		= null;
	this.Message	= "";
	this.Source		= "";
	this.HelpLink	= "";
	this.Item		= null;
}

LeadingMIS.Error.addItem = function(Number,Object,Message,Source,HelpLink)
{
	this.Item[this.Item.length] = new Array(Number,Object,Message,Source,HelpLink);
}
	
LeadingMIS.Error.deleteItem = function(startIndex,deleteCount)
{
	this.Item.splice(startIndex,deleteCount);
}

LeadingMIS.Error.findInfo = function(errNumber)
{
	return LeadingMIS.Error.Dictionary.selectSingleNode("/ErrorDictionary/ErrorInfos/ErrorInfo[Number='" + errNumber + "']");
}

LeadingMIS.Error.fillInfo = function(errNumber,errObject,errSource)
{
	var tempElement = LeadingMIS.Error.findInfo(errNumber);
	this.Number		= tempElement.selectSingleNode("./Number").text.trim();
	this.Message	= tempElement.selectSingleNode("./Message").text.trim();
	this.HelpLink	= tempElement.selectSingleNode("./HelpLink").text.trim();
	if(typeof(errObject) == "undefined")
	{
		this.Object	= null;
		if(typeof(errSource) == "undefined")
		{
			this.Source	= tempElement.selectSingleNode("./Source").text.trim();
		}
		else
		{
			this.Source	= errSource.trim();
		}
	}
	else
	{
		this.Object	= errObject;
		this.Source	= LeadingMIS.UI.getObjectSource(errObject).trim();
	}
	tempElement = null;
}
