// Javascript for biophily
// =======================

function set_goodie(num, str)
{
  if (score.charAt(num) == "0")
  {
    if (ns4)
    {
      document.score.document.images[num].src = "symbole/" + str + ".gif";
    }
    else if (ie4)
    {
      document.images[num+1].src = "symbole/" + str + ".gif";
    }
    else if (ns6)
    {
      document.images[num+1].src = "symbole/" + str + ".gif";
    }
  }
}

function set_note(str)
{
  if (ns4)
  {
    if (document.layers["d-" + str].document.images[0].src.indexOf("glas.gif") >= 0)
      {
        document.layers["d-" + str].document.images[0].src = "noten/" + str + ".gif";
        document.layers["d-" + str].visibility = "show";
      }
  }
  else if (ie4)
  {
    if (document.all.tags("img")[str].src.indexOf("glas.gif") >= 0)
      {
        document.all.tags("img")[str].src = "noten/" + str + ".gif";
      }
  }
  else if (ns6)
  {
    if (document.getElementById(str).src.indexOf("glas.gif") >= 0)
      {
        document.getElementById(str).src = "noten/" + str + ".gif";
      }
  }
  noten ++;
}

// keep the pace
// =============

function got_plan()
{
  score = parse_score(6);
  set_cookie("biop_score", score);
}

function move_over()
{
  if (score.indexOf("111111") == 0)
  {
    shake(2);
    set_seen(6);
  }
  else
    alert("Visit the five places on the map.");
}

function the_end()
{
    //       alert ("1234567890123\n" + score);
  if (score.indexOf("1111111111111") == 0)
    alert ("At last, I'm free !");
  else
    alert ("Impostor !");
}

function take_off()
{
  //alert ("1234567890123\n" + score);
  if (score.indexOf("1111111111111") == 0)
  {
    check = confirm ("You will now be teleported back home."
                     + "\nIf you did not print the desktop sculptures"
                     + " you may want to cancel now.");
    if (check == true)
      close();
  }
  else
    alert ("Impostor !");
}

// and the winner is
// =================

function set_seen(num)
{
  prand();
  if (score.indexOf("111111") == 0)
  {
    score = parse_score(num);
    set_cookie("biop_score", score);

    window.location.href = "plan.html";
    return;
  }

  if (score.charAt(num) == 1)
  {
    window.location.href = "overview.html";
    return;
  }

  if (noten <= 4)
  {
    alert("Find all the five hidden fetishs\n"
          +"and ask me again.");
    return;
  }

  score = parse_score(num);
  set_cookie("biop_score", score);
  prand();

  window.location.href = "overview.html";
}

function set_oper(num)
{
  if (score.indexOf("111111111111") == 0) {
    window.location.href = "avattractor.html";
    return;
  }

  if (kompleted()) {
    score = parse_score(num);
    set_cookie("biop_score", score);
    if (score.indexOf("111111111111") == 0)
      window.location.href = "avattractor.html";
    else if (score.indexOf("0") <= 5)
      window.location.href = "overview.html";
    else
      choose_kh();
  }
  else
    alert ("Reanimate the poor creature,"
           + "\nand remember the phrases !");
}

function choose_kh()
{
  kh = new Array;
  kh[7] = "kueche_kh.html";
  kh[8] = "schlafzimmer_kh.html";
  kh[9] = "bad_kh.html";
  kh[10] = "diele_kh.html";
  kh[11] = "wohnzimmer_kh.html";

  for (i=7; i<=11; i++)
  {
    if (score.charAt(i) == 0)
    {
      window.location.href = kh[i];
      return;
    }
  }
  window.location.href= "avattractor.html";
}

