
function initImageEnlargement() {
	oPictureTable = document.getElementById('picture-table');
	if (oPictureTable) {
		aImages = oPictureTable.getElementsByTagName('img');
		for (index = 0; index < aImages.length; index++) {
			// attach event handles
			aImages[index].onmouseover = borderOn;
			aImages[index].onmouseout = borderOff;
			aImages[index].onclick = showEnlargement;
			// number pictures
			aImages[index].name = index;
			if (aImages[index].alt == '') {
				aImages[index].alt = 'bitte klicken';
			}
		}
		
		oEnlargedPictures = document.getElementById('enlarged-pictures');
		// attach event handle of enlarged picture div
		oEnlargedPictures.onclick = hideEnlargement;
		aEnlargedImages = oEnlargedPictures.getElementsByTagName('img');
		for (index = 0; index < aEnlargedImages.length; index++) {
			// hide all
			if (aEnlargedImages[index].style) {
//				aEnlargedImages[index].onmouseover = borderOn;
//				aEnlargedImages[index].onmouseout = borderOff;
				if (aImages[index].alt == '') {
					aEnlargedImages[index].alt = 'bitte klicken';
				}
			}
		}
	}
}

// event handles
borderOn = function() {
	this.style.border = "2px solid #767679";
}

borderOff = function() {
	this.style.border = "2px solid white";
}

showEnlargement = function() {
	oPictureTable = document.getElementById('picture-table');
	oPictureTable.style.display = 'none';
	oEnlargedPictures = document.getElementById('enlarged-pictures');
	oEnlargedPictures.style.display = 'block';
	
	aEnlargedImages = oEnlargedPictures.getElementsByTagName('img');
	for (index = 0; index < aEnlargedImages.length; index++) {
		// hide all
		if (aEnlargedImages[index].style) {
			aEnlargedImages[index].style.display = 'none';
//			aEnlargedImages[index].onmouseover = borderOn;
//			aEnlargedImages[index].onmouseout = borderOff;
		}
	}
	// show correct enlarged picture
	aEnlargedImages[this.name].style.display = 'block';
}

hideEnlargement = function() {
	oPictureTable = document.getElementById('picture-table');
	oPictureTable.style.display = 'block';
	oEnlargedPictures = document.getElementById('enlarged-pictures');
	oEnlargedPictures.style.display = 'none';
}

	function trace(object) {
		var message = '';
		var maxMessages = 100;
		var recursive = false;
		if (typeof object == "object") {
			for (prop in object) {
				maxMessages --;
				if (maxMessages == 0) {
					return message + "\nmessage too long";
				}
				message += 'prop: ' + prop + ' value: ' + object[prop] + '\t';
				if (typeof object[prop] == 'object' && recursive == true) {
					message += '----------\t';
					message += trace(object[prop]);
					message += '----------\t';
				}
			}
			return message;
		}
		return object;
	}

