function displayset(module,set)
{
getmodule = quiz1.get(module)
getset = getmodule.get(set)
globalset = getset

//set subheader for set

var sheader = document.getElementById('hl')
headertext = getmodule.name + " - " + getset.name + ": TEST"
header.childNodes[0].nodeValue = headertext

// clear questions

questionsdiv = document.getElementById('bodydiv')
if(questionsdiv.childNodes)
{
for(var i = 0;i<questionsdiv.childNodes.length;i++)
{
questionsdiv.removeChild(questionsdiv.childNodes[i]) 
}

}
//write out questions and choices for current selected set

totalproblems = getset.total()
questionlist = document.createElement('OL')

for(var i=0;i<totalproblems;i++)
{
currentproblem = getset.get(i)
listitem = document.createElement('LI')
questionbreak = document.createElement('BR')
listquestion = document.createTextNode(currentproblem.question)

//list choices for current problem

choicelist = document.createElement('UL')

uniqueid = uniquename(5)
totalchoices = currentproblem.totalchoices()
for(var x = 0;x < totalchoices;x++)
{

choiceitem = document.createElement('LI') 
listradio = document.createElement('INPUT')
listradio.setAttribute('type','radio')
listradio.setAttribute('onClick','selectoption('+module+','+set+','+i+','+x+')')

listradio.setAttribute('name',uniqueid)
listradio.setAttribute('value',uniqueid) 
choiceitemchar = document.createTextNode(chars.charAt(x) + ".) ")
choiceitemtext = document.createTextNode(currentproblem.getchoice(x))
choiceitem.appendChild(listradio)
choiceitem.appendChild(choiceitemchar)
choiceitem.appendChild(choiceitemtext)
choicelist.appendChild(choiceitem)

}
listitem.appendChild(listquestion)
listitem.appendChild(choicelist)
questionlist.appendChild(listitem)

}
questionsdiv.appendChild(questionlist) 
iefix()
}
function selectoption(module,set,problem,roption)
{
//alert(module +"/"+ set +"/"+ problem +"/"+ roption)

getmodule = quiz1.get(module)
getset = getmodule.get(set)
getproblem = getset.get(problem)
getproblem.selection = roption
}
function uniquename(length)
{

name = "";
for(x=0;x<length;x++)
{
i = Math.floor(Math.random() * 52);
name += chars.charAt(i);
}
return name;
}
function displayresults()
{
//alert(document.getElementById('bodydiv').innerHTML)

var noanswer = new Array()
globalset.rightanswers = 0
for(var i = 0;i<globalset.total();i++)
{
getproblem = globalset.get(i)
if(getproblem.selection == -1)
{
noanswer.push(i + 1)
}
if(getproblem.selection == getproblem.answer)
{
globalset.rightanswers++ 
}
}
switch(noanswer.length)
{
case 0 :
percentage = Math.round(100 * (globalset.rightanswers/globalset.total()))
totalwrong = (globalset.total() - globalset.rightanswers)
var tocnniodgovori = (globalset.rightanswers)


if (tocnniodgovori >1 && tocnniodgovori <=14) 
{
levelcef = ("A1")
levelmemento = ("1. STUPANJ")
}
if (tocnniodgovori >=15 && tocnniodgovori <=17) 
{
levelcef = ("A2")
levelmemento = ("2. STUPANJ")
}
if (tocnniodgovori >=18 && tocnniodgovori <=20) 
{
levelcef = ("B1")
levelmemento = ("3. STUPANJ")
}
if (tocnniodgovori >=21 && tocnniodgovori <=24) 
{
levelcef = ("B2")
levelmemento = ("4. STUPANJ")
}
if (tocnniodgovori >=25 && tocnniodgovori <=30) 
{
levelcef = ("C1")
levelmemento = ("5. STUPANJ")
}
if (tocnniodgovori >30) 
{
levelcef = ("C2")
levelmemento = ("6. STUPANJ")
}



var resultstring = globalmodule.name +' - '+ globalset.name + '<BR><BR>'
resultstring+= 'Va&scaron; rezultat je: <span class="style1">' + percentage + '%</span>' + ' ('+ globalset.rightanswers+'/'+ globalset.total() +')' + '<BR>Neto&#269;ni odgovori: ' + totalwrong + '<BR>'
resultstring+= '<HR>YOUR LEVEL:<BR>'
resultstring+= '<span class="style1">CEF = ' + levelcef + '<BR>'
resultstring+= 'MEMENTO = ' + levelmemento + '</span><HR>'


resultstring+= 'Pitanje - Rezultat <HR>'
for(var x=0;x<globalset.total();x++)
{
question = x+1
getproblem = globalset.get(x)
resultstring+=' '+ question + '. '
resultstring+= (getproblem.selection == getproblem.answer)? 'To&#269;no<BR>':'-<span class="style1">NETO&#268;NO!</span><BR>'
}

resultstring+= '<HR><div align="center"><a href="#" onClick="window.location.reload( true );">Ponovi test</a></div><HR>'

document.getElementById('rezultati').innerHTML = (resultstring)
scroll(0,0)
//alert(resultstring);
break;
default :
var noanswerstring =""
for(var j=0;j<noanswer.length;j++)
{
noanswerstring += ' ' + noanswer[j] + ', ' 
}
alert("Slijedeca pitanja nisu ogdovorena:\n\n" + noanswerstring + "\n\n Molimo odgovorite na sva ponudjena pitanja kako bismo mogli ispraviti vas test.")
}


}

function iefix()
{
if(document.all)
{
rawdata = document.getElementById('bodydiv').innerHTML
fixdata = rawdata.replace(/value/g,"name")
document.getElementById('bodydiv').innerHTML = fixdata
}
}  
