// zeigt Infofenster an (Ersatz fuer ALERT)
function show_message_window(message) {
 var nav = navigator.appName.indexOf("Explorer");
 var vers = parseInt(navigator.appVersion);
 var y_pos = 0;
 var x_pos = 0; 
 if ( nav != -1 && vers >= 4) {
  // IE
  y_pos = (document.body.offsetHeight/2)-100+(document.body.scrollTop/2);
  x_pos = (document.body.offsetWidth/2)-50+document.body.scrollLeft;
 } else {
  // Firefox
  y_pos = (window.innerHeight/2)-100+(window.pageYOffset/2);
  x_pos = (window.innerWidth/2)-50+window.pageXOffset;
 }
  document.getElementById('message_window_text').firstChild.nodeValue = message;
  document.getElementById('message_window').style.left = x_pos;
  document.getElementById('message_window').style.top = y_pos;
  document.getElementById('message_window').style.display = 'block';
}

// zeigt die Grossansicht eines Bild in einem extra Fenster
function show_popup(datei) {  
  var picturesize = document.getElementById('big_picture').name.split("_");
  var picture_width = (Number(picturesize[0])+50);
  var picture_height = (Number(picturesize[1])+50); 
  window.open(datei, "big_picture_popup", "height="+picture_height+",width="+picture_width+",dependent=yes,hotkeys=no,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,top=50,left=50");
}

function show_popup_resized(datei, width, height) {
  window.open(datei, "big_picture_popup", "height="+height+",width="+width+",dependent=yes,hotkeys=no,menubar=no,location=no,resizable=no,scrollbars=no,status=no,toolbar=no,top=25,left=25");
}

function change_picture(small_picture_id, picture_array) {
    
  // den Abstand des Bildes vom DIV auslesen (margin-top)
  var picturesize = document.getElementById('small_picture_'+small_picture_id).name.split("_");
  var margin_top = Number(picturesize[2]);
  document.getElementById('big_picture').style.marginTop = margin_top;

  // URL vom bisherigen grossen Bild holen
  var old_big_picture_src = document.getElementById('big_picture').src;
  old_big_picture_src = old_big_picture_src.replace(/big_/, "thumb_");
  var old_big_picture_name = document.getElementById('big_picture').name;
 
  // URL vom bisherigen kleinen Bild holen
  var new_big_picture_src = document.getElementById('small_picture_'+small_picture_id).src;
  new_big_picture_src = new_big_picture_src.replace(/thumb_/, "big_");
  new_big_picture_popup_src = new_big_picture_src.replace(/big_/, "");
  var new_big_picture_name = document.getElementById('small_picture_'+small_picture_id).name;
  
  // Bilder tauschen
  document.getElementById('big_picture').src = new_big_picture_src;
  document.getElementById('small_picture_'+small_picture_id).src = old_big_picture_src;
  
  // zum Blog Link aktualisieren
  var link = "myblog.php?bbn="+picturesize[3];
  document.getElementById('blog_link').href = link;
  
  // zum Artikel Link aktualisieren
  var link = "myblog.php?bbn="+picturesize[3]+"&story_id="+picturesize[4];
  document.getElementById('story_link').href = link;

  // 'Namen' der Bilder tauschen
  document.getElementById('small_picture_'+small_picture_id).name = old_big_picture_name;
  document.getElementById('big_picture').name = new_big_picture_name;
        
  // den Link des grossen Bildes aktualisieren
  document.getElementById('big_picture_link').href = "javascript:show_popup('"+new_big_picture_popup_src+"')";
}