function my_slidebox(sb_id, images, next_function)
{
	this.next = function()
	{
		var i = this.current_image;
		if(this.sb_type == "normal")
			return (i + 1) % this.files.length;
		if(this.sb_type == "reverse")
			return (i - 1 + this.files.length) % this.files.length;
		if(this.sb_type == "shuffle")
			return Math.floor(Math.random() * this.files.length);
		return 0;
	}
	
	this.id = sb_id;
	this.files = images;
	this.sb_type = next_function;
	this.show_time = 2000;
	this.change_time = 5000;
	this.total_time = this.show_time + this.change_time;

	this.quant = 40;
	this.current_image = 0;
	this.next_image = this.next();
	this.current_time = 0;
	this.top = 0;
	var obj = document.getElementById(sb_id);
	obj.my_slidebox = this;
	obj.innerHTML = '<img id="' + sb_id + '_img1" style="position:absolute;left:0px;top:0px;width:100%;height:100%;z-index:10;" src="' + images[0] + '" alt=""/><img id="' + sb_id + '_img2" style="position:absolute;left:0px;top:0px;width:100%;height:100%;z-index:5;" src="' + images[1] + '" alt=""/>';
	this.img = obj.getElementsByTagName('img');
	this.expr = 'document.getElementById("' + this.id + '").my_slidebox.refresh()';
	if(typeof(document.body.style.opacity) == 'string')
		this.browser_type = 0;
	else if(document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1] >= 5.5)
		this.browser_type = 1;
	else
		this.browser_type = 2;

	this.set_time = function(t1, t2)
	{
		this.show_time = parseInt(t1);
		this.change_time = parseInt(t2);
		this.total_time = this.show_time + this.change_time;
	}

	this.start = function()
	{
		this.timer = setTimeout(this.expr, this.quant);
	}
	
	this.stop = function()
	{
		clearTimeout(this.timer);
	}

	this.refresh = function()
	{
		this.current_time += this.quant;
		if(this.current_time >= this.total_time)
		{
			this.current_time %= this.total_time;
			this.current_image = this.next_image;
			this.next_image = this.next();
			this.img[1 - this.top].style.zIndex = 10;
			this.img[this.top].style.zIndex = 5;
			this.img[this.top].src = this.files[this.next_image];
			this.set_opacity(this.img[this.top], 1);
			this.top = 1 - this.top;
		}
		else if(this.current_time >= this.show_time)
		{
			this.set_opacity(this.img[this.top], (this.total_time - this.current_time) / this.change_time);
		}
		this.timer = setTimeout(this.expr, this.quant);
	}
	
	this.set_opacity = function(obj, value)
	{
		switch(this.browser_type)
		{
			case 0:
				obj.style.opacity = value;
				break;
			case 1:
				value *= 100;
				var alpha = obj.filters['DXImageTransform.Microsoft.Alpha'] || obj.filters.alpha;
				if (alpha)
					alpha.opacity = value;
				else
					obj.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity=" + value + ")";
				break;
			default:;
		}
	}
}
