var dkicare = {
	pordlist: (function(w, d) {
		function getId(id) {
			return d.getElementById(id);
		};
		var
			index = 0,
			scrollDiv,
			container,
			width = 290,
			indicator = null,
			currentIndex = 0,
			autorun = !w.core,
			fx = new secoya.fx({
			    from: 0,
			    to: 0,
			    duration: w.core ? 0.3 : 1,
			    type: secoya.fx.power,
			    callback: function(x) {
			        scrollDiv.scrollLeft = x + index*width;
			    }
			});
		function getLength() {
			var length = (!!w.core)+0;
			var items = scrollDiv.getElementsByTagName('div');
			for (var c = 0; c < items.length; c++) {
				if (items[c].className == "itemSpot")
					length++;
			}
			return length;
		};
		function create() {
			return secoya.dom.createElement.apply(secoya.dom, arguments);
		};
		function selectIndex(move) {
			var length = indicator.childNodes.length;
			indicator.childNodes[currentIndex].className = '';
			currentIndex = (currentIndex+move) % length;
			if (currentIndex < 0)
				currentIndex += length;

			indicator.childNodes[currentIndex].className = 'selected';

			if (fx.running) {
				fx.resetToEnd();
				fx.finish();
			}
			if (move < 0) {
				fx.finish = function() {
					while (move++) {
						container.appendChild(container.firstChild);
					}
					scrollDiv.scrollLeft = 0;
				};
				fx.from = 0;
				fx.to = -width * move;
			} else {
				fx.from = width * move;
				while (move--) {
					container.insertBefore(container.lastChild, container.firstChild);
				}
				fx.to = 0;
				scrollDiv.scrollLeft = fx.from;
				fx.finish = function(){};
			}
			fx.start();
		};
		function createIndicators(parent) {
			function createDot(index) {
				return create('div', {
					onclick:function(){
						var l = this.parentNode.childNodes.length;
						var x = index-currentIndex;
						if (Math.abs(x) > l/2)
							if (x < 0)
								x += l;
							else
								x -= l;
						selectIndex(x);
					}
				});
			};
			var length = getLength();
			indicator = create('div', {className: 'indicator'});
			for (var i = 0; i < length; i++) {
				indicator.appendChild(createDot(i));
			}
			indicator.firstChild.className = 'selected';
			parent.appendChild(indicator);
		};
		return function(){
			scrollDiv = getId('contentInnerWrapper');
			container = getId('content');
			container.style.width = getLength() * width + 'px';
			var left = getId('leftlist');
			var right = getId('rightlist');
			if (!right)
				return;
			left.onclick = function() {
				if (index > 0) {
					if (fx.running)
						fx.resetToEnd();
					index--;
					fx.from = width;
					fx.to = 0;
					fx.start();
				}
			};
			right.onclick = function() {
				var length = getLength();
				container.style.width = length * width + 'px';
				if (index < length-3) { // we show 3 items
					if (fx.running)
						fx.resetToEnd();
					index++;
					fx.from = -width;
					fx.to = 0;
					fx.start();
				}
			};
			if (autorun) {
				createIndicators(scrollDiv.parentNode);
				for (var i = container.childNodes.length-1; i >= 0; i--) {
					if (container.childNodes[i].nodeType != 1)
						container.removeChild(container.childNodes[i]);
				}
				left.onclick = function() {
					selectIndex(3);
				};
				right.onclick = function(arg) {
					selectIndex(-3);
				};
				var intervalId = setInterval(function(){
					if (!autorun) {
						clearInterval(intervalId);
					} else {
						var i = index;
						right.onclick(true);
					}
				}, 6000);
				autorun = false;
			}
		};
	})(window, document)
};
