function timerEvent () {
	if (active) {
		var temp = window.location.hash.substr(1);
		var pos = $.inArray(temp, products);
		pos = pos < 0 ? 0 : pos;
		if (time == 0) {
			if (pos == total) pos = 0;
			else pos++;
		} else {
			time--;
		}
		temp = products[pos];
		
		if (temp != hash) {
			$('#productnav_' + hash).removeClass('active');
			$('#productlist_' + hash).fadeOut();
			hash = temp;
			$('#productnav_' + hash).addClass('active');
			$('#productlist_' + hash).fadeIn();
			time = interval;
			window.location.hash = hash;
		}
	}
}
function getProducts () {
	var temp = $(this).attr('id').split('_');
	products.push(temp[1]);
}
function mouseHandler () {
	active = !active;
}
function init () {
	$('#productlist li').each(getProducts);
	total = products.length - 1;
	$('#productlist').mouseover(mouseHandler).mouseout(mouseHandler);
	timer = setInterval('timerEvent()', 500);
}

var active = true;
var products = new Array();
var total;
var hash = '';
var timer;
var interval = 10 * 2; //Sekunder * 2!
var time = interval;

$(document).ready(init);

