function getNext(){
  currentIndex++;
  if(currentIndex == (opener.imgArray.length-1))document.getElementById('nextLink').style.display = 'none';
  else document.getElementById('nextLink').style.display = '';
  document.getElementById('prevLink').style.display = '';
  document.getElementById('mainImage').src = 'http://' + opener.location.host + '/' + opener.imgArray[currentIndex];
 }

function getPrevious(){
  if(currentIndex>0)currentIndex--;
  if(currentIndex==0)document.getElementById('prevLink').style.display = 'none';
  else document.getElementById('prevLink').style.display = '';
  document.getElementById('nextLink').style.display = '';
  document.getElementById('mainImage').src = 'http://' + opener.location.host + '/' + opener.imgArray[currentIndex];
}

var f;


function galleryPopup(index,imgSrc){
	if(!f || f.closed){
		f = window.open('','',"width=650,height=650,left=150,top=150");
		f.document.open();
	}
	f.focus();
	if(index==0)prevDisplay = 'display:none';
	else prevDisplay = '';
	
	if(index==(imgArray.length - 1))nextDisplay = 'display:none';
	else nextDisplay = '';
	f.document.write('<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>Einzelbild-Ansicht</title><script src="http://' + window.location.host + '/typo3conf/ext/riegel_gallery/gallery.js" type="text/javascript"></script><script type="text/javascript">var currentIndex=' + index + ';</script></head><body style="margin:20px;text-align:center;" ><div id="content"><div style="width:570px;height:550px;margin:0 20px;"><img src="/' + imgSrc + '" alt="Bild" id="mainImage"/></div><br /><a href="javascript:getPrevious()"  style="font-family:Arial;color:#666;' + prevDisplay + '" id="prevLink" >&lt;&lt; </a>&nbsp;&nbsp;&nbsp;<a href="javascript:window.opener.f = false;window.close()" style="font-family:Arial;color:#666">Fenster schließen</a>&nbsp;&nbsp;&nbsp;<a href="javascript:getNext()" style="font-family:Arial;color:#666;' + nextDisplay + '" id="nextLink"> &gt;&gt;</a><br /></div></body></html>');
	f.document.close();
	
}


