function NewWindow(object,url) {
 object.target = '_blank';
}

function ExternalOpenInNew() {
 if ( !document.getElementsByTagName ) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
 var anchor = anchors[i];
 if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
 try {
 anchor.target = "_blank";
 if (anchor.getAttribute("title")) {
 anchor.title = anchor.title + " [neues Fenster]";
 } else {
 anchor.title = "[neues Fenster]";
 }
 }
 catch(err) {}
 }
 }
}

function resizeSWF(objName, nHeight) {
nHeight = nHeight * 0.0625;
nHeight += "em";
if (document.getElementById(objName)) {
 document.getElementById(objName).style.height = nHeight;
 }
}

var myimages=new Array();
function preloadimages() {
 for (i=0;i<preloadimages.arguments.length;i++){
 myimages[i]=new Image();
 myimages[i].src=preloadimages.arguments[i];
 }
} 

function replace(string,text,by) {
// Replaces text with by in string
 var strLength = string.length, txtLength = text.length;
 if ((strLength == 0) || (txtLength == 0)) {return string;}

 var i = string.indexOf(text);
 if ((!i) && (text != string.substring(0,txtLength))) {return string;}
 if (i == -1) {return string;}

 var newstr = string.substring(0,i) + by;

 if (i+txtLength < strLength) {
 newstr += replace(string.substring(i+txtLength,strLength),text,by);
 }

 return newstr;
}

function trim(strText) { 
 // this will get rid of leading spaces 
 while (strText.substring(0,1) == ' ') {
 strText = strText.substring(1, strText.length);
 }
 // this will get rid of trailing spaces 
 while (strText.substring(strText.length-1,strText.length) == ' ') {
 strText = strText.substring(0, strText.length-1);
 }
 return strText;
} 
function println(s) { document.write(s); } 


function download_popup(linkurl) {
js_popup=window.open('','','width=300,height=200,scrollbars=no,buttons=no,statusbar=no,location=no,resizable=no');
js_popup.document.writeln('<html><head><meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"><title>MDR.DE Download</title>');
js_popup.document.writeln('</head> <body OnBlur="self.close()" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0">');
js_popup.document.writeln('<div style="padding:10<br>px; font-family: Verdana, Arial; font-size: 12 px;">Das Herunterladen ist im ersten Versuch fehlgeschlagen.<br> Versuchen Sie bitte alternativ diese Datei mit der rechten Maustaste zu speichern:<br><br><div align="center"><a href="'+linkurl+'">Datei zum Herunteladen</a></div></div>');
js_popup.document.writeln('</body></html>');
js_popup.resizeTo(300, 200);
js_popup.focus();
}

/* Soll flackern der BG-images im IE6 vermeiden */
(function(){

 /*Use Object Detection to detect IE6*/
 var m = document.uniqueID /*IE*/
 && document.compatMode /*>=IE6*/
 && !window.XMLHttpRequest /*<=IE6*/
 && document.execCommand ;
 
 try{
 if(!!m){
 m("BackgroundImageCache", false, true) /* = IE6 only */ 
 }
 
 }catch(oh){};
})();

function floating_frame(js_url,js_width,js_height,js_pos_x,js_pos_y,js_center_p,js_scrollbar_p,js_menu_p,js_tools_p,js_status_p) {
if(js_center_p=='yes') {
js_window_width=screen.width;
js_window_height=screen.height;
js_new_pos_x=parseInt(js_window_width)-parseInt(js_width);
js_new_pos_y=parseInt(js_window_height)-parseInt(js_height);
js_new_pos_x=js_new_pos_x/2;
js_new_pos_y=js_new_pos_y/2;
popup_win=window.open(js_url,'Popup','left='+js_new_pos_x+',top='+js_new_pos_y+',width='+js_width+',height='+js_height+',locationbar=no,buttons=no,status='+js_status_p+',menubar='+js_menu_p+',scrollbars='+js_scrollbar_p+',resizable=yes');
} else {
popup_win=window.open(js_url,'Popup','left='+js_pos_x+',top='+js_pos_y+',width='+js_width+',height='+js_height+',locationbar=no,buttons=no,status='+js_status_p+',menubar='+js_menu_p+',scrollbars='+js_scrollbar_p+',resizable=yes');
}
return false;
}

