function onClickNext(elem)
{
	all_img = elem.parentNode.getElementsByTagName('img');
	all_div = elem.parentNode.getElementsByTagName('div');

	for (var i = 3;i < all_img.length;i++)
	{
		if (!(all_img[i].className.search(/ hidden$/) > 0))
		{
			active = i;
			all_img[i].className += ' hidden';
			all_div[i-3].className += ' hidden';

		}

	}

	if (active == all_img.length-1)
		alert('Das hätte nie passieren dürfen');

	all_img[active+1].className = all_img[active+1].className.replace(/ hidden$/, '');
	all_div[active-2].className = all_div[active-2].className.replace(/ hidden$/, '');

	if (active == all_img.length-2)
		all_img[2].className += ' hidden';

	all_img[1].className = all_img[1].className.replace(/ hidden$/, '');
}

function onClickPrevious(elem)
{
	all_img = elem.parentNode.getElementsByTagName('img');
	all_div = elem.parentNode.getElementsByTagName('div');

	for (var i = 3;i < all_img.length;i++)
	{
		if (!(all_img[i].className.search(/ hidden$/) > 0))
		{
			active = i;
			all_img[i].className += ' hidden';
			all_div[i-3].className += ' hidden';
		}

	}

	if (active == 3)
		alert('Das hätte nie passieren dürfen');

	all_img[active-1].className = all_img[active-1].className.replace(/ hidden$/, '');
	all_div[active-4].className = all_div[active-4].className.replace(/ hidden$/, '');

	if (active == 4)
		all_img[1].className += ' hidden';

	all_img[2].className = all_img[2].className.replace(/ hidden$/, '');
}

function onClickMagnifier(elem)
{
	imgwidth = 750;
	imgheight = 500;

	windowheight = (window.ActiveXObject)?
		document.documentElement.clientHeight:
		window.innerHeight;

	windowwidth = (window.ActiveXObject)?
		document.documentElement.clientWidth:
		window.innerWidth;

	all_img = elem.parentNode.getElementsByTagName('img');
	all_div = elem.parentNode.getElementsByTagName('div');

	NewLayer = document.createElement('div');
	NewLayer.id = 'softwhitelayer';
	NewLayer.onclick = new Function('closeImgBox(this);');
	if (window.ActiveXObject)
	{
		NewLayer.style.top = document.documentElement.scrollTop + 'px';
		NewLayer.style.left = document.documentElement.scrollLeft + 'px';
	}

	NewImgBox = document.createElement('div');
	NewImgBox.id = 'imgbox';
	NewImgBox.style.top = (window.ActiveXObject)?
		((windowheight - (imgheight + 4)) / 2 + document.documentElement.scrollTop) + 'px':
		(windowheight - (imgheight + 4)) / 2 + 'px';
	NewImgBox.style.left = (window.ActiveXObject)?
		((windowwidth - (imgwidth + 4)) / 2 + document.documentElement.scrollLeft) + 'px':
		(windowwidth - (imgwidth + 4)) / 2 + 'px';

	NewImgBoxClose = document.createElement('img');
	NewImgBoxClose.src = absoluter_pfad + 'images/controls/lightbox_close.png';
	NewImgBoxClose.alt = 'schließen';
	NewImgBoxClose.className = 'closebutton';
	NewImgBoxClose.onclick = new Function('closeImgBox(this);');
	NewImgBox.appendChild(NewImgBoxClose);

	NewImgBoxPrevious = document.createElement('img');
	NewImgBoxPrevious.src = absoluter_pfad + 'images/controls/lightbox_left.png';
	NewImgBoxPrevious.alt = 'vorheriges Bild';
	NewImgBoxPrevious.className = all_img[1].className;
	NewImgBoxPrevious.onclick = new Function('onClickPrevious(this);');
	NewImgBox.appendChild(NewImgBoxPrevious);

	NewImgBoxNext = document.createElement('img');
	NewImgBoxNext.src = absoluter_pfad + 'images/controls/lightbox_right.png';
	NewImgBoxNext.alt = 'nächstes Bild';
	NewImgBoxNext.className = all_img[2].className;
	NewImgBoxNext.onclick = new Function('onClickNext(this);');
	NewImgBox.appendChild(NewImgBoxNext);

	for (var i = 3;i < all_img.length;i++)
	{
		NewImgBoxImg = document.createElement('img');
		NewImgBoxImg.src = all_img[i].src.replace(/\?w=198&h=148/,'?w='+imgwidth+'&h='+imgheight);
		NewImgBoxImg.alt = all_img[i].alt;
		NewImgBoxImg.className = all_img[i].className;

		if (window.ActiveXObject)
		{
			NewImgBoxNext.onmouseover = new Function('setHoverPopup(this,1);');
			NewImgBoxNext.onmouseout = new Function('setHoverPopup(this,0);');
		}

		NewImgBox.appendChild(NewImgBoxImg);
		
		NewImgBoxDiv = document.createElement('div');
		NewImgBoxDiv.className = all_div[i-3].className;
		NewImgBoxDiv.innerHTML = all_div[i-3].innerHTML;
		NewImgBox.appendChild(NewImgBoxDiv);
	}

	document.getElementsByTagName('body')[0].insertBefore(NewImgBox,document.getElementById('container'));
	document.getElementsByTagName('body')[0].insertBefore(NewLayer,document.getElementById('container'));
}

