var hl_show_now=0;
var hl_cnt=1;
var hl_max=34;
var hl_img0=0;
var hl_img1=0;

var now_show=0;

function delay_show(id)
{
var obj=document.getElementById(id);
var delayBefore=100;
var delayAfter=100;
var timeout=1;
var id=id;
this.show=function ()
	{
	window.clearTimeout(timeout);
	timeout=window.setTimeout(showing,delayBefore);

	}

this.hide=function ()
	{
	if(now_show!=0&&id==now_show.getId())return;
	window.clearTimeout(timeout);
	timeout=window.setTimeout(hiding,delayAfter);
	}

obj.onmouseover=this.show;
obj.onmouseout=this.hide;


this.just_hide=function ()
{
hiding();
}
this.just_show=function ()
{
showing();
}
this.getId=function ()
{
return id;
}
	function showing()
	{
	obj.style.display="block";
	window.clearTimeout(timeout);
	if(now_show!=0&&id!=now_show.getId())
	now_show.just_hide();
	}


	function hiding()
	{
	obj.style.display="none";
	window.clearTimeout(timeout);
	if(now_show!=0&&id!=now_show.getId())
	now_show.just_show();
	}
}

var hl_tracer=new delay();

hl_tracer.onIteration=hl_iteration;
hl_tracer.onEnd=hl_prepare_image;
hl_tracer.time=10;


function hl_start()
{hl_img0=document.getElementById('headline_img0');
hl_img1=document.getElementById('headline_img1');hl_prepare_image();
}

function hl_prepare_image()
{hl_cnt=Math.floor(Math.random()*(hl_max-1))+1;
if(hl_cnt>hl_max)hl_cnt=1;
if(hl_show_now==0)
{
hl_img1.src="/topimg/"+hl_cnt+".jpg";
hl_tracer.from=0;
hl_tracer.to=99;
hl_tracer.step=1;

}
else
{hl_tracer.from=99;
hl_tracer.to=0;
hl_tracer.step=-1;
hl_img0.src="/topimg/"+hl_cnt+".jpg";
}
hl_show_now=1-hl_show_now;

hl_tracer.start();
}

function hl_iteration(now_op)
{set_opacity(hl_img1,now_op);
}

function set_opacity(obj,procent)
{	obj.style.opacity = procent/100;
	obj.style.filter = "alpha(opacity:" + procent + ")";
}
















