// neues fenster fuer links und zoombild
function newWindow(url, name, width, height, toolbar, status, scrollbar, resizable, menubar, location) {
  if (width < 240 ) {
    width = 240 + 58;
    }
  else {
    width = width + 58;
    }
  if (width > 768 ) {
    width = 768;
    scrollbar="1";
    }
  if (height == 400 ) {
    height = height + 30;
	  }
  else {
    height = height + 199;
    if (height > 550 ) {
      height = 550;
      scrollbar="1";
      }
    }
  var win = window.open(url,name,"width=" + width + ",height=" + height + ", toolbar=" + toolbar + ",status=" + status + ",scrollbars=" + scrollbar + ",resizable=" + resizable + ",menubar=" + menubar + ",location=" + location);
  win.focus();
  return false;
  }

// Ein neues Fenster per JS fuer den Stoerertyp Bild erzeugen
function stoererZoomBild(url, name, width, height) {
  height = height + 140;
  width = width + 58;
  // Sitestat
  var countNS = new Image();
  countNS.src = "http://de.sitestat.com/sueddeutsche/sueddeutsche/s?onclick_artikel.stoerer.bild.zoombild";
  // Open Window
  var win = window.open(url,name,"width=" + width + ",height=" + height + ", toolbar=no,status=no,scrollbars=yes,resizable=yes,menubar=no,location=no");
  win.focus();
  return false;
}

//Ausgelagerte Hilfefunktion für Suchfelder
function setEmpty(content, field) {
  if (document.getElementById(field).value == content) {
    document.getElementById(field).value = "";
    }
  }

function setFully(content, field) {
  if (document.getElementById(field).value == "") {
    document.getElementById(field).value = content;
    }
  }

function setValue(content, field) {
  if (document.getElementById(field).value == "") {
    document.getElementById(field).value = content;
    }
  }

function openHilfe(url) {
  loadUrl(2,url,520,220,200,50);
  }

function loadUrl (type, url, width, height, x, y) {
  // 0: load into current window
  if (type=="0") {
    window.location.href = url;
    }
  if (type=="1") {
    var prefs = "";
    if (arguments.length > 3) prefs += "width="+width+",height="+height;
    prefs += ",scrollbars=yes";
    w = window.top.open(url, "popwin", prefs);
    w.focus();
    }
  if (type=="2") {
    var prefs = "";
    if (arguments.length > 3) prefs += "width="+width+",height="+height+",screenX="+x+",screenY="+y;
    prefs += ",scrollbars=yes";
    w = window.top.open(url, "popwin", prefs);
    w.moveTo(x,y);
    w.focus();
    }
  if (type=="4") {
    window.opener.location.href = url;
    }
  }

// angepasste funktion fuer ivw-zählung
function new_callIVW (code, doctype)  {
  // Funktion liefert nur noch einen Standardpixel zurück
  // Wenn Code gesetzt, dann wird die Angebotskennung von "A" auf "a" gesetzt
  var printcode;
  if (code.length == 12) {
    if (code == '140AD0J1012o') {
      printcode = 'N140aD1B0000';
      }
    else {
      printcode = code.slice(0,4)+'a'+code.slice(5,12);
      }
    }
  else {
    printcode = 'N399aN1B0000';    
    }
  // IVW
  var get_rand = "d=" + (Math.random()*100000);
  var get_referer = "r=" + escape(document.referrer);
  var countIVW = new Image();
  countIVW.src = "http://sueddeut.ivwbox.de/cgi-bin/ivw/CP/" + printcode + "?" + get_referer + "&" + get_rand;
  // Sitestat
  var countNS = new Image();
  countNS.src = "http://de.sitestat.com/sueddeutsche/sueddeutsche/s?nachrichten_werbung.index&category=news_werbung&" + get_rand;
  }

// funktion fuer sitestat - linktracking
// Sitestat OnClick v1.0 Copyright (c) 2001-2007 Nedstat B.V. All rights reserved
function ns_onclick (a, url, name, type, winopt) {
  var ns_l = "http://de.sitestat.com/sueddeutsche/sueddeutsche/s?";
  ns_l += name;
  ns_l += '&ns_type='+type+'&ns_action=view';
  ns_l += '&ns__t='+(new Date()).getTime();
  if (!url) {
    url = a.href;
    }
  var ns_0 = document.referrer;
  if (ns_0.lastIndexOf('/') == ns_0.length - 1) {
    ns_0 = ns_0.substring(ns_0.lastIndexOf('/'), 0);
    }
  if (ns_0.length > 0) {
    ns_l += '&amp;ns_referrer=' + escape(ns_0);
    }
  winopt = winopt||"";
  var target = (a&&a.target&&a.target!="") ? (a.target.substring(0,1)=="_") ? a.target.substring(1) : a.target :"self";
  var ns_i = new Image();
  if (target&&url) {
    if (window[target]) {
      window.ns_softclick_timer = function(target,url) {
        return function() {
          ns_i.onload = ns_i.onerror = function() {
            return;
            };
          window[((window[target]) ? target : "self")].location.href = url;
          }
        }(target,url);
      window.setTimeout('ns_softclick_timer()',5000);
      ns_i.onload = ns_i.onerror = window.ns_softclick_timer;
      }  
    else{
      window.open(url,target,winopt);
      }
    }
  ns_i.src = ns_l;
  return false;
  } 

// funktionen fuer videointegration
function SZFlashDetectInit(){
	if(!document.getElementById('swfversionscript')){
		var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
		var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
		var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
		if(isIE && isWin && !isOpera){
			document.write('<scr'+'ipt id="swfversionscript" type="text/vbscript">\n');
			document.write('Function SZwhichflash(i)\n');
			document.write('on error resume next\n');
			document.write('Dim swControl, swVersion\n');
			document.write('swVersion = 0\n');
			document.write('set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))\n');
			document.write('if (IsObject(swControl)) then\n');
			document.write('swVersion = swControl.GetVariable("$version")\n');
			document.write('end if\n');
			document.write('SZwhichflash = swVersion\n');
			document.write('End Function\n');
			document.write('<\/scr'+'ipt>\n');
			document.write('\n');
		} else {
			document.write('<scr'+'ipt id="swfversionscript" type="text/javascript">\n');
			document.write('function SZwhichflash(i)\n');
			document.write('{\n');
			document.write('if (navigator.plugins != null && navigator.plugins.length > 0) {\n');
			document.write('if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {\n');
			document.write('var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";\n');
			document.write('var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;\n');
			document.write('descArray = flashDescription.split(" ");\n');
			document.write('tempArrayMajor = descArray[2].split(".");\n');
			document.write('versionMajor = tempArrayMajor[0];\n');
			document.write('versionMinor = tempArrayMajor[1];\n');
			document.write('if ( descArray[3] != "" ) {tempArrayMinor = descArray[3].split("r");} else {tempArrayMinor = descArray[4].split("r");}\n');
			document.write('versionRevision=tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;\n');
			document.write('// variable flashVer zusammensetzen -> analog zu ie\n');
			document.write('flashVer="x " + versionMajor + "," + versionMinor + "," + versionRevision;\n');
			document.write('}else{flashVer=-1;}\n');
			document.write('}\n');
			document.write('// MSN/WebTV 2.6 supports Flash 4\n');
			document.write('else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;\n');
			document.write('// WebTV 2.5 supports Flash 3\n');
			document.write('else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;\n');
			document.write('// older WebTV supports Flash 2\n');
			document.write('else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;\n');
			document.write('// Can\'t detect in all other cases\n');
			document.write('else {flashVer = -1;}\n');
			document.write('return flashVer;\n');
			document.write('}\n');
			document.write('<\/scr'+'ipt>\n');
			document.write('\n');
		}
	}
}

