
function delay()
{
this.from=0;
this.to=100;
this.step=1;
this.time=1; //seconds


this.onStart='none';
this.onIteration='none';
this.onEnd='none';
this.now=this.from;
_this=this;

this.start=function()
{
_this.speed=(this.time*1000)/((this.to-this.from)/this.step);
_this.now=_this.from;
_this.stop();
_this.go();
if(_this.onStart!='none')_this.onStart();
}

this.end=function()
{
_this.stop();
if(_this.onEnd!='none')_this.onEnd();
}

this.stop=function()
{
	window.clearInterval(_this.iterator);
}

this.go=function()
{
	_this.iterator=window.setInterval(iteration,_this.speed);
}

function iteration()
{	_this.now+=_this.step;
	if(_this.onIteration!='none')_this.onIteration(_this.now);
	brk=0;
	if(_this.step>0&&_this.now>=_this.to)brk=1;
	if(_this.step<0&&_this.now<=_this.to)brk=1;
	if(brk==1)_this.end();
}


}
/*
//------------------------------------------------------------------------------

	function RegisterEventHandler (object, eventName, handler)
	{
		if (object.attachEvent)
		object.attachEvent ('on' + eventName, handler);
		else if (object.addEventListener)
		object.addEventListener (eventName, handler, true);
	}

function getMouseX(e) {
	xMousePos = event.clientX + document.body.scrollLeft
	if (xMousePos < 0){xMousePos = 0}
return xMousePos;
}

function getMouseY(e) {
	yMousePos = event.clientY + document.body.scrollTop
	if (xMousePos < 0){xMousePos = 0}
return yMousePos;
}

//------------------------------------------------------------------------------

function preloadImage(src)
{
	t = new Image();
	t.src=src;
}

//------------------------------------------------------------------------------

function question(a)
{
if(confirm('Вы уверены?'))
document.location=a
}

//------------------------------------------------------------------------------

function show(a)
{
t=document.getElementById(a)
t.style.display='inline'
t.style.visibility='visible'
}
function hide(a)
{t=document.getElementById(a)
t.style.display='none'
t.style.visibility='hidden'
}
function show_hide(id)
{
t=document.getElementById(id)
if(t.style.display=='none')
{show(id);return 1;}
else
{hide(id);return 0;}
}


//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
*/

