function Slider(id, module, initpage) {
	this.SliderPage = 1;
	this.SliderMaxPage = 1;
	this.module = module;
	this.id = id;
	this.spacer = true;
	
	this.autoslidetime = 8500;
	
	if (this.module == "m03") {
		this.modulesperLine = 4
	}
	if (this.module == "m07") {
		this.spacer = false;
		this.modulesperLine = 1
	}
	$("#" + this.id + " .loader").hide();
	this.Init(initpage);
	var self = this;
	setTimeout(function () {self.SlideTimer();}, self.autoslidetime);
}

Slider.prototype.Init = function(page) {
	$("#" + this.id + " ." + this.module + "small").removeClass("height200");
	$("#" + this.id + " .loader").hide();
	var maxitems = $("#" + this.id + " ." + this.module + "small").length - 2;
	this.SliderMaxPage = maxitems / this.modulesperLine;
	var start = page;
	var ende = this.modulesperLine;
	if (start > 1) {
		start--;
		start = start * this.modulesperLine + 1;
	}
	ende = start + this.modulesperLine;
	$("#" + this.id + " ." + this.module + "sliderhead .pagenav").text(page + " / " + this.SliderMaxPage);  
	$("#" + this.id + " ." + this.module + "slidernav").show();
	var dc = 1;
	$("#" + this.id + " ." + this.module + "small").each(
			function(intIndex) {
				if (!$(this).hasClass("." + this.module + "slidernav") && intIndex >= start && intIndex < ende) {
						$(this).show();
					if (dc < this.modulesperLine && this.spacer == true) {
						$(this).next().show();
						dc++;
					}
					
					if ($(this).hasClass("m07small")) {
						$($(this).parent().children(".m07sliderhead").children(".headline")).text($(this).children(".m07head").text());
					}
					
				}
			});
}

Slider.prototype.SlideTimer = function() {
	var self = this;
	setTimeout(function () {self.SlideTimer();}, self.autoslidetime);
	this.Slide(1);
}

Slider.prototype.Slide = function(paging) {
	var page = this.SliderPage + paging;
	if (page > this.SliderMaxPage) {
		page = 1;
	}
	if (page == 0) {
		page = this.SliderMaxPage;
	}
	if (page > 0 && page <= this.SliderMaxPage) {
		$("#" + this.id + " ." + this.module + "small").hide();
		$("#" + this.id + " ." + this.module + "space").hide();
		//$("#" + this.id + " .loader").show();
		this.SliderPage = page;
		this.Init(this.SliderPage);
	}

}
