// Füge target="_blank" zu externen Links hinzu
function add_targets()
{
 links = document.getElementsByTagName("A");
 for (i=0;i<links.length;i++) {
         var anchor = links[i];
         var att = anchor.attributes;
         var link = "";
         for (j=0;j<att.length;j++) {
                  if (att[j].nodeName == "href") {
                         link = att[j].nodeValue;
                        break;
                 }
         }
         if (link.length > 0 && anchor.target == "" && (((link.substr(0,7) == "http://" || link.substr(0,8) == "https://") && link.indexOf(document.domain) == -1) || link.search(/\.pdf$/i) != -1) ) {
                 anchor.target = "_blank";
                 anchor.title = (anchor.title != "") ? anchor.title : "(in neuem Fenster)";
                 anchor.className = (anchor.className != '') ? anchor.className+' external' : 'external';
         }
        // aufgebohrt, da wir hier eh schon alle Links durchnudeln: Versehe alle mp3-Dateien mit einem Abspiel-Symbol
         else if (link.search(/\.mp3$/i) > 0) {
           $(anchor).after('<object type="application/x-shockwave-flash" data="player_mp3_maxi.swf" width="16" height="16" style="position:relative;bottom:-4px;margin-left:6px;margin-right:6px;"><param name="movie" value="player_mp3_maxi.swf" /><param name="FlashVars" value="mp3='+link+'&amp;width=16&amp;height=16&amp;showslider=0&amp;showloading=never&amp;buttonwidth=16&amp;bgcolor1=F47A64&amp;bgcolor2=F15B40&amp;buttonovercolor=000000" /></object>');
         }
 }
}

jQuery(document).ready(function(){
  add_targets();
});
function getWindowDimensions() {
  var x, y;
  if (self.innerHeight) {
      x = self.innerWidth;
      y = self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight) {
      x = document.documentElement.clientWidth;
      y = document.documentElement.clientHeight;
  }
  else if (document.body) {
      x = document.body.clientWidth;
      y = document.body.clientHeight;
  }
  return Array(x, y);
}
function launchWindow(doct,popW,popH)
{
  var w = getWindowDimensions()[0];
  var h = getWindowDimensions()[1];
  var x,y;
  // var popW = 700, popH = 675;
  var leftPos = (w-popW)/2, topPos = (h-popH)/2;
  window.open( doct,"","width=" + popW + ",height=" + popH + ",top=" + topPos + ",left=" + leftPos + ",menubar=no,locationbar=no,statusbar=no,resizable=yes,toolbar=no,dependent=yes,scrollbars=no").focus();
}

// Cookie handling
var Cookie =
{
    read: function (name)
    {
        var arrCookies = document.cookie.split ('; ');
        for (var i=0; i<arrCookies.length; i++)
        {
            var arrCookie = arrCookies[i].split ('=');
            if (arrCookie[0] == name)
            {
                return decodeURIComponent (arrCookie[1]);
            }
        }
        return false;
    },
    write: function (name, value, expires, path)
    {
        if (expires)
        {
            var date = new Date ();
            date.setTime (date.getTime () + (((((expires * 24) * 60) * 60) * 1000)));
            expires = '; expires=' + date.toGMTString ();
        }
        else expires = '';
        if (!path) path = '/';
        document.cookie = name+'='+encodeURIComponent (value)+expires+'; path='+path;
    },
    remove: function (name)
    {
        this.write (name, '', -1);
    }
}
// Detects if can set a cookie in the browser
function browserSupportsCookies()
{
    Cookie.write('cookiesEnabled', 1);
    var boolCookiesEnabled = Cookie.read('cookiesEnabled');
    Cookie.remove('cookiesEnabled');
    if (boolCookiesEnabled != 1)
    {
        return false;
    }
    return true;
}
