$(document).ready(
	function (){
		einszweidrei.init();
	}
);

einszweidrei = new Object();

einszweidrei.init = function (){

	if ($("#einszweidrei").length != 0 && ! global.thisBrowserIsAPieceOfS___()){
		
		this.selektor = "#einszweidrei .block:not(#einszweidrei .block .block)";
		this.alpha = {
			"min": 0.6,
			"max": 1
		};
		
		this.intervall = null;
		this.aktuelle_id = 0;
		this.dauer = 3000;
		this.warten = 3000;
		

		$(this.selektor).each(function (index){
			
			/*
			$(this).click(function(){
				var link = $("a", this)[0].href;
				window.location = $("a", this)[0].href;
			});
			*/
			
			$(this).hover(
				function (){
					einszweidrei.animation(index);
				}, 
				function (){
					einszweidrei.animation();
				}
			);
			
		});
		
	
		this.animation = function(index){
		
			window.clearTimeout(this.timer);
			
			if (index != null){
									
				this.aktuelle_id = index;

				window.clearInterval(this.intervall);
				this.intervall = null;
			
				for (var id = 0; id < $(this.selektor).length; id++){
				
					$(this.selektor).eq(id).stop()
								
					if (id == this.aktuelle_id){
						$(this.selektor).eq(id).fadeTo(100, this.alpha.max);
					} else {
						$(this.selektor).eq(id).fadeTo(300, this.alpha.min);
					}
					
				}
								
			} else {

				if (this.intervall == null){
											
					this.intervall = window.setInterval("einszweidrei.animation()", this.dauer);
					
				} else {
								
					this.aktuelle_id++;
										
					if (this.aktuelle_id >= $(this.selektor).length){
						this.aktuelle_id = 0;
					}
					
					for (var id = 0; id < $(this.selektor).length; id++){
					
						if (id == this.aktuelle_id){
							$(this.selektor).eq(id).fadeTo(100, this.alpha.max);
						} else {
							$(this.selektor).eq(id).fadeTo(700, this.alpha.min);
						}
						
					}
				
				}
			
			}		
		
		}
		
		this.animation(0);
		this.timer = window.setTimeout("einszweidrei.animation()", this.warten);

	}
		
}

