// Requires select.js::AlphaOnly()
// Requires popups.js::CgiFileText()
// Requires popups.js::FileNameGet()
function cLoadFileBlock(ShowDiv, sel, id)
{
	this.TagDiv = ShowDiv;
	this.TagSelect = sel;
	this.FileId = id;
	this.aFileNames = new Array();
	this.show = function(i)
	{
		var list = document.getElementById(this.TagSelect);
		var idx = list.selectedIndex;
		if (typeof(i) != "undefined")
		{
			idx = i;
		}
		if (idx < 0)
		{
			idx = list.length - 1;
		}
		if (idx >= list.length)
		{
			idx = 0;
		}
		list.selectedIndex = idx;
		if (idx < this.aFileNames.length)
		{
			var	fn = "file=" + this.aFileNames[idx] + "&id=" + this.FileId + "&pop=0";
			CgiFileText('./SharedServer/php/FileTextFunction.php', fn, this.TagDiv);
		}
	}
	this.adjust = function(ofs)
	{
		this.show(document.getElementById(this.TagSelect).selectedIndex + ofs);
	}
	this.next = function()
	{
		this.adjust(1);
	}
	this.prev = function()
	{
		this.adjust(-1);
	}
	this.add = function(fn)
	{
		this.aFileNames.push(fn);
	}
	this.reset = function()
	{
		var list = document.getElementById(this.TagSelect);
		list.selectedIndex = 0;
	}
}
// Set <body> to txt
function LoadFileBody(txt)
{
	document.getElementsByTagName('body')[0].innerHTML = txt;
}
// Replace <body> with topic from this file
function ReadFileBody(topic)
{
	var	fn = "file=" + FileNameGet() + "&id=" + topic + "&pop=0";
	CgiFileText('./SharedServer/php/FileTextFunction.php', fn, LoadFileBody);
}

