﻿ counter = 0;    
        function fade(step) {
            var imgs = document.getElementById("meinFader").getElementsByTagName("img");
            counter1 = counter -1; 
            if(counter1 < 0){
	            	counter1 =imgs.length-1;
	        }
            step = step || 0;
            imgs[counter].style.opacity = step/700;
            imgs[counter].style.filter = "alpha(opacity=" + step + ")"; //     
                    
            imgs[counter1].style.opacity = 1-(step/700);
          	imgs[counter1].style.filter = "alpha(opacity=" + (700-step) + ")"; // 
          	step = step + 2;
            if (step <= 700) {
                warte =  window.setTimeout(function () { fade(step); }, 1);
            } else {
            	
               warte = window.setTimeout(next, 3000);
            }
                   
        }

        function next() {
            var imgs = document.getElementById("meinFader").getElementsByTagName("img");
	
            if (typeof(counter) != "number") {
                counter = 0;
            }
			step = 0;
        	counter++;
			
            if (counter < imgs.length) {
                fade();
            }else{
				counter = 0;
				fade();
            }
        }
  	   function shownext(){
  		     var imgs = document.getElementById("meinFader").getElementsByTagName("img");
  		     	if (typeof(warte)!="undefined"){
	  		     	clearTimeout(warte);
	  		    }
	  		   
	  		    if (typeof(warte1)!="undefined"){
		  		    counter2 = counter-1;
	  		    	if(counter2<0){
	  		    		counter2 = imgs.length-1;
	  		    	}
	  		    	imgs[counter2].style.opacity = 0;
					imgs[counter2].style.filter = "alpha(opacity=" + (0) + ")"; // 	
	  		    	clearTimeout(warte1);
	  		    }
	  		   if(typeof(warte)!="undefined" && gestartet && warte > warte1+25){
	  		    	imgs[counter].style.opacity = 1;
					imgs[counter].style.filter = "alpha(opacity=" + (100) + ")"; // 
	  		    }else{
		  		    imgs[counter].style.opacity = 0;
					imgs[counter].style.filter = "alpha(opacity=" + (0) + ")"; //  
			     	counter++;
					if (counter >= imgs.length) {
						counter = 0;
					}
		  		  	imgs[counter].style.opacity = 1;
		            imgs[counter].style.filter = "alpha(opacity=" + 100 + ")"; //
	           }
		     	if(typeof(gestartet)!="undefined" && gestartet == 1){
		       	 warte1 = window.setTimeout(next, 3000);  
		        }		     	
		}
		
	   function start(){
	   		gestartet = 1;
	   		if (typeof(warte)!="undefined"){
	  		     	clearTimeout(warte);
	  		    }
  		    if (typeof(warte1)!="undefined"){
  		    	   	clearTimeout(warte1);
  		    }
	   		warte1 = window.setTimeout(next, 3000);
	   }
	   
	    function stop(){
	     var imgs = document.getElementById("meinFader").getElementsByTagName("img");
	     	gestartet = 0;
	   		if (typeof(warte)!="undefined"){
	  		     	clearTimeout(warte);
	  		     	counter2 = counter-1;
	  		    	if(counter2<0){
	  		    		counter2 = imgs.length-1;
	  		    	}
	  		    	imgs[counter2].style.opacity = 0;
					imgs[counter2].style.filter = "alpha(opacity=" + (0) + ")"; // 
					imgs[counter].style.opacity = 1;
	            	imgs[counter].style.filter = "alpha(opacity=" + 100 + ")"; //
	  		    
	  		    }
  		    if (typeof(warte1)!="undefined"){
  		    	   	clearTimeout(warte1);
  		    }
	   }
