/*
 * negetics.ps.02.js
 *
 * Javascript Class - where the magic happens ;)
 *
 * @package      negetics "Presentation Slider Slim"
 * @version      0.2.0_RC1
 *
 * @description  A horizontal Presentation Slider
 *
 * @author       Jan Jost <support@negetics.de>
 * @link         http://www.negetics.de
 * @linkProject  http://extensions.negetics.de
 * @copyright    Copyright (C) 2010 Jan Jost! All Rights Reserved
 * @license      GNU/GPL see GPL.txt / license.txt
*/
function negeticsPresentationSlider(){var o,n,i,v,y,x,k,d,e,A,c,p,h,u,j,q,f,b,z,a,r,g;this.build=function(L,N,E,R,C,W,V,Y,P,F,X,l,M,t,H,B){o=document.getElementById(L);n=o.offsetWidth;i=N;v=E;R=R;y=C;o.clickEffect=true;k=W;e=V;A=Y;var K=o.getElementsByTagName("li");c=new Array();var w=0;for(var Q=0;Q<K.length;Q++){if(K[Q].parentNode.id==L){c[w]=K[Q];w++}}p=c.length;h=o.offsetWidth;o.heigh=parseInt(o.style.height);o.padding=H;o.handleWidth=t;o.slideMinWidth=t+o.padding;o.slideMin=M;o.slideO=h-(((p-1)*o.slideMinWidth));if(o.slideMin){n=o.slideO}l=l;o.desSpeed=b;o.over=false;o.active=false;o.list_width=h/p;o.desDir=1;o.desDirH=1;o.lastOver=false;o.lastOut=false;o.firstActive=o.active;o.autoPlayOn=P;o.autoPlayPause=false;o.clickStopsAutoPlay=F;o.autoPlaySpeed=X;if(R!=null){o.actual=c[R-1]}if(navigator.appName.indexOf("Microsoft")!=-1){o.ie=true}else{o.ie=false}if(navigator.userAgent.indexOf("Mozilla")!=-1){o.mozilla=true}else{o.mozilla=false}if(navigator.userAgent.indexOf("Firefox")==-1){i=parseInt(N*2);v=parseInt(E/2)}o.horizon=this;for(var Q=0;Q<p;Q++){var J=c[Q];J.style.width=o.list_width+"px";var Z=J.getElementsByTagName("div");var U=Z[0].getElementsByTagName("div");if(Q!=0){Z[0].style.marginLeft=(o.padding)+"px"}if(M){Z[0].style.width=(o.slideO)+"px"}if(o.slideMin){Z[0].style.width=o.slideO+"px"}var S;J.desc=false;for(var D=0;D<U.length;D++){if(U[D].className=="nePSf"){S=U[D];J.fader=U[D]}if(U[D].className=="nePSb"){J.desc=U[D];J.desc.m=o;if(o.handleWidth>0){J.desc.style.paddingLeft=o.handleWidth+"px"}if(o.slideMin){J.desc.style.width=(o.slideO-o.handleWidth)+"px"}J.desc.style.top="0px";J.desc.style.left="0px";var G=J.desc.getElementsByTagName("div");J.desc.beBa=G[0];J.desc.beTe=G[1];o.horizon.setOpacity(J.desc.beBa,l);J.desc.beBa.style.width=(o.slideO-o.handleWidth)+"px";if(o.ie){J.desc.beTe.style.width=(o.slideO-o.handleWidth)+"px"}J.desc.beBa.style.height=J.desc.offsetHeight+"px";J.desc.s=J;J.desc.beBa.s=J}if(U[D].className=="nePSi"){J.img=U[D];J.img.s=J;if(o.handleWidth>0){J.img.style.backgroundPosition=o.handleWidth+"px 0px"}if(o.slideMin){J.img.style.width=(o.slideO)+"px"}}var I=U[D].parentNode.getElementsByTagName("img");var m=new Array();for(var O=0;O<I.length;O++){if(I[O].className=="handle"){m[m.length]=I[O]}}if(m.length>0){var T=m[0];J.handle=T;J.handle.s=J;this.setClick(J.handle)}}J.num=Q;this.setOpacity(S,0);if(Q==R-1){o.actual=J}this.timerFade(J)}if(R!=null){o.over=c[R-1];o.actual=c[R-1]}o.timerFade=setInterval(function(){o.horizon.fade(false)},i);o.onmouseout=function(){o.lastOver=o.over;o.over=false;o.autoPlayPause=false};if(B){this.setMouseWheel(o)}if(o.autoPlayOn){o.horizon.startAutoPlay()}return(this)};this.setClick=function(l){if(o.clickEffect||(l.s.handle&&l.s.handle==l)){l.onclick=function(){o.slideEnded=false;l=this.s;if(o.clickStopsAutoPlay){o.horizon.stopAutoPlay()}if(l==o.actual&&!y){var m=-1;for(var t=0;t<p;t++){var w=c[t];if(w==o.actual&&m==-1){m=parseInt(t)}}if(k==0){if(m<p-1&&m!=-1){o.actual=c[m+1];l=c[m+1]}else{o.actual=c[0];l=c[0]}}else{if(m>0&&m!=-1){o.actual=c[m-1];l=c[m-1]}else{o.actual=c[p-1];l=c[p-1]}}}else{o.actual=l}clearInterval(o.timerFade);o.timerFade=setInterval(function(){o.horizon.fade(l)},i)}}};this.mouseWheel=function(t){var l;var w=0;if(!t){t=window.event}if(t.wheelDelta){w=t.wheelDelta/60}else{if(t.detail){w=-t.detail/2}}if(t.preventDefault){t.preventDefault()}else{t.returnValue=false}var m=0;if(w>0){m=1}var l=o.actual.num;if(m==0){if(l<p-1&&l!=-1){o.actual=c[l+1];s=c[l+1]}else{o.actual=c[0];s=c[0]}}else{if(l>0&&l!=-1){o.actual=c[l-1];s=c[l-1]}else{o.actual=c[p-1];s=c[p-1]}}o.over=o.actual;clearInterval(o.timerFade);o.timerFade=setInterval(function(){o.horizon.fade(s)},i)};this.setMouseWheel=function(l){if(window.addEventListener){l.addEventListener("DOMMouseScroll",o.horizon.mouseWheel,false);l.addEventListener("mousewheel",o.horizon.mouseWheel,false)}else{l.onmousewheel=o.horizon.mouseWheel}};this.timerFade=function(l){l.onmouseover=function(){o.over=l;o.autoPlayPause=true;if((!o.lastOver&&!o.over)||(o.lastOver.num&&o.lastOver.num!=o.over.num)){clearInterval(o.timerFade);o.timerFade=setInterval(function(){o.horizon.fade(l)},i)}o.lastOver=l}};this.startAutoPlay=function(){if(o.autoPlay){clearInterval(o.autoPlay)}o.over=false;o.autoPlay=setInterval(function(){o.horizon.autoPlay()},o.autoPlaySpeed)};this.stopAutoPlay=function(){if(o.autoPlay){clearInterval(o.autoPlay)}};this.autoPlay=function(){if(!o.autoPlayPause){if(!o.actual){o.actual=c[c.length-1]}var l=o.actual.num;var m=false;if(k==0){if(l<p-1&&l!=-1){o.actual=c[l+1];m=c[l+1]}else{o.actual=c[0];m=c[0]}}else{if(l>0&&l!=-1){o.actual=c[l-1];m=c[l-1]}else{o.actual=c[p-1];m=c[p-1]}}clearInterval(o.timerFade);o.timerFade=setInterval(function(){o.horizon.fade(m)},i)}};this.slide=function(I){var H=o.list_width;o.slideEnded=false;if(I==undefined){I=false}if(I.style){var w=parseInt(I.style.width)}var D=true;if(1>0){var F=0;var B=0;for(B;B<p;B++){if(c[B]!=I||(I==false&&c[B]!=o.actual)){var l,m;var G=0;l=c[B];C=o.slideMinWidth;var E=o.slideMinWidth;if(B==0){E=o.slideMinWidth-o.padding}m=parseInt(l.style.width);if(m>E){D=false;G=Math.floor((m-E)/v);G=(G>0)?G:1;var C=m-G;if(C<E){C=E}l.style.width=(C)+"px";if(B==0){C=C+o.padding}}F=F+C}}if(I.style){if(I!=c[0]){I.style.width=(h-F+o.padding)+"px"}else{I.style.width=(h-F+o.padding-o.padding)+"px"}}else{if(I==false&&o.actual){var t=parseInt(h);for(var B=0;B<p;B++){if(c[B]!=o.actual){t=t-parseInt(c[B].style.width)}}if(o.slideO>t){t=o.slideO}o.actual.style.width=(t)+"px"}}if(D){o.slideEnded=true;if(o.actual&&o.actual.desc){o.actual.desc.aktiv=true}if((I&&I.desc)&&I!=o.actual){I.desc.aktiv=true}}}};this.fade=function(t){if(y){if(o.over!=false&&y){o.horizon.slide(o.over)}else{if(o.actual){o.horizon.slide(o.actual)}else{o.horizon.slide(false)}}}else{if(o.actual){o.horizon.slide(o.actual)}}var m=0;var l=1;for(m;m<p;m++){var B;var w=c[m];B=this.getOpacity(w.fader);if(w!=o.actual){if(B<A){w.fader.style.display="block";B=B+e;this.setOpacity(w.fader,B);if(B<A){l=0}}}}if(o.actual){B=B-e;if(o.actual.fader.style.display!="none"){this.setOpacity(o.actual.fader,0);o.actual.fader.style.display="none"}}if(o.over){var B;B=this.getOpacity(o.over.fader);if(B>0){B=B-e;if(o.over.fader.style.display!="none"){this.setOpacity(o.over.fader,0);o.over.fader.style.display="none"}}}if(l==1){o.lastOver=false}};this.setOpacity=function(l,m){if(o.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(o.ie){m=parseInt(parseFloat(l.style.filter.replace(/[\D\.]/g,"")))/100}else{m=parseFloat(l.style.opacity)}return(m)}};
