$ImgDiv = '';
$ImgLay = '';
$PosX = 0;
$PosY = 0;
$Status = "";

if (window.attachEvent) {window.attachEvent("onload", InitGallery); } else { window.addEventListener('load', InitGallery, false); }

function InitGallery()
{
$Status = document.body.style.overflow;
SetupImgDiv();
}


function SetupImgDiv()
{
$ImgLay = document.createElement("div");
$ImgDiv = document.createElement("div");

$ImgLay.className = "GalleryLayer";
$ImgDiv.className = "GalleryContent";

$ImgDiv.innerHTML = '<a class="GalleryLeftDiv" href="#"><</a><a class="GalleryRightDiv" href="#">></a>';

document.body.appendChild($ImgLay);
document.body.appendChild($ImgDiv);
}

function Zoom($Datei)
{
var Request = '';
var Url	= "/check/galerie.php";

Request = CreateAjaxObject('UpdatePicture');
Request.open("POST", Url, true);

Request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
Request.send("b="+$Datei);
}

function UpdatePicture(Requester)
{
$ImgDiv.innerHTML = Requester.responseText;
document.body.style.overflow = "hidden";
CenterWindow($ImgDiv);
ShowLayer();
$ImgDiv.style.visibility = "visible";		
}

function CloseGallery()
{
$ImgLay.style.width = "0px";
$ImgLay.style.height= "0px";
document.body.style.overflow = "auto";
$ImgDiv.style.visibility = "hidden";
$ImgLay.style.visibility = "hidden";
$ImgDiv.innerHTML = '';
}


function CenterWindow($MyWindow)
{
var $ScrolledX 	= window.pageXOffset || document.body.scrollLeft;
var $ScrolledY 	= window.pageYOffset || document.body.scrollTop;

var $BodyX		= document.body.clientWidth || window.innerWidth;
var $BodyY		= document.body.clientHeight || window.innerHeight;

var $MyOffsetWidth = 0;
if ($MyWindow.offsetWidth) { $MyOffsetWidth = $MyWindow.offsetWidth; }

var $PosX		= Math.floor($ScrolledX + (($BodyX - $MyOffsetWidth) / 2));
var $PosY		= Math.floor($ScrolledY + (($BodyY - $MyWindow.offsetHeight) / 2));
$MyWindow.style.top = $PosY;
$MyWindow.style.left= $PosX;
}

function ShowLayer()
{
$ImgLay.style.width = document.body.scrollWidth + 'px';
$ImgLay.style.height= document.body.scrollHeight + 'px';
$ImgLay.style.visibility = 'visible';
}