function SZFlashDetect(reqMajorVer, reqMinorVer, reqRevision) {
	var reqVer = parseFloat(reqMajorVer + "." + reqRevision);
	// loop backwards through the versions until we find the newest version
	for (var i=25;i>0;i--) {
		versionStr = SZwhichflash(i);
		if (versionStr == -1 ) {
			return false;
		} else if (versionStr != 0) {
			var versionArray = new Array();
			var tempArray   = versionStr.split(" ");
			var tempString  = tempArray[1];
			versionArray    = tempString .split(",");
			var versionMajor    = versionArray[0];
			var versionMinor    = versionArray[1];
			var versionRevision = versionArray[2];
			var versionString   = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
			var versionNum      = parseFloat(versionString);
			// is the major.revision >= requested major.revision AND the minor version >= requested minor
			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
				return true;
			} else {
				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
			}
		}
	}
}

/*
function SZLoadFlash(videoid, flashvars){
	if(document.getElementById){
		if ( SZFlashDetect(9,0,114) ) {
			document.getElementById('flashvideoswf'+videoid).innerHTML = '<div><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="180" height="161" id="sz-video" align="middle">\n<param name="allowScriptAccess" value="sameDomain" />\n<param name="FlashVars" value="' + flashvars + '" />\n<param name="movie" value="/app/video/sz-video.swf" />\n<param name="quality" value="high" />\n<param name="bgcolor" value="#ffffff" />\n<param name="allowFullScreen" value="true" />\n<embed src="/app/video/sz-video.swf" quality="high" bgcolor="#ffffff" width="180" height="169" name="sz-video" align="middle" FlashVars="' + flashvars + '" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n</embed>\n</object>\n</div>';
		} else {
			document.getElementById('flashvideoswf'+videoid).innerHTML = '<div style="width:100%;height:161px;background-color:#f0f0f0;font-size:9px;font-family:verdana;">\nDer benÃ¶tigte Flash Player 9 wurde nicht gefunden.<br />\nMÃ¶gliche Ursachen:<br /><br />\nJavaScript erkennt den Player nicht korrekt.<br />\n<br /><br />\nDer Player ist nicht vorhanden.<br />\n<a href="http://www.macromedia.com/go/getflash/" target="_blank">Jetzt installieren<\/a>\n<\/div>';
			document.getElementById('flashvideoswf'+videoid).style.zIndex=3;
		}
	}
}
*/

function winOpen(url){
	breite = 470;
	hoehe = 470;
	links=(screen.width/2)-(breite/2);
	oben=(screen.height/2)-(hoehe/2);
	window.open(url,"SZ","height="+hoehe+",width="+breite+",status=no,toolbar=no,menubar=no,locateion=no,resizable=yes,titlebar=yes,scrollbars=yes,fullscreen=no,top="+oben+",left="+links);
}

function SZLoadFlash_New(videoid, flashvars, width, height, format) {

  if (document.getElementById) {
    if ( SZFlashDetect(9,0,114) ) {

	  if (width == 180) {
	    format = "sde_videoplayer_180";
		height = 153;
	  } else if (width == 456)  {
	    format = "sde_videoplayer_456";
		height = 369;
	  }
      document.getElementById('flashvideoswf'+videoid).style.zIndex = "3";
      document.getElementById('flashvideoswf'+videoid).innerHTML = '<div><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + width + '" height="' + height + '" id="sz-video" align="middle">\n<param name="allowScriptAccess" value="always" />\n<param name="FlashVars" value="' + flashvars + '" />\n<param name="movie" value="/app/video/' + format + '.swf" />\n<param name="quality" value="high" />\n<param name="bgcolor" value="#ffffff" />\n<param name="allowFullScreen" value="true" />\n<embed src="/app/video/' + format + '.swf" quality="high" bgcolor="#ffffff" width="' + width + '" height="' + height + '" name="sz-video" align="middle" FlashVars="' + flashvars + '" allowScriptAccess="always" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n</embed>\n</object>\n</div>';
	  
    } else {
      document.getElementById('flashvideoswf'+videoid).innerHTML = '<div style="width:100%;height:169px;background-color:#f0f0f0;font-size:9px;font-family:verdana;">\nDer benÃ¶tigte Flash Player 9 wurde nicht gefunden.<br />\nMÃ¶gliche Ursachen:<br /><br />\nJavaScript erkennt den Player nicht korrekt.<br />\n<br /><br />\nDer Player ist nicht vorhanden.<br />\n<a href="http://www.macromedia.com/go/getflash/" target="_blank">Jetzt installieren<\/a>\n<\/div>';
      document.getElementById('flashvideoswf'+videoid).style.zIndex=3;
	  
    }
  }
}

function winOpen_New(url, breite, hoehe) {
  if (isNaN(breite)) {breite = 775;}
  if (isNaN(hoehe))  {hoehe  = 635;}
  links=(screen.width/2)-(breite/2);
  oben=(screen.height/2)-(hoehe/2);
  window.open(url,"SZ","height="+hoehe+",width="+breite+",status=no,toolbar=no,menubar=no,locateion=no,resizable=yes,titlebar=yes,scrollbars=yes,fullscreen=no,top="+oben+",left="+links);
  }

// ##### Funktionen fuer LBox-Schnipsel #####
// Funktion: Abfrage ob Suche nach Archiv oder Web (im Header)
function getGoogleSearch() {
  if (document.getElementById) {
    var modi = 'archiv';
    for (var i = 0; i <= document.googleSearch.radiosearch.length; i++) {
      if (document.googleSearch.radiosearch[i].checked == true) {
        modi = document.googleSearch.radiosearch[i].value;
        break;
        }
      }
    if (modi == 'web') {
      window.open('http://www.sueddeutsche.de/app/google/suche/index.html?q=' + escape(document.googleSearch.inputsearch.value) + '&sa=Google-Suche&client=pub-8726208069393245&forid=1&channel=8700697642&ie=ISO-8859-1&oe=ISO-8859-1&cof=GALT%3A%23003399%3BGL%3A1%3BDIV%3A%239E9898%3BVLC%3A003399%3BAH%3Acenter%3BBGC%3AFFFFFF%3BLBGC%3A336699%3BALC%3A000000%3BLC%3A000000%3BT%3A000000%3BGFNT%3A003399%3BGIMP%3A003399%3BFORID%3A11&hl=de&back=startsite','google');
      //window.open('http://www.google.de/search?q=' + escape(document.googleSearch.inputsearch.value) + '&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:de:official&client=firefox-a','google');
      //location.href = 'http://www.google.de/search?q=' + escape(document.googleSearch.inputsearch.value) + '&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:de:official&client=firefox-a';
      return false;
      }
    }
  return true;
  }

