var slider_c = function()
{
	this.prefix_s = false;
	this.separator_s = false;
	this.suffix_s = false;

	this.scroller_up_id_s = false;
	this.scroller_down_id_s = false;
	this.scroller_speed_i = false;

	this.div_a = new Array();

	this.expand_interval_i = false;
};

/**/

slider_c.prototype.getDivByPrefixAndSuffix = function(prefix_s, suffix_s)
{
	for (var i_i = 0; i_i < this.div_a.length; i_i++)
	{
		if (this.div_a[i_i].id.substr(0, prefix_s.length) == prefix_s)
		{
			if (this.div_a[i_i].id.substr((this.div_a[i_i].id.length - suffix_s.length), suffix_s.length) == suffix_s)
			{
				return this.div_a[i_i];
			}
		}
	}

	return false;
};

slider_c.prototype.getX = function(element_o)
{
   return element_o.offsetParent ? element_o.offsetLeft + this.getX(element_o.offsetParent) : element_o.offsetLeft;
}


slider_c.prototype.getY = function(element_o)
{
   return element_o.offsetParent ? element_o.offsetTop + this.getY(element_o.offsetParent) : element_o.offsetTop;
}

slider_c.prototype.getWidth = function(element_o)
{
   return element_o.offsetWidth;
}

slider_c.prototype.getHeight = function(element_o)
{
   return element_o.offsetHeight;
}

slider_c.prototype.getInnerHeight = function(element_o)
{
	var height_i = 0;

	for (var i_i = 0; i_i < element_o.childNodes.length; i_i++)
	{
		if (typeof element_o.childNodes[i_i].offsetHeight != 'undefined')
		{
			height_i += element_o.childNodes[i_i].offsetHeight;
		}
	}

	return height_i;
};

/**/

slider_c.prototype.setDivArray = function()
{
	var div_a = document.getElementsByTagName('div');

	for (var i_i = 0; i_i < div_a.length; i_i++)
	{
		if (typeof div_a[i_i].id != 'undefined')
		{
			if (div_a[i_i].id.substr(0, this.prefix_s.length) == this.prefix_s)
			{
				if (div_a[i_i].id.substr((div_a[i_i].id.length - this.suffix_s.length), this.suffix_s.length) == this.suffix_s)
				{
					this.div_a[this.div_a.length] = div_a[i_i];
				}
			}
		}
	}
};

slider_c.prototype.setCollapse = function()
{
	for (var i_i = 0; i_i < this.div_a.length; i_i++)
	{
		this.div_a[i_i].style.height = '1px';
		this.div_a[i_i].style.display = 'none';
	}
};

slider_c.prototype.setResize = function()
{
	alert('Hallo');
};

slider_c.prototype.setExpand = function(group_i)
{
	var owner_o = this;

	var prefix_s = this.prefix_s + group_i;
	var suffix_s = this.suffix_s;

	var group_o = this.getDivByPrefixAndSuffix(prefix_s, suffix_s);

	if (group_o)
	{
		clearInterval(this.expand_interval_i);

		group_o.style.display = '';

		var preferred_height_i = Number(group_o.id.substring(prefix_s.length + this.separator_s.length, group_o.id.length - suffix_s.length));
		var content_height_i = this.getInnerHeight(group_o);

		if (this.scroller_up_id_s)
		{
			var scroller_up_o = document.getElementById(this.scroller_up_id_s);
			var scroller_down_o = document.getElementById(this.scroller_down_id_s);

			scroller_up_o.onmouseover = function()
			{
				var setScroll = function()
				{
					group_o.scrollTop -= 1;
				};

				this.scroll_interval_i = setInterval(setScroll, owner_o.scroller_speed_i);
			};

			scroller_up_o.onmouseout = function()
			{
				clearInterval(this.scroll_interval_i);
			};

			/**/

			scroller_down_o.onmouseover = function()
			{
				var setScroll = function()
				{
					group_o.scrollTop += 1;
				};

				this.scroll_interval_i = setInterval(setScroll, owner_o.scroller_speed_i);
			};

			scroller_down_o.onmouseout = function()
			{
				clearInterval(this.scroll_interval_i);
			};

			scroller_up_o.style.display = (content_height_i > preferred_height_i) ? '' : 'none';
			scroller_down_o.style.display = (content_height_i > preferred_height_i) ? '' : 'none';

			scroller_up_o.style.top = (this.getY(group_o) - this.getHeight(scroller_up_o)) + 'px';
			scroller_up_o.style.left = ((this.getX(group_o) + this.getWidth(group_o)) - this.getWidth(scroller_up_o)) + 'px';

			scroller_down_o.style.left = ((this.getX(group_o) + this.getWidth(group_o)) - this.getWidth(scroller_down_o)) + 'px';
		}
		else
		{
			group_o.style.overflow = (content_height_i > preferred_height_i) ? 'auto' : 'hidden';
		}

		var setSlide = function()
		{
			var height_i = Number(group_o.style.height.substring(0, group_o.style.height.length - 2));

			if (height_i < preferred_height_i)
			{
				var difference_i = ((preferred_height_i + 2) - height_i) / 3;

				group_o.style.height = (height_i + difference_i) + 'px';

				if (owner_o.scroller_up_id_s)
				{
					scroller_down_o.style.top = (owner_o.getY(group_o) + owner_o.getHeight(group_o)) + 'px';
				}
			}
			else
			{
				clearInterval(owner_o.expand_interval_i);
			}
		};

		this.expand_interval_i = setInterval(setSlide, 50);
	}
};

/**/

slider_c.prototype.setOver = function(element_o)
{
	element_o.className = 'menu-row-over';
};

slider_c.prototype.setClick = function(group_i)
{
	this.setCollapse();
	this.setExpand(group_i);
};

slider_c.prototype.setOut = function(element_o)
{
	element_o.className = 'menu-row-out';
};

/**/

slider_c.prototype.setPrefix = function(prefix_s)
{
	this.prefix_s = prefix_s;
};

slider_c.prototype.setSeparator = function(separator_s)
{
	this.separator_s = separator_s;
};

slider_c.prototype.setSuffix = function(suffix_s)
{
	this.suffix_s = suffix_s;
};

/**/

slider_c.prototype.setScrollerUpId = function(id_s)
{
	this.scroller_up_id_s = id_s;
};

slider_c.prototype.setScrollerDownId = function(id_s)
{
	this.scroller_down_id_s = id_s;
};

slider_c.prototype.setScrollerSpeed = function(speed_i)
{
	this.scroller_speed_i = speed_i;
};

/**/

slider_c.prototype.setSlider = function(group_i)
{
	this.setDivArray();

	this.setCollapse();
	this.setExpand(group_i);
};