var bildtext = {
	"motiv1.jpg": "Lüftung in einem Gewerbebetrieb",
	"motiv2.jpg": "Eigenkreation Waschbecken",
	"motiv3.jpg": "Heizkreisverteilung",
	"motiv4.jpg": "Solarthermie, harmonisch integriert",
	"motiv5.jpg": "moderner Handtuchheizkörper",
    "motiv6.jpg": "Fußboden Heizregister",
    "motiv7.jpg": "Heizkreisverteilung (Detailaufnahme)",
    "motiv8.jpg": "Firmengelände Fraunberger",
    "motiv9.jpg": "Heizzentrale einer Schule",
    "motiv10.jpg": "Eigenkreation Waschbecken",
    "motiv11.jpg": "Erdreich- Wärmepumpe in einem Wohnhaus",
    "motiv12.jpg": "Brunnenwasser- Wärmepumpen- anlage",

}

var bilderpfad = "animation/images/";

$(function() {

$(".scrollable").scrollable();

$(".items img").click(function() {

  clearTimeout(timer);


	// see if same thumb is being clicked
	if ($(this).hasClass("active")) { return; }

	// calclulate large image's URL based on the thumbnail URL
	var url = $(this).attr("src").replace("_t", "");

	// get handle to element that wraps the image and make it semi-transparent
	var wrap = $("#image_wrap").fadeTo("fast", 1);


	// the large image
	var img = new Image();

	// call this function after it's loaded
	img.onload = function() {

		// make wrapper fully visible
		wrap.fadeTo("slow", 1);
		
		// change the image
		wrap.find("img").attr("src", url);
		
	
		// Bildtext dazu (zuerst Pfad entfernen.
		var index = url.replace(bilderpfad,"");
		$("#textbox").text(bildtext[index]);

	};

	// begin loading the image
	img.src = url;

	// activate item
	$(".items img").removeClass("active");
	$(this).addClass("active");

// when page loads simulate a "click" on the first image
//}).filter(":first").click();
});
});

/* ================================================================
This copyright notice must be untouched at all times.
Copyright (c) 2009 Stu Nicholls - stunicholls.com - all rights reserved.
=================================================================== */

onload = function() {

	/* default variable settings */
	timer=0;
	current = 1;
	button = 1;

	/* delay in miliiseconds */
	showTime=5500;

	/* automatic variable settings */
	pictures = 12; // Anzahl Bilder!!!
	/*pictures = $('#buttons div img').length;*/
	width = 438; // $('#p1 img').outerWidth();


	/* initial set up */
	$('#p1').animate({"left": "0px"}, 400, "swing");
	/*$('#loading').css("display","none");*/

	/* start the timer */
	timer = setTimeout ("autoPlay()", showTime);

}

function autoPlay () {
	previous = current;
	current++
	if (current == (pictures+1) ) {
		current = 1
	}
	animateLeft(current,previous);

	timer = setTimeout ("autoPlay()", showTime);
}
function animateLeft(current,previous) {
	$('#p'+current).css("left",width +"px");
	$('#p'+current).animate({"left": "0px"}, 400, "swing");
	$('#p'+previous).animate({"left": -width+"px"}, 400, "swing");
}