// Funktion: Hintergrundbild von Google bei Websuche anzeigen
function googleImage(show) {
  if (show == '1') {
    document.getElementById("inputsearch").style.backgroundImage = 'url(/app/google/img/google_wasserzeichen.gif)';
    }
  else {
    document.getElementById("inputsearch").style.backgroundImage = 'url(g_.gif)';
    }
  }

// Funktion: Nicht eingeloggter Zustand ausblenden (im Header)
// NEU NEU NEU
function changeLBox() {
  var ElemIdDiv = document.getElementById('headerLBox');
  for (var i=0; i < (ElemIdDiv.childNodes.length); i++) {
    //var ElemIdHide = document.getElementById(ElemIdDiv.childNodes[i].id);
    var ElemIdHide = document.getElementById('logout');
    ElemIdHide.style.visibility = "hidden";
    ElemIdHide.style.position = "absolute";
    ElemIdHide.style.left = -800;
    ElemIdHide.style.top = -800;
    }
  var ElemIdShow = document.getElementById('logfield');
  var PareNdShow = document.getElementById('logfield').parentNode;
  ElemIdShow.parentNode.removeChild(ElemIdShow);
  ElemIdShow.style.visibility = "visible";
  ElemIdShow.style.position = "relative";
  ElemIdShow.style.left = 0;
  ElemIdShow.style.top = 0;
  PareNdShow.appendChild(ElemIdShow);
  }

// Funktion: Nicht eingeloggter Zustand ausblenden
// ALT ALT ALT
function changeLog() {
  var ElemIdDiv = document.getElementById('myLogin');
  for (var i=0; i < (ElemIdDiv.childNodes.length); i++) {
    var ElemIdHide = document.getElementById(ElemIdDiv.childNodes[i].id);
    ElemIdHide.style.visibility = "hidden";
    ElemIdHide.style.position = "absolute";
    ElemIdHide.style.left = -800;
    ElemIdHide.style.top = -800;
    }
  var ElemIdShow = document.getElementById('headerLogin');
  var PareNdShow = document.getElementById('headerLogin').parentNode;
  ElemIdShow.parentNode.removeChild(ElemIdShow);
  ElemIdShow.style.visibility = "visible";
  ElemIdShow.style.position = "relative";
  ElemIdShow.style.left = 0;
  ElemIdShow.style.top = 0;
  PareNdShow.appendChild(ElemIdShow);
  }

// Funktion: Benamung des Passwortfeldes mit Klartext und erst bei Eingabe verschlÃ¼sselte Ansicht
function LoginBoxPassFocus() {
  document.lbox.passtxt.style.display = "none";
  document.lbox.login_passwort.style.display = "inline";
  document.lbox.login_passwort.focus();
  }

function LoginBoxExit() {
  if(document.getElementById("login_passwort").value == '') {
    document.getElementById("login_passwort").style.display = "none";
    document.getElementById("passtxt").style.display = "inline";
    }
  }

// Funktion: Je nach Browsertyp wird eine andere Möglichkeit der "Startseite einrichten" angezeigt
function startseiteLink() {
  var echoStartseite = '';
  // wenn Internet Explorer (also auch kein verkappter Opera)
  if ((navigator.userAgent.indexOf("Opera") == -1) && (navigator.appName.indexOf("Explorer") != -1)) {
    echoStartseite = '<a href="' + document.URL + '" onClick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\'http://www.sueddeutsche.de\');">';
    }
  // wenn Firefox
  else if (navigator.userAgent.indexOf("Firefox") != -1) {
    echoStartseite = '<a href="' + document.URL + '" onClick="javascript:window.open(\'http://www.sueddeutsche.de/app/homepage/startseite/\',\'Startseite\',\'width=600,height=800,resizable\').focus();">';
    }
  // alle anderen Browser
  else {
    echoStartseite = '<a href="http://www.sueddeutsche.de/service/app/923/18905/">';
    }
  document.write(echoStartseite);
  }

// ##### Funktionen fuer rechte Leiste #####
// Wechsel BG Box Meinung + Tausch Font + FontWeight
// layernameshow,bgimage,colorhi,fontWeighthi,colorlow,fontWeightlow
function changeBgBox(layernamehide,layernameshow,bgimage,colorhi,weighthi,colorlow,weightlow) {
  hideLayer (layernamehide);
  showLayer (layernameshow);
  var nmyobj0 = document.getElementById("nmeinungbg");
  var nmyobj1 = document.getElementById("nmeinungheader");
  var nmyobj2 = document.getElementById("nkolumneheader");
  nmyobj1.style.color = colorhi;
  nmyobj1.style.fontWeight = weighthi;
  nmyobj2.style.color = colorlow;
  nmyobj2.style.fontWeight = weightlow;
  nmyobj0.style.backgroundImage = "url('"+bgimage+"')";
  }

// Themen der Woche
function _debug(msg) {
    document.getElementById("debug").value += msg + "\n";
}

/**
 * Array der Bilder (Thumbnails) fuer die Themen der Woche. Kann z. B. dynamisch generiert werden
 * Format:
 * ------
 * szTOWTeaserImages[<element_id>]["over"] = "Bildname fuer aktivstatus";
 * szTOWTeaserImages[<element_id>]["out"]  = "Bildname fuer normalen status";
 */
var szTOWTeaserImages = {
    "themaderwoche_bildklein:1": {"over": "/g_abdunkeln.png", "out": "/g_.gif"},
    "themaderwoche_bildklein:2": {"over": "/g_abdunkeln.png", "out": "/g_.gif"},
    "themaderwoche_bildklein:3": {"over": "/g_abdunkeln.png", "out": "/g_.gif"},
    "themaderwoche_bildklein:4": {"over": "/g_abdunkeln.png", "out": "/g_.gif"},
    "themaderwoche_bildklein:5": {"over": "/g_abdunkeln.png", "out": "/g_.gif"}
};
/* Array fuer das 2. Modul Themen der Woche */
var szTOWTeaserImages2 = {
    "themaderwoche_bildklein2:1": {"over": "/g_abdunkeln.png", "out": "/g_.gif"},
    "themaderwoche_bildklein2:2": {"over": "/g_abdunkeln.png", "out": "/g_.gif"},
    "themaderwoche_bildklein2:3": {"over": "/g_abdunkeln.png", "out": "/g_.gif"},
    "themaderwoche_bildklein2:4": {"over": "/g_abdunkeln.png", "out": "/g_.gif"},
    "themaderwoche_bildklein2:5": {"over": "/g_abdunkeln.png", "out": "/g_.gif"}
};


