jQuery.noConflict();



jQuery(document).ready(function(){

















	/* This code is executed after the DOM has been completely loaded */
	var totWidth=0;
	var positions = new Array();
	
	jQuery('#slides .slide').each(function(i){
		
		/* Traverse through all the slides and store their accumulative widths in totWidth */
		positions[i]= totWidth;
		totWidth += jQuery(this).width();
		
		/* The positions array contains each slide's commulutative offset from the left part of the container */
		if(!jQuery(this).width())
		{
			alert("Please, fill in width & height for all your images!");
			return false;
		}
	});
	
	jQuery('#slides').width(totWidth);

	/* Change the cotnainer div's width to the exact width of all the slides combined */

    //Anzahl der Bilder	
	var max = jQuery(".slide").size()-1;
	var min=0;
	//var num=max;    //wird im Modul über php gesetzt!

	
/****** Effecte *******/	
	
//Verschieben		
	jQuery('#Plus_wipe_vor').click(function(){
	    num=num+1;
		//wiederholen
		if (jLoop == true) {
		   if (num == jQuery(".slide").size()) num=1;	
		} else {
		//nach Durchlauf stoppen
		   if (num == jQuery(".slide").size()) {
		      clearInterval(itvl);
              autoPlay = false;	
              jQuery('#Plus_stop').css('color','#808080')	
		      num=num-1;
           }	
	    }
		 
		jQuery('#slides').stop().animate({marginLeft:-positions[num]+'px'},450);    //Geschwindigkeit
	});
	
	jQuery('#Plus_wipe_zurueck').click(function(){
		if (num >0) num=num-1;	

		jQuery('#slides').stop().animate({marginLeft:-positions[num]+'px'},450);    //Geschwindigkeit
	});
	
//Überblenden	

    //css ändern
    if (effect == 'fade') {
     jQuery(".slide").css({'position' : 'absolute'});
     jQuery(".slide").css({'visibility' : 'hidden'});
	 jQuery(".slide").eq(num).css({'visibility' : 'visible'});
    }
	
	jQuery('#Plus_fade_vor').click(function(){
		//wiederholen
		if (jLoop == true) {
		   if (num == 0 ) num = jQuery(".slide").size();	
		} else {
		//nach Durchlauf stoppen
		   if (num == 1) {
		      clearInterval(itvl);
              autoPlay = false;	
              jQuery('#Plus_stop').css('color','#808080')	
		      num=num-1;
           }	
	    }
        
		if (num == 0) num = 1;
		jQuery(".slide").eq(num-1).animate({ opacity: 1.0},800);
		jQuery(".slide").eq(num-1).css({'visibility' : 'visible'});
        jQuery(".slide").eq(num).animate({ opacity: 0.0},1200);	
		num=num-1;
		
		
		
	});	
	
	jQuery('#Plus_fade_zurueck').click(function(){
        num=num+1;
		jQuery(".slide").eq(num+1).css({'visibility' : 'visible'});
        jQuery(".slide").eq(num).animate({ opacity: 1.0},1200);
		
		if (num >= jQuery(".slide").size()) num = jQuery(".slide").size()-1;
	});		

//AutoPlay Stop	
	jQuery('#Plus_stop').click(function(){
        // Stopping the auto-advance if an icon has been clicked:
		if (autoPlay == true) {
		   clearInterval(itvl);
           autoPlay = false;	
           jQuery('#Plus_stop').css('color','#808080')		   
		} else {
		itvl = setInterval(function(){autoAdvance()},changeEvery*1000);
		   autoPlay = true;
           jQuery('#Plus_stop').css('color','#B5152C')				
		}
	});  
	/*****
	 *
	 *	Enabling AutoAdvance
	 *
	 ****/
	//var autoPlay = false;
	var itvl;
	var changeEvery = 6;   //Zeit wechseln der Bilder
	function autoAdvance()
	{
		if (effect == 'wipe') jQuery('#menu #Plus_wipe_vor').trigger('click');
		if (effect == 'fade') jQuery('#menu #Plus_fade_vor').trigger('click');			
	}

	// The number of seconds that the slider will auto-advance in:
	if (autoPlay == true) {
	    var itvl = setInterval(function(){autoAdvance()},changeEvery*1000);
    } else {
	    jQuery('#Plus_stop').css('color','#808080')
	}
	/* End of customizations */
});

