function createGallery()
{	
	var imgContainer=document.getElementById('ImgContainer');
	var loadingMsg=document.getElementById('LoadingMsg');
	var d=document.getElementById('Thumbs');
	if(!d){return;}
	var piclinks=d.getElementsByTagName('a');
	for(var i=0;i<piclinks.length;i++) {
		piclinks[i].onclick=function() {
			if(imgContainer.getElementsByTagName('img').length>0) {
				imgContainer.removeChild(imgContainer.getElementsByTagName('img')[0]);
			}
			var newPic=document.createElement('img');
			newPic.id='bigPicture';
			newPic.src=this.href;
			if(!newPic.complete) {
				loadingMsg.style.display='block';
				imgContainer.style.display='none';
			}
			newPic.alt=this.getElementsByTagName('img')[0].alt;
			newPic.title='Click to return to images';
			newPic.onload=function() {
				// für Opera nochmals festlegen
				if(this.width>0 && this.height>0) {
					imgContainer.style.marginTop = (Math.abs(this.width-this.height-50)+this.width-this.height)/4+'px';
				}
				loadingMsg.style.display='none';
				imgContainer.style.display='block';
			}
			imgContainer.style.marginTop = (Math.abs(newPic.width-newPic.height-50)+newPic.width-newPic.height)/4+'px';
			imgContainer.appendChild(newPic);
			return false;
		}
	}
	if(picToLoad = document.getElementById('PicToLoad')) {
		picToLoad.onclick();
	} else {
		piclinks[0].onclick();
	}
}

window.onload=function() {
	if(document.getElementById && document.createTextNode) {
		createGallery();	
	}
}
