var clicked = 'no';
var w2 = null; // Breite
var h = 20; // korrektur höhe
var h2 = null; // Höhe
var bild = "";
var anzbilder = 19;
var bildname=new Array(19);
bildname[0]=new Array("aarau")  
bildname[1]=new Array("baden")
bildname[2]=new Array("basel")
bildname[3]=new Array("bern")
bildname[4]=new Array("biel") 
bildname[5]=new Array("fribourg")
bildname[6]=new Array("genf")
bildname[7]=new Array("locarno")
bildname[8]=new Array("lausanne") 
bildname[9]=new Array("luzern")
bildname[10]=new Array("lugano")
bildname[11]=new Array("neuenburg")
bildname[12]=new Array("olten")
bildname[13]=new Array("sion")
bildname[14]=new Array("thurgau")
bildname[15]=new Array("thun")
bildname[16]=new Array("stgallen") 
bildname[17]=new Array("winterthur")
bildname[18]=new Array("zuerich")

var bildpos=new Array(19);   // left / top
bildpos[0]=new Array(300,217)  // aarau
bildpos[1]=new Array(332,201)  // Baden
bildpos[2]=new Array(278,187)  // basel
bildpos[3]=new Array(270,270)  // bern
bildpos[4]=new Array(245,230)  // biel
bildpos[5]=new Array(230,285)  // fribourg
bildpos[6]=new Array(142,350)  // genf
bildpos[7]=new Array(360,360)  // locarno
bildpos[8]=new Array(180,317)  // lausanne
bildpos[9]=new Array(340,266)  // luzern
bildpos[10]=new Array(390,390) // lugano
bildpos[11]=new Array(200,260) // neuenburg
bildpos[12]=new Array(325,240) // olten
bildpos[13]=new Array(270,340) // sion
bildpos[14]=new Array(390,180) // thurgau
bildpos[15]=new Array(302,296) // thun
bildpos[16]=new Array(420,210) // stgallen
bildpos[17]=new Array(395,195) // winterthur
bildpos[18]=new Array(364,222) // Zuerich

function anfang () {
  over('home','menu');
  window.setInterval('uhr()',100)
}

function over (x,typ) {
  if (typ == 'menu') {
    clicked = "no";
    alle_menu_weg ();
    menu_x_an(x);
    alle_orte_weg ();
    ort_x_an(x);
    iframe_x_an(x);
  }
  if (typ == 'map') {
    if (clicked == 'no') {
      alle_menu_weg ();  
      menu_x_an(x);
      alle_orte_weg ();
      ort_x_an(x);
      iframe_x_an(x);
	}
  }
}

function klick(x) {
  alle_menu_weg ();
  menu_x_an(x);
  alle_orte_weg ();
  ort_x_an(x);
  iframe_x_an(x);
  if (x != 'home') {
    clicked = "yes";
  } 
}

function alle_menu_weg () {
  // alle Texte neutralisieren
  document.getElementById('t-home').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-home').style.color = '#c33';
  document.getElementById('t-aarau').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-aarau').style.color = '#c33';
  document.getElementById('t-baden').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-baden').style.color = '#c33';
  document.getElementById('t-basel').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-basel').style.color = '#c33';
  //document.getElementById('t-bern').style.backgroundColor = '#F7E9C2';
  //document.getElementById('t-bern').style.color = '#c33';
  document.getElementById('t-biel').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-biel').style.color = '#c33';
  document.getElementById('t-fribourg').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-fribourg').style.color = '#c33';
  document.getElementById('t-genf').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-genf').style.color = '#c33';
  document.getElementById('t-locarno').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-locarno').style.color = '#c33';
  document.getElementById('t-lausanne').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-lausanne').style.color = '#c33';
  document.getElementById('t-luzern').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-luzern').style.color = '#c33';
  document.getElementById('t-lugano').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-lugano').style.color = '#c33';
  document.getElementById('t-neuenburg').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-neuenburg').style.color = '#c33';
  document.getElementById('t-olten').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-olten').style.color = '#c33';
  //document.getElementById('t-sion').style.backgroundColor = '#F7E9C2';
  //document.getElementById('t-sion').style.color = '#c33';
  document.getElementById('t-stgallen').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-stgallen').style.color = '#c33';
  document.getElementById('t-thun').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-thun').style.color = '#c33';
  document.getElementById('t-thurgau').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-thurgau').style.color = '#c33';
  document.getElementById('t-winterthur').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-winterthur').style.color = '#c33';
  document.getElementById('t-zuerich').style.backgroundColor = '#F7E9C2';
  document.getElementById('t-zuerich').style.color = '#c33';
}

