
var slideGallery={width:470,div:null,nav:null,count:0,current:0,step:0,pos:0,next:0,factor:0,movement:null,auto:null,autoplay:false,tmp:null,stopMove:function(){if(slideGallery.auto){window.clearInterval(slideGallery.auto);slideGallery.auto=null;}
if(slideGallery.movement){window.clearInterval(slideGallery.movement);slideGallery.movement=null;}
slideGallery.current=slideGallery.next;if(slideGallery.autoplay)slideGallery.play();},play:function(){slideGallery.auto=window.setInterval(function(){slideGallery.change((slideGallery.next+1)%slideGallery.count);},5000);},shift:function(){var stop=-2*slideGallery.current*slideGallery.width;var pos;var fac;slideGallery.factor+=.05;fac=Math.sin(Math.PI/2*slideGallery.factor);pos=fac*slideGallery.next+(1-fac)*slideGallery.current;if(slideGallery.factor>=1){pos=slideGallery.next;slideGallery.stopMove();}
slideGallery.div.style.marginLeft=(-2*slideGallery.width*pos)+'px';slideGallery.pos=pos;},change:function(next){slideGallery.nav.childNodes[slideGallery.current+1].className='';slideGallery.factor=0;slideGallery.current=slideGallery.pos;slideGallery.nav.childNodes[next+1].className='active';slideGallery.next=next;slideGallery.movement=window.setInterval(slideGallery.shift,40);},select:function(n){var next=isNaN(n)?1*this.lang:n;next=Math.max(0,Math.min(slideGallery.count-1,next));if(next==slideGallery.current)return;slideGallery.stopMove();slideGallery.change(next);},init:function(){var gallery=document.getElementById('references');var div=document.createElement('DIV');var count=0;slideGallery.width=gallery.clientWidth/2;slideGallery.div=div;gallery.style.display='none';div.id='box';while(gallery.firstChild){var child=gallery.firstChild;gallery.removeChild(child);if(child.nodeName=='DIV'){div.appendChild(child);count++;}}
div.style.width=(slideGallery.width*count)+'px';gallery.appendChild(div);gallery.className+=' js';gallery.style.display='block';var li=document.createElement('LI');var img=document.createElement('IMG');var nav=document.createElement('UL');slideGallery.nav=nav;nav.className='nav';img.src='/tpl/pfeil-l.png';img.alt='Zurück';img.onclick=function(){slideGallery.select(slideGallery.next-1);};li.appendChild(img);nav.appendChild(li);slideGallery.count=Math.ceil(count/2);for(var i=0,l=slideGallery.count;i<l;i++){li=document.createElement('LI');li.lang=i;li.onclick=slideGallery.select;li.innerHTML=i+1;if(i==slideGallery.current)li.className='active';nav.appendChild(li);}
li=document.createElement('LI');img=document.createElement('IMG');img.src='/tpl/pfeil-r.png';img.alt='Vorwärts';img.onclick=function(){slideGallery.select(slideGallery.next+1);};li.appendChild(img);nav.appendChild(li);gallery.appendChild(nav);if(gallery.className.indexOf('autoplay')+1){div.onmouseover=function(){img.src='/tpl/pause.png';slideGallery.autoplay=false;if(slideGallery.auto){window.clearInterval(slideGallery.auto);slideGallery.auto=null;}
window.clearTimeout(slideGallery.tmp);};div.onmouseout=function(){img.src='/tpl/pfeil-r.png';slideGallery.autoplay=true;slideGallery.tmp=window.setTimeout(slideGallery.stopMove,1000);};div.onmouseout();}}}
if(!window.initFunc)initFunc=[];initFunc.push(slideGallery.init);
