function firstcook() {
if (!get_cookie('totexe')) {document.cookie='totexe=0'}
if (!get_cookie('totcor')) {document.cookie='totcor=0'}
if (!get_cookie('totero')) {document.cookie='totero=0'}
writeresults();
}


function cook(exe,ans,cor){
var totexe=parseInt(get_cookie('totexe'));
var totcor=parseInt(get_cookie('totcor'));
var totero=parseInt(get_cookie('totero'));
var i=parseInt(ans)+1

if (!get_cookie(exe)) {
totexe=totexe+1
document.cookie="totexe=" + (""+totexe);
document.cookie= exe + "=OONNNNO"
}


var exestring=get_cookie(exe)
var value=exestring.slice(i,i+1)
if (value=="N") {
var newstring=exestring.slice(0,i) + "Y" + exestring.slice(i+1)
document.cookie= exe + "=" + newstring


if (cor==1) {
totcor=totcor+1;
document.cookie="totcor=" +(""+totcor);
}
else {
totero=totero+1;
document.cookie="totero=" + (""+totero);
}
}
writeresults()

}


function writeresults(){
var mycontent=formresults();
//if IE 4+
if (document.all) {
place1.innerHTML=mycontent;
}
//else if NS 4
else if (document.layers){
document.place2.document.place3.document.write(mycontent);
document.place2.document.place3.document.close();
}
//else if NS 6 (supports new DOM)
else if (document.getElementById){
rng = document.createRange();
el = document.getElementById("place1");
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragment(mycontent);
while (el.hasChildNodes())
el.removeChild(el.lastChild);
el.appendChild(htmlFrag);
}
}


//Get cookie routine by Shelley Powers 
function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    // if cookie exists
    if (offset != -1) { 
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}



function formresults(){
if (parseInt(get_cookie('totexe'))==0) {var aa='<span class="ExResult">&nbsp;&nbsp;&nbsp;&nbsp;Δεν έχεις απαντήσει σε ερωτήσεις μέχρι τώρα στο θέμα αυτό.</span>'
}
else {
var aa='<span class="ExResult">&nbsp;&nbsp;&nbsp;&nbsp;Ερωτήσεις που απαντήθηκαν στο θέμα αυτό: ';
aa=aa+get_cookie('totexe')+ '.<br>&nbsp;&nbsp;&nbsp;&nbsp;Σωστές επιλογές: '+  get_cookie('totcor') + '. Λανθασμένες επιλογές: ' + get_cookie('totero') + '.</span>';
}

return aa;
}

