var i = 1
var thumbnail_string = "Bild %PicNr% von %PicAll%"

images = new Array



function previmg()
{
	if (i > 1)
	{
		i --
		document.uk_img.src = images[i]["bildname"]
	}
	else if (i <= 1)
	{
		i = AnzPic;
		document.uk_img.src = images[i]["bildname"]
	}
	countimg ();
}

function nextimg()
{
	if (i < AnzPic)
	{
		i ++
		document.uk_img.src = images[i]["bildname"];
		countimg ();
	}
	else if (i >= AnzPic)
	{
		i = 1
		document.uk_img.src = images[i]["bildname"];
		countimg ();
	}
}

function countimg()
{
	if (AnzPic < 0) AnzPic = 0;

	if (!document.getElementById ('pic_counter').firstChild)
		document.getElementById ('pic_counter').appendChild (document.createTextNode (""));

	counter = thumbnail_string.replace (/%PicNr%/i, i);
	counter = counter.replace (/%PicAll%/i, AnzPic);

	document.getElementById ('pic_counter').firstChild.data = counter;
}

function OpenNewWindow()
{
    //CloseWindow();
    Picture = images[i]["bigbild"];
    //xsize = Breit+60;// Zusatz für Rand rechts und links
    //ysize = Hoch+140; //Zusatz für Rand oben und unten - damit Button angezeit werden kann
    xsize = images[i]["breite"];
    ysize = images[i]["hoehe"];

    ScreenWidth = screen.width;
    ScreenHeight = screen.height;

    xpos = (ScreenWidth/2)-(xsize/2);
    ypos = (ScreenHeight/2)-(ysize/2);

	NewWindow=window.open("","Picture","height="+ysize+",width="+xsize+",scrollbars=no,resizable=no,top="+ypos+",left="+xpos+"");
	if (!NewWindow)
	{
    	alert("Ein Popup-Blocker wurde entdeckt. Eine Anzeige ist nicht möglich.");
	}
	else
	{
        NewWindow.document.write ("<html><head><title>BILDANZEIGE");
        NewWindow.document.write ("</title>");
        NewWindow.document.write ("<script>");
        NewWindow.document.write ("self.focus();");
        NewWindow.document.write ("</script>");
        NewWindow.document.write ("</head>");
        NewWindow.document.write ("<body bgcolor='#fffbe4' onload='focus()' topmargin='0' leftmargin='0' marginwidth='0' marginheight='0'>");
        NewWindow.document.write ("<table height='100%' align='center' cellpadding='0' cellspacing='0' border='0'><tr>");
        NewWindow.document.write ("<td align='center'>");
        NewWindow.document.write ("<table border='0' bgcolor='#000000' cellpadding='0' cellspacing='0'><tr><td align='center' valign='middle'>");
        NewWindow.document.write ("<img src=");
        NewWindow.document.write (Picture);
        NewWindow.document.write (" onClick='self.close()' title='Fenster schließen'");
        NewWindow.document.write (">");
        NewWindow.document.write ("</tr></table>");
        NewWindow.document.write ("</td></tr>");
        NewWindow.document.write ("</table>");
        NewWindow.document.write ("</body></html>");
        NewWindow.document.close();
        NewWindow.resizeTo(xsize,ysize);

        Picture.focus();
	}
}

function CloseWindow()
{
   if (Picture != null)
     if (!Picture.closed)
       Picture.close();
}
