function MainRotator(newName, newId)
{
	var name = newName;
	var id = newId;
	var objects;
	var timer=null;
	var anim=false;
	var step=0;
	var open=0;
	var pause=false;
	var direction=0;
	var prev;
	
	function getAmount()
	{
		return objects.length+1;
	}
	this.getAmount = getAmount;
	
	function startStop(obj)
	{
		if(pause)
		{
			pause=false;
			timer = setTimeout(name+'.go(1)', 4000);
		}
		else
		{
			pause=true;
			try {
				clearTimeout(timer);
			} catch(e) {}
		}
		
	}
	this.startStop = startStop;
	
	function animation()
	{
		step+=Math.abs(direction)*5;
		try {
			objects[open].style.opacity=step/100;
			objects[open].style.filter='alpha(opacity='+step+')';
			objects[prev].style.opacity=(100-step)/100;
			objects[prev].style.filter='alpha(opacity='+(100-step)+')';
		} catch (e) {}
		if(step>=100)
		{
			anim=false;
			objects[prev].style.display='none';
			objects[prev].style.position='static';
			if(!pause) { timer = setTimeout(name+'.go(1)', 4000); }
		}
		else
		{
			timer = setTimeout(name+'.animation()', 50);
		}
	}
	this.animation = animation;
	
	function go(newDirection)
	{
		if(!anim)
		{
			direction = newDirection;
			clearTimeout(timer);
			anim=true;
			step=0;
			prev=open;
			open+=direction;
			if(open>=objects.length){open=0;}
			else if(open<0) { open=objects.length-1; }
			objects[prev].style.position='absolute';
			objects[open].style.position='absolute';
			objects[prev].style.zIndex='1';
			objects[open].style.zIndex='2';
			objects[open].style.display='block';
			try {
				objects[prev].style.opacity=1;
				objects[prev].style.filter='alpha(opacity=100)';
				objects[open].style.opacity=0;
				objects[open].style.filter='alpha(opacity=0)';
			} catch (e) {}
			timer = setTimeout(name+'.animation()', 50);
		}
	}
	this.go = go;
	
	function openImage(nr) { go(nr-open); }
	this.openImage = openImage;
	
	function init()
	{
		objectsAll = document.getElementById(id).getElementsByTagName('div');
		objects=[];
		
		for(a=0;a<objectsAll.length;a++)
		{
			if(objectsAll[a].className=='banner') { objects[objects.length]=objectsAll[a]; }
		}
		
		if(objects.length>1)
		{
			for(a=0;a<objects.length;a++)
			{
				objects[a].style.display='none';
			}
			open=0;
			objects[0].style.display='block';
			timer = setTimeout(name+'.go(1)', 4000);
		}
	}
	this.init=init;
	
}

