﻿this.billboardCount = 2;
this.billboardSwitchTime = 10000;
this.billboardCache = new Array(this.billboardCount);
this.currentBillboard = 0;

function StartBillboard()
{
	this.currentBillboard = Math.floor(Math.random()*this.billboardCount);
	ShowBillboard();
}

function SwitchBillboard()
{
	this.currentBillboard++;
	if(this.currentBillboard >= this.billboardCount)
	{
		this.currentBillboard = 0;
	}
	ShowBillboard();
	return true;
}

function ShowBillboard()
{
	if(document.getElementById('BillboardContainer'))
	{
		if(document.images)
		{
			if(this.billboardCache[this.currentBillboard] == null)
			{
				sourcePath = 'images/billboard' + (this.currentBillboard + 1) + '.jpg';
				this.billboardCache[this.currentBillboard] = new Image;
				this.billboardCache[this.currentBillboard].src = sourcePath;
			}
			document.getElementById('BillboardContainer').src = this.billboardCache[this.currentBillboard].src;
		}
		else
		{
			sourcePath = 'images/billboard' + (this.currentBillboard + 1) + '.jpg';
			document.getElementById('BillboardContainer').src = sourcePath;
		}
		this.billboardTimer = setTimeout('SwitchBillboard();',this.billboardSwitchTime);
	}
}

