var element = null;
var opacity = 0;
var cur = 1;
var prev = 1;
var anim_over = 1;
var on = 1;

function slideshow()
{
	if (on==1)
	{
		next_img('slide');
		setTimeout('slideshow()',5000);
	}
}

function show(el)
{
	element = el;
	opacity = 0;
	anim_over = 0;
	document.getElementById('link'+cur).innerHTML = '<img src="'+imgPath+'n_'+cur+'.gif" alt="" style="padding-bottom: 3px" />';
	document.getElementById('link'+prev).innerHTML = '<img src="'+imgPath+'n_'+prev+'.gif" alt="" />';
	if (document.all && !window.opera)
		opacity_upIE();
	else
		opacity_up();
}

function opacity_up()
{
	element.style.opacity = opacity;
	opacity += 0.1;
	if (opacity<=1)
		setTimeout('opacity_up()',50);
	else if (element.id!='current')
	{
		document.getElementById('current').src = element.src;
		element.style.opacity = 0;
		anim_over = 1;
	}
}

function opacity_upIE()
{
	opIE = opacity * 100;
	element.style.filter = 'alpha(opacity='+opIE+')';
	opacity += 0.1;
	if (opacity<=1)
		setTimeout('opacity_upIE()',50);
	else if (element.id!='current')
	{
		document.getElementById('current').src = element.src;
		element.filter = 'alpha(opacity=0)';
		anim_over = 1;
	}
}

function next_img(z)
{
	if (z != 'slide')
	{
		on = 0;	
	}
	if (anim_over == 1)
	{
		prev = cur;
		cur += 1;
		if (cur > 4)
			cur = 1;
		document.getElementById('next').src = imgPath+'mg/img'+cur+'.jpg'
	}
}

function prev_img()
{
	on = 0;
	if (anim_over == 1)
	{
		prev = cur;
		cur -= 1;
		if (cur < 1)
			cur = 4;
		document.getElementById('next').src = imgPath+'mg/img'+cur+'.jpg';
	}
}

function set_img(i)
{
	on = 0;
	if (anim_over == 1 && i!=cur)
	{
		prev = cur;
		cur = i;
		document.getElementById('next').src = imgPath+'mg/img'+cur+'.jpg';
	}
}

