  function Collection()
{
	this.Items = new Array();
	var pocet_hodnot = 0;
	// Methods
	this.Add	  = Add;
	this.Get  	  = Get;
	this.Remove   = Remove;
	this.Count	  = Count;
	this.Clear	  = Clear;
	this.IndexOf  = IndexOf;
	this.Contains = Contains;
	this.Sort = Sort;
	// Events
	this.Inserting = null;
	this.Inserted = null;
	this.Deleting = null;
	this.Deleted = null;

	this.OnInserting = function (args) { if (this.Inserting) this.Inserting(args)};
	this.OnInserted  = function (args) { if (this.Inserted)	 this.Inserted(args)};
	this.OnDeleting  = function (args) { if (this.Deleting)  this.Deleting(args)};
	this.OnDeleted   = function (args) { if (this.Deleted)	 this.Deleted(args)};

	function Add(value)
	{
		this.OnInserting(value);

		var ind=this.Count();
		this.Items[ind] = value;
		pocet_hodnot++;

		this.OnInserted(value)
		return ind;
	}

	function Get(index)
	{
		if ((index < 0) || (index > this.Count() - 1)) return null;
		return this.Items[index];
	}

	function Count()
	{
		return pocet_hodnot;
	}

	function Remove(index)
	{
		if ((index<0)||(index>pocet_hodnot-1))
			return;

		this.OnDeleting();

		for (a=index;a<pocet_hodnot;a++)
			this.Items[a]=this.Items[a+1];

		this.Items.length = --pocet_hodnot;

		this.OnDeleted;
	}

	function Clear()
	{
		for (a=0;a<pocet_hodnot;a++)
			this.Items[a]=this.Items[pocet_hodnot];
		pocet_hodnot=0;
	}

	function IndexOf(value)
	{
		for (a=0;a<pocet_hodnot;a++)
			if (this.Items[a]==value)
				return a;
		return -1;
	}

	function Contains(value)
	{
		return (this.IndexOf(value)!=-1);
	}

	function Sort(sortFunction)
	{
		return this.Items.sort(sortFunction);
	}
}

  function StringCollection()
  {
        this.Parse = Parse;
        this.Delimiter = ",";
        this.ToString = ToString;
        
        function Parse(value)
        {
            this.Items = value.split(this.Delimiter);
        }
        
        function ToString()
        {
            var result = "";
            for (var i = 0; i < this.Items.length; i++)
            {
                if (result != '')
                {
                    result += this.Delimiter;
                }
                result += this.Items[i];
            }
            return result;
        }
  }
  StringCollection.prototype = new Collection;

function Hashtable()
{
	var indexy=new Collection();
	var values=new Collection();
	
	this.Add = Add;
	this.Get = Get;
	this.GetKey = GetKey;
	this.GetValue = GetValue;
	this.Remove = Remove;
	this.Count = Count;
	this.Clear = Clear;
	this.Contains = Contains;

	function Add(key,value)
	{
		//? ma zjistovat existenci "key" v seznamu ?
		indexy.Add(key);
		values.Add(value);
	}
	
	function Get(key)
	{
		var ind=indexy.IndexOf(key);
		if (ind==-1)
			return null;
		return values.Get(ind);
	}

	function GetKey(index)
	{
		return indexy.Get(index);
	}

	function GetValue(index)
	{
		return values.Get(index);
	}
	
	function Remove(key)
	{
		var ind=indexy.IndexOf(key);
		if (ind==-1)
			return;
		indexy.Remove(ind);
		values.Remove(ind);
	}
	
	function Count()
	{
		return indexy.Count();
	}

	function Clear()
	{
		indexy.Clear();
		values.Clear();
	}

	function Contains(key)
	{
		return indexy.Contains(key);
	}
}