// Ebenen eines Stapels ueber Liste umschalten
function initStapel() {
 var divliste = document.getElementsByTagName('div');
 var stapelzaehler = 0;
 for ( var i = 0; i < divliste.length; i++ ) {
 if (divliste[i].className == 'stapel' || divliste[i].className.indexOf("stapel ") != -1) { 
 stapelzaehler = stapelzaehler + 1;
 var stapel = divliste[i];
 var myUl = document.createElement( 'ul' );
 if (stapel.id) {
 myUl.id = 'stapelnavi' + stapel.id;
 } else {
 myUl.id = 'stapelnavi' + stapelzaehler;
 }
 var erster = true;
 var vorauswahl = '';
 var anker = '';
 myUl.className = 'stapelnavi';
 var divliste_stapel = stapel.getElementsByTagName('div'); 
 for ( var j = 0; j < divliste_stapel.length; j++ ) {
 if (divliste_stapel[j].className == "ebene" || divliste_stapel[j].className.indexOf("ebene ") != -1) {
 var ebene = divliste_stapel[j];
 var title = "*";
 if (ebene.title) {var title = ebene.title;}
 if (ebene.className.indexOf("vorauswahl") != -1) {vorauswahl = ebene.id;}
 if (window.location.hash == '#' + ebene.id) {anker = ebene.id;}
 var schalter_id = 'schalter-' + ebene.id;
 var myLi = document.createElement( 'li' );
 myLi.id = schalter_id;
 var link = '<a href="#' + ebene.id + '" onclick="return zeigeEbene(\'' + ebene.id + '\',\'' + myUl.id + '\');" onkeypress="return zeigeEbene(\'' + ebene.id + '\',\'' + myUl.id + '\');">' + title + '</a>';
 myLi.innerHTML = link;
 myUl.appendChild( myLi );
 if ( erster==true ) {
 ebene.parentNode.insertBefore( myUl, ebene );
 myLi.className = 'aktiv erster';
 ebene.className = 'ebene jsaktiv';
 } else {
 myLi.className = '';
 ebene.className = 'ebene jsaktiv inv';
 }
 if (stapel.className.indexOf("turm") != -1) {
 var myH2 = document.createElement( 'h2' );
 myH2.id = "h2-" + ebene.id;
 var link = '<a href="#h2-' + ebene.id + '" onclick="return toogleEbene(\'' + ebene.id + '\',\'' + myUl.id + '\');" onkeypress="return toogleEbene(\'' + ebene.id + '\',\'' + myUl.id + '\');">' + title + '</a>';
 myH2.innerHTML = link;
 ebene.parentNode.insertBefore( myH2, ebene );
 if ( erster==true ) {
 myUl.className = 'stapelnavi inv';
 myH2.className = 'aktiv erster';
 }
 }
 erster = false;
 }
 }
 if (anker != "") {
 zeigeEbene(anker,myUl.id);
 window.setTimeout("window.scrollTo(1, 1)",100);
 
 } else if (vorauswahl != "") {
 zeigeEbene(vorauswahl,myUl.id);
 } 
 
 }
 }
}

function zeigeEbene(divId,ulId) {
 var myUl = document.getElementById(ulId);
 var liListe = myUl.getElementsByTagName('li');
 for ( var i=0; i<liListe.length; i++ ) {
 var actLi = liListe[i];
 var actDivId = actLi.id.substr(9);
 var actDiv = document.getElementById(actDivId);
 var actH2Id = "h2-" + actLi.id.substr(9);
 if (document.getElementById(actH2Id)) {var actH2 = document.getElementById(actH2Id);}
 var erster = '';
 if (i == 0) {var erster = ' erster';}
 if ( actDivId == divId ) {
 actLi.className = 'aktiv' + erster;
 actDiv.className = 'ebene jsaktiv';
 if (actH2) {actH2.className = 'aktiv' + erster;}
 } else {
 actLi.className = '' + erster.replace(/ /,'');
 actDiv.className = 'ebene jsaktiv inv';
 if (actH2) {actH2.className = '' + erster.replace(/ /,'');}
 }
 }
 return false;
}

function toogleEbene(divId,ulId) {
 var actDiv = document.getElementById(divId);
 var actLi = document.getElementById('schalter-' + divId);
 var actH2 = document.getElementById('h2-' + divId);
 var erster = "";
 if (actLi.className.indexOf(" erster") != -1) {var erster = " erster";}
 if (actDiv.className.indexOf(" inv") != -1) {
 actLi.className = 'aktiv' + erster;
 actDiv.className = 'ebene jsaktiv'; 
 actH2.className = 'aktiv' + erster; 
 } else {
 actLi.className = '' + erster.replace(' ','');
 actDiv.className = 'ebene jsaktiv inv';
 actH2.className = '' + erster.replace(' ','');
 }
 return false;
}


// Create event 'ondomload' which runs once when the dom of the document
// has loaded. This is before images and other long downloads start.
// If the browser does not support this, falls back to window.onload.
// (Firefox and Opera)
if (document.addEventListener) {
 document.addEventListener("DOMContentLoaded", onDOMContentLoaded, false);
}

// (Safari)
if (/WebKit/i.test(navigator.userAgent)) { // sniff
 var _timer = setInterval(function() {
 if (/loaded|complete/.test(document.readyState)) {
 clearInterval(_timer);
 onDOMContentLoaded(); // call the onload handler
 }
 }, 10);
}
// (Internet Explorer(using conditional comments))
/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
 if (this.readyState == "complete") {
 onDOMContentLoaded(); // call the onload handler
 }
};
/*@end @*/
window.onload = onDOMContentLoaded;
function onDOMContentLoaded(){
 // quit if this function has already been called
 if (arguments.callee.done) return;
 // flag this function so we don't do the same thing twice
 arguments.callee.done = true;
 ondomload();
}
