function startView(nr,gal,galNameReal,start)
{
	GALCOUNT=(start!=null)?start:GALCOUNT;
	//SCROLLTOP=pageOffset(1);
	standardbody.style.overflow="hidden";
	$("overlay").style.display = "block";
	$("galDescInput").firstChild.nodeValue=galNameReal;
	galN=nr;
	galFolder=gal;
	loadPic(true);
	startShadow();
	divTopNew();	
}

function divTopNew()
{
	Co=$(document.body).getCoordinates();
	Co2=$("inline").getCoordinates();
	//$(document.body).scrollTo(0,0);
	//Co=Co-$(document.body).getScrollSize().x;
	a=$(document.body).getScroll().y;
	b=$(document.body).getScrollSize().y;
	c=Co.height;
	d=Co2.height;
	$("OverlayInput").style.top=Math.round((c-d)/2)+a+"px";
	//alert(a+"   "+b+"   "+d);
	//mmm=$(document.body).getScrollSize().y-$(document.body).getScroll().y;
	$("opacity").style.height=b+"px";
	
	//alert(mmm+"   "+Co2.height+"   "+$(document.body).getScroll().y+"    "+$(document.body).getScrollSize().y);
	//$("OverlayInput").style.top=Math.round((mmm-Co2.height)/2)+"px";
	//$("opacity").style.height=Co.height+"px";
	/*return;
	h2=$("inline").clientHeight;
	 h=$("opacity").clientHeight;
	 //h=document.body.clientHeight;
	h3=(h-h2)/2;
	t=Math.round((100/h)*h3);
	//alert(t+"|"+h+"|"+h3+"|"+h2);
	$("OverlayInput").style.top=t+"%";
	$("overlay").style.top=pageOffset(1);
	$("opacity").style.margin="0px auto";*/
}

function nextPic()
{
  GALCOUNT++;
	if(GALCOUNT>pics[galN].length-1) GALCOUNT=0;
	loadPic();
}

function backPic()
{
  GALCOUNT--;
	if(GALCOUNT<0) GALCOUNT=pics[galN].length-1;
	loadPic();
}

function loadPic(start)
{
  $("imgInput").style.height="auto";
	if(GAL_ERROR)
	{
  	GAL_ERROR=false; 
  	$$("div.loadInf")[0].getElementsByTagName("p")[0].firstChild.nodeValue="Lade Bild...";
  	$$("div.loadInf")[0].getElementsByTagName("img")[0].style.display="";
	}
	$("wait").style.display="";
	$("imgDescInput").style.display="none";
	img=new Image();
	descr=pics[galN][GALCOUNT];
	splitA=descr.split("|");
	img.className="prevImgBig";
	$("imgInput").style.height="";
	img.id="prevImgBig";
	img.style.display="none";
	img.onload=hideLoadInf;
	//img.onload=function(){setTimeout("hideLoadInf()",1);};
	img.onerror=function() 
	{
  	GAL_ERROR=true; 
  	$$("div.loadInf")[0].getElementsByTagName("p")[0].firstChild.nodeValue="Fehler beim Laden des Bildes!";
  	$$("div.loadInf")[0].getElementsByTagName("img")[0].style.display="none";
	}
	if(start==null) $("imgInput").removeChild($("prevImgBig"));
	$("imgInput").appendChild(img);
	img.src=PATH+galFolder+"/"+splitA[0];
}

function Ausgabe (Ereignis) {
  if(Ereignis==null) 
	{
  	Ereignis=window.event;
	}
	key=Ereignis.keyCode || Ereignis.which;
	if(key==27 && $("overlay").style.display!="none") closeView();
	if(key==104 || key==38 || key==37 || key==33 || key==100) backPic()
	if(key==102 || key==39 || key==34 || key==40 || key==98) nextPic()
}

function hideLoadInf()
{
	h=$("prevImgBig").height;
	w=$("prevImgBig").width;
	if(w>=PICDIMENSIONX && w>=h) 
	{
  	$("prevImgBig").width=PICDIMENSIONX;
  	$("prevImgBig").height=(PICDIMENSIONX/w)*h;
	}
	else 
	{
  	$("prevImgBig").height=PICDIMENSIONY;
  	$("prevImgBig").width=(PICDIMENSIONY/h)*w;
	}
	imgDesc=unescape(splitA[1]);
	$("imgDescInput").style.display="";
	$("imgInput").style.height="auto";
	$("wait").style.display="none";
	$("prevImgBig").style.display="";
	$("imgDescInput").firstChild.nodeValue=imgDesc;
	divTopNew();
}

function closeView()
{
	$("overlay").style.display="none";
	standardbody.style.overflow="auto";
	//standardbody.scrollTop=SCROLLTOP;
	iI=$("imgInput");
	iI.removeChild($("prevImgBig"));
	GALCOUNT=0;
	startShadow();
}

/*function pageOffset(nr)
{
    win = window;
    var pos = new Array(0,0);

    if(typeof win.pageXOffset != 'undefined')
    {
         // Mozilla/Netscape
         pos[0] = win.pageXOffset;
         pos[1] = win.pageYOffset;
    }
    else
    {
         var obj = (win.document.compatMode && win.document.compatMode == "CSS1Compat") ?
         win.document.documentElement : win.document.body || null;
         pos[0] = obj.scrollLeft;
         pos[1] = obj.scrollTop;
    }
		return pos[nr];
}*/