function TOW(id) {
	this.id = id;
    this.oTopic=       null;
    this.numImages=    null;
    this.actImageId=   "";
    this.pos=          1;               // Position des Startthemas
    this.imgDir=       "http://pix.sueddeutsche.de/img";  // Pfad zum Bilderordner, das die Bilder der Themen enthaelt
    this.delay=        8000;            // Verzoegerung in Milisekunden fuer den Wechsel des Themas
    this.timeoutId=    null;
    this.initialized=  false;

    this.setImgOverState = function (img) {
        img.src = this.imgDir + this.szTOWTeaserImages[img.id].over;
    };

    this.setImgOutState = function (img) {
        if (img.id == this.actImageId) { return; }
        //alert(img.id + "=>" + szTOWTeaserImages);
        img.src = this.imgDir + this.szTOWTeaserImages[img.id].out;
    };

    this.showNext = function () {
        if (++this.pos > this.numImages) {
            this.pos = 1;
        }

        this._showTopic();
    };

    this.show = function (pos) {
        if (pos < 1) {
            this.pos = 1;
        } else if (pos > this.numImages) {
            this.pos = this.numImages;
        } else {
            this.pos = pos;
        }
        this.clearTimer();
        this._showTopic();
    };

    this.setTimer = function () {
        this.timeoutId = window.setTimeout("szTOWTeaser"+this.id+".showNext()", this.delay);
    };

    this.clearTimer = function () {
        if (this.timeoutId !== null) {
            window.clearTimeout(this.timeoutId);
            this.timeoutId = null;
        }
    };

    this._showTopic = function() {
        if (!this.initialized) { return; }

        var newTopic = document.getElementById("themaderwoche_sammlung"+this.id+"_"+this.pos);
        if (!newTopic) {
            return;
        }

        // handle image over out states
        if (this.actImageId != "") {
            // reset previous over state
            var img = document.getElementById(this.actImageId);
            this.actImageId = "";
            this.setImgOutState(img);
        }

        this.actImageId = "themaderwoche_bildklein"+this.id+":"+this.pos;
        // set image over state of actual topic
        this.setImgOverState(document.getElementById(this.actImageId));

        // set new topic
        this.oTopic.innerHTML = newTopic.innerHTML;

        this.setTimer();
    };
    this.init = function(mySzTOWTeaserImages) {
    	this.szTOWTeaserImages = mySzTOWTeaserImages;
        if (!document.getElementById) {
            return;
        }
		// sitestat links in den onclick Handler eintragen:
		// dazu iterieren wir ueber alle Links in den Themen der Woche
		var my_id = this.id;
		if (my_id == '') my_id = '1';
		for (var i = 0; i<6; i++) {
			var sitestat_links = document.getElementsByName("themaderwoche_"+my_id+"_link_"+i);
			if (! sitestat_links) continue;

			// Links gefunden? dann alle onclick Hanlder anpassen
			for (var k=0; k<sitestat_links.length; k++) {
				var my_link = sitestat_links[k];

				//if (i<1 && k<1 && !this.id) alert('Test:' + k+" ->"+my_link.onclick);
				
				// bisherigen Event Hanlder fuer den HPM generieren und 
				// jetzt zus. den sitestat Aufruf anhaengen:
          my_link.onclick = function () {
					// wir muessen uns noch die Projektor ID und die Position holen:
					var buffer = this.name.split('_');
					// alle notwendigen IDs sind gefunden => tracking einschalten
					if (buffer[1] && buffer[3]) {
						// Das hpm Prefix richtig setzen, leider ist tdw[1|2] beim hpm nicht moeglich :-(
						var my_container_id = 'tdwa';
						if ( buffer[1] == 2 ) my_container_id = 'tdwb';
						// Prefix fuer den Sitestat Aufruf umbiegen, onclick_projektor1 gibt es nicht, das ist "onclick_projektor":
						if ( buffer[1] == 1 ) buffer[1] = '';
      			  trackClick(this.id,',' + my_container_id + buffer[3] + 'm1',true);
              if (my_id == 1) {
                ns_onclick(this, '', 'onclick_homepage.modul.projektor.themaderwoche', 'clickin');
              } else {
                ns_onclick(this, '', 'onclick_homepage.modul.projektor.multimedia', 'clickin');
              }
						//alert(this.name);
					}
					return false;
					
				};
				//if (i<1 && k<1 && !this.id) alert("---->"+my_link.onclick);
			}
			
		}
		
        var images = document.getElementsByName("themaderwoche_bildklein"+this.id);
        if (!images) {
            return;
        }

        var img;
        for (var i=0; i<images.length; i++) {
            img = images[i];

			// id des Themen der Woche Moduls merken:
			img.t_id = this.id;
			
            img.onmouseover = function () {
                //szTOWTeaser.setImgOverState(this);
                var arr = this.id.split(":");
                eval("szTOWTeaser"+this.t_id+".show(arr[1]);");
                //new_callIVW ('N137aN0S2009');
            }
            img.onmouseout = function () {
                eval("szTOWTeaser"+this.t_id+".setImgOutState(this);");
            }
            img.onclick = function () {
                var arr = this.id.split(":");
                eval("szTOWTeaser"+this.t_id+".show(arr[1]);");
            }
        }

        this.oTopic = document.getElementById("themaderwoche_container"+this.id);
        this.numImages = 0;
        for (img in this.szTOWTeaserImages) {
            this.numImages++;
        }
        this.initialized = true;
        this._showTopic();
    };

}

var szTOWTeaser = new TOW('');
var szTOWTeaser2 = new TOW('2');

window.onload = function () {
    /**
     * Aufruf der Funktion szTOWTeaser.init() bei onload
     */
    szTOWTeaser.init(szTOWTeaserImages);
  	szTOWTeaser2.init(szTOWTeaserImages2);
}

// END Themen der Woche

// Teaser Meinung/Kolumne

/**
 * Tabbed teaser header. Used to switch tabbed elements inside a teaser. Changes header
 * class name, switches content by hiding previous and displaying new element content.
 * Usage:
 * -----
 * <code>
 * <script>
 * oTTH = new szTabbedTeaserHeader("teaserid", "activeelementid");
 * </script>
 * <div id="headerA"><a href="#" onmouseover="oTTH.show('headerA');">Activate me</a></div>
 * <div id="headerB"><a href="#" onmouseover="oTTH.show('headerB');">or me</a></div>
 * </code>
 */

/**
 * Constructor. Initialize a new tabbed teaser.
 * @param  string  teaserId  Id of element which holds te tabbed teaser header
 * @param  string  activeElement  Id of element witch is the initial one
 */
function szTabbedTeaserHeader(teaserId, activeElement) {
    this.teaserId = teaserId;
    this.activeElement = activeElement;
}

/**
 * Switch to tab based on passed key.
 *
 * @param  string  key  Key of element to activate
 */
