// Allgemeine Funktionalitaeten

function popUpFenster(seite, fenstername, breite, hoehe) {
	var popup = window.open(seite,fenstername, 'toolbar=0,location=0, directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=' + breite + ',height=' + hoehe);
}

// Rollover bei Titelbildern

function MM_swapImgRestore() { //v2.0
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_swapImage() { //v2.0
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore
}

// Flash-Detect

function einfuegeFlashDeFacto(flashUri, flashName, flashBgColor, breitePx, hoehePx, altBildUri, altBildAltText) {
	var d = document;
	if (flashUri && flashName && breitePx && hoehePx) {
		if (detectFlash() && !((navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)==4))) {
			d.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td class="blk"><obj'+'ect ');
			d.write('  classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
			d.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"');
			d.write('  width="'+breitePx+'" height="'+hoehePx+'">');
			d.write('  <param name="movie" value="'+flashUri+'">');
			d.write('  <param name="quality" value="high"><param name="wmode" value="transparent"><param name="scale" value="exactfit"><param name="bgcolor" value="'+flashBgColor+'">');
			d.write('  <em'+'bed src="'+flashUri+'" quality="high" ');
			d.write('    pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"');
			d.write('    type="application/x-shockwave-flash" width="'+breitePx+'" height="'+hoehePx+'" bgcolor="'+flashBgColor+'" border="0" hspace="0" vspace="0"></em'+'bed></obj'+'ect></td></tr></table>');
		} else if (altBildUri) {
			var alt = altBildAltText;
			if (!altBildAltText)
				alt = "";
			d.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td class="blk"><img src="'+altBildUri+'" alt="'+alt+'" width="'+breitePx+'" height="'+hoehePx+'"></td></tr></table>');
		}
	}
}

var detectableWithVB = false;

if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
	var d = document;
    d.writeln('<script language="VBscript">');

    d.writeln('detectableWithVB = False');
    d.writeln('If ScriptEngineMajorVersion >= 2 then');
    d.writeln('  detectableWithVB = True');
    d.writeln('End If');

    d.writeln('Function detectActiveXControl(activeXControlName)');
    d.writeln('  on error resume next');
    d.writeln('  detectActiveXControl = False');
    d.writeln('  If detectableWithVB Then');
    d.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    d.writeln('  End If');
    d.writeln('End Function');

    d.writeln('</scr' + 'ipt>');
}

function detectFlash() {
	var pluginFound = false;
    pluginFound = detectPlugin('Shockwave', 'Flash');
    if(!pluginFound && detectableWithVB) {
		pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash');
    }
    return pluginFound;
}

function detectPlugin() {
    var daPlugins = detectPlugin.arguments;
    var pluginFound = false;
    if (navigator.plugins && navigator.plugins.length > 0) {
		var pluginsArrayLength = navigator.plugins.length;
		for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
			var numFound = 0;
			for (namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
				if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) ||
					(navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
					numFound++;
				}
			}
			if(numFound == daPlugins.length) {
				pluginFound = true;
				break;
			}
		}
    }
    return pluginFound;
}
function optimizePresseThumbs() {
	setTimeout("optimizeLater()", 10000);
	
}

function optimizeLater() {	
	
	var contentTD = document.getElementById("contentTD");
	if(contentTD) {
		var maxDivHeight = 0;
		var divs = contentTD.getElementsByTagName("div");
		for(var i = 0; i < divs.length; i++) {
			var div = divs[i];
			if(div.className == 'pressethumb') {
				if(div.offsetHeight > maxDivHeight) {
					maxDivHeight = div.offsetHeight;
				}
			}
		}
		for(var i = 0; i < divs.length; i++) {
			var div = divs[i];
			if(div.className == 'pressethumb') {
				div.style.height = maxDivHeight + "px";
			}
		}
	}	
}