
function XMLOperations (fContinueOnError)
{
	this.continueonerror = fContinueOnError;
	this.AddOperation = AddXMLOperation;
	this.EndOperation = EndXMLOperation;
	this.AddInput = AddXMLInput;
	this.XMLOperation = "";
	this.XMLInputs = "";
}

function AddXMLOperation (szCommand, CID, ID, type, dependson)
{
	if (!type || type == undefined)
		type = "XX";
	var szOperation = "<operation";
	szOperation += " name=\"" + szCommand + "\"";
	szOperation += " id=\"" + ID + "\"";
	szOperation += " cid=\"" + CID + "\"";
	szOperation += " objtype=\"" + type + "\"";
	if (dependson != undefined) {
		szOperation += " depends-on=\"" + dependson + "\"";
	}
	szOperation += "></operation>";
	this.XMLOperation = szOperation;
}

function AddXMLInput (szElementName, szValue, fInsertCDATA)
{	
	var szInput = "<input name=\"" + szElementName + "\">";

	if (fInsertCDATA || fInsertCDATA == undefined)
		szInput += "<![CDATA[" + szValue + "]]>";
	else 
		szInput += szValue;

	szInput += "</input>";
	
	var idxStart = this.XMLOperation.indexOf ("</operation>");
	var szTmp = this.XMLOperation.substring (0, idxStart);
	this.XMLOperation = szTmp + szInput + "</operation>";
}

function EndXMLOperation ()
{
	if (this.XMLInputs == "") {
		this.XMLInputs = "<operations continueonerror=\"";
		if (this.continueonerror)
			this.XMLInputs += "1";
		else
			this.XMLInputs += "0";
		this.XMLInputs += "\"></operations>";
	}
	var idxStart = this.XMLInputs.indexOf ("</operations>");
	var szTmp = this.XMLInputs.substring (0, idxStart);
	this.XMLInputs = szTmp + this.XMLOperation + "</operations>";
	this.XMLOperation = "";
}
