
function inArray(needle) {
  for (var i=0; i < this.length; i++) {
    if (this[i] === needle) {
      return i;
    }
  }
  return false;
}
Array.prototype.inArray = inArray;

function addClass(obj, theClass) {
  if (obj.className != '') {
    obj.className += ' ' + theClass;
  } else {
    obj.className = theClass;
  }
}

// xhtml 1.1 Kompatibilität: External targets ;-)

function changeAllLinksWithClassToTargetBlanks()
{
  for (i = 0; i < document.links.length; i++)
  {
    if (document.links[i].getAttribute('class') == 'extern'
        || document.links[i].className.match(/extern/))
    {
      document.links[i].setAttribute('target', '_blank');
    }
  }
}

daisychain(changeAllLinksWithClassToTargetBlanks);

/****************************************************************
"bretteleben.de JavaScript Slideshow" - Version 20090406
License: http://www.gnu.org/copyleft/gpl.html
Author: Andreas Berger
Copyright (c) 2009 Andreas Berger - andreas_berger@bretteleben.de
Project page and Demo at http://www.bretteleben.de
Last update: 2009-04-06
*****************************************************************/

var def_contr=new Array('/pics/be_slide/bwd.png','/pics/be_slide/start.png','/pics/be_slide/stop.png','/pics/be_slide/fwd.png');

var be_action = new Array('Voriges Bild', 'Slideshow starten', 'Slideshow stoppen', 'Nächstes Bild');

//daisychain onload-events
function daisychain(sl)
{
  if(window.onload)
  {
    var ld = window.onload;
    window.onload = function() { ld(); sl(); };
  }
  else
  {
    window.onload = function(){ sl(); };
  }
}

