function CData()
{
	this.Objekt = "";
	this.Command = "";
	
	this.Attrib = new Array();
	this.Value = new Array();

	this.ParamName = new Array();
	this.ParamValue = new Array();

	this.Ciphering = InitCiphering && window.parent.document.location.protocol != 'https:';
}

CData.prototype.SetObject = function(Value)
{
	this.Objekt = utf8_encode(Value);
}

CData.prototype.SetCommand = function(Value)
{
	this.Command = utf8_encode(Value);
}

CData.prototype.SetAttrib = function(Attrib, Value)
{
	this.Attrib.push(Attrib);
	this.Value.push(utf8_encode(Value));
}

CData.prototype.SetParam = function(Name, Value)
{
	this.ParamName.push(Name);
	this.ParamValue.push(utf8_encode(Value));
}

CData.prototype.GetParam = function(Name)
{
	for(var i = 0; i < this.ParamName.length; ++i) if(Name == this.ParamName[i]) return utf8_decode(this.ParamValue[i]);
	return "";
}

CData.prototype.GetParamCount = function()
{
	return this.ParamName.length;
}

CData.prototype.GetParamName = function(i)
{
	return i < 0 || i >= this.ParamName.length ? "" : this.ParamName[i];
}

CData.prototype.GetParamValue = function(i)
{
	return i < 0 || i >= this.ParamName.length ? "" : utf8_decode(this.ParamValue[i]);
}

CData.prototype._Cipher = function(i, k) { return (Math.abs(k[2] * i - k[1]) * Math.abs(i - k[0])) % 256; }

CData.prototype.Encode = function(Text, Key)
{
	Code = "";
	for(i = 0; i < Text.length; ++i)
	{
		var C = this.Ciphering ? Text.charCodeAt(i) ^ this._Cipher(i, Key) : Text.charCodeAt(i);
		var Ch = C.toString(16);
		if(Ch.length < 2) Code += "0";
		Code += Ch;
	}
	
	return (this.Ciphering ? "AFFE1" : "AFFE2") + Code;
}

CData.prototype.Decode = function(Payload, Key)
{
	var Ciphering = null;

	switch(Payload.substr(0, 5))
	{
		case "AFFE1":
			Ciphering = true;
			break;
		
		case "AFFE2":
			Ciphering = false;
			break;
		
		default:
			return Payload;
	}

	var Text = "";
	var Code = Payload.substr(5, Payload.length - 5);
	for(i = 0; i < Code.length; i += 2) Text += Ciphering ? String.fromCharCode(parseInt(Code.substr(i, 2), 16) ^ this._Cipher(i / 2, Key)) : String.fromCharCode(parseInt(Code.substr(i, 2), 16));
	return Text;
}

CData.prototype.Get = function()
{
	Xml = "<PHPRE2>";
	Xml += "<OBJECT>" + this.Objekt + "</OBJECT>";
	Xml += "<COMMAND>" + this.Command + "</COMMAND>";
	Xml += "<ATTRIBUTES>";
	while(this.Attrib.length > 0)	Xml += "<ATTRIBUTE name=\"" + this.Attrib.shift() + "\" value=\"" + this.Value.shift() + "\"/>";
	Xml += "</ATTRIBUTES>";
	Xml += "<PARAMETERS>";
	while(this.ParamName.length > 0)	Xml += "<PARAMETER name=\"" + this.ParamName.shift() + "\" value=\"" + this.ParamValue.shift() + "\"/>";
	Xml += "</PARAMETERS>";
	Xml += "</PHPRE2>";

	return this.Encode(XMLEncode(Xml), Session.GetK());
}
