S0 = new Image();
var Leicht=true,Ende=false;L=5;
function Difficult() {
if (confirm("With higher degree of difficulty you are able to move only\n the neighbouring fields to the empty field.\n\n Do you want this?"))Leicht=false;}
function Spielstufe() {
if (confirm("Bei höherem Schwierigkeitsgrad können Sie nur\ndie Nachbarfelder des Leerfeldes anklicken.\n\nWollen Sie das?"))Leicht=false;}
function Rules(){alert(
"Rules\n\n"+
"Eight partial figures and an empty field are to move by mouse click.\n" +
"You are able to make every field by clicking move to the empty field.\n" +
"Aim is to arrange all fields properly (empty field in the middle).\n" +
"Then the missing figure, in addition, appears.\n\n" +
"Higher degree of difficulty:\n" +
"You are only able to click the fields aside the empty field one.\n\n");}

function Regeln(){alert(
"Regeln\n\n"+
"Acht Teilbilder und ein Leerfeld sind zu verschieben.\n"+
"Sie können jedes Feld durch Anklicken gegen das Leerfeld austauschen.\n"+
"Ziel ist es, alle Felder richtig anzuordnen (Leerfeld in der Mitte).\n"+
"Das fehlende Bild wird dann zusätzlich eingeblendet.\n\n"+
"Höherer Schwierigkeitsgrad:\n"+
"Sie können nur die beiden Nachbarfelder des Leerfeldes anklicken.\n\n");}
function Chg(Nr1,Nr2){
if(Ende==false){
Ende=true;
S0.src=document.images['V'+Nr1].src;
document.images['V'+Nr1].src = document.images['V'+Nr2].src;
document.images['V'+Nr2].src = S0.src;
BDat=document.images['V'+Nr1].src;
BDat=BDat.substring(0,BDat.length-5);   // Achtung: besondere Version (2 Icons)
for(var i=1;i<10;i++)if((i!=5)&(document.images['V'+i].src!=BDat+i+".jpg"))Ende=false;
if(Ende)
{Str=document.images[10].src;
Str=Str.replace(/0.jpg/i,"5.jpg");
Str=Str.replace(/1.jpg/i,"5.jpg");
Str=Str.replace(/2.jpg/i,"5.jpg");
Str=Str.replace(/3.jpg/i,"5.jpg");
Str=Str.replace(/4.jpg/i,"5.jpg");
Str=Str.replace(/6.jpg/i,"5.jpg");
Str=Str.replace(/7.jpg/i,"5.jpg");
Str=Str.replace(/8.jpg/i,"5.jpg");
Str=Str.replace(/9.jpg/i,"5.jpg");
document.images['V'+5].src=Str;}}}

function Bildw(Nr){
if(Leicht){
if((Nr==1)&(L!=1)){Chg(1,L);L=1;}
if((Nr==2)&(L!=2)){Chg(2,L);L=2;}
if((Nr==3)&(L!=3)){Chg(3,L);L=3;}
if((Nr==4)&(L!=4)){Chg(4,L);L=4;}
if((Nr==5)&(L!=5)){Chg(5,L);L=5;}
if((Nr==6)&(L!=6)){Chg(6,L);L=6;}
if((Nr==7)&(L!=7)){Chg(7,L);L=7;}
if((Nr==8)&(L!=8)){Chg(8,L);L=8;}
if((Nr==9)&(L!=9)){Chg(9,L);L=9;}
}else{
if((Nr==1)&((L==2)|(L==4))){Chg(1,L);L=1;}
if((Nr==2)&((L==1)|(L==3)|(L==5))){Chg(2,L);L=2;}
if((Nr==3)&((L==2)|(L==6))){Chg(3,L);L=3;}
if((Nr==4)&((L==1)|(L==5)|(L==7))){Chg(4,L);L=4;}
if((Nr==5)&((L==2)|(L==4)|(L==6)|(L==8))){Chg(5,L);L=5;}
if((Nr==6)&((L==3)|(L==5)|(L==9))){Chg(6,L);L=6;}
if((Nr==7)&((L==4)|(L==8))){Chg(7,L); L=7;}
if((Nr==8)&((L==5)|(L==7)|(L==9))){Chg(8,L);L=8;}
if((Nr==9)&((L==6)|(L==8))){Chg(9,L); L=9;}}}