szTabbedTeaserHeader.prototype.show = function(key){
    if ( key === 'nmeinung' || key === 'nkolumne' || key === 'nforum' ) { return; }
    if (key == this.activeElement) {
        // passed key is allready active, get out here
        return;
    }

    if (this.activeElement !== "") {
        // hide previous displayed element
        document.getElementById(this.activeElement).style.display = "none";
    }

    // set active key, display new element and change classname
    // formatting definitions are set by different class selectors
    this.activeElement = key;
    document.getElementById(this.activeElement).style.display = "block";
    document.getElementById(this.teaserId).className = key + "_headerbox";
}

// END Teaser Meinung/Kolumne
// Listenmodul mit Reiter

/**
 * Tabbed teaser header. Used to switch tabbed elements inside a teaser. Changes header
 * class name, switches content by hiding previous and displaying new element content.
 *
 * Usage:
 * -----
 * <code>
 * <script>
 * oTTH = new szTabbedSliders("listId", "activeelementid");
 * </script>
 * <div id="headerA"><a href="#" onmouseover="oTTH.show('headerA');">Activate me</a></div>
 * <div id="headerB"><a href="#" onmouseover="oTTH.show('headerB');">or me</a></div>
 * </code>
 */

/**
 * Constructor. Initialize a new tabbed teaser.
 *
 * @param  string  listId  Id of list which holds the tabbed teaser
 * @param  string  activeElement  Id of element witch is the initial one
 */
function szTabbedSliders(listId, activeElement) {
    this.listId = listId;
    this.activeElement = activeElement;
    this.ok = false;
    if(!document.getElementById || !document.createTextNode){
        return;
    }

    var elem = document.getElementById(this.listId);
    if(!elem){ return; }

    this.list = elem.getElementsByTagName("li");
    if(!this.list){ return; }

    this.ok = true;
}


/**
 * Switch to tab based on passed key.
 *
 * @param  string  key  Key of element to activate
 */
szTabbedSliders.prototype.show = function(key){

    if(!this.ok){
        return;
    }

    if (key == this.activeElement) {
        // passed key is allready active, get out here
        return;
    }

    if (this.activeElement !== "") {
        // hide previous displayed element
        document.getElementById(this.activeElement).style.display = "none";
    }

    // set active key, display new element and change classname
    // formatting definitions are set by different class selectors
    this.activeElement = key;
    document.getElementById(this.activeElement).style.display = "block";

    // reset other list item
    for (var i=0; i < this.list.length; i++) {
        if (this.list[i].className == "firstActive") {
            this.list[i].className = "first";
        } else if (this.list[i].className == "middleActive") {
            this.list[i].className = "middle";
        } else if (this.list[i].className == "lastActive") {
            this.list[i].className = "last";
        }
    }

    // activate actual list item
    var item = document.getElementById(key+"Item");
    if (item.className == "first") {
        item.className = "firstActive";
    } else if (item.className == "middle") {
        item.className = "middleActive";
    } else if (item.className == "last") {
        item.className = "lastActive";
    }

    if (key == "nbanderolePictures") {
      //new_callIVW('N399aE0R0000');
      }
    else if (key == "nbanderoleVideos") {
      //new_callIVW('N399aE0R0000');
      }
}

// END: Listenmodul mit Reiter

// START: Google Adsense
var google_adnum  = 0; // Skip-Parameter
var google_cont   = 0; // Google im Content
var google_sky    = 0; // Google als Skyscraper
var google_renav  = 0; // Google in der rechten Leiste
var google_home   = 0; // Google auf der Homepage
var google_search = 0; // Google in der Suche
var google_super  = 0; // Google als Superbanner

/*
* This function is required and is used to display the ads
* that are returned from the JavaScript request. You should
* modify the document.write commands so that the HTML they
* write out fits with your desired ad layout.
*/

function google_ad_request_done(google_ads) {        
  var s = '';
  var i;
  var anzahlAds = google_ads.length;

  if (anzahlAds > 0) {
    // Google-Anzeigen als Flash
    if (google_ads[0].type == "image") {
      // wird aktuell nicht verwendet
      }
    // Google-Anzeigen als Image
    else if (google_ads[0].type == "flash") {
      // wird aktuell nicht verwendet
      }
    // Google-Anzeigen im Content
    else if (google_cont == 1) {
      s += '<div id="googlead-cont">';
      }
    // Google-Anzeigen im Skyscraper
    else if (google_sky == 1) {
      s += '<div id="googlead-sky">';
      }
    // Google-Anzeigen im Superbanner
    else if (google_super == 1) {
      s += '<div id="googlead-super">';
      }
    // Google-Anzeigen in der rechte Leiste
    else if (google_renav == 1) {
      s += '<div id="googlead">';
      }
    // Google-Anzeigen auf der Homepage
    else if (google_home == 1) {
      s += '<div id="googlead-home">';
      }
    // Google-Anzeigen in der Suche
    else if (google_search == 1) {
      s += '<div id="googlead-search">';
      }
    // Google-Anzeigen ausgeblendet
    else {
      // es passiert nichts
      }

    if (google_home == 1) {
      s += '<p><a href="' + google_info.feedback_url + '" onclick="ns_onclick (this,\'\',\'onclick_homepage.info.googleanzeigen\',\'clickin\'); return false;" class="marker">GOOGLE-ANZEIGEN &raquo;</a></p>';
      }
    else {
      s += '<p><a href="' + google_info.feedback_url + '" class="marker">GOOGLE-ANZEIGEN &raquo;</a></p>';
      }

    if (anzahlAds == 3 && google_super == 1) {
      var suffix = "_a";
      }
    else if (anzahlAds == 2 && google_super == 1) {
      var suffix = "_b";
      }
    else {
      var suffix = "";
      }

    s += '<div class="border">';
    for(i = 0; i < anzahlAds; i++) {
      (i == (anzahlAds - 1)) ? s += '<div class="adbox' + suffix + ' last">' : s += '<div class="adbox' + suffix + '">';
      if (google_home == 1) {
        s += '<p><a href="' + google_ads[i].url  + '" onclick="ns_onclick (this,\'\',\'onclick_homepage.info.googleanzeigen\',\'clickin\'); return false;" class="line1' + suffix + '">' + google_ads[i].line1 + '</a></p>';
        s += '<p><a href="' + google_ads[i].url  + '" onclick="ns_onclick (this,\'\',\'onclick_homepage.info.googleanzeigen\',\'clickin\'); return false;" class="line2' + suffix + '">' + google_ads[i].line2 + '&nbsp;' + google_ads[i].line3 + '</a></p>';
        s += '<p><a href="' + google_ads[i].url  + '" onclick="ns_onclick (this,\'\',\'onclick_homepage.info.googleanzeigen\',\'clickin\'); return false;" class="line3' + suffix + '">' + google_ads[i].visible_url + '</a></p>';
        }
      else {
        s += '<p><a href="' + google_ads[i].url + '" class="line1' + suffix + '">' + google_ads[i].line1 + '</a></p>';
        s += '<p><a href="' + google_ads[i].url + '" class="line2' + suffix + '">' + google_ads[i].line2 + '&nbsp;' + google_ads[i].line3 + '</a></p>';
        s += '<p><a href="' + google_ads[i].url + '" class="line3' + suffix + '">' + google_ads[i].visible_url + '</a></p>';
        }
      s += '</div>';
      }
    s += '</div>';
    s += '<div class="abstand"></div>';
    s += '</div>';

    document.write(s);

    // Note that google_adnum is only incremented for CPC text ads
    if (google_ads[0].bidtype == "CPC") {
      google_adnum = google_adnum + google_ads.length;
      }
    }
  return;
  }
