//paulgrant.ca 2007

function show(bHide)
{
	var oDiv = document.getElementById("newsPlayerItem_" + this.iIdx);
	if(!oDiv)
		return false;

	oDiv.style.visibility = ((bHide) ? "hidden" : "visible");

	var oImg = document.getElementById("imgNews_" + this.iIdx);
	if(!oImg)
		return false;

	oImg.src = ((bHide) ? (this.sImgDir + "circle" + this.iIdx + ".gif") : (this.sImgDir + "square" + this.iIdx + ".gif"));

	return true;
}

function go(iIdx)
{
	this.show(true);

	this.iIdx = iIdx;

	this.show();

	return true;
}

function next()
{
	this.show(true);

	this.iIdx++;
	if(this.iIdx > this.iIdxMax)
		this.iIdx = 1;

	this.show();

	return true;
}

function back()
{
	this.show(true);

	this.iIdx--;
	if(this.iIdx < 1)
		this.iIdx = this.iIdxMax;

	this.show();

	return true;
}

function play()
{
	var oImg = document.getElementById("imgPlay");
	if(!oImg)
		return false;

	oImg.src = ((this.bPaused) ? (this.sImgDir + "pause.gif") : (this.sImgDir + "play.gif"));

	this.bPaused = !this.bPaused;

	if(this.bPaused == true)
		window.clearTimeout(this.iTimeout);
	else
		window.setTimeout("oNewsPlayer.run();", 1000);

	return true;
}

function run()
{
	if(this.bPaused == true)
		return false;

	this.next();

	window.setTimeout("oNewsPlayer.run();", 10000);

	return true;
}

function LoadImages()
{
	var aImages = new Array(this.iIdxMax+1);

	for(var i = 1; i <= this.iIdxMax; i++)
	{
		aImages[ i ] = new Image();
		aImages.src = (this.sImgDir + "square" + i + ".gif");
	}

	aImages[ i ] = new Image();
	aImages.src = (this.sImgDir + "pause.gif");

	return true;
}

function NewsPlayerClass()
{
	this.sImgDir	= "/site/player/";

	this.iIdx		= 0;
	this.iIdxMax	= 5;

	this.bPaused	= true;
	this.iTimeout	= null;

	this.next		= next;
	this.back		= back;
	this.play		= play;
	this.go			= go;
	this.show		= show;
	this.run		= run;
	this.LoadImages	= LoadImages;

	return this;
}

var oNewsPlayer = new NewsPlayerClass();

oNewsPlayer.LoadImages();

//End.