/**
 * horizon.beta.0.1.1.js
 * @package		horizonSlim
 * @license		GNU/AGPL, see AGPL.txt
 */
var descFader=new Array();function horizon(){var p,o,j,x,z,y,h,n,e,B,c,q,i,f,d,v,k,s,g,b,A,a,u,r;this.build=function(J,E,L,D,O,w,P,F,T,S,V,t,K,M,G,m,U,l){p=document.getElementById(J);o=E;j=L;x=D;O=O;z=w;p.clickEffect=P;p.even=F;n=T;e=S;B=V;t=t;c=p.getElementsByTagName("li");q=c.length;i=p.offsetWidth;f=Math.floor((i-o)/(q-1));r=(i-(f*(q-1))-o);l=l;p.desSpeed=m;p.over=false;p.active=false;p.list_width=i/q;p.desDir=K;p.desDirV=10;p.lastOver=false;p.lastOut=false;p.firstActive=p.active;p.autoPlayOn=M;p.autoPlayPause=false;p.clickStopsAutoPlay=G;p.autoPlaySpeed=U;if(O!=null){p.actual=c[O-1]}if(navigator.appName.indexOf("Microsoft")!=-1){p.ie=true}else{p.ie=false}if(navigator.userAgent.indexOf("Firefox")==-1){j=parseInt(L*2);x=parseInt(D/2)}p.horizon=this;for(var N=0;N<q;N++){var I=c[N];I.style.width=p.list_width+"px";var W=I.getElementsByTagName("div");var R=W[0].getElementsByTagName("div");var Q;I.desc=false;for(var C=0;C<R.length;C++){if(R[C].className=="fade"){Q=R[C];I.fader=R[C]}if(R[C].className=="beschreibung"){I.desc=R[C];I.desc.m=p;if(p.desDir==0){I.desc.style.top=(I.desc.parentNode.offsetHeight)+"px"}if(p.desDir==1){I.desc.style.top=(0-I.desc.offsetHeight)+"px"}if(p.desDir==2||p.desDirV==0){I.desc.style.left=(I.desc.parentNode.offsetWidth)+"px"}if(p.desDir==3){I.desc.style.left="-"+(I.desc.offsetWidth)+"px"}var H=I.desc.getElementsByTagName("div");I.desc.beBa=H[0];I.desc.beTe=H[1];p.horizon.setOpacity(I.desc.beBa,l);I.desc.beBa.style.width=I.desc.offsetWidth+"px";I.desc.beBa.style.height=I.desc.offsetHeight+"px";I.desc.s=I;I.desc.beBa.s=I;this.setClick(I.desc.beBa)}if(R[C].className=="imageB"){I.fadeInImg=R[C];p.horizon.setOpacity(I.fadeInImg,0);I.fadeInImg.s=I;this.setClick(I.fadeInImg)}if(R[C].className=="image"){I.img=R[C];I.img.s=I;this.setClick(I.img)}}I.num=N;this.setOpacity(Q,0);if(N==O-1){p.actual=I}this.timerFade(I)}if(O!=null){p.over=c[O-1];p.actual=c[O-1]}p.timerFade=setInterval(function(){p.horizon.fade(false)},j);p.onmouseout=function(){if(t){p.actual=false}p.lastOver=p.over;p.over=false;p.autoPlayPause=false};if(p.autoPlayOn){p.horizon.startAutoPlay()}return(this)};this.setClick=function(l){if(p.clickEffect){l.onclick=function(){p.slideEnded=false;l=this.s;if(p.clickStopsAutoPlay){p.horizon.stopAutoPlay()}if(l==p.actual&&!z){var m=-1;for(var t=0;t<q;t++){var w=c[t];if(w==p.actual&&m==-1){m=parseInt(t)}}if(n==0){if(m<q-1&&m!=-1){p.actual=c[m+1];l=c[m+1]}else{p.actual=c[0];l=c[0]}}else{if(m>0&&m!=-1){p.actual=c[m-1];l=c[m-1]}else{p.actual=c[q-1];l=c[q-1]}}}else{p.actual=l}clearInterval(p.timerFade);p.timerFade=setInterval(function(){p.horizon.fade(l)},j)}}};this.fadeDesc=function(m){if(p.over){m=p.over.desc}else{if(p.actual){m=p.actual.desc}}var l=false;if(m&&(m.s==p.over||m.s==p.actual)&&m.parentNode.style.width>=m.parentNode.parentNode.style.width){l=p.horizon.moveIt(m,p.desDir,true)}p.horizon.clearDesc(m.s);p.returner=l;return(l)};this.clearDesc=function(w){if(p.over){w=p.over}else{if(p.actual){w=p.actual}}var m=true;for(var l=0;l<c.length;l++){var t=c[l].desc;if(t&&w!=t.s&&(!p.actual||t.s!=p.actual)){m=p.horizon.moveIt(t,p.desDir,false)}}return(m)};this.moveIt=function(H,t,C){var F=t;var E=true;var w;if(F==0){if(C){w=H.offsetHeight}else{w=0}var m=(H.parentNode.offsetHeight-w);var G=parseInt(H.style.top);if(G>m||(!C&&G<m)){var l;if(C){l=parseInt((G-m)/p.desSpeed)}else{l=parseInt((m-G)/p.desSpeed)}l=(l>0)?l:1;if(!C){l=l*-1}var D=G-l;if(D>m||(!C&&G<m)){H.style.top=D+"px"}else{H.style.top=m+"px";E=true}}}if(F==1){if(!C){w=H.offsetHeight}else{w=0}var m=0-w;var G=parseInt(H.style.top);if(G<m||(!C&&G>m)){var l;if(C){l=parseInt((m-G)/p.desSpeed)}else{l=parseInt((G-m)/p.desSpeed)}l=(l>0)?l:1;if(!C){l=l*-1}var D=G+l;if(D<m||(!C&&G>m)){H.style.top=D+"px"}else{H.style.top=m+"px";E=true}}}if(F==2||p.desDirV==0){if(C){w=H.offsetWidth}else{w=0}var m=(H.parentNode.offsetWidth-w);var G=parseInt(H.style.left);if(G>m||(!C&&G<m)){var l;if(C){l=parseInt((G-m)/p.desSpeed)}else{l=parseInt((m-G)/p.desSpeed)}l=(l>0)?l:1;if(!C){l=l*-1}var D=G-l;if(D>m||(!C&&G<m)){H.style.left=D+"px"}else{H.style.left=m+"px";E=true}}}if(F==3){if(!C){w=H.offsetWidth}else{w=0}var m=0-w;var G=parseInt(H.style.left);if(G<m||(!C&&G>m)){var l;if(C){l=parseInt((m+-G)/p.desSpeed)}else{l=parseInt((G-m)/p.desSpeed)}l=(l>0)?l:1;if(!C){l=l*-1}var D=G+l;if(D<m||(!C&&G>m)){H.style.left=D+"px"}else{H.style.left=m+"px";E=true}}}return(E)};this.timerFade=function(l){l.onmouseover=function(){p.over=l;p.autoPlayPause=true;if((!p.lastOver&&!p.over)||(p.lastOver.num&&p.lastOver.num!=p.over.num)){clearInterval(p.timerFade);p.timerFade=setInterval(function(){p.horizon.fade(l)},j)}p.lastOver=l}};this.startAutoPlay=function(){if(p.autoPlay){clearInterval(p.autoPlay)}p.over=false;p.autoPlay=setInterval(function(){p.horizon.autoPlay()},p.autoPlaySpeed)};this.stopAutoPlay=function(){if(p.autoPlay){clearInterval(p.autoPlay)}};this.autoPlay=function(){if(!p.autoPlayPause){if(!p.actual){p.actual=c[c.length-1]}var l=p.actual.num;var m=false;if(n==0){if(l<q-1&&l!=-1){p.actual=c[l+1];m=c[l+1]}else{p.actual=c[0];m=c[0]}}else{if(l>0&&l!=-1){p.actual=c[l-1];m=c[l-1]}else{p.actual=c[q-1];m=c[q-1]}}clearInterval(p.timerFade);p.timerFade=setInterval(function(){p.horizon.fade(m)},j)}};this.slide=function(O){var L=p.list_width;p.slideEnded=false;if(O==undefined){O=false}if(O.style){var F=parseInt(O.style.width)}if(O==false&&p.even==true&&!p.actual||(p.actual==undefined&&!O)){p.horizon.clearDesc(O);p.slideEnded=true;var N=new Array();var m=new Array();var M=0;for(var G=0;G<q;G++){t=c[G];w=parseInt(t.style.width);if(w<L){m[m.length]=t;M=M+parseInt(t.style.width)}else{if(w>=L){N[N.length]=t}}}var E=i;for(var G=0;G<N.length;G++){var t,w,C;var K=0;t=N[G];w=parseInt(t.style.width);K=(w-L)/x;K=(K>0)?K:1;if(w-K>L){C=w-K;p.slideEnded=false}else{C=L}t.style.width=(C)+"px";E=E-C}var I=m.length;K=Math.floor((E-M)/I);K=(K>0)?K:1;for(var G=0;G<m.length;G++){t=m[G];w=parseInt(t.style.width);if(w+K<=L){C=w+K;if(w+K!=L){p.slideEnded=false}}else{C=L}if(G==m.length-1){t.style.width=(E)+"px"}else{t.style.width=(C)+"px";E=E-C}}}else{if(F<o||(O==false&&p.actual&&parseInt(p.actual.style.width)<o)){p.horizon.clearDesc(O);var J=0;var G=0;var l=r;for(G;G<q;G++){if(c[G]!=O||(O==false&&c[G]!=p.actual)){var t,w;var K=0;t=c[G];w=parseInt(t.style.width);if(w>f){K=Math.floor((w-f)/x);K=(K>0)?K:1;var H=w-K;if(H==f&&l>0){H++;l--;K--}t.style.width=(H)+"px"}J=J+(w-K)}}if(O.style){O.style.width=(i-J)+"px"}else{if(O==false&&p.actual){var D=parseInt(i);for(var G=0;G<q;G++){if(c[G]!=p.actual){D=D-parseInt(c[G].style.width)}}p.actual.style.width=(D)+"px"}}}else{p.slideEnded=true;if(p.actual&&p.actual.desc){p.actual.desc.aktiv=true;p.slideEnded=p.horizon.fadeDesc(p.actual.desc)}if((O&&O.desc)&&O!=p.actual){O.desc.aktiv=true;p.slideEnded=p.horizon.fadeDesc(O.desc)}}}};this.fade=function(H){if((z||d)){if(p.over!=false&&z){p.horizon.slide(p.over)}else{if(d&&H==false){p.actual=false;p.over=false}if(p.even&&H==false){p.horizon.slide(false)}else{if(p.actual){p.horizon.slide(p.actual)}else{p.horizon.slide(false)}}}}else{if(p.actual){p.horizon.slide(p.actual)}}var w=0;var F=p.getElementsByTagName("li");var t=F.length;var C=1;for(w;w<t;w++){var D;var E=F[w];D=this.getOpacity(E.fader);if(E!=p.actual){if(D<B){E.fader.style.display="block";D=D+0.04;this.setOpacity(E.fader,D);if(D<B){C=0}}if(E.fadeInImg&&E!=p.over){var m=this.getOpacity(E.fadeInImg);m=m-0.04;m=(m>0)?m:0;this.setOpacity(E.fadeInImg,m);if(m>0){C=0}}}}if(p.actual){D=D-e;if(p.actual.fader.style.display!="none"){this.setOpacity(p.actual.fader,0);p.actual.fader.style.display="none"}if(p.actual.fadeInImg){var m=this.getOpacity(p.actual.fadeInImg);m=m+0.04;if(m<1){this.setOpacity(p.actual.fadeInImg,m);if(m<1){C=0}}else{this.setOpacity(p.actual.fadeInImg,1)}}}if(p.over){var D;D=this.getOpacity(p.over.fader);if(D>0){D=D-e;if(p.over.fader.style.display!="none"){this.setOpacity(p.over.fader,0);p.over.fader.style.display="none"}}if(p.over.fadeInImg){var m=this.getOpacity(p.over.fadeInImg);m=m+0.04;m=(m<1)?m:1;if(m<1){this.setOpacity(p.over.fadeInImg,m);if(m<1){C=0}}else{this.setOpacity(p.over.fadeInImg,1)}}}var G=true;if(p.actual){G=p.horizon.clearDesc(p.actual)}if(C==1&&G&&(p.slideEnded||(p.slideEnded==undefined&&p.even))){p.over=false;p.lastOver=false}};this.setOpacity=function(l,m){if(p.ie){var t=parseInt(m*100);if(t>(100)){t=100}l.style.filter="alpha(opacity="+t+")"}else{l.style.opacity=m}};this.getOpacity=function(l){var m;if(p.ie){m=parseInt(parseFloat(l.style.filter.replace(/[\D\.]/g,"")))/100}else{m=parseFloat(l.style.opacity)}return(m)}};
