Array.prototype.each = function(callback)
{
	if(is(callback,'function'))
	{
		for(var i = 0; i < this.length; i++)
		{
			callback(this[i],i);
		}
	}
};

Array.prototype.pointer=0;
Array.prototype.current = function()
{
	return this[this.pointer];
};

Array.prototype.hasNext = function()
{
	return is(this[this.pointer+1]);
};

Array.prototype.hasPrev = function()
{
	return is(this[this.pointer-1]);
};

Array.prototype.next = function()
{
	if(this.hasNext() == false)
		return false;
	else
	{
		this.pointer++;
		return this.current();
	}
};

Array.prototype.prev = function()
{
	if(this.hasPrev() == false)
		return false;
	else
	{
		this.pointer--;
		return this.current();
	}
};


var is = function (v,type)
{
	if(typeof type == 'undefined')
		return !!v;
	
	type=type.toLowerCase();
	if(type == 'nan')
	{
		return isNaN(v);
	}
	
	var vt = typeof v;
	if(vt === 'object')
	{
		if(v)
		{
			if (typeof v.length === 'number' && !(v.propertyIsEnumerable('length')) && typeof v.splice === 'function') 
			{              
				vt = 'array';
			}
		}
		else
		{
			vt = 'null';
		}
	}
	
	if(type=="type")
		return vt;
	
	return vt == type ? true : false;
};



window.onkeypress = function(e)
{
	if(!is(e))
		e = window.event;
	
	if(!is(dood,'object'))
		return;
	else
		dood.handle(e.keyCode);
};