// ENDE: Google Adsense

// #######################################################################################
// BEGIN Homepage Spaltenausgleich

function getTableHeight() {
        TABLE = document.getElementById('contentTable');
        TDs = TABLE.getElementsByTagName('div');
        return parseInt(TDs[0].offsetHeight);
}

function getDivHeight() {
        return parseInt(document.getElementById('rechteSpalte').offsetHeight);
}

function RLspaltenausgleich() {
        var tabHeight = getTableHeight();
        var divHeight  = getDivHeight();

        try {
                for (var i = 0; i < divLayer.length; i++) {
                        if ( (tabHeight - 50) > divHeight ) {
                                document.getElementById(divLayer[i]).style.display = "block";
                                divHeight = getDivHeight();
                                // Jetzt zu gross? dann wieder ausblenden :-)
                                if ( divHeight > (tabHeight + 50)  ) {
                                        document.getElementById(divLayer[i]).style.display = "none";
                                        divHeight = getDivHeight();
                                }
                        }
                }
        } catch (e) {}
}
// END Homepage Spaltenausgleich

// #######################################################################################
// BEGIN AJAX Bildstrecken
function showPic(uri, picId, prefix, init){

	//erstellen des requests
	var req = null;

	// Request erzeugen
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		try {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {
			try {
				new ActiveXObject('Msxml2.XMLHTTP');
			} catch (e) {}
		}
	}
	if (req == null)
		return false;
                  
	//request ist asynchron      
	try {
		req.open("GET", '/app/dynamic/bildstrecke.php?uri='+uri+'&picId='+picId+'&prefix='+prefix, true);
	} catch (e) {
		return;
	}

	//Beim abschliessen des request wird diese Funktion ausgefÃ¼hrt
	req.onreadystatechange = function(){            
		if (req.readyState == 4 && req.status == 200) {
			var xml = req.responseXML;

			if (prefix != '') {
				id0_1 = prefix+'_bildstreckeRef0_1';
				id0_2 = prefix+'_bildstreckeRef0_2';
				id0_3 = prefix+'_bildstreckeRef0_3';
				id0_4 = prefix+'_bildstreckeRef0_4';
				id0_5 = prefix+'_bildstreckeRef0_5';
				id0_6 = prefix+'_bildstreckeRef0_6';
				id1_1 = prefix+'_bildstreckeRef1_1';
				id1_2 = prefix+'_bildstreckeRef1_2';
				id1_3 = prefix+'_bildstreckeRef1_3';
				id1_4 = prefix+'_bildstreckeRef1_4';
						id1_5 = prefix+'_bildstreckeRef1_5';
				id1_6 = prefix+'_bildstreckeRef1_6';
				id0_t = prefix+'_bildstreckeTxtCenter0_0';
				id1_t = prefix+'_bildstreckeTxtCenter1_0';
				idabs = prefix+'_bildStreckeAbsatz';
				idpic = prefix+'_bildStreckePic';
				idpicl = prefix+'_bildStreckePicLink';
			} else {
				id0_1 = 'bildstreckeRef0_1';
				id0_2 = 'bildstreckeRef0_2';
				id0_3 = 'bildstreckeRef0_3';
				id0_4 = 'bildstreckeRef0_4';
				id0_5 = 'bildstreckeRef0_5';
				id0_6 = 'bildstreckeRef0_6';
				id1_1 = 'bildstreckeRef1_1';
				id1_2 = 'bildstreckeRef1_2';
				id1_3 = 'bildstreckeRef1_3';
				id1_4 = 'bildstreckeRef1_4';
				id1_5 = 'bildstreckeRef1_5';
				id1_6 = 'bildstreckeRef1_6';
				id0_t = 'bildstreckeTxtCenter0_0';
				id1_t = 'bildstreckeTxtCenter1_0';
				idabs = 'bildStreckeAbsatz';
				idpic = 'bildStreckePic';
				idpicl = 'bildStreckePicLink';
			}

			// previous picture
			var prevLink = xml.getElementsByTagName('prevImgLink')[0].firstChild.nodeValue;
			if (document.getElementById(id0_1)) { document.getElementById(id0_1).href = prevLink; }
			if (document.getElementById(id0_3)) { document.getElementById(id0_3).href = prevLink; }
			if (document.getElementById(id1_1)) { document.getElementById(id1_1).href = prevLink; }
			if (document.getElementById(id1_3)) { document.getElementById(id1_3).href = prevLink; }

			var txtPrevImg = xml.getElementsByTagName('txtPrevImg')[0].firstChild.nodeValue;
			if (document.getElementById(id0_2)) { document.getElementById(id0_2).alt = txtPrevImg; }
			if (document.getElementById(id0_2)) { document.getElementById(id0_2).title = txtPrevImg; }
			if (document.getElementById(id0_3)) { document.getElementById(id0_3).firstChild.nodeValue = txtPrevImg; }
			if (document.getElementById(id1_2)) { document.getElementById(id1_2).alt = txtPrevImg; }
			if (document.getElementById(id1_2)) { document.getElementById(id1_2).title = txtPrevImg; }
			if (document.getElementById(id1_3)) { document.getElementById(id1_3).firstChild.nodeValue = txtPrevImg; }

			// center text (picture x of y)
			var txtCenter = xml.getElementsByTagName('txtCenter')[0].firstChild.nodeValue;
			if (document.getElementById(id0_t)) { document.getElementById(id0_t).innerHTML = txtCenter; }
			if (document.getElementById(id1_t)) { document.getElementById(id1_t).innerHTML = txtCenter; }

			// next picture
			var nextImgLink = xml.getElementsByTagName('nextImgLink')[0].firstChild.nodeValue;
			if (document.getElementById(id0_4)) { document.getElementById(id0_4).href = nextImgLink; }
			if (document.getElementById(id0_5)) { document.getElementById(id0_5).href = nextImgLink; }
			if (document.getElementById(id1_4)) { document.getElementById(id1_4).href = nextImgLink; }
			if (document.getElementById(id1_5)) { document.getElementById(id1_5).href = nextImgLink; }
			if (document.getElementById(idpicl)) { document.getElementById(idpicl).href = nextImgLink; }

			var txtNextImg = xml.getElementsByTagName('txtNextImg')[0].firstChild.nodeValue;
			if (document.getElementById(id0_4)) { document.getElementById(id0_4).firstChild.nodeValue = txtNextImg; }
			if (document.getElementById(id0_6)) { document.getElementById(id0_6).alt = txtNextImg; }
			if (document.getElementById(id0_6)) { document.getElementById(id0_6).title = txtNextImg; }
			if (document.getElementById(id1_4)) { document.getElementById(id1_4).firstChild.nodeValue = txtNextImg; }
			if (document.getElementById(id1_6)) { document.getElementById(id1_6).alt = txtNextImg; }
			if (document.getElementById(id1_6)) { document.getElementById(id1_6).title = txtNextImg; }

			// text absatz
			if (xml.getElementsByTagName('absatz')[0].firstChild) {
				var absatz = xml.getElementsByTagName('absatz')[0].firstChild.nodeValue
				if (document.getElementById(idabs)) { document.getElementById(idabs).innerHTML = absatz; }
			} else {
				if (document.getElementById(idabs)) { document.getElementById(idabs).innerHTML = ""; }
			}

			// picture
			var picUrl = xml.getElementsByTagName('picUrl')[0].firstChild.nodeValue;
			var picHeight = xml.getElementsByTagName('picHeight')[0].firstChild.nodeValue;
			var picWidth = xml.getElementsByTagName('picWidth')[0].firstChild.nodeValue;
			var picStyle = xml.getElementsByTagName('picStyle')[0].firstChild.nodeValue;
			var picAlt = xml.getElementsByTagName('picAlt')[0].firstChild ? xml.getElementsByTagName('picAlt')[0].firstChild.nodeValue : "";
			if (document.getElementById(idpic)) { document.getElementById(idpic).src = picUrl; }
			if (document.getElementById(idpic)) { document.getElementById(idpic).height = picHeight; }
			if (document.getElementById(idpic)) { document.getElementById(idpic).width = picWidth; }
			if (document.getElementById(idpic)) { document.getElementById(idpic).className = picStyle; }
			if (document.getElementById(idpic)) { document.getElementById(idpic).alt = picAlt; }

			// IVW-Tag einblenden, wenn Bild per AJAX umgeschaltet wird
			if (init != '0') 
				ivwcount = ivwcount + 1;
			if (ivwcount > 0) {
				if (typeof(IVW)!="undefined") {
					var teilstr = IVW.split("/");
					var ivwcode = teilstr[teilstr.length-1];
					new_callIVW(ivwcode, 'bilderstrecke');
				}

				// OAS-Werbung austauschen
				var oasPositions = OAS_listpos.split(",");
				for (var oasPos = 0; oasPos < oasPositions.length; ++oasPos) {
					tauscheOASad(OAS_url, OAS_sitepage, oasPositions[oasPos], OAS_listpos);
				}

			}
		}
		else
			return false;
	};
 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	req.send(null);
}

