// Positionierung Aktionselement
// benoetigt prototype 1.5.0

var fontsizeLineWrapperEm = 1.4;
		
var topElement = $('line_topcontent');
var actElement = $('line_aktionswrapper');
var wrapElement = $('line_wrapper');
var headlineElement = $('line_subline');
var textElement = $('line_text');


Event.observe(window, 'load', function lineDetailLayout() {
	var actHeight = actElement.getHeight();
	var topHeight = topElement.getHeight();
	var actOffTop = Position.positionedOffset(actElement)[1];
	
	/* Layoutänderungen nur wenn Aktionselement vorhanden */
	if (actHeight) {
		actElement.style.margin = '0';
		actHeight = actElement.getHeight();
		
		/* Padding TopContent entfernen */	
		topElement.style.padding = '0';
		var topHeightNoPadding = topElement.getHeight();
		var paddingOffActTopPx = topHeight-topHeightNoPadding;
	
		/* Margin-Top des Aktionselements setzen */
		var mvOffActTopPx = topHeight-actOffTop-actHeight;
		var mvOffActTopEm = mvOffActTopPx/(fontsizeLineWrapperEm*10);
		actElement.style.margin = (mvOffActTopEm)+'em 0 0 0';
	}
	
	
	// PNG f. IE5 + IE6
	// benoetigt prototype 1.5.0, browser-Objekt aus browser.js
	// @see http://homepage.ntlworld.com/bobosola
	
	if (Browser.IE) {
		var arVersion = navigator.appVersion.split("MSIE")
		var version = parseFloat(arVersion[1])
		
		if ((version >= 5.5)
			&& (version < 7.0)
			&& (document.body.filters)
			&& $('line_aktionslink')) 
		{
			var actLinkElement = $('line_aktionslink');	
			var actImgElement = actLinkElement.immediateDescendants()[0];
			var imgSrc = actImgElement.readAttribute('src');
			var imgSrcUC = imgSrc.toUpperCase();
			if (imgSrcUC.substring(imgSrcUC.length-3, imgSrcUC.length) == "PNG")
			{
				var imgDim = actImgElement.getDimensions();
				
				var imgWidthEm = imgDim.width/(fontsizeLineWrapperEm*10);
				var imgHeightEm = imgDim.height/(fontsizeLineWrapperEm*10);
				
				var style = '';
				style += 'width: ' + imgWidthEm + 'em;';
				style += 'height: ' + imgHeightEm + 'em;';
				// http://msdn.microsoft.com/workshop/author/filter/reference/filters/alphaimageloader.asp
				style += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + imgSrc + '\', sizingMethod=\'crop\')';		
				
				actLinkElement.update('<span style="'+style+'"></span>');
			}
		}
	}
});