function be_slideshow( be_slideid, be_imges, be_divid, be_picwid, be_pichei, be_backgr, be_sdur, be_fdur, be_steps, be_startwhen, be_shuffle, be_showcontr, be_contr)
{
  //declarations and defaults
	var slideid = (be_slideid) ? be_slideid : "0";
	var imges = (be_imges) ? be_imges : def_imges;
	var divid = (be_divid) ? be_divid : "slideshow";
	var picwid = (be_picwid) ? be_picwid : "400";
	var pichei = (be_pichei) ? be_pichei : "300";
	var backgr = (be_backgr) ? be_backgr : "#ff00ff";
	var sdur = (be_sdur) ? be_sdur : '3';
	var fdur = (be_fdur) ? be_fdur : '1';
	var steps = (be_steps) ? be_steps : '20';
	var startwhen = (be_startwhen) ? be_startwhen : 'y';
			startwhen = (startwhen.toLowerCase() == "y") ? 1 : 0;
	var shuffle = (be_shuffle) ? be_shuffle : 'n';
			shuffle = (shuffle.toLowerCase() == "y") ? 1 : 0;
	var showcontr = (be_showcontr) ? be_showcontr : 'y';
			showcontr = (showcontr.toLowerCase() == "y") ? 1 : 0;
	var contr = (be_contr) ? be_contr : 'n';
	var ftim = fdur * 1000 / steps;
	var stim = sdur * 1000;
	var emax = imges.length;
	var self = this;
	var stopit = 1;
	var startim = 1;
	var u = 0;
	var parr = new Array();
	var ptofade, pnext, factor, mytimeout;

  //check if there are at least 3 pictures, elswhere double the array
	if( emax <= 2)
  {
    imges = imges.concat(imges);
    emax = imges.length;
  }

  //shuffle images if set
  if (shuffle)
  {
    var i;
    for( i = 0; i <=Math.floor(Math.random()*imges.length); i++)
    {
      imges.push(imges.shift());
    }
  }

  //push images into array and get things going
	this.b_myfade = function()
  {
		var a, idakt, paktidakt, ie5exep;
		for( a = 1; a <= emax; a++)
    {
			idakt = "img_" + slideid + "_" + a;
      paktidakt = document.getElementById(idakt);
    	ie5exep = new Array(paktidakt);
      parr = parr.concat(ie5exep);
    }
		if (startwhen)
    {
	    this.b_stopit(0);
 			mytimeout = setTimeout( function(){ self.b_slide(); }, stim);
 		}
	}

  //prepare current and next and trigger slide
	this.b_slide = function()
  {
		clearTimeout(mytimeout);
		u = 0;
		ptofade = parr[startim - 1];
		if( startim < emax )
    {
      pnext = parr[startim];
    }
		else
    {
      pnext=parr[0];
    }
		pnext.style.zIndex = 1;
		pnext.style.visibility = "visible";
		pnext.style.filter = "Alpha(Opacity=100)";
		pnext.style.MozOpacity = 1;
		pnext.style.opacity = 1;
		ptofade.style.zIndex = 2;
		ptofade.style.visibility = "visible";
		ptofade.style.filter = "Alpha(Opacity=100)";
		ptofade.style.MozOpacity = 1;
		ptofade.style.opacity = 1;
		factor = 100 / steps;
		if (stopit == "0")
    {
			this.b_slidenow();
		}
	}

  this.b_stopit = function(newstate)
  {
    if ( stopit != newstate )
    {
      if ( newstate == 1 )
      {
        stopit = 1;
        document.getElementById("ctrl_" + slideid+'2').style.display='inline';
        document.getElementById("ctrl_" + slideid+'3').style.display='none';
      }
      else
      {
        stopit = 0;
        document.getElementById("ctrl_" + slideid+'3').style.display='inline';
        document.getElementById("ctrl_" + slideid+'2').style.display='none';
      }
    }
  }

  //one step forward
	this.b_forw = function()
  {
    this.b_stopit(1);
		clearTimeout(mytimeout);
		ptofade = parr[startim-1];
		if (startim < emax)
    {
      pnext=parr[startim];
      startim=startim+1;
    }
		else
    {
      pnext=parr[0];
      startim=1;
    }
		ptofade.style.visibility = "hidden";
		ptofade.style.zIndex = 1;
		pnext.style.visibility = "visible";
		pnext.style.zIndex = 2;
		self.b_slide();
	}

  //one step back
	this.b_back = function()
  {
    this.b_stopit(1);
		clearTimeout(mytimeout);
		if (u == 0) //between two slides
    {
			ptofade=parr[startim-1];
			if( startim < emax)
      {
        pnext=parr[startim];
      }
			else
      {
        pnext=parr[0];
      }
			pnext.style.visibility = "hidden";
			ptofade.style.zIndex = 1;
			ptofade.style.visibility = "visible";
			if (startim >= 2)
      {
        startim=startim-1;
      }
			else
      {
        startim=emax;
      }
			self.b_slide();
		}
		else //whilst sliding
    {
			self.b_slide();
		}
	}

  //slide as said, then give back
	this.b_slidenow = function()
  {
		var check1, maxalpha, curralpha;
		check1 = ptofade.style.MozOpacity;
		maxalpha = (100 - factor * u) / 100 * 105;
		if (check1 <= maxalpha / 100)
    {
      u = u + 1;
    }
		curralpha = 100 - factor * u;
		ptofade.style.filter = "Alpha(Opacity=" + curralpha + ")";
		ptofade.style.MozOpacity = curralpha / 100;
		ptofade.style.opacity = curralpha / 100;
		if ( u < steps)  //slide not finished
    {
			if ( stopit == "0" )
      {
        mytimeout = setTimeout(function(){ self.b_slidenow(); }, ftim);
      }
			else
      {
        this.b_slide();
      }
		}
		else //slide finished
    {
			if ( startim < emax)
      {
				ptofade.style.visibility = "hidden";
				ptofade.style.zIndex = 1;
				pnext.style.zIndex = 2;
				startim = startim + 1;
        u=0;
				mytimeout = setTimeout(function(){ self.b_slide(); }, stim);
			}
			else
      {
				ptofade.style.visibility = "hidden";
				ptofade.style.zIndex = 1;
				pnext.style.zIndex = 2;
				startim = 1;
        u = 0;
				mytimeout = setTimeout(function(){ self.b_slide(); }, stim);
			}
		}
	}

  //manual start
	this.b_start = function()
  {
		if(stopit==1)
    {
      this.b_stopit(0);
 			mytimeout=setTimeout(function(){ self.b_slide(); }, stim);
 		}
	}

  //manual stop
	this.b_stop= function()
  {
		clearTimeout(mytimeout);
    this.b_stopit(1);
		this.b_slide();
	}

  //insert css and images
	this.b_insert= function()
  {
		var b, thestylid, thez, thevis, slidehei;
		slidehei = ( showcontr ) ? ( pichei + 25 ) : ( pichei ); //add space for the controls
		var myhtml = "<div style='width:" + picwid + "px;height:" + slidehei + "px;'>";
		myhtml += "<div style='position:absolute;width:" + picwid + "px;height:" + pichei + "px;'>";
		for ( b = 1; b <= emax; b++)
    {
			thez=1;
      thevis='hidden';
			if ( b <= 1)
      {
        thez=2;
        thevis='visible';
      }
			myhtml += "<div id='img_" + slideid + "_" + b
          + "' style='font-size:0;line-height:" + pichei + "px;margin:0;padding:0;text-align:center;visibility:" + thevis + ";z-index:" + thez + ";position:absolute;left:0;top:0;width:" + picwid + "px;height:" + pichei + "px;background-color:" + backgr + ";'>";
			myhtml += "<img src='" + imges[(b-1)] + "' style='vertical-align:middle;border:0;' alt=''/></div>";
		}
   	myhtml+="</div>";
    //show controls
		if (showcontr)
    {
			for ( b = 1; b <= 4; b++)
      {
        var check = contr[b-1].substring(contr[b-1].length-3).toLowerCase();
        //check for buttons
				contr[b-1] = ( check == "jpg" || check == "gif" || check == "png") ? ("<img id='ctrl_" + slideid + b + "' src='" + contr[b-1] + "' style='border:none;' alt='" + be_action[b-1] +"' title='" + be_action[b-1] +"'/>") : (contr[b-1]);
      }
   		myhtml += "<div style='display:block;width:" + picwid + "px;padding-top:" + (pichei + 3) + "px;text-align:center;'>";
      myhtml += "<a href='javascript:be_" + slideid + ".b_back();' style='text-decoration:none'>" + contr[0] + "</a>&nbsp;";
   		myhtml += "<a href='javascript:be_" + slideid + ".b_start();' style='text-decoration:none'>" + contr[1] + "</a>";
      myhtml += "<a href='javascript:be_" + slideid + ".b_stop();' style='text-decoration:none'>" + contr[2] + "</a>&nbsp;";
   		myhtml += "<a href='javascript:be_" + slideid + ".b_forw();' style='text-decoration:none'>" + contr[3] + "</a>";
		}
   	myhtml += "</div>";
		document.getElementById(divid).innerHTML = myhtml;
		self.b_myfade();
	}
  //call autostart-function
  daisychain(this.b_insert);
}


