

function showHide(thisDiv)
{
	if (document.getElementById(thisDiv).style.display == 'none')
	{
		document.getElementById(thisDiv).style.display = 'block';
	}
	else
	{
		document.getElementById(thisDiv).style.display = 'none';
	}
}
function waitForLoad(popupMessage)
{

	var contentDiv = document.getElementById("content");

	d = document.getElementsByTagName("BODY")[0];

	coverDiv = document.createElement("DIV");
	xPos = contentDiv.offsetLeft;
	yPos = contentDiv.offsetTop;
	oWidth = contentDiv.offsetWidth;
	oHeight = contentDiv.offsetHeight;
	coverDiv.style.width = oWidth + "px";
	coverDiv.style.height = oHeight + "px";

	coverDiv.style.position = "absolute";
	coverDiv.style.left = xPos+"px";
	coverDiv.style.top = yPos+"px";
	coverDiv.style.backgroundColor = "#FFFFFF";
	coverDiv.style.opacity = .6;
	coverDiv.style.filter = "alpha(opacity=60)";	
	d.appendChild(coverDiv);	
	
	popupDiv = document.createElement("DIV");
	popupDiv.className = "popup";
	popupDiv.innerHTML = popupMessage;
	d.appendChild(popupDiv);	
	
	
}

function stopLoad()
{
	
	document.getElementsByTagName("BODY")[0].removeChild(coverDiv);
	document.getElementsByTagName("BODY")[0].removeChild(popupDiv);
}

function giveTranslation(translation,event)
{
	div = document.getElementById("translationDiv");
	if (!div)
	{
		d = document.getElementsByTagName("BODY")[0];
		div = document.createElement("DIV");
		div.id = "translationDiv";	
		d.appendChild(div);	
	}
	else
	{
		div.style.display = "block";
	}
	
	div.innerHTML = translation;
	div.style.left = event.clientX + "px";
	div.style.top = (event.clientY +15 ) + "px";
}
function removeTranslation()
{
	div = document.getElementById("translationDiv");
	if (div)
	{
		div.style.display = "none";
	}
}

function toggleView(hideThis, displayThis)
	{
		document.getElementById(hideThis).style.display = "none";
		document.getElementById(displayThis).style.display = "block";
	}

function test(text)
	{
		alert(text);
	}

function giveGrammar(form, grammar,noWords)
{
	
	var grammarCatsSource = grammar.split("|");
	var grammarCats = new Array();
	var grammarCats2 = new Array();
	for (var i = 0; i < grammarCatsSource.length; i++) 
	{
		if (grammarCatsSource[i])
		{
			var grammarCatsID = grammarCatsSource[i].split(":");
			
			var grammarCatIDSource = grammarCatsID[1].split(",");
			grammarCats[grammarCatsID[0]] = new Array();
			for (var a = 0; a < grammarCatIDSource.length; a ++) 
			{
				grammarCats[grammarCatsID[0]][grammarCatIDSource[a]] = 'ja';
			}
			
		}
	
	}
	for (var j = 0; j < form.options.length; j++) {
		if (form.options[j].selected) {
			for (var k = 0; k < noWords; k++) 
			{
				targetWord = document.getElementById("word_" + k);
				if (form.options[j].value == "empty")
				{
					targetWord = document.getElementById("word_" + k);
					targetWord.style.backgroundColor = "";
				}
				else 
				{
					if (grammarCats[form.options[j].value][k])
						targetWord.style.backgroundColor = "#bbbbbb";
					else
						targetWord.style.backgroundColor = "";
				}
			}
		}
		
	}
	
}