var MM_contentVersion = 7;
var plugin = (navigator.mimeTypes && navigator.mimeTypes['application/x-shockwave-flash']) ? navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin : 0;
if (plugin) {
	var words = navigator.plugins['Shockwave Flash'].description.split(' ');
	for (i = 0; i < words.length; i++) {
		if (isNaN(parseInt(words[i]))) {
			continue;
		}
		var MM_PluginVersion = words[i]; 
	}
	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
} else if (navigator.userAgent && navigator.userAgent.indexOf('MSIE') >=0 && (navigator.appVersion.indexOf('Win') != -1)) {
	document.write('<script type="text\/vbscript" language="VBScript" charset="iso-8859-1">\n');
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('<\/script>\n');
}

function replace(title) {
	title = title.replace(/%C4/g,"&Auml;");
	title = title.replace(/%D6/g,"&Ouml;");
	title = title.replace(/%DC/g,"&Uuml;");
	title = title.replace(/%DF/g,"&szlig;");
	title = title.replace(/%E4/g,"&auml;");
    title = title.replace(/%E9/g,"&eacute;");
	title = title.replace(/%F6/g,"&ouml;");
	title = title.replace(/%FC/g,"&uuml;");
	title = title.replace(/%26amp%3B/g,"%26");
	title = title.replace(/%3CBR%20%5C%3E/g,"\n");
	title = title.replace(/%3CBR%3E/g,"\n");
	return title;
}

function replaceHeading(htmltag) {
	for(var i = 0; i < document.getElementsByTagName(htmltag).length; i++) {
		var title = document.getElementsByTagName(htmltag)[i].innerHTML;
		if (title != undefined) {
			if (title != "") {
				myObj = document.getElementsByTagName(htmltag)[i];
				myParent = myObj.parentNode;
				
				width = myObj.offsetWidth;
				height = myObj.offsetHeight + 20 + parseInt(title.length/40) * 15;
				
				title= replace(escape('<'+htmltag+'>' + title + '</'+htmltag+'>'));						
				var movie = 'fileadmin/swf/heading.swf';
				var htmlOutput = '';
				htmlOutput += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + width + '" height="' + height + '" align="middle">';
				htmlOutput += '<param name="allowScriptAccess" value="sameDomain" />';
				htmlOutput += '<param name="wmode" value="transparent" />';
				htmlOutput += '<param name="movie" value="' + movie + '" />';
				htmlOutput += '<param name="FlashVars" value="title=' + title + '" />';
				htmlOutput += '<param name="quality" value="high" />';
				htmlOutput += '<param name="scale" value="noscale" />';
				htmlOutput += '<param name="salign" value="lt" />';
				htmlOutput += '<param name="bgcolor" value="#ffffff" />';
				htmlOutput += '<embed src="' + movie + '" FlashVars="title=' + title + '" quality="high" wmode="transparent" scale="noscale" salign="lt" bgcolor="#ffffff" width="' + width + '" height="' + height + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
				htmlOutput += '</object>';

				replaceDiv = document.createElement('div');
				replaceDiv.innerHTML = htmlOutput;
				replaceDiv.style.margin = "0px 0px 0px 0px";
				replaceDiv.style.padding = "0px 0px 0px 0px";
				
				myParent.replaceChild(replaceDiv, myObj);	
				i--;
			}
		}	
	}
}

if (MM_FlashCanPlay && document.getElementsByTagName) {
	replaceHeading("h2");
	replaceHeading("h1");
}
