// koordinatensystem.js
// (c) Andreas Meier
// Sophie-Scholl-Realschule Weiden
// erstellt am 02.11. 2005
// geändert am 02.11. 2005
// alle Rechte liegen beim Autor


var geloest= 0;
var versuch= 0;
var score =0;

function zufall()
{
// Ermittelt eine Zufallszahl
   var zufallszahl = 0;
 zufallszahl=Math.floor(8*Math.random());  // zwischen 0 und 7
return zufallszahl;
}

function zufall2()
{
// Ermittelt eine Zufallszahl
   var zufallszahl2 = 0;
 zufallszahl2=Math.floor(6*Math.random()+1);  // zwischen 1 und 6
return zufallszahl2;
}


function zufall3()
{
// Ermittelt eine Zufallszahl
   var zufallszahl3 = 0;
 zufallszahl3=Math.floor(2*Math.random()+1);  // zwischen 1 und 2
return zufallszahl3;
}

function zufall4()
{
// Ermittelt eine Zufallszahl
   var zufallszahl4 = 0;
 zufallszahl4=Math.floor(5*Math.random()+1);  // zwischen 1 und 5
return zufallszahl4;
}

function brueche()
{
versuch = 0;
merker = 0;
document.Para.wertung.value = "";
document.Para.z1.value = "";
document.Para.w1.value = "";
document.Para.z2.value = "";
document.Para.w2.value = "";
document.Para.z3.value = "";
document.Para.w3.value = "";


applet = document.applets[0];
applet.evalCommand("A = (1,6)");
applet.evalCommand("B = (3,6)");
applet.evalCommand("C = (5,6)");


xA = zufall();
vorz= zufall2();
if (vorz<4) xA = (-1) * xA;
yA = zufall();
vorz= zufall2();
if (vorz<4) yA = (-1) * yA;
if (xA>=0 & yA>=0) yA = yA*(-1);

xB = zufall();
vorz= zufall2();
if (vorz<4) xB = (-1) * xB;
yB = zufall();
vorz= zufall2();
if (vorz<4) yB = (-1) * yB;
if (xB>=0 & yB>=0) yB = yB*(-1);

xC = zufall();
vorz= zufall2();
if (vorz<4) xC = (-1) * xC;
yC = zufall();
vorz= zufall2();
if (vorz<4) yC = (-1) * yC;
if (xC>=0 & yC>=0) yC = yC*(-1);



document.Para.z1.value = "A("+xA+"|"+yA+")";
document.Para.z2.value = "B("+xB+"|"+yB+")";
document.Para.z3.value = "C("+xC+"|"+yC+")";

}



function pruefe()
{
versuch++;
fehler = 0;
applet = document.applets[0];
var Ax = applet.getXcoord("A");
var Bx = applet.getXcoord("B");
var Cx = applet.getXcoord("C");
var Ay = applet.getYcoord("A");
var By = applet.getYcoord("B");
var Cy = applet.getYcoord("C");

if (yA == Ay & Ax==xA) document.Para.w1.value = "";
else {document.Para.w1.value = "(f)"; fehler++;}

if (yB == By & Bx == xB) document.Para.w2.value = "";
else {document.Para.w2.value = "(f)"; fehler++;}

if (yC == Cy & Cx == xC) document.Para.w3.value = "";
else {document.Para.w3.value = "(f)";fehler++;}


if (versuch == 1) points = 15-fehler*5;
else points = 0;
score = score + points;
if (score<0) score =0;


if (fehler ==0){
document.Para.wertung.value = "Ausgezeichnet! Alle Punkte sind richtig eingezeichnet.\n"+
"Aktueller Punktestand: "+String(score);
}
else
document.Para.wertung.value = String(3-fehler)+" Punkte sind richtig! Die mit (f) markierten\n"+
"musst du noch verbessern, dann gibt's Punkte.";

}



/*     Highscore Eintrag vornehmen                                           */
/*                                                                           */
/*     Ausgabe-Fenster definieren und ausgeben                               */
/*                                                                           */
function messagewindow(message, title){
    msgWindow= open("rangliste.htm","msgwin","scrollbars=yes,toolbar=no,directories=no,menubar=no,width=800,height=620,location=no,status=no,resizable=yes");
     msgWindow.document.clear();
     msgWindow.document.open();

     msgWindow.document.writeln('<HTML><HEAD><TITLE>'+title+'</TITLE></HEAD><BODY TEXT="#000000" LINK="#0000FF" VLINK="#FF0000" ALINK="#0080FF" BGCOLOR="EFECA5">');
     msgWindow.document.writeln(message);
     msgWindow.document.writeln('</BODY></HTML>');
}

