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.speed=(this.time*1000)/((this.to-this.from)/this.step);
_this=this;

this.start=function()
{
_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(event) {
	xMousePos = event.clientX + document.body.scrollLeft
	if (xMousePos < 0){xMousePos = 0}
return xMousePos;
}

function getMouseY(event) {
	yMousePos = event.clientY + document.body.scrollTop
	if (yMousePos < 0){yMousePos = 0}
return yMousePos;
}

function updateMousePosition(event)
{
xMousePos=getMouseX(event);
yMousePos=getMouseY(event);
}
//------------------------------------------------------------------------------

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;}
}

  //----------------------------------------------------------------------------
  // Прочитать кук
  //----------------------------------------------------------------------------
	function getCookie(name)
	{
		var cookie=" "+document.cookie;
		var search=" "+name+"=";
		var ret=null;
		var offset=0;
		var end=0;
		if (cookie.length>0)
		{
			offset=cookie.indexOf(search);
			if (offset!=-1)
			{
				offset+=search.length;
				end=cookie.indexOf(";",offset);
				if (end==-1)end=cookie.length;
				ret=unescape(cookie.substring(offset,end));
			}
		}
		return ret;
	}

  //----------------------------------------------------------------------------
  // Записать кук
  //----------------------------------------------------------------------------
  function setCookie (name, value) 
  {
    // Ставим дату 1 день
    var clive = new Date();
		clive.setDate(clive.getDate()+1);
		clive = clive.toGMTString();
    document.cookie = name + "=" + escape(value) + ";expires=" + clive;
  }

//----------------------------------------------------------------------------
// Отладка
//----------------------------------------------------------------------------
function d(text)
{
  document.getElementById('trace').innerHTML += text + "<br>";
}

function d_clr() {document.getElementById('trace').innerHTML = '';}


//------------------------------------------------------------------------------
//------------------------------------------------------------------------------