function tauscheOASad(url,sitepage,listpos,allelistpos) {

	var oasDocID = 'oas_' + listpos;
	if (! document.getElementById(oasDocID)) { return; }

	//erstellen des requests
	var reqoas = null;

	// Request erzeugen
	if (window.XMLHttpRequest) {
		reqoas = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		try {
			reqoas = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {
			try {
				new ActiveXObject('Msxml2.XMLHTTP');
				} catch (e) {}
		}
	}

	if (reqoas == null)
		return false;

	rn = new String (Math.random());
	rns = rn.substring (2, 11);

	//request ist asynchron
	try {
		reqoas.open("GET", '/app/dynamic/oas_proxy.php?url='+url+'&sitepage='+sitepage+'&rns='+rns+'&listpos='+listpos+'&allelistpos='+allelistpos, true);
	} catch (e) {
		return;
	}

	//Beim abschliessen des request wird diese Funktion ausgefÃ¼hrt
	reqoas.onreadystatechange = function(){
		if (reqoas.readyState == 4 && reqoas.status == 200) {

			// response from AJAX request
			var xml = reqoas.responseXML;

			var htmlcode = '';
			if (xml.getElementsByTagName('htmlcode')[0].firstChild) {
				htmlcode = xml.getElementsByTagName('htmlcode')[0].firstChild.nodeValue;

				// schreibt man JS-Code in den DOM, wird dieser nicht interpretiert, also
				// schreiben wir ihn per 'eval' rein
				// alle anderen Elemente kÃ¶nnen so in den DOM eingekippt werden
				var ScriptFragment = '<script type="text/javascript"[^>]*>([\\S\\s]*?)<\/script>';
				var matchAll = new RegExp(ScriptFragment, 'im');
				var js_in_html = htmlcode.match(matchAll);
				if (js_in_html) { 

					ehtml = '';
					try {
						ehtml = eval(htmlcode);
						document.getElementById(oasDocID).innerHTML = ehtml;
					} catch (e) {
						alert('Fehler bei Interpretation JS: ' + e);
						return false;
					}
					
				} else {
					document.getElementById(oasDocID).innerHTML = htmlcode; 
				}
			}
		}
		else
			return false;
	};

	reqoas.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	reqoas.send(null);
}

// homepagemanager tracking urls
function trackClick(linkid,hpmcode,useHref) {
	var am_i_home = (window.location.pathname.length > 2 ) ? 0 : 1; // sind wir die Homepage?
	if (!am_i_home) return false;
	
    // default parameters
    if (useHref==null) {
      useHref=false;
    }
    
    // main function
    var trackURL     = document.getElementById(linkid).href;
    var documentHOST = "http://"+document.location.host;
    if (trackURL.indexOf(documentHOST)!=-1) {
      trackURL = trackURL.substr(documentHOST.length);
    }else if (trackURL.substr(0,1)!='/') {
      trackURL = '/'+trackURL;
    }
    
    if (trackURL.indexOf('/'+hpmcode+'/') == -1) { 
      trackURL = '/'+hpmcode+trackURL;
    }

    // prüfen welcher bereich geklickt wurde
    var trackingname = '';
    if (hpmcode.indexOf('abild') != -1) {
      // Aktionsbanderole Bilder
      trackingname = 'aktionsbanderole.teaser.bilder';
    } else if (hpmcode.indexOf('avideo') != -1) {
      // Aktionsbanderole Spiele (ehemals Video)
      trackingname = 'aktionsbanderole.teaser.spiele'; 
    } else if (hpmcode.indexOf('aaudio') != -1) {
      // Aktionsbanderole Audio
      trackingname = 'aktionsbanderole.teaser.audio';
    } else if (hpmcode.indexOf('mein') != -1) {
      // Rechteleiste-Box Meinung
//      trackingname = 'modul.meinung.teaser';
    } else if (hpmcode.indexOf('kolu') != -1) {
      // Rechteleiste-Box Kolumne
//      trackingname = 'modul.kolumne.teaser';
    } else if (hpmcode.indexOf('tt') != -1 && hpmcode.indexOf('m') != -1) {
      // Topthema Teaser
      trackingname = 'topthema.teaser';
    } else if (hpmcode.indexOf('tt') != -1 && hpmcode.indexOf('l') != -1) {
      // Topthema Linkmeldung
      trackingname = 'topthema.linkmeldung';
    } else if (hpmcode.indexOf('ra') != -1 && hpmcode.indexOf('m') != -1) {
      // Ressortaufmacher Teaser
      trackingname = 'ressortaufmacher.teaser';
    } else if (hpmcode.indexOf('ra') != -1 && hpmcode.indexOf('l') != -1) {
      // Ressortaufmacher Linkmeldung
      trackingname = 'ressortaufmacher.linkmeldung';
    }

    if (trackingname.length > 5) {
      // sitestat-pixel abrufen
      var random  = (Math.random()*100000);
      var countNS = new Image();
      countNS.src = 'http://de.sitestat.com/sueddeutsche/sueddeutsche/s?onclick_homepage.' + trackingname + '&d=' + random;
      }

    if (useHref) {
      document.getElementById(linkid).href = trackURL;
      return true;
    } else {
      document.location = trackURL;
      return false;    
    }
}

// homepagemanager: entfernen des tracking-codes aus urls fuer social bookmarking
function untrackUrl() {
  var str = location.href;
  var posComma = str.indexOf(",");
  var posSlash = str.indexOf("/", posComma);
  var tracking = str.substr(posComma, (posSlash+1)-posComma);
  var newUrl =  str.replace(tracking, "");
  
  if(posComma!=-1 && newUrl!=''){return newUrl;}
  else{return str;}
}

// Maskieren der 'mehr'-Links in Topthemen und Aufmacher
function maskLink (dest, hpm, count, text){
  var externLink = "0";
  // wenn externe urls (http://), dann springt nur der bloede makearticle an und nicht der spymask.
  // daher steht der zu verlinkende text im parameter hpm drin, wenn er existiert.
  if (dest.substr(0,4) == "http") {
    if (!hpm) {
      var linktext = "mehr ...";
    } else {
      var linktext = hpm;
    }
    externLink = "1";
  // ansonsten springt der spymask an und die parameter werden auch richtig uebergeben.
  } else {
    if (!text) {
      var linktext = "mehr ...";
    } else {
      var linktext = text;
    }
  }
  if (!hpm || externLink == "1") {
    document.writeln('<a href="'+dest+'" class="mehr">'+linktext+'</a>');
  } else {
    document.writeln('<a href="'+dest+'" id="hpm_link_'+count+'" onclick="trackClick(\'hpm_link_'+count+'\',\''+hpm+'\', true)" class="mehr">'+linktext+'</a>');
  }
}

//------------------- xlinks (artikelkontext) --------------------------
/**
 * Öffnet oder schließt weitere vorhandene Elemente der Navigator Boxen.
 * @param  {String}  navId  Id der Navigatorbox.
 */
function toggleArticleNavigator(navId) {
    var list = $(navId).getElementsByTagName('li');
    if (!list) {
        return;
    }

    var status = "";
    
    for (var i=0; i<list.length; i++) {
        var el = list[i];
        if (Element.hasClassName(el, "close")) {
            Element.removeClassName(el, "close");
            Element.addClassName(el, "open");
            status = "open";
        } else if (Element.hasClassName(el, "open")) {
            Element.removeClassName(el, "open");
            Element.addClassName(el, "close");
            status = "close";
        }
    }

    if (status == "open") {
        $(navId + "-anchor").innerHTML = "weniger";
        $(navId + "-anchor").title = "Weitere Eintr&auml;ge zuklappen";
    } else {
        $(navId + "-anchor").innerHTML = "mehr";
        $(navId + "-anchor").title = "Weitere Eintr&auml;ge anzeigen";
    }
}

/* Used on the article page to control popups for bookmarks and page lists */
ContainerToggle = function() {
  var open    = function (e) {
    this.container.removeClassName( 'closed' );
    this.list.focus();
    e && Event.stop(e);
  };
  var close   = function (e) {
    this.container.addClassName( 'closed' );
    e && Event.stop(e);
  };
  var toggle = function(e) {
    if ( this.container.hasClassName( 'closed' ) ) {
      this.open(e);
    } else {
      this.close(e);
    }
  };
  
  
  return {
    init:   function( listID ) {
      this.list       = $( listID );
      if ( this.list ) {
        this.container  = $( this.list.parentNode );

        $(this.container.getElementsByTagName('a')[0]).observe( 'click', toggle.bind( this ) );
        $(this.list.getElementsByTagName('a')[0]).observe( 'click', close.bind( this ) );
	if ( Prototype.Browser.IE ) { /* Tremendously ugly hack to solve [FRONT-195] */
            this.open();
	    this.close();
	}
      }
    },
    open:  open,
    close: close
  };
};

/* Replaces the current login-form functions.  I'll rip those out as soon as the new header is rolled onto all pages. */
LoginBehaviors = (function() {
    var container       = null;
    var formDefaults    = {
        benutzer:       'Benutzername',
        login_passwort: 'Passwort'
    };
    
    var toggle = function ( e ) {
        if ( container.hasClassName( 'login' ) ) {
            conainer.removeClassName( 'login' );
        } else {
            container.addClassName( 'login' );
        }
        e && Event.stop( e );
    };
    
    var fieldFocus = function ( e ) {
        var element = Event.element( e );
        if ( element.id && $F( element ) === formDefaults[ element.id ] ) {
            element.value = '';
        }
    };
    var fieldBlur = function ( e ) {
        var element = Event.element( e );
        if ( element.id && $F( element ) === '' ) {
            element.value = formDefaults[ element.id ];
        }
    }
    
    return {
        init: function ( containerID ) {
            container = $( containerID );
            if ( container ) {
                container.getElementsBySelector('.login a')[0].observe( 'click', toggle );
                container.getElementsBySelector( 'input' ).each( function( o ) {
                    o.observe( 'focus', fieldFocus );
                    o.observe( 'blur', fieldBlur );
                });
            }
        }
    }
})();

//
// Wrapper Funktion um sitestat Aufrufe zum onclick Hanlder eines HPM links hinzufuegen zu koennen (vgl. DHTML Box Kolumne/Meinung)
//
function wrapSitestatLink(sitestat_id, sitestat_onclick, hpm_id, hpm_rubrik) {
	var sitestat_links = document.getElementsByName(sitestat_id);
	if (! sitestat_links) return;

	// Links gefunden? dann alle onclick Hanlder anpassen
	for (var k=0; k<sitestat_links.length; k++) {
		var my_link = sitestat_links[k];

    if (sitestat_id.indexOf('meinung_teaser') != -1) {
      sitestat_onclick = 'onclick_homepage.modul.meinung.teaser';
    }else if (sitestat_id.indexOf('kolumne_teaser') != -1) {
      sitestat_onclick = 'onclick_homepage.modul.kolumne.teaser';
    }

		// bisherigen Event Hanlder fuer den HPM generieren und 
		// jetzt zus. den sitestat Aufruf anhaengen:
		my_link.onclick = function () {
			trackClick(this.id,',' + hpm_rubrik + 'm1' ,true);
			ns_onclick (this,'',sitestat_onclick,'clickin');
			return false;
		}
	}
}
