﻿function ContentCarousel(f,m){var k,g;var h,d,n,c,l,j,e;if(this._isString(m)){g=document.getElementById(m)}else{g=m}if(this._isString(f)){k=document.getElementById(f)}else{if(f.nodeType!=1){if(this._isString(f.content)){k=document.getElementById(f.content)}else{k=f.content}if(f.controls!=null){if(this._isString(f.controls)){g=document.getElementById(f.controls)}else{g=f.controls}}d=f.loop;n=f.displayTime;c=f.fadeSteps;l=f.fadeTime;j=f.userPauseTime;h=f.autoStart;e=f.autoStartAfterDelay}else{k=f}}this._containerElement=k;this._containerElement.style.position="relative";this._blocks=new Array();for(var b=0;b<this._containerElement.childNodes.length;b++){var a=this._containerElement.childNodes[b];if(a.nodeType==8){continue}if(a.nodeType==3&&!a.nodeValue.match(/\w+/)){continue}this._blocks.push(new ContentCarouselBlock(this._containerElement.childNodes[b]))}this.blockCount=this._blocks.length;if(g!=null){this._controls=new ContentCarouselControls(g,this)}this._currentBlock=this._blocks[0];this._currentBlock.display();this._containerElementSizer=document.createElement("div");this._containerElement.appendChild(this._containerElementSizer);this._sizeContainer();this._buildTransitions();if(d!=null){this.setLoop(d)}if(n!=null){this.setDisplayTime(n)}if(c!=null){this.setFadeSteps(c)}if(l!=null){this.setFadeTime(l)}if(j!=null){this.setUserPauseTime(j)}if(e!=null){this._delayedStart(e)}if(h!=null&&h===true&&e==null){this._start()}}ContentCarousel.prototype._displayTimer=null;ContentCarousel.prototype._displayTime=1000;ContentCarousel.prototype._fadeTime=250;ContentCarousel.prototype._fadeSteps=10;ContentCarousel.prototype._userPauseTime=5000;ContentCarousel.prototype._loop=true;ContentCarousel.prototype._blocks=null;ContentCarousel.prototype._transitionsHead=null;ContentCarousel.prototype._currentTransition=null;ContentCarousel.prototype._currentBlock=null;ContentCarousel.prototype._controls=null;ContentCarousel.prototype._running=false;ContentCarousel.prototype._containerElement=null;ContentCarousel.prototype._containerElementSizer=null;ContentCarousel.prototype.blockCount=0;ContentCarousel.prototype.start=function(){this._stop();this._start()};ContentCarousel.prototype.delayedStart=function(a){this._stop();this._delayedStart(a)};ContentCarousel.prototype.resume=function(){this._stop();this._delayedStart(0)};ContentCarousel.prototype.stop=function(){this._stop()};ContentCarousel.prototype.next=function(){var a=this._running;this._stop();this._next();if(a){this._delayedStart(this._userPauseTime)}};ContentCarousel.prototype.previous=function(){var a=this._running;this._stop();this._previous();if(a){this._delayedStart(this._userPauseTime)}};ContentCarousel.prototype.jump=function(b){var c=this._running;this._stop();var a=this._transitionToIndex(b);if(c){this._delayedStart(this._userPauseTime)}return a};ContentCarousel.prototype._start=function(){this._delayedStart(this._displayTime)};ContentCarousel.prototype._delayedStart=function(a){var b=this;this._running=true;this._displayTimer=setTimeout(function(){b._autoNext()},a)};ContentCarousel.prototype._stop=function(){clearTimeout(this._displayTimer);this._running=false};ContentCarousel.prototype._autoNext=function(){var a=this;if(this._next()){this._displayTimer=setTimeout(function(){a._autoNext()},this._displayTime+this._fadeTime)}};ContentCarousel.prototype._next=function(){if(this._currentTransition==null){this._currentTransition=this._transitionsHead}else{if(this._currentTransition.data.inProgress){return true}}if(this._currentTransition.data.controlsBlock!=null){this._currentTransition.data.controlsBlock.normal();this._currentTransition.data.controlsBlock.enableHover()}this._currentTransition=this._currentTransition._next;if(this._currentTransition==null){return false}this._currentTransition.data.fade(this._currentBlock);this._currentBlock=this._currentTransition.data._targetBlock;this._sizeContainer();return true};ContentCarousel.prototype._previous=function(){if(this._currentTransition==null){this._currentTransition=this._transitionsHead}else{if(this._currentTransition.data.inProgress){return true}}if(this._currentTransition.data.controlsBlock!=null){this._currentTransition.data.controlsBlock.normal();this._currentTransition.data.controlsBlock.enableHover()}this._currentTransition=this._currentTransition._previous;if(this._currentTransition==null){return false}this._currentTransition.data.fade(this._currentBlock);this._currentBlock=this._currentTransition.data._targetBlock;this._sizeContainer();return true};ContentCarousel.prototype._transitionToIndex=function(a){if(this._currentTransition!=null&&this._currentTransition.data.inProgress){return false}var c=this._transitionsHead;for(var b=0;b<a&&c!=null;b++){c=c._next}if(c==null||c.data._targetBlock==this._currentBlock){return true}if(this._controls!=null){if(this._currentTransition!=null&&this._currentTransition.data.controlsBlock!=null){this._currentTransition.data.controlsBlock.normal();this._currentTransition.data.controlsBlock.enableHover()}else{this._controls.revertAll()}}this._currentTransition=c;this._currentTransition.data.fade(this._currentBlock);this._currentBlock=this._currentTransition.data._targetBlock;this._sizeContainer();return true};ContentCarousel.prototype.setLoop=function(a){this._loop=a;this._buildTransitions()};ContentCarousel.prototype.getLoop=function(){return this._loop};ContentCarousel.prototype.setDisplayTime=function(a){this._displayTime=a};ContentCarousel.prototype.getDisplayTime=function(){return this._displayTime};ContentCarousel.prototype.setFadeSteps=function(a){this._fadeSteps=a;this._buildTransitions()};ContentCarousel.prototype.getFadeSteps=function(){return this._fadeSteps};ContentCarousel.prototype.setFadeTime=function(a){this._fadeTime=a;this._buildTransitions()};ContentCarousel.prototype.getFadeTime=function(){return this._fadeTime};ContentCarousel.prototype.setUserPauseTime=function(a){this._userPauseTime=a};ContentCarousel.prototype.getUserPauseTime=function(){return this._userPauseTime};ContentCarousel.prototype._buildTransitions=function(){this._transitionsHead=null;var b=null;var c=null;for(var a=0;a<this._blocks.length;a++){var d=null;if(this._controls!=null){d=this._controls.blocks[a]}c=new ContentCarouselList(new ContentCarouselTransition(this._blocks[a],this._fadeTime,this._fadeTime/this._fadeSteps,1/this._fadeSteps,d));if(b!=null){b._next=c;c._previous=b}if(this._transitionsHead==null){this._transitionsHead=c}b=c}if(this._loop&&b!=null){b._next=this._transitionsHead;this._transitionsHead._previous=b}};ContentCarousel.prototype._sizeContainer=function(){this._containerElementSizer.style.width=this._currentBlock.element.clientWidth+"px";this._containerElementSizer.style.height=this._currentBlock.element.clientHeight+"px"};ContentCarousel.prototype._isString=function(b){if(typeof b=="string"){return true}if(typeof b=="object"){if(b.constructor==null){return false}var a=b.constructor.toString().match(/function string\(/i);return(a!=null)}return false};function ContentCarouselControls(c,f){var b,e,a=0;this.blocks=new Array();if(c instanceof Array){for(var g=0;g<c.length;g++){if(c[g]==null){continue}this.blocks.push(new ImageControlsFunction(c[g].normal,c[g].active,g))}}else{if(c.nodeType==1){for(var d=0;d<c.childNodes.length;d++){if(c.childNodes[d].nodeType==1){b=c.childNodes[d];do{d++}while(c.childNodes[d].nodeType!=1);e=c.childNodes[d];this.blocks.push(new ImageControlsBlock(b,e,f,a));a++}}}else{for(var g=0;g<f.blockCount;g++){this.blocks.push(new ImageControlsFunction(c.normal,c.active,g))}}}this.blocks[0].active();this.blocks[0].disableHover();this.revertAll=function(){for(var h=0;h<this.blocks.length;h++){this.blocks[h].normal();this.blocks[h].enableHover()}}}ContentCarouselControls.prototype.blocks=null;function ImageControlsBlock(c,b,e,a){this._elementNormal=c;this._elementActive=b;this._faderObject=e;this._imageIndex=a;var d=this;this._elementActive.onclick=function(){d._click()};this.enableHover();this.normal()}ImageControlsBlock.prototype._elementNormal=null;ImageControlsBlock.prototype._elementActive=null;ImageControlsBlock.prototype._faderObject=null;ImageControlsBlock.prototype._imageIndex=0;ImageControlsBlock.prototype.active=function(){this._elementNormal.style.display="none";this._elementActive.style.display="inline"};ImageControlsBlock.prototype.normal=function(){this._elementActive.style.display="none";this._elementNormal.style.display="inline"};ImageControlsBlock.prototype._click=function(){this._faderObject.jump(this._imageIndex)};ImageControlsBlock.prototype.disableHover=function(){this._elementNormal.onmouseover=null;this._elementActive.onmouseout=null};ImageControlsBlock.prototype.enableHover=function(){var a=this;this._elementNormal.onmouseover=function(){a.active()};this._elementActive.onmouseout=function(){a.normal()}};function ImageControlsFunction(c,b,a){this._functionNormal=c;this._functionActive=b;this._index=a}ImageControlsFunction.prototype._functionNormal=null;ImageControlsFunction.prototype._functionActive=null;ImageControlsFunction.prototype._index=null;ImageControlsFunction.prototype.active=function(){if(this._functionActive){this._functionActive(this._index)}};ImageControlsFunction.prototype.normal=function(){if(this._functionNormal){this._functionNormal(this._index)}};ImageControlsFunction.prototype.disableHover=function(){};ImageControlsFunction.prototype.enableHover=function(){};function ContentCarouselBlock(a){this.element=a;this.element.style.position="absolute";this.element.style.top="0px";this.element.style.left="0px";this.element.style.width="100%";this.element.style.height="100%";this.element.style.height="auto";this.element.style.display="none";this.element.style.opacity="1.0";this.element.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity = 100)";this.element.style.zIndex="0";if(this.element.filters!=null){this._useFilters=true}}ContentCarouselBlock.prototype.element=null;ContentCarouselBlock.prototype._useFilters=false;ContentCarouselBlock.prototype.setOpacity=function(a){if(this._useFilters){this.element.filters.item("DXImageTransform.Microsoft.Alpha").opacity=a*100}else{this.element.style.opacity=a}};ContentCarouselBlock.prototype.display=function(){this.element.style.display="block"};ContentCarouselBlock.prototype.hide=function(){this.element.style.display="none"};function ContentCarouselTransition(d,a,b,c,e){this._fadeTime=a;this._fadeStepTime=b;this._fadeStepAmount=c;this._CurrentOpacity=1;this._startBlock=null;this._targetBlock=d;this.controlsBlock=e}ContentCarouselTransition.prototype._fadeTime=0;ContentCarouselTransition.prototype._fadeStepTime=0;ContentCarouselTransition.prototype._fadeStepAmount=0;ContentCarouselTransition.prototype._CurrentOpacity=1;ContentCarouselTransition.prototype._targetBlock=null;ContentCarouselTransition.prototype._startBlock=null;ContentCarouselTransition.prototype._fadeTimer=null;ContentCarouselTransition.prototype.inProgress=null;ContentCarouselTransition.prototype.controlsBlock=null;ContentCarouselTransition.ZIndex=65536;ContentCarouselTransition.prototype.fade=function(a){this.inProgress=true;this._startBlock=a;this._startBlock.element.style.zIndex="1";this._startBlock.setOpacity(1);this._startBlock.display();this._targetBlock.display();this._targetBlock.element.style.zIndex="0";if(this.controlsBlock!=null){this.controlsBlock.active();this.controlsBlock.disableHover()}this._fadeStep()};ContentCarouselTransition.prototype._fadeStep=function(a){var b=this;if(a==undefined){a=0}this._CurrentOpacity-=this._fadeStepAmount;this._startBlock.setOpacity(this._CurrentOpacity);if(a>=this._fadeTime){this._finalizeTransition()}else{this._fadeTimer=setTimeout(function(){b._fadeStep(a+b._fadeStepTime)},this._fadeStepTime)}};ContentCarouselTransition.prototype._finalizeTransition=function(){this._CurrentOpacity=1;this._startBlock.element.style.zIndex="0";this._startBlock.setOpacity(1);this._startBlock.hide();this.inProgress=false};function ContentCarouselList(a){this.data=a}ContentCarouselList.prototype.data=null;ContentCarouselList.prototype.next=null;ContentCarouselList.prototype.previous=null;