/*------------------------------------------------------------------------------
Function:       footnoteLinks()
Author:         Aaron Gustafson (aaron at easy-designs dot net)
Creation Date:  8 May 2005
Version:        1.3
Homepage:       http://www.easy-designs.net/code/footnoteLinks/
License:        Creative Commons Attribution-ShareAlike 2.0 License
                http://creativecommons.org/licenses/by-sa/2.0/
Note:           If you change or improve on this script, please let us know by
                emailing the author (above) with a link to your demo page.
------------------------------------------------------------------------------*/
function footnoteLinks()
{

  var containerID = 'contentrow';
  var targetID = 'linklist';
  if (!document.getElementById ||
      !document.getElementsByTagName ||
      !document.createElement) return false;
  if (!document.getElementById(containerID) ||
      !document.getElementById(targetID)) return false;

  var container = document.getElementById(containerID);
  var target    = document.getElementById(targetID);

  var coll = container.getElementsByTagName('a');
  var ol   = document.createElement('ol');
  var myArr = [];
  var thisLink;
  var num = 1;
  for (var i=0; i<coll.length; i++) {
    var thisClass = coll[i].className;
    if ( (coll[i].getAttribute('href') || coll[i].getAttribute('cite'))
        && (thisClass == '' || thisClass.indexOf('ignore') == -1)
        && (! thisClass.match(/ignore/)))
    {
      thisLink = coll[i].getAttribute('href') ? coll[i].href : coll[i].cite;
      var note = document.createElement('span');
      addClass(note,['linklist']);
      var note_txt;
      var j = inArray.apply(myArr,[thisLink]);
      if ( j || j===0 ) {
        note_txt = document.createTextNode(' [' + (j+1) + ']');
      } else {
        var li     = document.createElement('li');
        var li_txt = document.createTextNode(thisLink);
        li.appendChild(li_txt);
        ol.appendChild(li);
        myArr.push(thisLink);
        note_txt = document.createTextNode(' [' + num + ']');
        num++;
      }
      note.appendChild(note_txt);
      if (coll[i].tagName.toLowerCase() == 'blockquote') {
        var lastChild = lastChildContainingText.apply(coll[i]);
        lastChild.appendChild(note);
      } else {
        coll[i].parentNode.insertBefore(note, coll[i].nextSibling);
      }
    }
  }
  target.appendChild(ol);
  return true;
}

daisychain(footnoteLinks);

