hanken = {
    init: function() {
	    this.banner.init();
    },
	
	banner: {
		showTimer: 5, // in seconds
		fadeTimer: 1, // in seconds
		
		firstrun: true,
		data: null,
		count: 0,
		banner: null,
		
		init: function() {
			this.banner = $('#content-default-banner');
			this.count = this.getRandom();
			this.showBanner();
		},

		showBanner: function() {
			var self = this;
		
			if (!this.firstrun) {
				if(this.count==this.data.length) {
					this.count = 0;
				};
			
				this.banner.fadeOut(self.fadeTimer*1000, function() {
					self.setBannerHTML('image', self.count);
					self.banner.fadeIn(self.fadeTimer*1000, function() {
						self.count++;
						
						window.setTimeout(function() {
							self.showBanner();
						}, self.showTimer*1000);
					});
				});
				
				this.firstrun = false;
			}
			else {				
				this.setBannerHTML('image', self.count);
				this.count++;
				this.firstrun = false;
				
				window.setTimeout(function() {
					self.showBanner();
				}, self.showTimer*1000);
			};
		},
		
		setBannerHTML: function(type, count) {
			var dataEntry = this.data[count];
			var imageUrl = dataEntry[0];
			var linkUrl = dataEntry[1];
			
			this.banner
			.html('<img src="'+imageUrl+'" />')
			.unbind('click');
			
			if (linkUrl) {
				this.banner.click(function() {
					document.location = linkUrl;
				});
			};
		},
		
		getRandom: function() {
			return Math.floor(Math.random()*this.data.length);
		}
	}
};


