window.dkinternational = (function(w, d){
	function getId(id) {
		return d.getElementById(id);
	};
	function create() {
		return secoya.dom.createElement.apply(secoya.dom, arguments);
	};
	return {
		slideshow: (function(){
			var domDots;
			var topNode;
			var parent;
			var autorun = !w.core;
			function selectIndex(newNode, dot) {
				if (newNode != topNode) {
					var d;
					for (var i = 0; i < domDots.childNodes.length; i++) {
						d = domDots.childNodes[i];
						d.className = d == dot ? 'dot selected' : 'dot';
					}
					topNode.style.zIndex = 5;
					newNode.style.zIndex = 10;
					(new secoya.fx({
						from: 0,
						to: 100,
						duration: 0.5,
						callback: function(x) {
							lightCore.setOpacity(newNode, x);
						},
						finish: function() {
							topNode.style.zIndex = 2;
							topNode = newNode;
						}
					})).start();
				}
			};
			function createDots() {
				function createDot(item) {
					return create('div', {
						className: 'dot',
						onclick: function(arg){
							selectIndex(item, this);
							if (typeof arg !== 'boolean')
								autorun = false;
						}
					});
				};
				if (domDots && domDots.parentNode) {
					domDots.parentNode.removeChild(domDots);
				}
				domDots = create('div', {className: 'dots'});
				var items = parent.getElementsByTagName('div');
				for (var i = 0; i < items.length; i++) {
					if (items[i].className == 'spot') {
						if (!topNode) {
							topNode = items[i];
							topNode.style.zIndex = 10;
						}
						domDots.appendChild(createDot(items[i]));
					}
				}
				domDots.firstChild.className = 'dot selected';
				return domDots;
			};
			return function(){
				parent = getId('spot2');
				parent.parentNode.appendChild(createDots());
				if (autorun && domDots.childNodes.length > 1) {
					var index = 0;
					var intervalId = setInterval(function(){
						if (autorun) {
							if (index < domDots.childNodes.length-1) {
								index++;
							} else {
								index = 0;
							}
							domDots.childNodes[index].onclick(true);
						} else {
							clearInterval(intervalId);
						}
					}, 6000);
				}
			};
		})(),
		showImage: function(div) {
		    var img = div.getElementsByTagName('img')[0];
		    if (img) {
		        var src = img.src.replace(/\/([a-z]+\.[a-z]+).(jpg|gif|png)/, '/version0.$2');
		        img = document.createElement('img');
		        img.src = src;
		        img.className = 'previewImage';
		        img.onclick = function() {
		            this.parentNode.removeChild(this);
		        }
		        document.getElementById('main').appendChild(img);
		    }
		}
	};
})(window, document);
