﻿/////////////////////////////////////////////////////////////////////////////////////////
// FelixNET Infobar class v 1.0 (c) 2005 PULAsoft s.r.o.
// Author: PulaSoft s.r.o.
//

function FxInfobarItem(itemid)
{
	this.ItemID = itemid;
	this.ItemText = '';
	this.ItemURL = '';
}

function FxInfobar(infobarid)
{
	this.InfobarID = infobarid;
	this.ClassName = 'infobaritem_' + infobarid;
	this.Items = new Array();
	this.SwitchInterval = 5;
	this.ActualItem = 0;
	this.SwitchEffect = 'typewriter';
	this.AddItem = function(NewItem) {this.Items.push(NewItem);};
	this.SwitchItem = function() {
		this.ActualItem++;
		if(this.ActualItem >= this.Items.length) this.ActualItem = 0;
		var ActualItem = this.Items[this.ActualItem];
		var InfobarElm = document.getElementById('ib_' + this.InfobarID + "_placeholder");
		if(this.SwitchEffect == 'none')
		{
			InfobarElm.innerHTML = "<a href=\"" + ActualItem.ItemURL  + "\" class=\"infobar_text_" + this.InfobarID  + "\">" + ActualItem.ItemText + "</a>";
		} else {
			this.DoSpecialSwitchEffect();
		}
		window.setTimeout("ib_" + this.InfobarID + ".SwitchItem();", this.SwitchInterval * 1000);
	}
	this.Start = function() {
		this.SwitchItem();
	}
	this.DoSpecialSwitchEffect = function() {
		switch(this.SwitchEffect)
		{
			case "typewriter":
				window.setTimeout("ib_" + this.InfobarID + ".DoTypewriter(0);", 40);
				break;
		}
	}
	this.DoTypewriter = function(charidx) {
		var ActualItem = this.Items[this.ActualItem];
		var InfobarElm = document.getElementById('ib_' + this.InfobarID + "_placeholder");
		if(charidx >= ActualItem.ItemText.length)
			return;
		var htmlcode = "<a href=\"" + ActualItem.ItemURL  + "\" class=\"infobar_text_" + this.InfobarID  + "\" style=\"text-decoration: none;\">";
		htmlcode += ActualItem.ItemText.substr(0, charidx + 1);
		if(charidx + 1 < ActualItem.ItemText.length)
			htmlcode += "_";
		htmlcode += "</a>";
		InfobarElm.innerHTML = htmlcode;
		window.setTimeout("ib_" + this.InfobarID + ".DoTypewriter(" + (charidx + 1)  + ");", 40);				
	}
}