function uncheckAll(radio)
{
if(!radio)
		return;
var len = radio.length;
if(len == undefined)
	{
	radio.checked = false;
	return;
	}
for(var i = 0; i < len; i++)
	radio[i].checked = false;
}

function KatButtonClick(arr, plakat_text, variants, capacity)
{
  clearTimeout(timeout_handle);
me = document.getElementById("KatButtonNext");
me.style.visibility = "hidden";
plakat = document.getElementById("Plakat");
setInnerText(plakat, plakat_text);
setInnerText(document.getElementById("Counter"), (i+2)+"/"+capacity);
j=0;
while (variants>=j)
	{
	document.getElementById("variant["+j+"]").style.color="black";
	setInnerText(document.getElementById("variant["+j+"]"), " "+arr[j]);
	j++;
	}
uncheckAll (document.forms['TestForm'].elements['variant']);
}

function katVariantClick(num,otvet,arr,i,allow_next)
{	
var plusColor = "008B8B";
me = document.getElementById("variant["+num+"]");
if (num==otvet)
	{
	me.style.color = plusColor;
	}
	else
	{
	alien = document.getElementById("variant["+otvet+"]");
	alien.style.color = plusColor;
	me.style.color = "red";
	}
button = document.getElementById("KatButtonNext");
button.style.visibility = "visible";
button.focus();
var check_box = document.getElementById("checkbox1");
if(check_box.checked && allow_next)
{
  var delay = document.getElementById("delay");
  timeout_handle = setTimeout("var button = document.getElementById('KatButtonNext'); button.click();", parseInt(delay.value)*1000);
}
}

function katShowResults (plakats, otvets, userotvet, arr, len, str1, backlink, lang)
{

if (userotvet[0]==-1)
	{
	top.location.href=backlink;
	return;
	}

var span = document.getElementById('TestSpan');
var test = document.getElementById('TestForm');
var test_footer = document.getElementById('TestFooter');
var test_header = document.getElementById('TestHeader');
span.removeChild(test);
span.removeChild(test_footer);
span.removeChild(test_header);
span.align="left";
paragraph = document.createElement('P');
span.appendChild(paragraph);
paragraph.setAttribute("id", "TestResultParagraph1");
setInnerText(paragraph, "Результаты теста:");
var table = document.createElement('TABLE');
table.setAttribute("id", "TestResultTable");
span.appendChild(table);
var row = table.insertRow(-1);
var cell = row.insertCell(-1);
setInnerText(cell,str1);
var cell = row.insertCell(-1);
setInnerText(cell, "Ваш ответ");
var cell = row.insertCell(-1);
setInnerText(cell, "Правильный ответ");
count=0;
j=0;
for(var i = 0; (i < len)&&(userotvet[i]!=-1); i++)
	{
	j++;
	u = userotvet[i];
	o = otvets[i];
	var row = table.insertRow(-1);
	var cell = row.insertCell(-1);
	cell.setAttribute("class", "katPlakat");
	cell.onmouseover=function(event1){showtip1(this,event1,getInnerText(this),'center',7);};
	cell.onmouseout=function(){hidetip();};
	setInnerText(cell, plakats[i]);
	if (u==o)
		{
		count++;
		var cell = row.insertCell(-1);
		cell.setAttribute("colspan", 2);
		cell.setAttribute("class", "katTrueAnswer");
		setInnerText(cell, arr[i][u]);
		}
		else
		{
		var cell = row.insertCell(-1);
		row.appendChild(cell);
		setInnerText(cell, arr[i][u]);
		cell.setAttribute("class", "katUserAnswer");
		var cell = row.insertCell(-1);
		row.appendChild(cell);
		setInnerText(cell, arr[i][o]);
		cell.setAttribute("class", "katTrueAnswer");
		}
	}

paragraph = document.createElement('P');
span.appendChild(paragraph);
paragraph.setAttribute("id", "TestResultParagraph2");
s = num_str(count, "правильный ответ", "правильных ответа", "правильных ответов");

setInnerText(paragraph, "Всего "+count+" "+s+" из "+j);
button = document.createElement('INPUT');
button.type = "button"; 
button.onclick = function(){document.location.href=backlink;}
button.value = lang[0];
span.appendChild(button);
}

