// Copyright: Goetz Witschke, Systemberatung
// Musikantenweg 18
// 60316 Frankfurt am Main - Germany
//
//


var loesung1=new Array('2','3','1','3','2','2','3','1','1','1','2','1','3','1','3','1','3','2','1','2','3','3','1','0');
var loesung2=new Array('2','3','1','3','3','3','3','2','2','1','2','1','3','1','3','1','3','3','1','2','3','3','1','0');
var eingabe=new Array('0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
var arr_fehler=new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
var arr_aus=new Array();


var curr_no = -1;
var max_no = 23;
var max_fehler = 2;

function init()
{
//  document.getElementById("fwd01").firstChild.nodeValue = "";
//  document.getElementById("rew01").firstChild.nodeValue = "";
  document.getElementById("fwd01").style.display = "none";
  document.getElementById("rew01").style.display = "none";

  return;
}

function dsp_fehler()
{
  for (var i = 0; i < arr_fehler.length; i++)
  {
    if (arr_fehler[i])
    {
//      arr_aus.push("Zu Frage " + ( i + 1 ) + ": "+question[i]);
//      arr_aus.push("Ihre Antwort ("+eingabe[i]+"): "+answer[i][eingabe[i]-1]);
//      arr_aus.push( "Ungünstig: "+hints[i][eingabe[i]-1]);    
      arr_aus[arr_aus.length] = "Zu Frage "+ (i + 1 ) + ": "+question[i];
      arr_aus[arr_aus.length] = "Ihre Antwort ("+eingabe[i]+"): "+answer[i][eingabe[i]-1];
      arr_aus[arr_aus.length] = "Ungünstig: "+hints[i][eingabe[i]-1];    
    }
  }
  
  document.getElementById("head1").firstChild.nodeValue = "Auswertung:";
  document.getElementById("error01").firstChild.nodeValue = arr_aus[0]; 
  document.getElementById("error02").firstChild.nodeValue = arr_aus[1]; 
  document.getElementById("error03").firstChild.nodeValue = arr_aus[2];
  document.getElementById("error04").firstChild.nodeValue = arr_aus[3];   
  document.getElementById("error05").firstChild.nodeValue = arr_aus[4];   
  document.getElementById("error06").firstChild.nodeValue = arr_aus[5];     
  document.getElementById("error07").firstChild.nodeValue = "Damit ist das Bewerbungsgespräch für Sie leider beendet. Sie können aber wieder erneut beginnen.";   
  // set elements to be displayed from array hints
//  document.getElementById("fwd01").firstChild.nodeValue = "";
//  document.getElementById("rew01").firstChild.nodeValue = "";
  document.getElementById("fwd01").style.display = "none";
  document.getElementById("rew01").style.display = "none";


  document.getElementById("xblock").style.display = "none";
  document.getElementById("qblock").style.display = "none";
  document.getElementById("trlink").style.display = "none";
  document.getElementById("eblock").style.display = "block";
  
  return;
}
  
function dsp_spiel()
{
  document.getElementById("head1").firstChild.nodeValue = "";
//  document.getElementById("fwd01").firstChild.nodeValue = "";
//  document.getElementById("rew01").firstChild.nodeValue = "";
  document.getElementById("fwd01").style.display = "none";
  document.getElementById("rew01").style.display = "none";

  document.getElementById("xblock").style.display = "none";
  document.getElementById("trlink").style.display = "none";
  document.getElementById("qblock").style.display = "block";
  document.getElementById("eblock").style.display = "none";
//  document.getElementById("rew01").firstChild.nodeValue = "Zurück";
  document.getElementById("rew01").style.display = "block";
}

function dsp_intro()
{
  curr_no = -1;
  
  document.getElementById("head1").firstChild.nodeValue = "Wie gut sind Sie vorbereitet? Interaktives Training Ihres Vorstellungsgesprächs";
  document.getElementById("xblock").style.display = "block";
  document.getElementById("trlink").style.display = "block";
  document.getElementById("qblock").style.display = "none";

//  document.getElementById("fwd01").firstChild.nodeValue = "";
//  document.getElementById("rew01").firstChild.nodeValue = "";
  document.getElementById("fwd01").style.display = "none";
  document.getElementById("rew01").style.display = "none";
  
  return;
}
 
function dsp_training()
{
  var divclassname = "intro";
  
  document.writeln('<div id="xblock" style="display:block" class="'+divclassname+'">');
  document.writeln('<p class="normal" id ="intro01"></p>');
  document.writeln('<p class="normal" id ="intro02"> Willkommen zum interaktiven Training Ihres Vorstellungsgesprächs. </p>');
  document.writeln('<p class="normal" id ="intro03"> Im Verlauf dieser Simulation werden Ihnen 24 typische Fragen aus einem Vorstellungsgespräch gestellt. Sie haben die Wahl zwischen drei Antwortmöglichkeiten. Wenn die Beispiele, die in den Antworten gegeben werden, nicht zu Ihrer Arbeitssituation oder zu Ihrer Branche passen, ersetzen Sie sie gedanklich. Wählen Sie die Antwort, die Sie für die angemessenste halten.</p>');
  document.writeln('<p class="normal" id ="intro04"> Stellen Sie sich zweimal ungünstig dar, ist das Gespräch für Sie beendet. Sie können die Simulation aber stets wieder starten und Ihr Glück erneut suchen.</p>');
  document.writeln('<p class="normal" id ="intro05"> Viel Erfolg!</p>');
  document.writeln("</div>");
  document.writeln('<div id="eblock" style="display:none" class="'+divclassname+'">');
  document.writeln('<p class="normal" id ="error01"> e1 </p>');
  document.writeln('<p class="normal" id ="error02"> e2 </p>');
  document.writeln('<p class="normal" id ="error03"> e3 </p>');
  document.writeln('<br>');
  document.writeln('<p class="normal" id ="error04"> e4 </p>');
  document.writeln('<p class="normal" id ="error05"> e5</p>');
  document.writeln('<p class="normal" id ="error06"> e6</p>');
  document.writeln('<p class="normal" id ="error07" class="errfoot"> e7</p>');
  document.writeln("</div>");
  
  dsp_quest( 0 );
  
  return;
}
 
function buttonselected(butno)
{
  eingabe[curr_no]=butno;
//  document.getElementById("fwd01").firstChild.nodeValue = "Weiter";
  document.getElementById("fwd01").style.display = "block";
    
  return;
}
  
function next_quest(gotonext)
{
  dsp_spiel();

  if ((curr_no + gotonext) == -1)
  {
    dsp_intro();
    return;
  }

  if ( eingabe[curr_no] == 0 )
  {
//    document.getElementById("fwd01").firstChild.nodeValue = "";
    document.getElementById("fwd01").style.display = "none";
  }

  if (gotonext >= 1)
  {
    if ( ( eingabe[curr_no] != loesung1[curr_no] ) && ( eingabe[curr_no] != loesung2[curr_no] ) )
    {
      arr_fehler[curr_no] = 1 ;
    }
    else
    {
      arr_fehler[curr_no] = 0 ;
    }
  }

  var fehler = 0;
  for (var i = 0; i < arr_fehler.length; i++)
  {
    fehler += arr_fehler[i];
  }
     
  if ( fehler >= max_fehler )
  {
    dsp_fehler();
    return;
  }

  curr_no = curr_no + gotonext ;
     
  if (curr_no > max_no)
  {
    dsp_success();
    return;
  }
     
  document.getElementById("q01").firstChild.nodeValue  = question[curr_no];  
  document.getElementById("t01").firstChild.nodeValue  = answer[curr_no][0];
  document.getElementById("t02").firstChild.nodeValue  = answer[curr_no][1];
  document.getElementById("t03").firstChild.nodeValue  = answer[curr_no][2];
  
  if ( eingabe[curr_no] == 0 )
  {
    document.x.sel[0].checked = false;
    document.x.sel[1].checked = false;
    document.x.sel[2].checked = false;
//    document.getElementById("fwd01").firstChild.nodeValue = "";
    document.getElementById("fwd01").style.display = "none";
  }
  else
  {
    document.x.sel[eingabe[curr_no]-1].checked = true;
//    document.getElementById("fwd01").firstChild.nodeValue = "Weiter";
    document.getElementById("fwd01").style.display = "block";
  }
 
  return;
}
  
function dsp_quest(parm)
{
  var lfd_nr = parm;
  var formname = "x"; 
  var selbut = "sel"; 
  var radio = "radio";
  var divclassname = "questdivcss";
  
  document.writeln('<div id="qblock" style="display:none" class="'+divclassname+'">');
  document.writeln('<p id="q01" class="quest">'+question[lfd_nr]+'</p>');
  document.writeln('<form name="'+formname+'" >');
  document.writeln('<table align="top" class="tbltop"><tr valign="top"><td class="tdtop" >');
  document.writeln('<input type="radio" name="'+selbut+'" value="'+1+'"  onfocus="javascript:buttonselected(1);"  accesskey="1" />');
  document.writeln('</td><td class="tdtop" >');
  document.writeln('<a class="identnormal" id="t01">'+answer[lfd_nr][0]+'</a><br>');
  document.writeln('</td></tr>');
  document.writeln('<tr valign="top"><td class="tdtop" >');
  document.writeln('<input type="radio" name="'+selbut+'" value="'+2+'"  onfocus="javascript:buttonselected(2);"  accesskey="2" />');
  document.writeln('</td><td class="tdtop" >');
  document.writeln('<a class="identnormal" id="t02">'+answer[lfd_nr][1]+'</a><br>');
  document.writeln('</td></tr>');
  document.writeln('<tr class="trtop"><td class="tdtop" >');
  document.writeln('<input type="radio" name="'+selbut+'" value="'+3+'"  onfocus="javascript:buttonselected(3);"  accesskey="3" />');
  document.writeln('</td><td class="tdtop" >');
  document.writeln('<a class="identnormal" id="t03">'+answer[lfd_nr][2]+'</a><br>');
  document.writeln('</td></tr></table>');
  document.writeln("</form>");
  document.writeln("</div>");
  
  return;  
}
  
function dsp_success(parm)
{
  document.getElementById("head1").firstChild.nodeValue = "Herzlichen Glückwunsch!";
  document.getElementById("error01").firstChild.nodeValue = "Sie haben das interaktive Training Ihres Vorstellungsgesprächs bestanden!";
  document.getElementById("error02").firstChild.nodeValue = "Sie sind hervorragend vorbereitet für den Ernstfall!"; 
  document.getElementById("error03").firstChild.nodeValue = "";
  document.getElementById("error04").firstChild.nodeValue = "";
  document.getElementById("error05").firstChild.nodeValue = "";
  document.getElementById("error06").firstChild.nodeValue = "";
  document.getElementById("error07").firstChild.nodeValue = "";
  // set elements to be displayed from array hints
//  document.getElementById("fwd01").firstChild.nodeValue = "";
//  document.getElementById("rew01").firstChild.nodeValue = "Zurück";
  document.getElementById("fwd01").style.display = "none";
  document.getElementById("rew01").style.display = "block";

  document.getElementById("xblock").style.display = "none";
  document.getElementById("qblock").style.display = "none";
  document.getElementById("trlink").style.display = "none";
  document.getElementById("eblock").style.display = "block";
  
  return;
}  

