/* ::---------------------------------------------------------------
:: +	imageSlider.js
	2011.03.03
	roberto cornice
	cornice@lemm.de

:: +	Image-Slider f?r jQuery  - l?dt Bilder erst wenn sie angezeigt werden sollen

:: +	[c] 2011 by Lemm Werbeagentur GmbH

	------------------------------------------------------------::
	
	
:: +	Aufruf

		jQuery(document).ready(function() {
    		bs			= new slideIt("slideshowContainer");		//::> Id des Divs
    		bs.cWidth	= "520px";									//::> Breite
    		bs.cHeight	= "307px";									//::> H?he
    		bs.speed	= 1000;										//::> Geschwindigkeit
			bs.start();												//::> Feuer
		});

*/

function imageSlider(slideContainer, images, links, texte) 		{

	this.modeArray						= new Array("fade");
	this.slideDirectionArray			= new Array(
		//"top",
		//"bottom",
		//"topfade",
		//"bottomfade",
		//"left"
		//"right"
		//"leftfade",
		//"rightfade",
		//"topleft",
		//"topright"
		//"topleftresize",
		//"toprightresize"
		"fade"
		);
		/*this.slideDirectionArray			= new Array(		
		"right",		
		"left",
		"bottomleft"
		);*/
			

	this.hoverpause			= true;
	this.hoverpauseTimeout;
	this.pauseimg			= "";
	
	this.showNextPrev		= true;
	
	this.showNext_img		= "";
	this.showPrev_img		= "";
	this.showNext_style		= "width:20px;height:97px;left:0;top:190px;";
	this.showPrev_style		= "width:20px;height:97px;right:0;top:190px;";
	
	this.controlls			= false;
	this.controll_pause		= "";
	this.controll_play		= "";
	this.controll_status		= "play";
	this.frequence	        = 1500;
	this.fadetime	        = 750;
	this.direction          = "right";
	// Wie soll der Slider animiert sein?
	//:>               fade || slide
	this.mode               = "fade";
	this.timeoutcontainer;
	
	this.showLogo			= false;
	this.logos				= Array();
	this.logoStyle			= "";
	
	this.showBlueboxes	    = true;
	this.showThumbs		    = true;
	this.showInfo			= false;
	this.naviBoxStyle	    = "bottom:0;padding-bottom: 5px;";
	this.naviBoxbuttonStyle			= "";
	this.naviBoxbuttonStyleActive	= "";
	this.sliderTextDeckStyle		= "";
	this.naviBoxButtonDummyInActive	= "";
	this.naviBoxButtonDummyActive	= "";
	
	this.naviBoxBackground  = '#336699';
	this.naviBoxBorder      = "1px solid #FFF";
	
	this.naviThumbStyle		= "position:absolute;bottom:10px;";
	
	this.imageSliderLinkButton_src		= "";
	this.imageSliderLinkButton_style	= "bottom:13px;right:15px;";
	
	this.topOffset			= $(slideContainer).offset();
	this.top				= this.topOffset.top;
	this.left				= this.topOffset.left;
	this.height				= $(slideContainer).height();
	this.width				= $(slideContainer).width();
	
	this.container			= slideContainer;
	this.parentContainer	= $(slideContainer).parent();
	
	
	this.texte				= texte;
	
	this.images				= images;
	this.size				= images["gross"].length;
	this.imagesIndex		= 0;
	this.imageHolder		= Array();
	this.links				= links;
	this.setLoadedSrc		= Array();
	
	this.activeImageHolder	= 0;
	this.nextImageHolder	= 1;
	this.zindexstart		= 9247;
	var me = this;
	this.hold				= false;
	this.entranceblocked	= false;	
	this.loadEventHolder;
	this.counter			= 0;
	
	this.counter2			= 0;
	
	// Ist der Slider gerade in Bewegung?
	var active = false;
	
	this.init	= function()	{
		for( i = 0; i < 2; i++ )	{
			me.imageHolder[i]	= $(me.container).not(".imageSliderContainerElement").clone().appendTo(me.parentContainer).css({
				zIndex		: me.zindexstart-i,
				position	: "absolute",
				top			: "0"+"px",
				//marginTop	: ( i * (-1) * me.height ),
				left		: 0
			}).addClass("imageSliderContainerElement").
			attr({
				src			: me.images["gross"][i]
			});
		}
		//::> Klappe zu, wenn es nicht mehr als 1 Bild gibt
		if(this.size <= 1){
            return;
        }

		var nextLevel	= me.zindexstart+i+1;

		$(me.container).not(".imageSliderContainerElement").remove();
		
		if(me.mode == "slide"){
            $(me.imageHolder[1]).hide(0,0);
            $(me.parentContainer).css({overflow: "hidden"});
        } else {
            $(me.imageHolder[1]).fadeTo(0,0);
        }
        
		if( this.showInfo )	{
			$(me.parentContainer).append('<div id="imageSlider_infodeck" style="overflow:hidden;z-index:'+(nextLevel+1)+';position:absolute;'+me.sliderTextDeckStyle+'"></div>');
			nextLevel++;
		}
		
		
		if( me.showNextPrev )	{
			
			$(me.parentContainer).append('<img src="'+this.showPrev_img+'" id="imageSlider_showPrev" style="cursor:pointer;position:absolute;z-index:'+nextLevel+';'+this.showPrev_style+'" />');
			nextLevel++;
			$(me.parentContainer).append('<img src="'+this.showNext_img+'" id="imageSlider_showNext" style="cursor:pointer;position:absolute;z-index:'+nextLevel+';'+this.showNext_style+'" />');
			
			$("#imageSlider_showPrev, #imageSlider_showNext").fadeTo(0,0);
			
			nextLevel++;
			
			$("#imageSlider_showPrev").click(function()	{
				me.showPrev();				
			});
			$("#imageSlider_showNext").click(function()	{
				me.showNext();				
			});
		}
		
		
		if( this.showBlueboxes )	{
			
			$(me.parentContainer).append('<div id="imageSliderNaviSquare_container" style="overflow:hidden;z-index:'+(nextLevel+1)+';position:absolute;'+me.naviBoxStyle+'"></div>');
			$("#startslidermemory").append(
				'<div id="imageSliderNaviSquare_dummyInActive" style="cursor:pointer;' + this.naviBoxbuttonStyle+'"></div>'+
				'<div id="imageSliderNaviSquare_dummyActive" style="cursor:pointer;' + this.naviBoxbuttonStyleActive+'"></div>'
			);
			for( i = 0; i < me.size; i++ )	{
				$("#imageSliderNaviSquare_container").append(
					'<div class="imageSliderNaviSquare" id="imageSliderNaviSquare_'+i+'" style="'+$("#imageSliderNaviSquare_dummyInActive").attr("style")+'"></div>'
						//$("#imageSliderNaviSquare_"+i).attr("style") = $("#imageSliderNaviSquare_dummyInActive").attr("style");
				);
				//alert( $("#imageSliderNaviSquare_"+i).attr("style") );
				
				
			}
//			var c = "";
//			for( var key in $("#imageSliderNaviSquare_dummyInActive") )	{
//				c += key + " => " + $("#imageSliderNaviSquare_dummyInActive")[key] + "\r\n";
//			}
			

			$(".imageSliderNaviSquare").bind("click", function()	{
				clearTimeout(me.timeoutcontainer);
				clearTimeout(me.tinyTimeoutcontainer);
				if( !typeof(me.loadEventHolder) == 'undefined' )    {
					me.loadEventHolder.unbind("load").unbind("complete");
				}
				var param		= $(this).attr("id").split("_");
				me.imagesIndex	= ( param[1] - 1 );
				me.showNext();
				//$(".imageSliderContainerElement, #imageSlider_infodeck, #imageSlider_autopause").mouseenter();
				window.setTimeout(function(){
                    me.pause();
                }, me.frequence);
			});

			//$("#imageSliderNaviSquare_0").css("border", this.naviBoxBorder);
			$("#imageSliderNaviSquare_0").attr("style", $("#imageSliderNaviSquare_dummyActive").attr("style") );
			
						
			
			$("#imageSliderNaviSquare_container").css("margin-left", ($("#startSlider").width()/2 - $("#imageSliderNaviSquare_container").width()/2)+"px" );
			
		}
		
		
		nextLevel++;
        if( me.controlls )	{
			$(me.parentContainer).append('<img id="imageslider_controll" src="'+me.controll_play+'" style="display:block;z-index:'+(nextLevel+1)+';'+me.controll_style+'" />');
			nextLevel++;		
        }
        
        
		if( me.showLogo )	{
			$(me.parentContainer).append('<img class="" width="68" height="68" id="imageSlider_logo" style="position:absolute;'+me.logoStyle+';z-index:'+nextLevel+'" />');
			nextLevel++;
		}
		
		
		if( me.hoverpause )	{
			$(me.parentContainer).append('<img width="71" height="20" src="'+me.pauseimg+'" id="imageSlider_autopause" style="position:absolute;top:30px;left:30px;z-index:'+nextLevel+'" />');
			nextLevel++;			
		}
		
		
		
		$(me.parentContainer).append('<div id="imageSliderLinkButton" style="position:absolute;cursor:pointer;z-index:'+(nextLevel+1)+';'+me.imageSliderLinkButton_style+'"><img src="'+me.imageSliderLinkButton_src+'" /></div>');
		nextLevel++;
		
		
		
		
		if( this.showThumbs )	{
			$(me.parentContainer).append('<div id="imageSliderNaviThumb_container" style="z-index:'+(nextLevel+1)+';'+me.naviThumbStyle+'"></div>');
			for( i = 0; i < me.size; i++ )	{
				$("#imageSliderNaviThumb_container").append('<img class="imageSliderNaviThumb" id="imageSliderNaviThumb_'+i+'" style="cursor:pointer;border:2px solid #000000;top:0;float:right;margin:0 7px;position:relative;height:25px;width:50px;" src="'+me.images["klein"][i]+'" />', function()	{

				});
			}

			$(".imageSliderNaviThumb").bind("click", function()	{
				clearTimeout(me.timeoutcontainer);
				clearTimeout(me.tinyTimeoutcontainer);
				if( !typeof(me.loadEventHolder) == 'undefined' )    {
					me.loadEventHolder.unbind("load").unbind("complete");
				}
				var param		= $(this).attr("id").split("_");
				me.imagesIndex	= ( param[1] - 1 );
				me.showNext();
			});

			$("#imageSliderNaviThumb_0").css("border", "2px dashed #000000");
		}
		

		if( me.logos[0] == "" )	{

			$("#imageSlider_logo").fadeTo(0,0, function()	{
				$("#imageSlider_logo").hide();
			});
		} else {
			$("#imageSlider_logo").attr(
				{
					src		: me.logos[0],
					width	: "68",
					height : "68"
				}
			);
		}
		
		if( me.links[0] == "" )	{

            if ($.browser.msie) {
                $("#imageSliderLinkButton").stop(true,true).animate({marginRight:"-200px"},0, function()	{
                    $("#imageSliderLinkButton").hide();
                });
            } else {
                $("#imageSliderLinkButton").fadeTo(0,0, function()	{
                    $("#imageSliderLinkButton").hide();
                });
            }


		} else {
			$("#imageSliderLinkButton").bind("click", function()	{
				location.href	= me.links[0];
			});
		}
		
		if( me.showInfo )	{
            /*$("#imageSlider_infodeck").
            html( me.texte[me.activeImageHolder] )
            .stop(true,true)
            .animate({right: "0"}, (me.fadetime/2) );*/
            
                    		$(".sliderLightbox").lightBox();
		}
		
		me.setTimer();
		 if( me.controlls )	{
			$("#imageslider_controll").click( function()	{
		 	 	if( me.controll_status == "play" )	{
					me.controll_status = "pause";
					$("#imageslider_controll").attr("src",  me.controll_pause );
					clearTimeout(me.timeoutcontainer);
					clearTimeout(me.tinyTimeoutcontainer);
				} else {
					me.setTimer();
					me.controll_status = "play";
					$("#imageslider_controll").attr("src",  me.controll_play );
				}
			});
        }
        
        if( me.hoverpause )	{
        	$("#imageSlider_autopause").fadeTo(0,0);
			$(".imageSliderContainerElement, #imageSlider_infodeck, #imageSlider_autopause").hover(
			//$("#startSlider").hover(
				function()	{
					me.pause();					
				},
				function()	{
					me.play();
				}
			);
        }
		
		
		if( me.showNextPrev )	{
			$("#imageSlider_showPrev, #imageSlider_showNext").fadeTo( me.fadetime,1);			
		}
		
	}
	
	
	me.pause	= function()	{
		clearTimeout(me.hoverpauseTimeout);
		clearTimeout(me.timeoutcontainer);
		clearTimeout(me.tinyTimeoutcontainer);
		//me.entranceblocked = true;
		$("#imageSlider_autopause").fadeTo(300,1);
		
		if( me.showInfo )	{
			//console.log(me.imagesIndex);
            $("#imageSlider_infodeck").
            html( me.texte[me.imagesIndex] ).stop(true,true).
            animate({right: "0"}, (me.fadetime/2) );
            $(".sliderLightbox").lightBox();
		}
		
	}
	
	me.play		= function()	{
		
		me.hoverpauseTimeout	= setTimeout(me.playIt,500);
	}
	me.playIt	= function()	{
		$("#imageSlider_infodeck").stop(true,true).animate({right: "-288px"}, (me.fadetime/2) );
		$("#imageSlider_autopause").fadeTo(300,0);
		me.setShortTimer();
		me.entranceblocked = false;
	}
	
	me.setTimer	= function()	{
		clearTimeout(me.timeoutcontainer);
		clearTimeout(me.tinyTimeoutcontainer);
		me.timeoutcontainer	= setTimeout(				
			function() {
				
				me.showNext()
			}, me.frequence
		);		
	}
	
	me.setShortTimer	= function()	{
		clearTimeout(me.timeoutcontainer);
		clearTimeout(me.tinyTimeoutcontainer);
		me.timeoutcontainer	= setTimeout(				
			function() {
				
				me.showNext()
			}, 1500
		);		
	}
	me.setTinyTimer	= function()	{
		clearTimeout(me.timeoutcontainer);
		clearTimeout(me.tinyTimeoutcontainer);
		me.tinyTimeoutcontainer	= setTimeout(				
			function() { 				
				me.showImage()
			}, 100
		);
		//me.setTimer();
	}
	
	me.setLoaded	= function(index)	{
		$(me.imageHolder[index]).load(function(){
			me.setLoadedSrc[index]	= true;
		});
	}
	me.unsetLoaded	= function(index)	{
		me.setLoadedSrc[index]	= false;
	}
	
	me.getImageHolder	= function()	{
		if( me.activeImageHolder == 0 )	{
			me.nextImageHolder	= 1;
		} else {
			me.activeImageHolder	= 1;
			me.nextImageHolder	= 0;
		}
	}
	
	me.toggleImageHolder	= function()	{
		if( me.activeImageHolder == 0 )	{
			me.activeImageHolder	= 1;
			me.nextImageHolder	= 0;
		} else {
			me.activeImageHolder	= 0;
			me.nextImageHolder	= 1;
		}
	}
	
	me.showNext	= function()	{
        me.imagesIndex++;
    	if( me.imagesIndex > ( me.size - 1 ) )	{
    		me.imagesIndex = 0;
    	}
    	me.direction = "left";
    	me.showImage();
	}
	
	me.showPrev	= function()	{
        me.imagesIndex--;
		if( me.imagesIndex < 0 )	{
			me.imagesIndex = me.size - 1;
		}
		me.direction = "right";
		me.showImage();
	}
	
	me.showImage	= function()	{
	
		if( me.hold )	{
			return;
		}
		active = true;
		
		if( me.entranceblocked == true )	{
			//me.debug("activated");
			me.setTinyTimer();
			active = false;
			return;
		} else if($("#lightbox-container-image-box").is(":visible")){
            $("#lightbox-secNav-btnClose, #jquery-overlay").click(function(){
                $("#lightbox-secNav-btnClose, #jquery-overlay").unbind("click");
                me.setShortTimer();
            });
            me.setTinyTimer();
            active = false;
            return;
        }

		//me.entranceblocked	= true;
		
		me.getImageHolder();
		$(me.imageHolder[me.nextImageHolder]).removeAttr("src");
		
		me.counter++;
		me.loadEventHolder	= $(me.imageHolder[me.nextImageHolder]);
		$(me.imageHolder[me.nextImageHolder]).attr("src", me.images["gross"][me.imagesIndex]).attr("alt", me.images["gross"][me.imagesIndex]).one("load",function(){
			//me.entranceblocked	= true;
			$(me.imageHolder[me.nextImageHolder]).unbind("load");	
			//$(".imageSliderNaviSquare").css("border", "1px solid transparent");
			$(".imageSliderNaviSquare").attr("style", $("#imageSliderNaviSquare_dummyInActive").attr("style") );
			$(".imageSliderNaviThumb").css("border", "2px solid #000000");
			
			//$("#imageSliderNaviSquare_"+me.imagesIndex).css("border", "1px solid #FFFFFF");
			$("#imageSliderNaviSquare_"+me.imagesIndex).attr("style", $("#imageSliderNaviSquare_dummyActive").attr("style") );
			
			
			$("#imageSliderNaviThumb_"+me.imagesIndex).css("border", "2px dashed #000000");
			
			
			if( me.links[me.imagesIndex] != "" )	{
                if ($.browser.msie) {
                    $("#imageSliderLinkButton").show(0, function()	{
                        $("#imageSliderLinkButton").stop(true,true).animate({marginRight:"0"}, me.fadetime, function()	{
                            $("#imageSliderLinkButton").bind( "click",  function()	{
                                location.href	= me.links[me.imagesIndex];
                            } );
                        });
                    });
				} else {
                    $("#imageSliderLinkButton").show(0, function()	{
                        $("#imageSliderLinkButton").fadeTo(me.fadetime, 1, function()	{
                            $("#imageSliderLinkButton").bind( "click",  function()	{
                                location.href	= me.links[me.imagesIndex];
                            } );
                        });
                    });
                }
			} else {
                if ($.browser.msie) {
                    $("#imageSliderLinkButton").show(0, function()	{
                        $("#imageSliderLinkButton").stop(true,true).animate({marginRight:"-200px"},me.fadetime, function()	{
                            $("#imageSliderLinkButton").hide().unbind("click");
                        });
                    });
                } else {
                    $("#imageSliderLinkButton").show(0, function()	{
                        $("#imageSliderLinkButton").fadeTo(me.fadetime, 0, function()	{
                            $("#imageSliderLinkButton").hide().unbind("click");
                        });
                    });
                }

			}
			
			
			
			if( me.logos[me.activeImageHolder]!= "" )	{
				$("#imageSlider_logo").fadeTo(Math.round(me.fadetime/1), 0, function()	{
					$("#imageSlider_logo").hide();


						if( me.logos[me.imagesIndex] != "" )	{
							
							$("#imageSlider_logo").show(0, function()	{
								//$("#imageSlider_logo").attr("src", me.logos[me.imagesIndex]).fadeTo(  Math.round(me.fadetime/2) , 1);
								$("#imageSlider_logo").attr(
									{
										src		: me.logos[me.imagesIndex],
										width	: "68",
										height : "68"
									}
								).fadeTo(  Math.round(me.fadetime/2) , 1);;
							});

						} else {
							$("#imageSlider_logo").show(0, function()	{
								$("#imageSlider_logo").fadeTo(me.fadetime, 0, function()	{
									$("#imageSlider_logo").hide();
								});
							});
						}




				});
			}
			
			
			me.mode			= "slide";
			 
			me.direction	= me.slideDirectionArray[Math.round( Math.random()* ( me.slideDirectionArray.length - 1 ) ) ];
			
			if(me.mode == "slide"){
				if( me.showInfo )	 {
					//$("#imageSlider_infodeck").stop(true,true).animate({right: "-288px"}, (me.fadetime/2) );
				}
				
				me.beforeEffects();
				
			
			$(me.imageHolder[me.activeImageHolder]).stop(true,true);	
			$(me.imageHolder[me.nextImageHolder]).stop(true,true).css(
				{
						width		: me.width, 
						height		: me.height, 
						left		: 0, 
						right		: 0,
						top			: 0, 
						bottom		: 0,
						opacity		: 1
				}
			).show(0);
			
			
              if(me.direction == "right"){
                    $(me.imageHolder[me.nextImageHolder]).css({width: me.width, height: me.height, left: me.width, top: 0, opacity:1}).
                    show(0).
                    stop(true,true).animate({left: 0}, me.fadetime * 1.5);
                    $(me.imageHolder[me.activeImageHolder]).stop(true,true).animate({left: -me.width}, me.fadetime * 1.5, function()	{
						me.afterEffects();	
                    });
				} else if(me.direction == "left") {                	
			
                    $(me.imageHolder[me.nextImageHolder]).css({width: me.width, height: me.height, left: -me.width, top: 0, opacity:1}).
                    show(0).stop(true,true).
                    animate({left: 0}, me.fadetime * 1.5);
                    $(me.imageHolder[me.activeImageHolder]).stop(true,true).animate({left: me.width}, me.fadetime * 1.5, 0, function(){
                    	me.afterEffects();		
                    }	);
                } else if(me.direction == "rightfade"){
                    $(me.imageHolder[me.nextImageHolder]).css({width: me.width, height: me.height, left: -me.width, opacity: 0, top: 0}).show(0).stop(true,true).
                    animate({left: 0, opacity: 1}, me.fadetime * 1.5);
                    $(me.imageHolder[me.activeImageHolder]).stop(true,true).animate({opacity: 0}, me.fadetime * 2, function()	{
						me.afterEffects();	
                    });
				} else if(me.direction == "leftfade") {                	
			
                    $(me.imageHolder[me.nextImageHolder]).css({width: me.width, height: me.height, left: me.width, opacity: 0, top: 0}).show(0).stop(true,true).animate({left: 0, opacity: 1}, me.fadetime * 1.5);
                    $(me.imageHolder[me.activeImageHolder]).stop(true,true).animate({opacity: 0}, me.fadetime * 2, 0, function(){
                    	me.afterEffects();		
                    }	);
                } else if(me.direction == "top") {                	
			
                    $(me.imageHolder[me.nextImageHolder]).css({width: me.width, height: me.height, top: -me.height, left: 0, opacity:1}).show(0).stop(true,true).animate({top: 0}, me.fadetime * 1.5);
                    $(me.imageHolder[me.activeImageHolder]).stop(true,true).animate({top: me.height}, me.fadetime * 1.5, 0, function(){
                    	me.afterEffects();		
                    }	);
                } else if(me.direction == "bottom") {                	
			
                    $(me.imageHolder[me.nextImageHolder]).css({width: me.width, height: me.height, top: me.height, left: 0, opacity:1}).show(0).stop(true,true).animate({top: 0}, me.fadetime * 1.5);
                    $(me.imageHolder[me.activeImageHolder]).stop(true,true).animate({top: -me.height}, me.fadetime * 1.5, 0, function(){
                    	me.afterEffects();		
                    }	);
                } else if(me.direction == "topfade") {                	
			
                    $(me.imageHolder[me.nextImageHolder]).
                    	css({width: me.width, height: me.height, top: -me.height, opacity: 0, left: 0}).
                    	show(0).stop(true,true).
                    	animate({top: 0, left:0, opacity: 1}, me.fadetime * 1.5);
                    $(me.imageHolder[me.activeImageHolder]).stop(true,true).animate({opacity: 0}, me.fadetime * 2, 0, function(){
                    	me.afterEffects();		
                    }	);
                } else if(me.direction == "bottomfade") {                	
			
                    $(me.imageHolder[me.nextImageHolder]).css({width: me.width, height: me.height, top: me.height, left: 0, opacity: 1}).show(0).stop(true,true).animate({top: 0, opacity: 1}, me.fadetime * 1.5);
                    $(me.imageHolder[me.activeImageHolder]).stop(true,true).animate({opacity: 0}, me.fadetime * 2, 0, function(){
                    	me.afterEffects();		
                    }	);
                } else if(me.direction == "topleft") {                	
			
                    $(me.imageHolder[me.nextImageHolder]).css({width: me.width, height: me.height, top: -me.height, left: -me.width, opacity:0}).show(0).stop(true,true).animate({top: 0, left: 0, opacity: 1}, me.fadetime * 1.5);
                    $(me.imageHolder[me.activeImageHolder]).stop(true,true).animate({opacity: 0}, me.fadetime * 2.0, 0, function(){
                    	me.afterEffects();		
                    }	);
                } else if(me.direction == "topright") {                	
			
                      $(me.imageHolder[me.nextImageHolder]).css({width: me.width, height: me.height, top: -me.height, left: me.width, opacity:0}).show(0).stop(true,true).
                      animate({top: 0, left: 0, opacity: 1}, me.fadetime * 1.5);
                    $(me.imageHolder[me.activeImageHolder]).stop(true,true).animate({opacity: 0}, me.fadetime * 2.0, 0, function(){
                    	me.afterEffects();		
                    }	);
                } else if(me.direction == "topleftresize") {
                      $(me.imageHolder[me.nextImageHolder]).
                      css({top: 0, left: 0, opacity:0, width:"1px", height:"1px"}).
                      show(0).stop(true,true).
                      animate({top:0, left:0,width: me.width, height: me.height, opacity: 1}, me.fadetime * 1.5);
                    $(me.imageHolder[me.activeImageHolder]).stop(true,true).animate({opacity: 0}, me.fadetime * 2.0, 0, function(){
                    	me.afterEffects();		
                    }	);
                } else if(me.direction == "toprightresize") {
                      $(me.imageHolder[me.nextImageHolder]).
                      css({top: 0, left: me.width, opacity:0, width:"1px", height:"1px"}).
                      show(0).stop(true,true).
                      animate({width: me.width, height: me.height, left:0, top:0, opacity: 1}, me.fadetime * 1.5);
                    $(me.imageHolder[me.activeImageHolder]).stop(true,true).animate({opacity: 0}, me.fadetime * 2.0, 0, function(){
                    	me.afterEffects();		
                    }	);
                } else if(me.direction == "fade") {
                      $(me.imageHolder[me.nextImageHolder]).
                      css({top: 0, left: 0, opacity:0, width: me.width, height: me.height}).
                      show(0).stop(true,true).
                      animate({opacity: 1}, me.fadetime * 1.5);
                    $(me.imageHolder[me.activeImageHolder]).stop(true,true).animate({ opacity: 0}, me.fadetime * 1.5, 0, function(){
                    	me.afterEffects();		
                    }	);
                }
                
                
                
                
                
                
                
                
            } else {
            	me.beforeEffects();
                $(me.imageHolder[me.nextImageHolder]).fadeTo(me.fadetime, 1, function()	{
					me.afterEffects();
                } );
                $(me.imageHolder[me.activeImageHolder]).fadeTo(me.fadetime, 0);
            }
            
			var groar = setTimeout(function()	{
				//me.entranceblocked	= false;				
				me.toggleImageHolder();
				me.counter2++;
				active = false;
				me.setTimer();
				},
				me.fadetime
			);
			/*$(me.imageHolder[me.activeImageHolder]).fadeTo(me.fadetime, 0, function()	{
				me.entranceblocked	= false;				
				//me.debug(me.frequence +" - "+ me.nextImageHolder +" - "+ me.activeImageHolder + " - "+me.counter + " - "+me.counter2 );
				me.toggleImageHolder();
				me.counter2++;
				me.setTimer();
			} );*/
		})
		.each(function(){
			if(this.complete) $(this).trigger("load");
		});
	}
	
	me.afterEffects	= function()	{
		if( me.showNextPrev )	{
			$("#imageSlider_showPrev, #imageSlider_showNext").fadeTo( me.fadetime,1);			
		}					
	}
	me.beforeEffects	= function()	{
		if( me.showNextPrev )	{
			$("#imageSlider_showPrev, #imageSlider_showNext").fadeTo( me.fadetime,0);			
		}
	}
	me.debug		= function( expr )	{
		$("#debug").html( expr );
	}
	
	me.notbremse	= function()	{
		me.hold	= true;
		clearTimeout(me.timeoutcontainer);		
		clearTimeout(me.tinyTimeoutcontainer);
		
		alert("Das Script wurde angehalten!");
	}
	
}
