
var Picture = new Array(4*7);
var Strange = new Array(4*7);
var SrcPage = new Array('/default.asp','../contact.htm','../gallery/graph7.htm','../gallery/graph7.htm','../gallery/graph7.htm','../gallery/graph7.htm','index.htm','../split/index.htm','index.htm','../order/pricing.htm','../order/index.htm','../logos/index.htm','../order/site.htm','../gdl/guide/index.htm','index.htm');
var Moves, Found, Nr1, Nr2, Busy;

var I0 = new Image(); I0.src = "0.gif";
var I1 = new Image(); I1.src = "1.jpg";
var I2 = new Image(); I2.src = "2.jpg";
var I3 = new Image(); I3.src = "3.jpg";
var I4 = new Image(); I4.src = "4.jpg";
var I5 = new Image(); I5.src = "5.jpg";
var I6 = new Image(); I6.src = "6.jpg";
var I7 = new Image(); I7.src = "7.jpg";
var I8 = new Image(); I8.src = "8.jpg";
var I9 = new Image(); I9.src = "9.jpg";
var I10 = new Image(); I10.src = "10.jpg";
var I11 = new Image(); I11.src = "11.jpg";
var I12 = new Image(); I12.src = "12.jpg";
var I13 = new Image(); I13.src = "13.jpg";
var I14 = new Image(); I14.src = "14.jpg";

function UnCover(j) {strI = "i"+(j); MM_findObj(strI).src = eval("I" + Picture[j] + ".src"); }

function Cover(k) {strI = "i"+(k); MM_findObj(strI).src = I0.src; }

function Hide() { Cover(Nr1); Nr1 = -1; Cover(Nr2); Nr2 = -1; Busy = 0; }


function aiSwap(i)
{
    Busy = 1;
    if (Strange[i] == 1) { Busy = 0; return; }
    if (Found == 14) { Busy = 0; return; }
    UnCover(i);
    if (Nr1 == -1 || i == Nr1 || Strange[i] == 1) { Nr1 = i; Busy = 0; return; };
    Nr2 = i;
    Moves++;
    if (Picture[Nr1] != Picture[Nr2]) { setTimeout("Hide()", 1500); }
    else
    {
        Found++;
        Strange[Nr1] = 1;
        Strange[Nr2] = 1;
        if (Found == 14)
        {
            if (Moves>28) alert("Congratulations!\nYou have completed the game in "+Moves+" moves.\nThat's no great shakes, but still ;-)\nWhy don't you play another game?");
            if (Moves<29 && Moves>24) alert("Good!\nYou have completed the game in "+Moves+" moves.");
            if (Moves<25 && Moves>19) alert("Very good!\nYou have completed the game in "+Moves+" moves.");
            if (Moves<20 && Moves>14) alert("Excellent!\nYou have completed the game in "+Moves+" moves.");
            if (Moves==14) alert("Perfect score!\nYou have completed the game in "+Moves+" moves.");
        }
    Nr1 = -1;
    Nr2 = -1;
    Busy = 0;
    }
}

function StartUp()
{
    Busy = 1;
    Moves = 0;
    Found = 0;
    Nr1 = -1;
    Nr2 = -1;
    for (n = 0; n < 28; n++)
    {
        Picture[n] = Math.floor(n/2) + 1;
        Strange[n] = 0;
        Cover(n);
    }
    for (n = 0; n < 28; n++)
    {
        i = Math.floor(Math.random()*28);
        HelpVar = Picture[i];
        Picture[i] = Picture[n];
        Picture[n] = HelpVar;
    }
    Busy = 0;
}

function aiSurf(i) // overhead: ist das Spiel vorbei, wird Weiterleitung freigeschaltet
{
    if (Busy==1) return;
    if (Found==14)  { i=Picture[i]; location.href = SrcPage[i]; }
    else { aiSwap(i); }
}

function UB(r) { status = r; return true; }
