	var maxWidth = 640;

	var fitonpage_topbar_resized = "Bild wurde um %PERCENT% verkleinert. Klicke auf diese Leiste, um das Bild in Originalgröße (%OSIZE%) anzuzeigen.";
	var fitonpage_topbar_full = "Bild wird in Originalgröße (%OSIZE%) angezeigt. Klicke auf diese Leiste, um das Bild um %PERCENT% zu verkleinern (%RSIZE%).";

	var imageUrl = "http://www.mb-treff.de/menue/";
	
	var orgWidth = new Array();

	function fitonpage(thisId)
	{
		var thisBar = document.getElementById(thisId+'_div');
		var thisImage = document.getElementById(thisId+'_img');

		if (thisImage.width < maxWidth)
		{
            //image is small enough		
		}
		else if (thisImage.width > maxWidth || orgWidth[thisId] > maxWidth)
		{
			if (thisImage.width == maxWidth)
			{
				// resize to original width
				thisImage.width = orgWidth[thisId];
				
                var resize_height = Math.ceil((thisImage.height/thisImage.width)*maxWidth);
    			var resize_percent = Math.ceil(((thisImage.width-maxWidth)/thisImage.width)*100);
                var orig_width = thisImage.width;
                var orig_height = thisImage.height;

				var infomessage = fitonpage_topbar_full.replace('%RSIZE%', maxWidth+'x'+resize_height);
				infomessage = infomessage.replace('%OSIZE%', orig_width+'x'+orig_height);
				infomessage = infomessage.replace('%PERCENT%', resize_percent+'%');				           

				thisBar.style.fontSize = "11px";
				if (navigator.appName == "Microsoft Internet Explorer")
				{
					thisBar.style.width = thisImage.width;
				}
				else
				{
					thisBar.style.width = thisImage.width - 23;
				}
				thisBar.style.textAlign = "left";
				thisBar.style.background = 'url("' + imageUrl + 'information.gif") no-repeat scroll left center rgb(255, 255, 153)';
				thisBar.style.padding = "3px 3px 3px 20px";
				thisBar.style.margin = "0px";
				thisBar.style.cursor = "pointer";
//				thisBar.firstChild.nodeValue = infomessage;
				thisBar.innerHTML = infomessage;
			}
			else
			{
				// resize to maxWidth
                var resize_height = Math.ceil((thisImage.height/thisImage.width)*maxWidth);
    			var resize_percent = Math.ceil(((thisImage.width-maxWidth)/thisImage.width)*100);
                var orig_width = thisImage.width;
                var orig_height = thisImage.height;

				orgWidth[thisId] = thisImage.width;
				thisImage.width = maxWidth;

                var infomessage = fitonpage_topbar_resized.replace('%RSIZE%', maxWidth+'x'+resize_height);
				infomessage = infomessage.replace('%OSIZE%', orig_width+'x'+orig_height);
				infomessage = infomessage.replace('%PERCENT%', resize_percent+'%');				           

				thisBar.style.fontSize = "11px";
				if (navigator.appName == "Microsoft Internet Explorer")
				{
					thisBar.style.width = thisImage.width;
				}
				else
				{
					thisBar.style.width = thisImage.width - 23;
				}
				thisBar.style.textAlign = "left";
				thisBar.style.background = 'url("' + imageUrl + 'information.gif") no-repeat scroll left center rgb(255, 255, 153)';
				thisBar.style.padding = "3px 3px 3px 20px";
				thisBar.style.margin = "0px";
				thisBar.style.cursor = "pointer";
//				thisBar.firstChild.nodeValue = infomessage;
				thisBar.innerHTML = infomessage;
			}
		}
	}

