function cTextPair(txt1, txt2)
{
	this.first = txt1;
	this.second = txt2;
}

function cMatchText(sel, div)
{
	this.TagSelect = sel;						// id of associated <select> tag
	this.TagDiv = div;							// id of associated <div> tag
	this.PairArray = new Array();		// Array of cTextPair
	this.idx = 0;
	this.show = function(i)
	{
		if (typeof(i) != "undefined")
		{
			this.idx = i;
		}
		if (this.idx < 0)
		{
			this.idx = this.PairArray.length - 1;
		}
		if (this.idx >= this.PairArray.length)
		{
			this.idx = 0;
		}
		var node = document.getElementById(this.TagDiv);
		if (node != null)
		{
			node.innerHTML = this.PairArray[this.idx].first;
			document.getElementById(this.TagSelect).selectedIndex = 0;
		}
	}
	this.adjust = function(ofs)
	{
		this.show(this.idx+ofs);
	}
	this.next = function()
	{
		this.adjust(1);
	}
	this.prev = function()
	{
		this.adjust(-1);
	}
	this.CheckAuthor = function()
	{
		var dropdown = document.getElementById(this.TagSelect);
		var dropauth = dropdown[dropdown.selectedIndex].value;
		var ldropauth = dropauth.toLowerCase();
		var lineauth = this.PairArray[this.idx].second
		lineauth = lineauth.toLowerCase();
		if (ldropauth.indexOf(lineauth) < 0)
		{
			alert(dropauth + " is wrong.  Try again.")
		}
		else
		{
			alert(dropauth + " is correct!")
		}
	}
	this.AddText = function(txt1, txt2)
	{
		this.PairArray.push(new cTextPair(txt1, txt2));
		this.idx = Math.round(Math.random() * (this.PairArray.length-1));	// Index for accessing PairArray
	}
}

