var xmlHttp;

function Ywindow()
{
	var scrollY = 0;
	
	if ( document.documentElement && document.documentElement.scrollTop )
	{
		scrollY = document.documentElement.scrollTop;
	}
	else if ( document.body && document.body.scrollTop )
	{
		scrollY = document.body.scrollTop;
	}
	else if ( window.pageYOffset )
	{
		scrollY = window.pageYOffset;
	}
	else if ( window.scrollY )
	{
		scrollY = window.scrollY;
	}
	
	return scrollY;
}

function showgif()
{
	try
	{
		var divobj = document.getElementById('loading-layer');
	}
	catch(e)
	{
		return;
	}
	
	//----------------------------------
	// Figure width and height
	//----------------------------------
	
	var my_width  = 0;
	var my_height = 0;
	
	if ( typeof( window.innerWidth ) == 'number' )
	{
		my_width  = window.innerWidth;
		my_height = window.innerHeight;
	}
	else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		my_width  = document.documentElement.clientWidth;
		my_height = document.documentElement.clientHeight;
	}
	else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		my_width  = document.body.clientWidth;
		my_height = document.body.clientHeight;
	}
	
	divobj.style.position = 'absolute';
	divobj.style.display  = 'block';
	divobj.style.zIndex   = 99;
	
	var divheight = parseInt( divobj.style.Height );
	var divwidth  = parseInt( divobj.style.Width );
	
	divheight = divheight ? divheight : 15;
	divwidth  = divwidth  ? divwidth  : 15;
	
	var scrolly = Ywindow();
	
	var setX = ( my_width  - divwidth  ) / 2;
	var setY = ( my_height - divheight ) / 2 + scrolly;
	
	setX = ( setX < 0 ) ? 0 : setX;
	setY = ( setY < 0 ) ? 0 : setY;
	
	divobj.style.left = setX + "px";
	divobj.style.top  = setY + "px";
}

function hidegif()
{
	try
	{
		var divobj = document.getElementById('loading-layer');
	}
	catch(e)
	{
		return;
	}
	divobj.style.display  = 'none';
}

function BackForward(url)
{
xmlHttp = GetXmlHttpObject();
if (xmlHttp == null)
 {
 alert ("Your browser does not support HTTP Request. Please, update your browser.");
 return;
 }
showgif();
xmlHttp.onreadystatechange = stateChanged;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}

function Back()
{ 
var n = document.getElementById('timepos').value;
n++;
document.getElementById('timepos').value = n;
var url = "/irget.php";
url = url + "?n=" + n;
BackForward(url);
}

function Forward()
{ 
var n = document.getElementById('timepos').value;
n--;
document.getElementById('timepos').value = n;
var url = "/irget.php";
url = url + "?n=" + n;
BackForward(url);
}

function stateChanged()
{ 
if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
{ 
 var temp = new Array();
 temp = xmlHttp.responseText.split('\n');
 hidegif();
 if (temp[0] == '1')
 {
  document.getElementById('la1').style.display = "none";
  document.getElementById('la2').style.display = "none";
 }
else
{
 document.getElementById('la1').style.display = "block";
 document.getElementById('la2').style.display = "block";
}
var n = document.getElementById('timepos').value;
if (n <= 0) 
{
 document.getElementById('ra1').style.display = "none";
 document.getElementById('ra2').style.display = "none";
}
else
{
 document.getElementById('ra1').style.display = "inline";
 document.getElementById('ra2').style.display = "inline";
}
 for (var i = 1; i <= 20; i++)
 {
  if (temp[i] == '-') continue;
  var interest = temp[i].split('*');

  if (i == 1) document.getElementById("ir"+i).innerHTML=interest[1] + "% &dagger;"; 
  else if (i == 8) document.getElementById("ir"+i).innerHTML=interest[1] + "% *"; 
  else document.getElementById("ir"+i).innerHTML=interest[1] + "%"; 

  document.getElementById("irlc"+i).innerHTML= " on " + interest[0] + " by " + interest[3] + "%"; 
  if (interest[2] == '1') document.getElementById("iru"+i).className = "vis";
  else document.getElementById("iru"+i).className = "invis";
  if (interest[2] == '0') document.getElementById("irn"+i).className = "vis";
  else document.getElementById("irn"+i).className = "invis";
  if (interest[2] == '-1') document.getElementById("ird"+i).className = "vis";
  else document.getElementById("ird"+i).className = "invis";
 }
} 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp = new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}