var kosk;
if (!kosk) kosk = {};
if (!kosk.logo) kosk.logo = {};

kosk.logo.item = function(imgsrc, imglink) {
	this.imgsrc = imgsrc;
	this.imglink = imglink;
}

kosk.logo.logos = function(id, interval) {
	this.el = document.getElementById(id);
	this.list = new Array();
	this.interval = interval;
}

kosk.logo.logos.prototype.add = function(img, uri) {
	this.list.push(new kosk.logo.item(img, uri));
}

kosk.logo.logos.prototype.start = function() {
	var self = this;
	this.current = -1;
	this.update();
	this.timer = setInterval(function() { self.update() }, this.interval);
}

kosk.logo.logos.prototype.update = function() {
	var self = this;
	var l = this.list.length;
	var ix = Math.floor(new Date().getTime() / this.interval) % l;
	if(this.current == ix) return;
	while (this.el.firstChild)
		this.el.removeChild(this.el.firstChild);
	var img = document.createElement('img');
	img.src = this.list[ix].imgsrc;
	img.onclick = function () {window.open(self.list[ix].imglink,'_blank');}
	this.el.appendChild(img);
}

