// swap image from xxx_1.png to xxx_2.png or backwards
function swapImg(img,over)
{
  if (over) var new_file = img.src.substr(0,img.src.length-5)+"2."+img.src.substr(img.src.length-3,img.src.length);
  else var new_file = img.src.substr(0,img.src.length-5)+"1."+img.src.substr(img.src.length-3,img.src.length);
  img.src = new_file;
}

// preload images (pairs with _1 and _2 even if only one of them is passed to the function)
function preloadImg(image_files)
{
  if (image_files)
  {
    //alert("Preloading "+image_files.length+" images.");

    images1 = new Array();
    images2 = new Array();

    for(i=0; i<image_files.length;i++)
    {
      var img1 = image_files[i];
      if (img1.length > 2)
      {
        images1[i] = new Image();
        images2[i] = new Image();
        
        var thisnum = img1.substr(img1.length-5,1);
        if (thisnum == "1") img2 = img1.substr(0,img1.length-5)+"2."+img1.substr(img1.length-3,img1.length);
        else img2 = img1.substr(0,img1.length-5)+"1."+img1.substr(img1.length-3,img1.length);

        images1[i].src = img1;
        images2[i].src = img2;
      }
    }
  }
}

// popup
function popup(url,w,h)
{
  win = window.open(url,"Fenster"+w,"width="+w+",height="+h+",left="+(screen.width/2-w/2)+",top="+(screen.height/2-h/2));
  win.opener = this;
  win.focus();			
}  
