$(document).ready(function() {	var startIndex		= $("#startIndex").attr("rel");	var currentIndex 	= 0;	var boempelNumber 	= $('.boempel').length;	var background 		= $('#background');	var description 	= '';	var title			= '';	var newBackground 	= '';	var backgroundImage = '';	var spinner 		= $('#spinner');	var loading 		= false;	// Add click event to the boempels	$(".boempel").click(function() {			if(loading == false) {					$(this).stop();					// stop event from propagation			$('body').stopTime();			// stop interval page loading					currentIndex = $(".boempel").index(this);							// stop current animations			if($('div:animated').length > 0) {				stop();			}			loadPageArtefacts(this.id, $('> img', this));		}				return false;	});	// Add click event to the next buttons	$("#boempel-next").click(function(){			if(loading == false) {					$(this).stop();					// stop event from propagation			$('body').stopTime();			// stop interval page loading								if($('div:animated').length > 0)				stop();						next();		}				return false;	})		// Add click event to the previous button	$("#boempel-previous").click(function(){			if(loading == false) {							$(this).stop();					// stop event from propagation			$('body').stopTime();			// stop interval page loading									if($('div:animated').length > 0)				stop();							previous();		}				return false;	})				//Start SlideShow	if ($('#main-wrapper').length > 0) {		//init loading on startpage		//Description and Image where set by TypoScript		$('.boempel:eq('+startIndex+') > img').attr('src', 'fileadmin/templates/images/boempel.gif');		currentIndex = startIndex;				$('body').everyTime(15000, 'controlled', function() {			if(loading == false) {				next();			}		});	}	// initiate loading for next page	function next() {				if(currentIndex < boempelNumber-1) {			currentIndex++;		} else {			currentIndex = 0;		}		var link = $('.boempel:eq('+currentIndex+')');				loadPageArtefacts(link.attr('id'), $('.boempel:eq('+currentIndex+') > img'));					return false;	}		// initiate loading for previous page	function previous() {			if(currentIndex > 0) {			currentIndex--;		} else {			currentIndex = boempelNumber-1;		}		var link = $('.boempel:eq('+currentIndex+')');		loadPageArtefacts(link.attr('id'), $('.boempel:eq('+currentIndex+') > img'));				return false;	}		// stop all current animations	function stop() {		newBackground.stop(true, true).show();		background.stop(true, true).remove();		background = $('#background');		spinner.hide();	}	// execute ajax request to load page artefacts	function loadPageArtefacts(pageId, boempel) {					$.ajax({			url: "index.php",			// Achtung mit RealURL!			type: "GET",				// Daten per GET verschicken			data: {				eID: "pagecontroller",	// die erstellte eID				uid: pageId				// page id			},			dataType: "json",			// das gibts zurück						// display loading image before sending ajax request			beforeSend: function()			{				spinner.fadeIn(100);				loading = true;			},			// upon successful request create new background element and insert before the current one			success: function(response)			{							background = $('#background');				newBackground = background.clone().css({					'opacity': 0,					'background': 'url(fileadmin/pageBG/'+ response.image + ') no-repeat top'				})								newBackground.insertBefore(background);				description = response.description;				backgroundImage = response.image				title = response.title							},						// 			complete: function(response)			{				var img = new Image();				$(img).hide().appendTo('body');					$(img).attr('src', 'fileadmin/pageBG/'+ backgroundImage).load(function() {									background.animate({						'opacity': 0					}, 1000)						newBackground.animate({						'opacity': 1					}, 1000, '', function() {						newBackground.parent().find('#page-teaser').html(description);						newBackground.parent().find('#page-teaser-title').html(title);						background.remove();						spinner.fadeOut(100);						$(img).remove();						loading = false;					})				})					$.each($(".boempel > img"), function(i,l) {					$(l).attr('src', 'fileadmin/templates/images/boempel-inactive.gif');				})				boempel.attr('src', 'fileadmin/templates/images/boempel.gif');			},			// display message if an error occures			error: function(error) 			{//				alert ('Error while loading page info!')			}		});	}});