function onClickMagnifierInner(elem)
{
	imgwidth = 750;
	imgheight = 500;

	windowheight = (window.ActiveXObject)?
		document.documentElement.clientHeight:
		window.innerHeight;

	windowwidth = (window.ActiveXObject)?
		document.documentElement.clientWidth:
		window.innerWidth;

	img = elem.getElementsByTagName('img')[0];
	
		NewLayer = document.createElement('div');
	NewLayer.id = 'softwhitelayer';
	NewLayer.onclick = new Function('closeImgBox(this);');
	if (window.ActiveXObject)
	{
		NewLayer.style.top = document.documentElement.scrollTop + 'px';
		NewLayer.style.left = document.documentElement.scrollLeft + 'px';
	}

	NewImgBox = document.createElement('div');
	NewImgBox.id = 'imgbox';
	NewImgBox.style.top = (window.ActiveXObject)?
		((windowheight - (imgheight + 4)) / 2 + document.documentElement.scrollTop) + 'px':
		(windowheight - (imgheight + 4)) / 2 + 'px';
	NewImgBox.style.left = (window.ActiveXObject)?
		((windowwidth - (imgwidth + 4)) / 2 + document.documentElement.scrollLeft) + 'px':
		(windowwidth - (imgwidth + 4)) / 2 + 'px';

	NewImgBoxClose = document.createElement('img');
	NewImgBoxClose.src = absoluter_pfad + 'images/controls/lightbox_close.png';
	NewImgBoxClose.alt = 'schließen';
	NewImgBoxClose.className = 'closebutton';
	NewImgBoxClose.onclick = new Function('closeImgBox(this);');
	NewImgBox.appendChild(NewImgBoxClose);
	
	NewImgBoxImg = document.createElement('img');
	NewImgBoxImg.src = img.src.replace(/\?w=384/,'?w='+imgwidth+'&h='+imgheight);
	NewImgBoxImg.alt = img.alt;
	NewImgBoxImg.className = img.className;

	NewImgBox.appendChild(NewImgBoxImg);
	
	document.getElementsByTagName('body')[0].insertBefore(NewImgBox,document.getElementById('container'));
	document.getElementsByTagName('body')[0].insertBefore(NewLayer,document.getElementById('container'));
}

function positionImgBox()
{
	windowwidth = (window.ActiveXObject)?
		document.documentElement.clientWidth:
		window.innerWidth;

	windowheight = (window.ActiveXObject)?
		document.documentElement.clientHeight:
		window.innerHeight;

	MyLayer = document.getElementById("softwhitelayer");
	MyImgbox = document.getElementById("imgbox");



	if (MyLayer && window.ActiveXObject)
	{
		MyLayer.style.top = document.documentElement.scrollTop + 'px';
		MyLayer.style.left = document.documentElement.scrollLeft + 'px';
	}

	if(MyImgbox) {
		imgwidth = MyImgbox.offsetWidth;
		imgheight = MyImgbox.offsetHeight;
		MyImgbox.style.top = (window.ActiveXObject)?
			((windowheight - (imgheight + 4)) / 2 + document.documentElement.scrollTop) + 'px':
			(windowheight - (imgheight + 4)) / 2 + 'px';
		MyImgbox.style.left = (window.ActiveXObject)?
			((windowwidth - (imgwidth + 4)) / 2 + document.documentElement.scrollLeft) + 'px':
			(windowwidth - (imgwidth + 4)) / 2 + 'px';
		//pathImgbox.style.top = (windowheight-(pathImgbox.offsetHeight+4))/2+"px";
		//pathImgbox.style.left = (windowwidth-(pathImgbox.offsetWidth+4))/2+"px";
	}
}

function closeImgBox()
{
	document.getElementsByTagName("body")[0].removeChild(document.getElementById("softwhitelayer"));
	document.getElementsByTagName("body")[0].removeChild(document.getElementById("imgbox"));
}
