Array.prototype.CurrentPosition=0;

Array.prototype.Contains=function(value)
{
	for(var i=0;i<this.length;i++)
		if(this[i]==value)
			return true;
	
	return false;
}

Array.prototype.GetNext=function()
{
	if(this.length==0)
		return;

	this.CurrentPosition++;
	if(this.CurrentPosition>=this.length)
		this.CurrentPosition=0;
	return this[this.CurrentPosition];
}

Array.prototype.GetPrevious=function()
{
	if(this.length==0)
		return;

	this.CurrentPosition--;
	if(this.CurrentPosition<0)
		this.CurrentPosition=this.length-1;
	return this[this.CurrentPosition];
}

Array.prototype.GetRandom=function()
{
	if(this.length==0)
		return;
	if(this.length==1)
		return this[0];

	var i;
	do 
	{
	  i = Math.floor(Math.random()*this.length);
	} while (i==this.CurrentPosition);

	this.CurrentPosition=i;
	return this[this.CurrentPosition];
}

Array.prototype.GetCurrent=function()
{
	if(this.length==0)
		return;
	return this[this.CurrentPosition];
}