var htmlStore = null;
// images
imgs = new Array();
	
//thumbs
var thumbId = 0;
	
var currImg = null;
	
var imgShown = false;

function registerImg(theURL, theCap, theUid, theIndex, w, h){

	if(imgs[theUid+""] == undefined){
		imgs[theUid+""] = new Array();
		
	}
	if (imgs[theUid+""][theIndex] == undefined){
		imgs[theUid+""][theIndex] = new Array(theURL, theCap, w, h);
	}
}
	
// define id for thumbnails
function defineId(id){
	thumbId = id;
}


		  function popDiv(theURL, theCap, theUid, theIndex, w, h, ex, historyMode){
		  	
		  	imgShown = true;

var div = document.getElementById("showPic");
  	var htm = "<table cellpaddin='0' cellspacing='0'><tr><td class='img'><a href='javascript:hidePic();'><img border='0' src='" + theURL + "'width='"+w+"' height='"+h+"'/></a></td><td class='caption'>";
  	div.style.display = "block";
  	
		  	htm  += "<div id='prevNext'><span id='prevImg'></span>";
			htm += "<a href='javascript:hidePic();' class='schliessen'>Schliessen</a>";
		  	htm += "<span id='nextImg'></span></div>";
//		  	htm += "<div class='divider'></div>";
		  	htm += theCap+"</td></tr></table>";
		    
		    // add img link to next
		    var nIndex = 0;
			
		    if((theIndex + 1) < imgs[theUid].length){
		      nIndex = theIndex + 1;
		    }
		  	var nURL = imgs[theUid][nIndex][0];
		  	var nCap = imgs[theUid][nIndex][1];
		  	var w = imgs[theUid][nIndex][2];
		  	var h = imgs[theUid][nIndex][3];
		  	
//		  	htm+= "<a href=\"javascript:popDiv('"+ nURL+"', '"+ nCap+"', '"+theUid+"', "+nIndex+", "+w+", "+h+", "+ex+");\">";

//		  	htm+= "<img border='0' src='" + theURL + "'width='"+w+"' height='"+h+"'/></td></tr><tr><td class='caption'>"+theCap+"</td></tr></table>";
//		  	htm+= "</a>";

			div.innerHTML = htm;
			
		  	if(htmlStore == null) htmlStore = document.getElementById("contentContainer").innerHTML;

		  	div.style.display = "block";
			
		  	document.getElementById("contentContainer").innerHTML = "";
		  	document.getElementById("prevNext").style.display = "block";
		  	
		  	
		  	if (theIndex > 0){
		  		writePrevNext(theUid, theIndex-1, "prevImg", "Zurück");
		  	}
		  			  	
		  	if((theIndex + 1) < imgs[theUid].length){
		  		writePrevNext(theUid, theIndex+1, "nextImg", "Weiter");
		  	}
		  	
		  }

/*
function popDiv(theURL, theCap){
  	var div = document.getElementById("showPic");
  	div.innerHTML = "<table cellpaddin='0' cellspacing='0'><tr><td class='img'><a href='javascript:hidePic();'><img border='0' src='" + theURL + "'/></a></td><td class='caption'>"+theCap+"<br/><br/><a href='javascript:hidePic();' class='schliessen'>[schlie&szlig;en]</a></td></tr></table>";
  	htmlStore = document.getElementById("contentContainer").innerHTML;
  	document.getElementById("contentContainer").innerHTML = "";
  	div.style.display = "block";
}
*/

function writePrevNext(theUid, theIndex, direction, theString){
  	var s = document.getElementById(direction);
  	if(imgs[theUid][theIndex] == undefined) return;
	var theURL = imgs[theUid][theIndex][0];
  	var theCap = imgs[theUid][theIndex][1];
  	var w = imgs[theUid][theIndex][2];
  	var h = imgs[theUid][theIndex][3];
		  	
  	s.innerHTML="<a href=\"javascript:popDiv('"+ theURL+"', '"+ theCap+"', '"+theUid+"', "+theIndex+", "+w+", "+h+");\">"+theString+"</a>";
		  }
		  
function hidePic(){
	  var div = document.getElementById("showPic");
	  div.innerHTML = "";
	  div.style.display = "none";
	  document.getElementById("contentContainer").innerHTML = htmlStore;
}