<!--

var self;
function Vocab5()
{
    self = this;this.notouch=true;
    this.right=300;this.vocabObj = null;
    this.defs = null;this.words=null;
    this.qnum = 0;this.opts = new Array(5);this.shfarr = new Array(10);
    this.letArr = new Array('','A.&nbsp;','B.&nbsp;','C.&nbsp;','D.&nbsp;');
    this.clicks=0;
    		
	this.initGame = function(darr,warr)
	{
	    this.notouch=true;
		this.defs = darr;
		this.words = warr;
	    this.qnum = 0;
	    this.clearBoard();
	}
	
	this.endGame = function()
	{
	    this.notouch=true;
		var str = '<div class="btntxt" style="margin-left:50px;">Check score:</div><div id="lbtn"></div><div id="mbtn" onClick="self.submitfrm();">Score</div><div id="rbtn"></div>';
		var f = document.getElementById("btnbrd"); if (f != null) {f.innerHTML = str;}        
	}
	
	this.showNext = function()
	{
	    this.qnum++; if (this.qnum > 5) {return this.endGame();}
		this.vocabObj = document.getElementById("vocabdef");
		if (this.vocabObj != null) {this.vocabObj.innerHTML = '<div class="deftxt">Definition:</div>' + this.defs[this.qnum];}
		this.showOptions(this.qnum);
		this.showBoard();
	}
	
	this.showOptions = function(n)
	{
	    this.opts[0] = n;this.opts[1]=n;
		var j = 0;
	    for (var i = n+1; i < 11; i++) {this.shfarr[j]=i;j++;}
	    this.shuffleArray(this.shfarr, j);
	    for (j = 2; j < 5; j++) {this.opts[j] = this.shfarr[j-2];}
	    var x = this.getRandom(1,4); if (x != 1) {var t = this.opts[1];this.opts[1]=this.opts[x];this.opts[x]=t;}
	    
	    for (var k = 1; k < 5; k++)
	    {
	        var o = document.getElementById("ansid_"+k); if (o != null) {o.className = "ans_0"; o.innerHTML = this.letArr[k] + this.words[this.opts[k]];}
	    }
	}
	
	this.shuffleArray = function(a, len)
	{
		for (var m = 0; m < len; m++)
		{
			t1 = this.getRandom(0,len-1);t2 = this.getRandom(0,len-1);
			if (t1 != t2) {tt = a[t1];a[t1]=a[t2];a[t2]=tt;}
		}
	}
	
	this.checkAns = function(n)
	{
	    if (this.notouch) {return;}
	    this.notouch = true;
	    this.clicks++;
	    if (this.opts[n] == this.opts[0])
	    {
	        this.changeClass(n,1);
	    	this.clearBoard();
	    }
	    else
	    {
	        this.changeClass(n,2);
	        this.notouch = false;
	    }
	}
	
	this.submitfrm = function()
	{
		var f = document.getElementById("vocab5brd");
		if (f != null) 
		{
		    var str = "Congratulations!</br> Your score is:" + Math.floor(500/this.clicks) + "%";
		    
			f.innerHTML = "";
			var o = f.appendChild(document.createElement('div'));
			o.innerHTML='<input type="hidden" name="helppage" value="vocab5help.html" />';
			var o = f.appendChild(document.createElement('div'));
			o.innerHTML='<input type="hidden" name="gamepage" value="vocab5.php" />';
			o = f.appendChild(document.createElement('div'));
			o.innerHTML='<input type="hidden" name="msg" value="' + str + '" />';
		}

		document.vocab5_frm.submit();
	}
		
			
	this.changeClass = function(n,clr)
	{
	    var o = document.getElementById("ansid_"+n);
	    if (o != null) {o.className = "ans_" + clr;}
	}
	

	this.getRandom = function(min,max)
	{
		return min + Math.floor(Math.random()*(max-min+1))
	}

	this.clearBoard = function()
	{
	    this.right=310;
	    this.clipRight();
	}
	
	this.clipRight = function ()
	{
		if (self.right > 0) 
		{
			self.right -= 10;
			if (self.vocabObj != null) {self.vocabObj.style.clip = "rect(0px " + self.right + "px 120px 0px)";}
			setTimeout("self.clipRight()", 10);
		}
		else {this.showNext();}
	}

	this.showBoard = function()
	{
	    this.right=0;
	    this.clipLeft();
	}

	this.clipLeft = function()
	{
		if (self.right < 310) 
		{
			self.right += 10;
			if (self.vocabObj != null) {self.vocabObj.style.clip = "rect(0px " + self.right + "px 120px 0px)";}
			setTimeout("self.clipLeft()", 10);
		} else {this.notouch = false;}
	}

}


-->


