var rubriken = new Array("produkte", "unternehmen", "kontakt", "impressum");
var required_version = 5;

var anzahl_bilder = 5;
var media_URL = "media/";
var name_flash = "kopf.swf";
var images_URL = "kopf/bild_";
var images_suffix = ".jpg";

// Browser ueberpruefen

checkBrowser();
function checkBrowser(){
	var version = navigator.appVersion.substr(0, 1);
	if (navigator.userAgent.indexOf("MSIE") == -1 && navigator.appVersion.substr(0, 1) < 5){
		self.location = getPfad() + "weiteres/error_NN4.html";
	}
}

// Dialog anzeigen: entweder Flash oder Image

var flash_intalliert = false, flash_version = 0;
var ActiveX_aktiv = false;

function zeigeKopf(){
	var breite = 528, hoehe = 140;

	// auf Flash pruefen
	var is_IE = (navigator.appVersion.indexOf("MSIE") != -1);
	var is_Win = (navigator.appVersion.indexOf("Windows") != -1);
	var is_IE_4_Mac = (is_IE && !is_Win && navigator.appVersion.substr((navigator.appVersion.indexOf("MSIE") + 5),1) < 5);
	
	if (is_IE && is_Win){
		writeVBScript();
	} else {
		if (! is_IE_4_Mac && (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"])){
			var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flash_description = navigator.plugins["Shockwave Flash" + isVersion2].description;
			flash_version = parseInt(flash_description.charAt(flash_description.indexOf(".") - 1));
			flash_intalliert = true;
		}
		ActiveX_aktiv = true;
	}

	if (flash_intalliert && flash_version >= required_version && ! is_IE_4_Mac && ActiveX_aktiv){ writeFlash(breite, hoehe); }
	else { writeImage(breite, hoehe); }	
}

function writeFlash(breite, hoehe){
	var pfad = getPfad() + media_URL;
	document.writeln("<OBJECT width='" + breite + "' height='" + hoehe + "' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0'>");
	document.writeln("<PARAM name='quality' value='best'>");
	document.writeln("<PARAM name='base' value='.'>");
	document.writeln("<PARAM name='movie' value='"+ pfad + name_flash + "'>");
	document.writeln("<EMBED src='" + pfad + name_flash + "' width='" + breite + "' height='" + hoehe + "' quality='best' base='.' type='application/x-shockwave-flash'>");
	document.writeln("</OBJECT>");
}

function writeImage(breite, hoehe){
	var pfad = getPfad() + media_URL;
	var name_image = images_URL + Math.floor(Math.random() * anzahl_bilder) + images_suffix;
	document.writeln("<IMG src='" + pfad + name_image + "' width='" + breite + "' height='" + hoehe + "' border='0' alt=''>");
}

function writeVBScript(){
	document.writeln('<SCR' + 'IPT language="VBScript">');
	document.writeln('   On Error Resume Next');
	document.writeln('   ActiveX_aktiv = IsObject(CreateObject("Microsoft.ActiveXPlugin.1"))');
	document.writeln('   Private i, x');
	document.writeln('   flash_intalliert = False');
	document.writeln('   For i = ' + required_version + ' To 1 Step -1');
	document.writeln('      Set x = CreateObject("ShockwaveFlash.ShockwaveFlash." & i)');
	document.writeln('      flash_intalliert = IsObject(x)');
	document.writeln('      If flash_intalliert Then');
	document.writeln('          flash_version = CStr(i)');
	document.writeln('          Exit For');
	document.writeln('      End If');
	document.writeln('   Next');
	document.writeln('</SCR' + 'IPT>');
}function getPfad(){	var pfad = self.location.href.toString();	for (var id = 0; id < rubriken.length; id++){		if (pfad.indexOf(rubriken[id]) != -1){ return pfad.slice(0, pfad.indexOf(rubriken[id])); }	}	return pfad.slice(0, pfad.lastIndexOf("/") + 1);}
