﻿function blurScrollEl(id, srcId, idx, rotation)
{
	if (!document.getElementById) return;
	var NUM_ROTS = 20;
	
	//validate input
	var el = document.getElementById(id);
	var srcEl = document.getElementById(srcId);
	
	if (rotation == null) rotation = NUM_ROTS;
	idx = idx || 0;
	
	//get or set the content
	var content = srcEl.innerHTML;
	
	//split into lines and get appropriate line
	var lines = content.split("|");
	if (idx >= lines.length) idx = 0;
	
	//set deafult text
	el.innerHTML = lines[idx];
	
	if (rotation < 0)
	{ //switch the message
		el.style.filter = "";
		el.style.opacity = "1";
		if (lines.length == 1)
		{
			//no need to switch if there's only one line
			setTimeout("blurScrollEl('"+id+"','"+srcId+"',0,-1)",2000);
		}
		else
		{ 
			setTimeout("blurScrollEl('"+id+"','"+srcId+"',"+(idx+1)+","+NUM_ROTS+")",2000);
		}
	}
	else
	{
		el.style.filter = "blur(add=0,strength="+(rotation/2)+",direction=90)";
		el.style.filter += " alpha(opacity="+((NUM_ROTS - rotation) / (NUM_ROTS/100))+")";
		el.style.opacity = (NUM_ROTS - rotation) / NUM_ROTS;
		setTimeout("blurScrollEl('"+id+"','"+srcId+"',"+(idx)+","+(rotation-1)+")",60);
	}
}

function updateFooter(id,firststart)
{ var REFRESH_RATE = 60000;
	if (!document.getElementById) return;
	if (firststart)
	{
		window.updateFooter__Timer = window.setTimeout("updateFooter('" + id + "');", REFRESH_RATE);	
		return;
	}
	
	if (window.XMLHttpRequest)
		window.updateFooter__xmlHttp = new XMLHttpRequest();
	else if (window.ActiveXObject) 
		window.updateFooter__xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return;
	
	try
	{
		window.updateFooter__xmlHttp.open("POST","/getFooter.aspx", true);
		window.updateFooter__xmlHttp.onreadystatechange = function() 
		{
			if ( (window.updateFooter__xmlHttp.readyState==4) && (window.updateFooter__xmlHttp.status==200) )
			{
				document.getElementById(id).innerHTML = window.updateFooter__xmlHttp.responseText;
				document.getElementById('notificationsDiv').style.display = 
					window.updateFooter__xmlHttp.getResponseHeader("CYSNTFCTNDISP");
				window.updateFooter__Timer = 
					window.setTimeout(
						"updateFooter('" + id + "');", 
						REFRESH_RATE);
			}
		}
		updateFooter__xmlHttp.send("");
	}
	catch (ex)
	{
		alert(ex);
		window.clearTimeout(window.updateFooter__Timer);
	}
}