Array.prototype.size = function(){return this.length;}
Array.prototype.elementAt = function(pos){return this[pos];}
Array.prototype.lastElement = function(){return this[this.length-1]};
Array.prototype.contains = function (elm){ return this.indexOf(elm)>-1;}
Array.prototype.addElement = function(elm)
{
	this[this.size()] = elm;
	return elm;
}
Array.prototype.insertElementAt = function(elm,pos)
{
	if(pos>=this.size())
		this.addElement(elm);
	else
	{
		for(var i=this.size()-1;i>=pos;i--)
		{
			this[i+1] = this[i];
		}
		this[pos] = elm;
	}
	return elm;
}
Array.prototype.removeElementAt = function(pos)
{
	var elm = this.elementAt(pos);
	for(var i=pos;i<this.size()-1;i++)
		this[i] = this[i+1];
	this.length--;
	return elm;
}

Array.prototype.removeElement = function(elm)
{
	var idx = this.indexOf(elm);
	if (idx>-1)
		return this.removeElementAt(idx);
	return null;
}

Array.prototype.indexOf = function(elm)
{
	var res=-1;
	for(var i=0;i<this.size() && res<0;i++)
		if(elm == this[i]) res=i;
	return res;
}

Array.prototype.emptyArray = function()
{
	this.length = 0;
}
