var timer;

function isLinked(node)
{
	do
	{
		node = node.parentNode;
		if (node.nodeName == 'A') return true;
	}
	while (node.nodeName != 'TD' && node.nodeName != 'BODY');
		
	return false;
}

function resizeImages()
{
	for (var i = 0; i < document.images.length ;i++)
	{
		if (document.images[i].className == 'resizeImage')
		{
			var imageWidth = document.images[i].width;
			var imageHeight = document.images[i].height;
			
			if ((imageMaxWidth != 0 && imageWidth > imageMaxWidth) || (imageMaxHeight != 0 && imageHeight > imageMaxHeight))
			{
				if (imageMaxWidth != 0) var div1 = imageMaxWidth / imageWidth;
				else var div1 = 1;
				if (imageMaxHeight != 0) var div2 = imageMaxHeight / imageHeight;
				else var div2 = 1;
							
				if (div1 < div2)
				{
					document.images[i].width = imageMaxWidth;
					document.images[i].height = Math.round(imageHeight * div1);
				}
				else
				{
					document.images[i].height = imageMaxHeight;
					document.images[i].width = Math.round(imageWidth * div2);
				}
				if (!isLinked(document.images[i]))
				{
					var popupLink = document.createElement("a");
					popupLink.setAttribute('href', document.images[i].src);
					popupLink.setAttribute('target', '_blank');
					popupLink.appendChild(document.images[i].cloneNode(true));
					
					document.images[i].parentNode.replaceChild(popupLink, document.images[i]);
				}
			}
		}
	}
}

function related_scroll(dir)
{
	if(timer) clearTimeout(timer);

	if(window.frames["related_articles"])
	{
		window.frames["related_articles"].scrollBy(dir, 0);

    	timer = setTimeout("related_scroll(" + dir + ")", 20);
	}
}

function stop_related_scroll()
{
	if(timer) clearTimeout(timer);
}

function image(url)
{
	var imgphp = '/images.php?url=' + url;

	window.open(imgphp, '', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizeable=1,width=500,height=400');
}

function versandkosten()
{
	window.open("/shop/versandkosten/", '', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizeable=0,width=320,height=400');
}

function friendmail(url)
{
	window.open(url, '', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizeable=0,width=330,height=400');
}

function printpage(url)
{
	window.open(url, '', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizeable=0,width=660,height=700');
}

function popup_center(width,height)
{
	x = (screen.availWidth - width) / 2;
	y = (screen.availHeight - height) / 2;

	self.moveTo(x,y);
}

star_high = new Image();
star_high.src = "/images/score/star_high.gif"
star_low = new Image();
star_low.src = "/images/score/star_low.gif"



function gewinnspiel(id)
{
	var url = '/gewinnspiel.php?id=' + id;

	window.open(url, '', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizeable=0,width=500,height=250');
}