function XmlWriter()
{
	// Fields
	this.ElementNames = new Array();
	this.Level	= 0;
	this.Output = "";
	this.NewLine = "";
	// Methods
	this.WriteAttributeString = WriteAttributeString;
	this.WriteCData			  = WriteCData;
	this.WriteElementString   = WriteElementString;
	this.WriteEndElement	  = WriteEndElement;
	this.WriteStartDocument   = WriteStartDocument
	this.WriteStartElement	  = WriteStartElement;
	/*if (Br.IE)
		this.NewLine="\n"; //delalo to problém ve firefoxu při přiřazaní hodnoty do inputu - přiřadilo jen 1. řádek
	*/
	
	this.WriteStartDocument();
	
	function WriteAttributeString(attName, value)
	{
		this.Output = this.Output.substr(0, this.Output.lastIndexOf(">"));
		this.Output += " " + attName + "=\"" + value.toString() + "\">"+this.NewLine;	
	}
	
	function WriteCData(text)
	{
		this.Output += "<![CDATA[" + text + "]]>";
	}

	function WriteElementString(elementName, value)
	{
		this.WriteStartElement(elementName);
		this.Output += value;
		this.WriteEndElement();
	}
	
	function WriteEndElement()
	{
		this.Output += "</" + this.ElementNames[--this.Level] + ">"+this.NewLine;
	}
	
	function WriteStartDocument()
	{
		this.Output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+this.NewLine;
	}
					
	function WriteStartElement(elementName)
	{
		this.Output += "<" + elementName + ">";
		this.ElementNames[this.Level++] = elementName;
	}
}

function RpcWriter()
{
	this.WriteStartMethodCall = function () {
		this.WriteStartElement("methodCall");
	}
	
	this.WriteEndMethodCall = function () {
		this.WriteEndElement();
	}
		
	this.WriteParameter = function (name, value) {
		this.WriteStartElement("param");
		this.WriteAttributeString("name", name);
		this.Output += value;
		this.WriteEndElement();
	}
	
	this.WriteStartMethod = function (name) {
		this.WriteStartElement("method");
		this.WriteAttributeString("name", name);
		this.WriteStartElement("params");
	}
		
	this.WriteEndMethod = function () {
		this.WriteEndElement();
		this.WriteEndElement();
	}		
}
RpcWriter.prototype = new XmlWriter;

