// Rollover beim Link-Pfeil
function changeArrow(element, mode) {
	var img = document.getElementById(element);
	if(mode) {
		img.src = "/standards/bilder/arrow_red.gif";
	} else {
		img.src = "/standards/bilder/arrow_blue.gif";
	}
}


// Saal-PopUp
function popUpSaal(file) {
	var popup = window.open(file,'PopUpSaal', 'toolbar=0,location=0, directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=600,height=450');
	popup.focus();
}

// Sitzplan-PopUp
function popUpSitzplan(file, height) {
	var popup = window.open(file,'PopUpSitzplan', 'toolbar=0,location=0, directories=0,status=0,menubar=1,scrollbars=0,resizable=0,width=675,height=' + (height + 150));
	popup.focus();
}


// Optische Anpassungen an diverse Browser
function optimizeBrowser() {
	
	// Ermitteln der Browser
	var browser = navigator.appName;
	var os = "Linux";
	if(navigator.appVersion.indexOf("Windows") != -1) {
		os = "Windows";	
	}
	if(navigator.appVersion.indexOf("Macintosh") != -1) {
		os = "Macintosh";	
	}
	
	// Modifikationen an den Styles je nach OS und Browser
	if(browser == "Microsoft Internet Explorer") {
		if(document.getElementById("bereichMetaHP")) {
			el = document.getElementById("bereichMetaHP").style;
			el.width = 301 + "px";
		}
		if(document.getElementById("bereichMetaUebersicht")) {
			el = document.getElementById("bereichMetaUebersicht").style;
			el.width = 301 + "px";
		}
		if(document.getElementById("bereichMetaInhalt")) {
			el = document.getElementById("bereichMetaInhalt").style;
			el.width = 301 + "px";
		}	
		if(document.getElementById("bereichAnfrage")) {
			el = document.getElementById("bereichAnfrage").style;
			el.width = 301 + "px";			
		}			
		if(document.getElementById("bereichThemen")) {
			el = document.getElementById("bereichThemen").style;
			el.width = 301 + "px";	
		}		
		if(document.getElementById("bereichPopupSaal")) {
			el = document.getElementById("bereichPopupSaal").style;
			el.width = 147 + "px";
		}
		if(document.getElementById("bereichServiceangebot")) {
			el = document.getElementById("bereichServiceangebot").style;
			el.width = 226 + "px";
		}
		if(document.getElementById("bereichDownloads")) {
			el = document.getElementById("bereichDownloads").style;
			el.width = 200 + "px";
		}
		if(document.getElementById("bereichStandardLinks")) {
			el = document.getElementById("bereichStandardLinks").style;
			el.width = 200 + "px";
		}	
		if(document.getElementById("redQuad")) {
			el = document.getElementById("redQuad").style;
			el.height = 76 + "px";
		}		
		if(document.getElementById("blueQuadMiddle")) {
			el = document.getElementById("blueQuadMiddle").style;
			el.top = 76 + "px";
		}
		if(document.getElementById("blueLine")) {
			el = document.getElementById("blueLine").style;
			el.top = 226 + "px";
		}
		if(document.getElementById("download")) {
			el = document.getElementById("download").style;
			el.width = 244 + "px";
		}
	}
	if(browser == "Netscape") {
		
	}
	if(os == "Macintosh") {		
		// Schriftgröße der oberen Navigationsleiste für Mac anpassen
		var items = document.getElementsByName("topNavItem");		
		for(i=0; i <= items.length; i++) {
			if(items[i]) {
				el = items[i].style;
				el.fontSize = "10px";
				el.marginTop = "7px";
			}
		}
		// 
		if(browser == "Microsoft Internet Explorer") {			
			
		}
	}
	if(os == "Linux") {
		
	}
}

// Flash-Detection
function einfuegeFlash(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 id="flashcontainer"><object ');
			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('  <embed 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"></embed></object></td></tr></table>');
		} else if (altBildUri) {
			var alt = altBildAltText;
			if (!altBildAltText)
				alt = "";
			d.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td><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.1');
    }
    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;
}

// Versendet das übergebene Formular
function sendForm(myForm) {
	var form = eval("document." + myForm);
	form.submit();
}


// Kalender für Veranstaltung besuchen Seite
function setzeDatum(heuteTag, heuteMonat, heuteJahr, tag_select, monat_select, jahr_select){
	var monate		= new Array("Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember");
	
	var el_tag 		= document.getElementById(tag_select);
	var el_monat	= document.getElementById(monat_select);
	var el_jahr		= document.getElementById(jahr_select);
			
	var childNode = el_tag.childNodes[0];
	while(childNode != null) {
		el_tag.removeChild(childNode);
		childNode = el_tag.childNodes[0];
	}
	
	var childNode = el_monat.childNodes[0];
	while(childNode != null) {
		el_monat.removeChild(childNode);
		childNode = el_monat.childNodes[0];
	}
	
	var childNode = el_jahr.childNodes[0];
	while(childNode != null) {
		el_jahr.removeChild(childNode);
		childNode = el_jahr.childNodes[0];
	}
	
	// Monatstag setzen
	for(var i = 1; i <= 31; i++) {
		datum = new Date(heuteJahr,heuteMonat,i);
		if (datum.getMonth() != heuteMonat){
			break;
		}
		var textNode	= document.createTextNode(""+i);
		var newOption	= document.createElement("option");
		newOption.setAttribute("value",i);
		if(i == heuteTag) {
			newOption.setAttribute("selected","selected");
		}
		newOption.appendChild(textNode);					
		el_tag.appendChild(newOption);
	}
	//Monat sezten
	for(var i = 0; i < 12; i++) {
		var textNode	= document.createTextNode(monate[i]);
		var newOption	= document.createElement("option");
		newOption.setAttribute("value",i);
		if(i == heuteMonat) {
			newOption.setAttribute("selected","selected");
		}
		newOption.appendChild(textNode);
		el_monat.appendChild(newOption);
	}
	// Jahr setzen
	for(var i = 2009; i <= 2015; i++) {
		var textNode	= document.createTextNode(i);
		var newOption	= document.createElement("option");
		newOption.setAttribute("value",i);
		if(i == heuteJahr) {
			newOption.setAttribute("selected","selected");
		}
		newOption.appendChild(textNode);
		el_jahr.appendChild(newOption);
	}	
}

function korrektesDatum(tag_select, monat_select, jahr_select) {
	
	var von_tag		= document.getElementById(tag_select).value;
	var von_monat	= document.getElementById(monat_select).value;
	var von_jahr	= document.getElementById(jahr_select).value;
	
	var el = document.getElementById(tag_select);
	
	var childNode = el.childNodes[0];
	while(childNode != null) {
		el.removeChild(childNode);
		childNode = el.childNodes[0];
	}
	
	for(var i = 1; i<=31; i++) {
		datum = new Date(von_jahr,von_monat,i);
		if (datum.getMonth() != von_monat){
			break;
		}
		
		var textNode	= document.createTextNode(""+i);
		var newOption	= document.createElement("option");
		newOption.setAttribute("value",i);
		if(von_tag == i) {
			newOption.setAttribute("selected","selected");
		}
		newOption.appendChild(textNode);		
		
		el = document.getElementById(tag_select);			
		el.appendChild(newOption);
	}
}