function EventScroller(layerId,wrapperId,buttonUpId,buttonDownId)
{
	var layer = document.getElementById(layerId);
	var wrapper = document.getElementById(wrapperId);
	var buttonUp = document.getElementById(buttonUpId);
	var buttonDown = document.getElementById(buttonDownId);
	var mintop = -1;
	var moveInterval;
	var stepY = 20;
	var interval = 40;
	if(layer.offsetHeight > wrapper.offsetHeight)
	{
		buttonDown.style.display = "inline";
	}
	this.start = function(down) {
		window.clearInterval(moveInterval);
		mintop = wrapper.offsetHeight-layer.offsetHeight;
		var y = parseInt(layer.style.top);
		if(down && y > mintop)
		{
			buttonUp.style.display = "inline";
			moveInterval = window.setInterval(this.moveDown, interval);
		}
		if(!down && y < 0)
		{
			buttonDown.style.display = "inline";
			moveInterval = window.setInterval(this.moveUp, interval);
		}
	}
	this.moveUp = function()
	{
		var y = parseInt(layer.style.top);
		if(y > -stepY)
		{
			y = -stepY;
			this.stop();
		}
		layer.style.top = (y+stepY)+"px";
	}
	this.moveDown = function()
	{
		var y = parseInt(layer.style.top);
		if(y-stepY < mintop)
		{
			y = mintop+stepY;
			this.stop();
		}
		layer.style.top = (y-stepY)+"px";
	}
	this.stop = function()
	{
		window.clearInterval(moveInterval);
		var y = parseInt(layer.style.top);
		if(y == 0)
		{
			buttonUp.style.display = "none";
		}
		if(y == mintop)
		{
			buttonDown.style.display = "none";
		}
	}
}

var events = new Array();

function addEvent(id,pic,club,title,text)
{
	var index = events.length;
	events[index] = new Array();
	events[index]["id"] = id;
	events[index]["pic"] = pic;
	events[index]["club"] = club;
	events[index]["title"] = title;
	events[index]["text"] = text;
}

var eventMoreHandle = null;

function showMore(id)
{
	var index = -1;
	for(var i=0;i<events.length;i++)
	{
		if(events[i]["id"] == id)
		{
			index = i;
		}
	}
	document.getElementById('moretitle').innerHTML = events[index]["title"];
	document.getElementById('moreclub').innerHTML = events[index]["club"];
	document.getElementById('moreimg').src = events[index]["pic"];
	document.getElementById('moreimg').style.display = (events[index]["pic"].length < 6) ? "none" : "inline";
	document.getElementById('moretxt').innerHTML = events[index]["text"];
	var div = document.getElementById('eventmore');
	if(div.parentNode != document.body)
	{
		document.body.appendChild(div);
	}
	if(div.style.display != 'inline')
	{
		div.style.display = 'inline';
		eventMoreHandle = window.setInterval("setEventMore()",100);
		setEventMore();
	}
}

function setEventMore()
{
	var bounds = getWindowBoundsRect();
	divBg = document.getElementById("eventmore");
	var outerPad = 20;
	var innerPad = 20;
	var boundW = bounds[2]-outerPad * 2;
	var boundH = bounds[3]-outerPad * 2;
	var w = 400;
	var h = document.getElementById("moresize").offsetHeight+2*innerPad;
	if(boundW < w) w = boundW;
	if(boundH < h) h = boundH;
	var div_l = (w < boundW) ? Math.round((bounds[2] - w) / 2) : outerPad;
	var div_t = (h < boundH) ? Math.round((bounds[3] - h) / 2) : outerPad;
	divBg.style.left = (bounds[0] + div_l)+"px";
	divBg.style.top =  (bounds[1] + div_t)+"px";
	divBg.style.width = (w-innerPad*2)+"px";
	divBg.style.height = (h-innerPad*2)+"px";
}

function hideMore()
{
	document.getElementById('eventmore').style.display = 'none';
	if(eventMoreHandle != null) window.clearInterval(eventMoreHandle);
}

