Slider = function(name, count){
	this.name = name;
	this.count = count;
	this.currentIntervall = null;

	
	currentElementId = 0;
	
	this.changeDiv = function(id){
		this.currentElementId=id;
		changeDiv(this.name, id, this.count);
	}
	
		
	this.automaticChange = function(){
		name = this.name;
		currentId = this.currentElementId;
		count = this.count;
		
		this.currentInterval = window.setInterval(
					function() {
						if(currentElementId == count-1){
							changeDiv(name, 0, count);
							this.currentElementId = 0;
						}
						else{
							changeDiv(name, currentElementId + 1, count);
							currentElementId++;
						}
					}, 12000)
	}
}


function changeDiv(name, id, count){
	if(document.getElementById(name + "[" + id + "]")){
		// Browserweiche

		IE = document.all&&!window.opera;
		DOM = document.getElementById&&!IE;
		
		displayInElement = document.getElementById(name + "[" + id + "]");
		displayOutElement = null;
		
		for (var i = 0; i < count; i++){
			if(document.getElementById(name + "[" + i + "]") && i!=id)
				if(document.getElementById(name + "[" + i + "]").style.display!='none')
					displayOutElement = document.getElementById(name + "[" + i + "]");
		}
		
		if(displayInElement != displayOutElement && displayOutElement != null){
			displayInElement.style.display = "inline"; //Element anzeigen
			
			if(IE) //Element transparent setzen
				displayInElement.style.filter = "alpha(opacity=0)";
			else
				displayInElement.style.opacity = 0;
			
			displayInElement.height="290px";
			
			opacityOutWert = 100;
			opacityInWert = 0;
			
			changeOpacity = window.setInterval(
				function() {
					opacityInWert+=5;
					opacityOutWert-=5;
	
					if(IE){
						displayInElement.style.filter = "alpha(opacity="+opacityInWert+")";
						displayOutElement.style.filter = "alpha(opacity="+opacityOutWert+")";
					}else{
						displayInElement.style.opacity = opacityInWert/100;
						displayOutElement.style.opacity = opacityOutWert/100;
					}
					
					if(opacityInWert == 100){
						window.clearInterval(changeOpacity);
						displayOutElement.style.display = "none";
					}
				} 
				, 40)
		}	
	}	
}
