
pic1 = new Image();
pic2 = new Image();
pic3 = new Image();
pic4 = new Image();
pic1.src="./common/img/rotationpicture_1.jpg";
pic2.src="./common/img/rotationpicture_2.jpg";
pic3.src="./common/img/rotationpicture_3.jpg";
pic4.src="./common/img/rotationpicture_4.jpg";

function newsShow(next)
{
	if(!next)
	{
		next = 1;
		var clock = setTimeout("newsShow("+next+");",5000);
	}else
	{
		lowerOpacity("news"+next);
		next = next + 1;
		if(next == 5)
			next = 1;
		addOpacity("news"+next);
		var clock = setTimeout("newsShow("+next+");",10000);
	}
}

function slideShow(next)
{
	var startfadingfrom;
	startfadingfrom = document.getElementById("topimage").style.opacity;
	if(startfadingfrom < 1 && startfadingfrom > 0)
	{
		var clock = setTimeout("slideShow("+next+");",2000);
	}else{
		if(!next && next != 0)
		{
			var curdate = new Date();
			var hours = curdate.getHours();
			var randi = hours % 4;
			next = randi;
		}
		var pictures= new Array("./common/img/rotationpicture_1.jpg","./common/img/rotationpicture_2.jpg","./common/img/rotationpicture_3.jpg","./common/img/rotationpicture_4.jpg");
		fadeToImage(pictures[next]);
		next = next + 1;
		if(next >= pictures.length)
			next = 0;
		//alert(pictures[next]);
		var clock = setTimeout("slideShow("+next+");",8000);
	}
}

function fadeToImage(imagefilename)
{
	startfadingfrom = document.getElementById("topimage").style.opacity;
	if(!startfadingfrom)
		startfadingfrom = 1;

	if(startfadingfrom == 1)
	{
		document.getElementById("bottomimage").style.backgroundImage = 'url('+imagefilename+')';
		lowerOpacity("topimage");
	}
	if(startfadingfrom == 0)
	{
		document.getElementById("topimage").src = imagefilename;
		addOpacity("topimage");
	}
}

function lowerOpacity(elementid,opacityvalue)
{
	var fadingtime = 1;
	if(!opacityvalue)
	{
		var opacityvalue = 1;
	}
	if(opacityvalue > 0)
	{
		opacityvalue = opacityvalue - 0.01;
		document.getElementById(elementid).style.opacity = opacityvalue;
		document.getElementById(elementid).style.filter = 'alpha(opacity=' + opacityvalue*100 + ')';
		var clock = setTimeout("lowerOpacity('"+elementid+"',"+opacityvalue+");",fadingtime*10);
	}else{
		opacityvalue = 0;
		document.getElementById(elementid).style.opacity = opacityvalue;
		document.getElementById(elementid).style.display = "none";
	}
}

function addOpacity(elementid,opacityvalue)
{
	var fadingtime = 1;
	if(!opacityvalue)
	{
		opacityvalue = 0;
		document.getElementById(elementid).style.display = "block";
	}
	if(opacityvalue < 1)
	{
		opacityvalue = opacityvalue + 0.01;
		document.getElementById(elementid).style.opacity = opacityvalue;
		document.getElementById(elementid).style.filter = 'alpha(opacity=' + opacityvalue*100 + ')';
		var clock = setTimeout("addOpacity('"+elementid+"',"+opacityvalue+");",fadingtime*10);
	}else{
		opacityvalue = 1;
		document.getElementById(elementid).style.opacity = opacityvalue;
		document.getElementById(elementid).style.filter = 'alpha(opacity=' + opacityvalue*100 + ')';
	}
	return;
}
