/*
 * negetics.ps.02.js
 *
 * Javascript Class - where the magic happens ;)
 *
 * @package      negetics "Presentation Slider"
 * @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/GPLv2 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(J,L,D,O,B,U,T,W,N,E,V,l,K,t,G,w){o=document.getElementById(J);n=o.offsetWidth;i=L;v=D;O=O;y=B;o.clickEffect=true;k=U;e=T;A=W;c=o.getElementsByTagName("li");p=c.length;h=o.offsetWidth;o.heigh=parseInt(o.style.height);o.padding=G;o.handleWidth=t;o.slideMinWidth=t+o.padding;o.slideMin=K;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=N;o.autoPlayPause=false;o.clickStopsAutoPlay=E;o.autoPlaySpeed=V;if(O!=null){o.actual=c[O-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(L*2);v=parseInt(D/2)}o.horizon=this;for(var P=0;P<p;P++){var I=c[P];I.style.width=o.list_width+"px";var X=I.getElementsByTagName("div");var S=X[0].getElementsByTagName("div");if(P!=0){X[0].style.marginLeft=(o.padding)+"px"}if(K){X[0].style.width=(o.slideO)+"px"}if(o.slideMin){X[0].style.width=o.slideO+"px"}var Q;I.desc=false;for(var C=0;C<S.length;C++){if(S[C].className=="nePSf"){Q=S[C];I.fader=S[C]}if(S[C].className=="nePSb"){I.desc=S[C];I.desc.m=o;if(o.handleWidth>0){I.desc.style.paddingLeft=o.handleWidth+"px"}if(o.slideMin){I.desc.style.width=(o.slideO-o.handleWidth)+"px"}I.desc.style.top="0px";I.desc.style.left="0px";var F=I.desc.getElementsByTagName("div");I.desc.beBa=F[0];I.desc.beTe=F[1];o.horizon.setOpacity(I.desc.beBa,l);I.desc.beBa.style.width=(o.slideO-o.handleWidth)+"px";if(o.ie){I.desc.beTe.style.width=(o.slideO-o.handleWidth)+"px"}I.desc.beBa.style.height=I.desc.offsetHeight+"px";I.desc.s=I;I.desc.beBa.s=I}if(S[C].className=="nePSi"){I.img=S[C];I.img.s=I;if(o.handleWidth>0){I.img.style.backgroundPosition=o.handleWidth+"px 0px"}if(o.slideMin){I.img.style.width=(o.slideO)+"px"}}var H=S[C].parentNode.getElementsByTagName("img");var m=new Array();for(var M=0;M<H.length;M++){if(H[M].className=="handle"){m[m.length]=H[M]}}if(m.length>0){var R=m[0];I.handle=R;I.handle.s=I;this.setClick(I.handle)}}I.num=P;this.setOpacity(Q,0);if(P==O-1){o.actual=I}this.timerFade(I)}if(O!=null){o.over=c[O-1];o.actual=c[O-1]}o.timerFade=setInterval(function(){o.horizon.fade(false)},i);o.onmouseout=function(){o.lastOver=o.over;o.over=false;o.autoPlayPause=false};if(w){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(C){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 B=0;var m=o.getElementsByTagName("li");var t=m.length;var w=1;for(B;B<t;B++){var F;var E=m[B];F=this.getOpacity(E.fader);if(E!=o.actual){if(F<A){E.fader.style.display="block";F=F+e;this.setOpacity(E.fader,F);if(F<A){w=0}}if(E.fadeInImg&&E!=o.over){var D=this.getOpacity(E.fadeInImg);D=D-e;D=(D>0)?D:0;this.setOpacity(E.fadeInImg,D);if(D>0){w=0}}}}if(o.actual){F=F-e;if(o.actual.fader.style.display!="none"){this.setOpacity(o.actual.fader,0);o.actual.fader.style.display="none"}if(o.actual.fadeInImg){var D=this.getOpacity(o.actual.fadeInImg);D=D+e;if(D<1){this.setOpacity(o.actual.fadeInImg,D);if(D<1){w=0}}else{this.setOpacity(o.actual.fadeInImg,1)}}}if(o.over){var F;F=this.getOpacity(o.over.fader);if(F>0){F=F-e;if(o.over.fader.style.display!="none"){this.setOpacity(o.over.fader,0);o.over.fader.style.display="none"}}if(o.over.fadeInImg){var D=this.getOpacity(o.over.fadeInImg);D=D+e;D=(D<1)?D:1;if(D<1){this.setOpacity(o.over.fadeInImg,D);if(D<1){w=0}}else{this.setOpacity(o.over.fadeInImg,1)}}}if(w==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)}};