function menu_x_an (x) {
  document.getElementById('t-'+x).style.backgroundColor = '#c33';
  document.getElementById('t-'+x).style.color = '#fff';
}

  // alle buttons auf "normal" setzen
function alle_orte_weg () {
  koordinaten();
  position();
  for (i = 0; i <= (anzbilder-1); i++)
	{		 
       bild = bildname[i]+'_over';
       if (bildname[i] != "home");
	   { document.getElementById(bild).style.visibility="hidden";
	     bild = bildname[i]+'_normal';
	     document.getElementById(bild).style.left = bildpos[i][0];
	     document.getElementById(bild).style.top = bildpos[i][1] + h;
		 document.getElementById(bild).style.visibility="visible";
	   }
	}
}

function ort_x_an (x) {
  // Normal-Bild durch overbild auf Karte erstzen
  i = 0;  
  for (i = 0; i <= (anzbilder-1); i++) {
	 bild=bildname[i];
	 if (bild == x && x != "home") {
       bild = bildname[i]+'_normal';
       document.getElementById(bild).style.visibility="hidden";
	  
	   bild = bildname[i]+'_over';
	   document.getElementById(bild).style.left = bildpos[i][0] ;
	   document.getElementById(bild).style.top = bildpos[i][1] + h;
	   document.getElementById(bild).style.visibility="visible";
	 }  
  }
}

function iframe_x_an (x) {
  boxchange(x+'.htm', 'box');
}


//end neu
// Aufruf, bei rezsizing
function fensterweite () {
  klick("home","menu");
}

// Ermittel linker und obiger Abstand (Zentrieren)
function koordinaten ()  {
  //  ( Gesamt-Breite - 900px(frame) ) / 2 = left-pos des frames = w2
  w2 = top.document.body.clientWidth;
  w2 = ((w2 - 900)/2);
  if (w2 < 0) {
     w2 = 1;
  };

  h2 = top.document.body.clientHeight;
  h2 = ((h2 - 537 - h)/2);
  if (h2 < 0) {
     h2 = 1;
  };
} 

// iframe auswechseln  
function boxchange( URL, Frame1 ) {
  Frame1=eval("parent."+ Frame1);
  Frame1.location.href = URL;
}
  
// Positionieren des Hauptlayers "frame" 
function position () {
  document.getElementById('frame').style.top = h2;
  document.getElementById('frame').style.left = w2;
}

function uhr() {
  Datum = new Date();
  Tag = Datum.getDate();
  Monat = Datum.getMonth() + 1;
  Jahr = Datum.getFullYear();
  Stunde = Datum.getHours();
  Minute = Datum.getMinutes();
  Sekunde = Datum.getSeconds();
  if(Tag<10)Tag = "0" + Tag;
  if(Monat<10)Monat = "0" + Monat;
  if(Stunde<10)Stunde = "0" + Stunde;
  if(Minute<10)Minute = "0" + Minute;
  if(Sekunde<10)Sekunde = "0" + Sekunde;
   
  document.formular.zeigezeit.value = Stunde + ":" + Minute + ":" + Sekunde;
  document.formular.zeigedatum.value = Tag + "." + Monat + "." + Jahr;
}