function auswerten() {

/* Achtung muss für jede Datei manuell angepasst werden */
/*                     Anfang                           */
var aufgabenart="Punkte im KO-System";
var punkte = score;
if (punkte < 1) punkte = 1;
// Zurücksetzen der Punkte auf Ausgangswert


geloest= 0;
vesuch= 0;
score = 0;

document.Para.wertung.value = "Deine Punkte werden übertragen.\n Du beginnst wieder bei 0 Punkten.";


/* Achtung muss für jede Datei manuell angepasst werden */
/*                        Ende                          */

   /* Hier wird das Ausgabe-fenster gefüllt und der HTML-Code geschrieben */
   /*                                                                    */
   ergebnisse = "<form name = 'eingabe' action ='../../../Mathematik/highsqlpost71w.php' method ='post'>";

   werbestring1="&nbsp;<img src='../../../bilder/anzeige1.gif' width='15' height='60' border='0' alt=''>";
werbestring2 = "<!-- ValueClick Media 468x60 and 728x90 Banner CODE for realmath.de -->"+
"<script language='javascript' src='http://media.fastclick.net/w/get.media?sid=41862&m=1&tp=5&d=j&t=s'></script>"+
"<noscript><a href='http://media.fastclick.net/w/click.here?sid=41862&m=1&c=1' target='_top'>"+
"<img src='http://media.fastclick.net/w/get.media?sid=41862&m=1&tp=5&d=s&c=1'"+
"width=728 height=90 border=1></a></noscript><!-- ValueClick Media 468x60 and 728x90 Banner CODE for realmath.de -->";

   ergebnisse += "<font face = 'arial, helvetica' size = 2>";
   ergebnisse += "<CENTER><H2><font color=#FF0000>Highscore</font></H2><H3><font color=#0000EC>Erreichte Punkte eintragen</font></H3>";

ergebnisse += "Du hast bei der Aufgabe<br>";
ergebnisse += "<input type= text size=35 maxlength=35 name='xx_aufgabenart' value ='"+ aufgabenart+"' style=' border: none; color: #dd0000; text-align: center; font-weight: bold; font-family: arial, helvetica; font-size: 15pt; background: #EFECA5' readonly> ";
ergebnisse += "<br>insgesamt <input type='text' size=6 maxlength=6 name=xx_punkte value = "+punkte+" style=' border: none; color: #dd0000; text-align: center; font-weight: bold; font-family: arial, helvetica; font-size: 15pt; background: #EFECA5' readonly> ";
ergebnisse += " Punkte erreicht.<br>";


   ergebnisse += "Die Eingabe der nachfolgenden Daten ist freiwillig.<br>";
   ergebnisse += "Anschließend kannst du deinen Highscore abschicken.<br>";
   ergebnisse += "Bitte keine Umlaute wie ü, ö oder ä verwenden.<br><br>";
   ergebnisse += "<font color= #0000cc>Beispiel: &nbsp;&nbsp;&nbsp;<b>Martina aus Koeln</b>&nbsp;<br></font>";
   ergebnisse += "<font color= #0000cc>Name:&nbsp;</font>";
   ergebnisse += "<input type= text  size= 35  maxlength= 38  name=xx_spieler style='border: 1px solid; border-color: #0000cc; color: #000095; text-align: left; font-weight: bold; font-family: arial, helvetica; font-size: 11pt; background: #ffffff'><br>";
   ergebnisse += "<br><table width = 60%><tr>";
   ergebnisse += "<td align = center><font color= #0000cc><b>Land</b></font></td>";
   ergebnisse += "<td align = center><font color= #0000cc><b>Schulart</b></font></td>";
   ergebnisse += "<td align = center><font color= #0000cc><b>Klasse</b></font></td>";
   ergebnisse += "</tr><tr>";

ergebnisse += "<td><select name= xx_land size=1 style='color: #000095; text-align: center; font-weight: bold; font-size: 10pt'>";
   ergebnisse += "<option value =0 > Bitte wählen ...";
   ergebnisse += "<option value =1> Deutschland";
   ergebnisse += "<option value =2> Österreich";
   ergebnisse += "<option value =3> Schweiz";
   ergebnisse += "<option value =4> anderes Land";
   ergebnisse += "</select></td>";

   ergebnisse += "<td><select name= xx_schulart size=1 style='color: #000095; text-align: center; font-weight: bold; font-size: 10pt'>";
ergebnisse += "<option value =0 > Bitte wählen ...";
   ergebnisse += "<option value =1> Realschule";
   ergebnisse += "<option value =2> Hauptschule";
   ergebnisse += "<option value =3> Gymnasium";
   ergebnisse += "<option value =4> Gesamtschule";
   ergebnisse += "<option value =5> -----";
   ergebnisse += "</select></td>";

   ergebnisse += "<td><select name= xx_klasse size= 1 style= 'color: #000095; text-align: center; font-weight: bold; font-size: 10pt'>";
   ergebnisse += "<option value =0 > Bitte wählen ...";
   ergebnisse += "<option value =1> 5";
   ergebnisse += "<option value =2> 6";
   ergebnisse += "<option value =3> 7";
   ergebnisse += "<option value =4> 8";
   ergebnisse += "<option value =5> 9";
   ergebnisse += "<option value =6> 10";
   ergebnisse += "<option value =7> --";
   ergebnisse += "</select></td></tr></table><br>";


   ergebnisse += "<input type =submit value ='Highscore abschicken'></form><br>";

ergebnisse += werbestring1+werbestring2;



   messagewindow(ergebnisse,"Highscore in Datenbank eintragen"); /* überträgt den formatierten String */
                                           /*  in ein seperates Fenster        */

}