
function updateMenu()
{

	if (typeof(parent.document)=="unknown") return ;

	if (parent.action!=action)
	{
		
		fname = extractBaseName(parent.action);
		cptop(parent.action,fname+"01.gif");
		fname = extractBaseName(action);
		cptop(action,fname+"02.gif");
		cptop("title",fname+"title.gif");
		parent.action=action;
		
	}
}

function divWrite(_id,_text)
{
	obj = document.getElementById(_id);
	if (!obj)
		alert("missing "+_id);
	obj.innerHTML=_text;
	
}

function cb(name,color)
{
	theRow = document.getElementById(name);
	if (theRow)
		theRow.style.backgroundColor=color;
}
function cp(cImg,pic)
{
	document.images[cImg].src = pic;
}

function cptop(cImg,pic)
{
	if (parent.document.images[cImg])
	{
		parent.document.images[cImg].src = pic;
	}
}


var curQuizz=0;
var curAnswer="";
var badColor = "C0C0C0"
var goodColor = "EDF1EF";	//"00A000"

function activate(_id,_v)
{
	if (curAnswer==_id) return ;

	theCell = document.getElementById(_id);
	if (theCell)
	{
		if (!_v)
			theCell.style.color = "000000";
		else
			theCell.style.color = "444444";
	}
}

function doAnswer(_v)
{
		
	divWrite("result",quizz[curQuizz][_v+3]);
	if (!_v)
	{
		curAnswer="bad";
		cb("good",background);
		cb("bad",badColor)
		cb("result",badColor)
		activate("good",0);
	
		
	}
	else
	{
		curAnswer="good";
		cb("good",goodColor);
		cb("bad",background)
		cb("result",goodColor)
		activate("bad",0);
	}
	
	
}

function doQuizz()
{
	
	curQuizz = (curQuizz+1)%nbQuizz;
	
	divWrite("long",quizz[curQuizz][0]);
	
	cb("bad",background)
	cb("good",background)
	cb("result",background)
	
	divWrite("bad",quizz[curQuizz][1]);
	divWrite("good",quizz[curQuizz][2]);
	divWrite("result","<font size='+2'> <center>?</center></font>");
	
	curAnswer="";
	activate("bad",0);
	activate("good",0);
	
}

function extractBaseName(_id)
{
	fn = document.images(_id);
	if (!fn) fn = parent.document.images(_id);
	if (!fn) return null;
	fn = fn.src;
	l = fn.length;
	
	return fn.substr(0,l-6);
}

function  switchMenu(_id,_type)
{

	if (action==_id)
	{
		// do nothing ?	
	}
	else
	{
		fname = extractBaseName(_id);
		if (!fname) return ;
		
		/*
		if (_type=="down")
			ext = " blur1.gif";
		else
			*/
		if (_type=="out")
			ext="01.gif";
		else
		// over
			ext="02.gif";

		cp(_id,fname+ext);
	}
	
}

function checkFrame(link,lan)
{
	
	dest = null;	
	if (typeof(parent.document)!="unknown") 
		dest = parent.document.getElementById("theFrame");
		
	if (!dest)
	{
		document.write("<H2>");
		if (lan=="fr")
			document.write("Cette page fait partie d'un cadre!<br> Cliquez sur le lien suivant pour voir le site en entier : ");
		else
			document.write("This page is part of another frame!<br> Click on the next link to watch the full site : ");
			
		document.write( "<a href='"+link+"'>SolidGame</a></h2>" );	
	}
}