/* Script 4 rutenbauer.de */

var $j = jQuery.noConflict();


$j(document).ready(function() {
	
	// Besondere Formatierung
	var cssObj = {
		'background'	: '#007EFF',
		'color'			: '#fff',
		'font-weight'	: 'bold',
		'opacity'		: '0.75'
	}
	$j('ul.menu li a[href="/cms/onlineshop.html"]').css(cssObj);
	$j('ul.menu li.current a[href="/cms/onlineshop.html"]').css("opacity", "1.0");
	
	// Image rotate
	$j("img#screenshot").rotate({
		bind: {
			mouseover	: function() {
				$j(this).rotate({
					animateTo	: 360
				})
			},
			mouseout	: function() {
				$j(this).rotate({
					animateTo	: 0
				})
			}
		}
	});
	
	var count = 1;
	var top = 0;
	// Futter Attribute
	function resizeMe() {
		$j(".img_produkt img").each(function(index) {
			var tmpSize = $j(this).outerHeight();
			//alert(index + " --> " + tmpSize);
			var thatSize = 0;
			var tmpRoot = $j(this).parent().parent().children("div.list_produkt");
			//thatSize += $j(tmpRoot).children("h2").ou
			
			$j(tmpRoot).each(function(index) {
				thatSize += $j(this).outerHeight();
			});
			//alert(index + " --> " + thatSize);
			if (thatSize > tmpSize) {
				$j(tmpRoot).css("overflow", "hidden");
				$j(tmpRoot).animate({
					height	: tmpSize
				}, 1000, function() {
					//alert("done");
					var flag = false;
					$j(this).hover(function() {
						$j(this).css("overflow", "visible").animate({
							height	: thatSize
						}, 1000);
					}, function() {
						$j(this).animate({
							height	: tmpSize
						}, 1000, function() {
							$j(this).css("overflow", "hidden");
						});
					});
					
				});
				
			}
		});
		//alert(imgSize);
	}
	
	
	// R & R
	$j(".animate #bild_02").hide();
	var src_01 = $j(".animate img#bild_01").attr("src");
	var src_02 = $j(".animate img#bild_02").attr("src");
	$j(".animate img").hover(function() {
		$j(this).attr("src", src_02);
	}, function() {
		$j(this).attr("src", src_01);
	});
	$j(".animate").click(function() {
		$j(this).attr("href", "");
		var url = "http://www.rutenbauer.de/cms/templates/beez5/restaurierung.php";
		$j.fancybox({
			'href'      : url,
			'padding'	: 0,
			'margin'	: 0,
			'autoDimensions'	: false,
			'width'				: 715,
			'height'			: 276,
			'scrolling'			: 'no',
			'showCloseButton'	: true,
			'type'				: 'iframe'
		});
	});
	
	/*
	function myAnimate() {
		$j(".animate #bild_02").hide("0", function() {
			$j(".animate #bild_01").fadeOut(2000, function() {
				$j(".animate #bild_02").fadeIn(2000, function() {
				//
				});
			});
		});
	}
	
	$j(".animate img").each(function(i, val){
		setTimeout(function() {
			var tmp = val;
			alert(i + " | " + val);
		}, 1000);
	});
	*/
	//$('.animate').innerfade({ speed: 'slow', timeout: 4000, type: 'sequence', containerheight: '220px' }); 

	// AGB
	$j(".agb .content").hide();
	$j(".agb h3").mouseover(function() {
		$j(this).css("cursor", "pointer");
	});
		
	$j(".agb h3").click(function() {
		var status = $j(this).next(".content").css("display");
	
		if (status == "none") {
			$j(this).next(".content").show("slow");
		} else {
			$j(this).next(".content").hide("slow");
		}
	});
	/*
	$j(".agb h3").each(function(e) {
		var tmp = $j(this).html();
		var add = '<a href="#' + tmp + '" title="' + tmp + '">' + tmp + '</a>';
		$j(this).html(add)
	});
	*/
	// Anfahrt
	$j("table.anfahrt").each(function() {
		$j(this).children("tbody").children("tr").children("td:first").css("background", "#ccc").css("font-weight", "bold").css("color", "#fff");
		$j(this).children("tbody").children("tr").children("td:last").css("background", "#ccc").css("font-weight", "bold").css("color", "#fff");
	});
	$j("table.anschrift tr:first td").css("background", "#ccc").css("font-weight", "bold").css("color", "#fff");
	
	// Musterruten
	
	$j(".rute").hide();
	$j(".rute").next("hr").hide();
	
	function addMyLinks(myObject) {
		var tmpNext = $j(myObject).next("hr").next(".rute").attr("class");
		var tmpPrev = $j(myObject).prev("hr").prev(".rute").attr("class");
		var myAppend = "";
		if (tmpNext == "rute") {
			myAppend = '<p style="text-align: center;"><a href="#" id="back" title="Zurück" style="text-decoration: none;">zurück</a> | <a href="#" id="up" title="Übersicht" style="text-decoration: none;">Übersicht</a> | <a href="#" id="forw" title="Vor" style="text-decoration: none;">vor</a></p>'
		} else {
			myAppend = '<p style="text-align: center;"><a href="#" id="back" title="Zurück" style="text-decoration: none;">zurück</a> | <a href="#" id="up" title="Übersicht" style="text-decoration: none;">Übersicht</a>'
		}
		if (tmpPrev != "rute") {
			myAppend = '<p style="text-align: center;"><a href="#" id="up" title="Übersicht" style="text-decoration: none;">Übersicht</a> | <a href="#" id="forw" title="Vor" style="text-decoration: none;">vor</a></p>'
		}
		$j(myObject).children(".img_show").after(myAppend);
	}
	
	function showMeMore(tmp) {
		$j('.rutenbau .rute .img_show a img[alt="' + tmp + '"]').parent().parent().parent().show(function() {
			$j(".rutenbau .small_img").slideUp("slow", function() {
				//
				
			});
			$j(this).children("p.ruten_nav").show();
			proofLinks($j(this));
			//addMyLinks($j(this));
			/*
			$j("a#up").click(function() {
				//alert("UP!");
				slideUpAndDown()
			});
			$j("a#forw").click(function() {
				$j(this).parent().parent().hide("slow", function() {
					$j(this).next("hr").next(".rute").show("slow", function() {
						addMyLinks($j(this));
					});
					
				});
			});
			*/
		});
	}

	function help4Links(myObject, p_01, p_02) {
		var tmpA = $j(myObject).children("p.ruten_nav").html();
		tmpA = $j.trim(tmpA);
		var myArray = tmpA.split(" | ");
		$j(myObject).children("p.ruten_nav").html(myArray[p_01] + " | " + myArray[p_02]);
	}

	function proofLinks(myObject) {
		//var tmpNext = $j(myObject).next("hr").next(".rute").attr("class");
		var tmpPrev = $j(myObject).prev("hr").prev(".rute");
		var tmpNext = $j(myObject).next("hr").next(".rute");
		var tmpCountP = tmpPrev.length;
		var tmpCountN = tmpNext.length;
		var tmpCountA = $j(myObject).children("p.ruten_nav").children("a").length;
		
		if (tmpCountA == 3) {
			if (tmpCountP == 0) {
				help4Links(myObject, 1, 2);
			}
			if (tmpCountN == 0) {
				help4Links(myObject, 0, 1);
			}
		}
		
	}

	// Mouse-Cursor
	$j(".rutenbau .small_img img").mouseover(function() {
		$j(this).css("cursor", "pointer");
	});

	$j(".rutenbau .small_img img").click(function() {
		var tmp = $j(this).attr("alt");
		showMeMore(tmp);
		
	});

	$j("p.ruten_nav a").live("click", function() {
		var tmpId = $j(this).attr("id");
		var myObject = $j(this).parent().parent();
		//alert(tmpId);
		switch(tmpId) {
			case "back":
				//alert("zurück");
				$j(myObject).hide("slow", function() {
					$j(this).prev("hr").prev("div.rute").show("slow", function() {
						$j(this).children("p.ruten_nav").show("slow", function() {
							proofLinks($j(this).parent());
						});
						
					});
				});
				break;
			case "up":
				//alert("hoch");
				slideUpAndDown();
				break;
			case "forw":
				//alert("vor...");
				$j(myObject).hide("slow", function() {
					$j(this).next("hr").next("div.rute").show("slow", function() {
						$j(this).children("p.ruten_nav").show("slow", function() {
							proofLinks($j(this).parent());
						});
						
					});
				});
				break;
			default:
		}
	});
	
/*	
	$j(".rutenbau .small_img img").click(function() {
		var tmp = $j(this).attr("alt");
		//alert(tmp);
		$j('.rutenbau .rute .img_show a img[alt="' + tmp + '"]').parent().parent().parent().show(function() {
			$j(".rutenbau .small_img").slideUp("slow", function() {
				//
				
			});
			var tmpNext = $j(this).next("hr").next(".rute").attr("class");
			var tmpPrev = $j(this).prev("hr").prev(".rute").attr("class");
			var myAppend = "";
			if (tmpNext == "rute") {
				myAppend = '<p style="text-align: center;"><a href="#" id="back" title="Zurück" style="text-decoration: none;">zurück</a> | <a href="#" id="up" title="Übersicht" style="text-decoration: none;">Übersicht</a> | <a href="#" id="forw" title="Vor" style="text-decoration: none;">vor</a></p>'
			} else {
				myAppend = '<p style="text-align: center;"><a href="#" id="back" title="Zurück" style="text-decoration: none;">zurück</a> | <a href="#" id="up" title="Übersicht" style="text-decoration: none;">Übersicht</a>'
			}
			if (tmpPrev != "rute") {
				myAppend = '<p style="text-align: center;"><a href="#" id="up" title="Übersicht" style="text-decoration: none;">Übersicht</a> | <a href="#" id="forw" title="Vor" style="text-decoration: none;">vor</a></p>'
			}
			$j(this).children(".img_show").after(myAppend);
			$j("a#up").click(function() {
				//alert("UP!");
				slideUpAndDown()
			});
		});
		//alert(tmp2);
	});
*/
	function slideUpAndDown() {
		$j(".rute").hide(function() {
			$j(".rutenbau .small_img").slideDown("slow", function() {
				//	
			});
		});
	}
/*
	$j(".rutenbau h3").click(function() {
		slideUpAndDown();
	});
*/
	/*
	$j('.rutenbau .rute .img_show img').click(function() {
		slideUpAndDown();
	});
*/
	
	// lädt bzw. blendet den Content ein, nachdem alles geladen wurde...
	
	$j(window).load(function() {
		$j("div.loader").remove();
		$j("div.konfigurator").show();
		// Zoom
		var tmp_L = $j("a.myOwnBox").length;
		if (tmp_L != 0) {
			$j("a.myOwnBox").fancybox();
		}
		
		// animate R&R
		//myAnimate();
		// Futter Attr
		resizeMe();
	});

	// Konfigurator
	// Styling
	// Handelt den Ablauf beim Klicken aufs Bild
	$j("div.konfigurator div.images div.kategorie div.img div.img_bg img").click(function() {
		// Infotext ausblenden
		$j("div.konfigurator div.showroom div.infoText").hide("slow");
		
		// Variablen zur Prüfung
		var toAdd = true;
		var tmp_1 = $j(this).attr("src");
		var imgName = $j(this).attr("title");
		// Überprüft alle Bilder im Showroom, ob das neue schon drin ist (keine Doppelt!)
		$j("div.konfigurator div.showroom img").each(function() {
			var tmp_2 = $j(this).attr("src");
			if (tmp_1 == tmp_2) {
				toAdd = false;
				return false;
			}
		});
		// wenn es noch nicht drin ist:
		if (toAdd) {
			$j(this).fadeTo("slow", 0.25);
			var newItem = $j(this).clone();
			// Animation
			$j(this).parent().parent().parent().parent().parent().children("div.showroom").append(newItem);
			// Erstellt die Liste, wenn sie noch nicht da ist
			var tmpo = $j("div.konfigurator_list ol").attr("class");
			if (tmpo == null) {
				$j("div.konfigurator_list").append('<ol>');
				
			}
			// Fügt Senden / Entfernen zur Liste hinzu
			//alert($j("div.konfigurator_list").children(".handling").length);
			
			if ($j("div.konfigurator_list").next(".handling").length == 0) {
				var tmpElement = $j(".konfigurator .handling").clone();
				$j("div.konfigurator_list").after(tmpElement);
			}
			// Fügt Listenelemente hinzu
			$j("div.konfigurator_list ol").append('<li>' + imgName + '</li>');
			$j("div.konfigurator_list").fadeTo("slow", 0.25, function() {
				$j(this).fadeTo("fast", 1.0);
			})
			// Breite und Höhe der kleinen Bilder + Animation
			var myWidth = 135;
			var myHeight = myWidth * 0.75;
			newItem.fadeIn(1000, function() {
				newItem.animate({ 
					width: myWidth 
				}).animate({ 
					height: myHeight 
				});
			});
		} else {
			// wenn es schon drin war, dann wird es durch erneuten Klick entfernt
			// händelt das Entfernen des gewählten Bildes
			$j("div.konfigurator div.showroom img").each(function() {
				var tmp_2 = $j(this).attr("src");
				if (tmp_1 == tmp_2) {
					$j(this).remove();
					return false;
				}
			});
			// händelt das Entfernen des gewählten Bildes aus der Liste
			$j("div.konfigurator_list ol li").each(function() {
				var tmpName = $j(this).html();
				if (imgName == tmpName) {
					$j(this).remove();
					// test
					$j('.kategorie .img .img_bg img[title="' + tmpName + '"]').fadeTo("slow", 1);
					return false;
				}
			});
			
			$j(this).fadeTo("slow", 1);
		}
		
		// Setzt immer den Margin neu
		var tmp = $j("div.konfigurator div.showroom img");
		$j.each(tmp, function() {
			$j(this).css("margin", "5px 5px 0px 0px");
		});
		// anschließend setzt es den Margin des letzten Bildes
		$j("div.konfigurator div.showroom img:last").css("margin-right", "0px");
		// ändert den Margin des letzten Bildes einer Liste (5 Stück)
		$j("div.konfigurator div.showroom img").eq(4).css("margin-right", "0px");
		$j("div.konfigurator div.showroom img").eq(8).css("margin-right", "0px");
		$j("div.konfigurator div.showroom img").eq(12).css("margin-right", "0px");
		$j("div.konfigurator div.showroom img").eq(16).css("margin-right", "0px");
		$j("div.konfigurator_list ol li:first").css("padding-top", "5px");
	});
	// Mouse-Cursor
	$j("div.konfigurator div.images h3").mouseover(function() {
		$j(this).css("cursor", "pointer");
	});
	$j("div.konfigurator div.images div.kategorie div.img div.img_bg img").mouseover(function() {
		$j(this).css("cursor", "pointer");
	});

	// Höhe

	// Handling
	$j("div.konfigurator div.handling p a").click(function() {
		var cur = $j(this).html();
		switch(cur) {
			case "Senden":
				//alert("Senden");
				var myString = "";
				/*
				$j("div.konfigurator div.showroom img").each(function() {
					myString += $j(this).attr("title") + "\n";
				});
				*/
				var count = 1;
				$j("div.konfigurator_list ol li").each(function() {
					myString += "(" + count + ") " + "\t" + $j(this).html() + "---" + "\n";
					count++;
				});
				//alert(myString);
				mySend(myString);
				break;
			case "Alles Entfernen":
				//alert("Alles Entfernen");
				$j("div.konfigurator div.showroom img").each(function() {
					$j(this).fadeTo("slow", 0, function() {
						$j(this).remove();
					});
				});
				$j("div.konfigurator_list ol li").each(function() {
					$j(this).fadeTo("slow", 0, function() {
						$j(this).remove();
					});
				});
				$j("div.konfigurator_list").next(".handling").remove();
				//$j("div.konfigurator div.showroom img").remove();
				$j("div.konfigurator img").each(function() {
					$j(this).fadeTo("fast", 1.0);
				});
				// Infotext wieder einblenden
				$j("div.konfigurator div.showroom div.infoText").show("slow");
				break;
			default:
				alert("Nothing");
				break;
		}
	});

	function mySend(liste) {
		//alert(liste);
		var add = " --- ---Machen Sie mir bitte für obige Artikel ein Angebot. --- ---Mit freundlichem Gruß ---";
		liste += add;
		var url = "http://www.rutenbauer.de/cms/templates/beez5/mail/index.php?name=Konfigurator&liste=" + liste + "";
		$j.fancybox({
			'href'      : url,
			'width'		: '75%',
			'height'	: '75%',
			'type'		: 'iframe'
		});
	}

	// TEST JCart
	
	$j("input#mail_button").click(function() {
		var bestellung = "";
		var elemente = $j('input[name="jcartItemQty[]"]');
		var lastID = elemente.length - 1;
		
		$j('input[name="jcartItemQty[]"]').each(function(index) {
			var qty = $j(this).attr("value");
			var artikel = $j(this).parent().parent().children("td.jcart-item-name").text();
			artikel = jQuery.trim(artikel);
			var preis = $j(this).parent().parent().children("td.jcart-item-price").children("span:first").text();

			bestellung += "Artikel: " + qty + " x " + artikel + " für: " + preis + "---";
			if (index == lastID) {
				var summe = $j("span#jcart-subtotal strong").text();
				bestellung += "---" + "Gesamtsumme: " + summe;
				//sendOrder(bestellung);
				var tmp = "Testbestellung";
				var url = "http://www.rutenbauer.de/cms/templates/beez5/mail/index.php?name=" + tmp + "&liste=" + bestellung + "";
				$j.fancybox({
					'href'      : url,
					'width'		: '75%',
					'height'	: '50%',
					'type'		: 'iframe'
				});
			}
		});
	});
	
	$j("div.attr").each(function() {
		var tmp_H = $j(this).outerHeight();
		var cssObj = {
			'overflow'	: 'scroll',
			'width'		: '100%',
			'height'	: '212px'
		}
		if (tmp_H > 212) {
			$j(this).css(cssObj);
		}
	});
	
	$j("div#header-image").click(function() {
		var url = "http://www.rutenbauer.de/cms/includes/futter_width_card_01.php";
		$j.fancybox({
			'href'      : url,
			'padding'	: 0,
			'margin'	: 0,
			'autoDimensions'	: false,
			'width'				: 960,
			'height'			: 640,
			'scrolling'			: 'yes',
			'showCloseButton'	: true,
			'type'				: 'iframe'
		});
	});
	
	/*
	$j("div.prod").hide("slow", function() {
		$j("div.kategorie").css("cursor", "pointer");
		$j("div.kategorie").click(function() {
			
			$j(this).children("div.prod").show("slow", function() {
				//
			});
		})
	});
	*/
	// TEST Ende

	// Frage zum Produkt
	$j("div.ask a").click(function() {
		var add = "Ich interessiere mich für diesen Artikel. Bitte lassen Sie mir nähere Informationen zukommen.--- ---Mit freundlichem Gruß ---";
		var vergleich = $j(this).attr("class");
		//alert(vergleich);
		if (vergleich == "a_right") {
			add = "Ich möchte diesen Artikel gern bestellen. Bitte machen Sie mir ein Angebot über die Menge: XXX.--- ---Mit freundlichem Gruß ---";
		}
		var tmp = $j(this).parent().parent().children("div.list_produkt").children("h2").html();
		if (tmp == null) {
			tmp = $j(this).attr("title");
		}
		var url = "http://www.rutenbauer.de/cms/templates/beez5/mail/index.php?name=" + tmp + "&liste=" + add + "";
		$j.fancybox({
			'href'      : url,
			'width'		: '75%',
			'height'	: '50%',
			'type'		: 'iframe'
		});
		return false;
	});
	// Frage zum Produkt Part 2 --> Kann noch mit der 1. zusammengefasst werden
	var target = "";
	var href = "";
	$j("div.ask2 a.a_left").hover(function() {
		target = $j(this).attr("target");
		$j(this).removeAttr("target");
		href = $j(this).attr("href");
		$j(this).removeAttr("href");
		$j(this).css("cursor", "pointer");
	}, function() {
		$j(this).attr("target", target);
		$j(this).attr("href", href);
	});
	$j("div.ask2 a.a_left").click(function() {
		var windowW		= $j(window).width();
		var windowH		= $j(window).height();
		var produkt_id	= $j(this).parent().parent().children('input[name="produkt_id"]').attr("value");
		//var url			= "https://ssl.webpack.de/rutenbauer.de/cms/includes/ocie/index.php?route=product/product&product_id=" + produkt_id + "";
		var newW		= 480 + 40;
		var newH		= 520 + 40;
		$j.fancybox({
			'href'      : href,
			'width'		: newW,
			'height'	: newH,
			'type'		: 'iframe'
		});
		return false;
	});
	$j("div.ask2 a.a_right").hover(function() {
		target = $j(this).attr("target");
		$j(this).removeAttr("target");
		href = $j(this).attr("href");
		$j(this).removeAttr("href");
		$j(this).css("cursor", "pointer");
	}, function() {
		$j(this).attr("target", target);
		$j(this).attr("href", href);
	});
	$j("div.ask2 a.a_right").click(function() {
		var windowW		= $j(window).width();
		var windowH		= $j(window).height();
		var produkt_id	= $j(this).parent().parent().children('input[name="produkt_id"]').attr("value");
		//var url			= "https://ssl.webpack.de/rutenbauer.de/cms/includes/ocie/index.php?route=product/product&product_id=" + produkt_id + "";
		var newW		= windowW - 100;
		var newH		= windowH - 100;
		$j.fancybox({
			'href'      : href,
			'width'		: newW,
			'height'	: newH,
			'type'		: 'iframe'
		});
		return false;
	});
	
	// andere Links für die Fancybox
	var mce_href = "";
	$j("div.onlineshop a").hover(function() {
		target = $j(this).attr("target");
		$j(this).removeAttr("target");
		href = $j(this).attr("href");
		$j(this).removeAttr("href");
		mce_href = $j(this).attr("_mce_href");
		$j(this).removeAttr("_mce_href");
		$j(this).css("cursor", "pointer");
	}, function() {
		$j(this).attr("target", target);
		$j(this).attr("href", href);
		$j(this).attr("_mce_href", mce_href);
	});
	$j("div.onlineshop a").click(function() {
		var windowW		= $j(window).width();
		var windowH		= $j(window).height();
		var newW		= windowW - 100;
		var newH		= windowH - 100;
		$j.fancybox({
			'href'      : href,
			'width'		: newW,
			'height'	: newH,
			'type'		: 'iframe'
		});
		return false;
	});
	
	// Formular
	$j("form.formular").submit(function() {
		var tmp			= $j("div.fehler").html();
		var vergleich	= "Ihre Mail wurde versendet!";
		//alert(tmp)
		if (tmp == vergleich) {
			//alert("aus");
		}
		
	});

	$j("div.img_rutenbau div.img_small").click(function (e) {  
		//alert($j(e.target).attr("src"));
		var mySrcSmall	= $j(e.target).attr("src");
		var mySrcBig	= $j("div.img_rutenbau div.img_big img").attr("src");
		$j("div.img_rutenbau div.img_big img").attr("src", mySrcSmall).blur();
		$j(e.target).attr("src", mySrcBig);
	});
	/* New Style Rutenbau */
	$j("div.img_rutenbau_img_small img").click(function () {  
		/*	Ablauf
			- speichere src von der Quelle
			- speicher html vom Bruder der Quelle
			- ermittle Ziel
			- speicher src vom Ziel
			- speicher html vom Bruder des Ziels
			- wechsel die Werte von Quelle --> Ziel
		*/
		var srcQuelle	= $j(this).attr("src");
			//$j(this).fadeOut("fast");
		var descQuelle	= $j(this).next().html();
			//$j(this).next().fadeTo("fast", 0);
		var ziel		= $j(this).parent().parent().children(".img_rutenbau_img_big").children("img");
			ziel.fadeOut("fast");
		var srcZiel		= ziel.attr("src");
		var descZiel	= ziel.next().html();
			ziel.next().fadeTo("fast", 0);
		$j(this).attr("src", srcZiel);
			//$j(this).fadeIn("fast");
		ziel.attr("src", srcQuelle);
			ziel.fadeIn("fast");
		$j(this).next().html(descZiel);
			//$j(this).next().fadeTo("slow", 1.0);
		ziel.next().html(descQuelle);
			ziel.next().fadeTo("slow", 1.0);
	});
	/* Table Style*/
	
	/* Accordion */
	var iconUp		= "/cms/templates/beez5/images/icon_slide_up.png"
	var iconDown	= "/cms/templates/beez5/images/icon_slide_down.png"
	
	$j(".konfigurator .images .heading").each(function() {
		$j(this).next(".kategorie").hide();
		var tmpName = $j(this).html();
		$j(this).html('<img src="' + iconDown + '" style="width: 12px; height: 12px; margin: 0px 10px 0px 0px;"/>' + tmpName);
	});
	
	var speed = 500;
	$j(".konfigurator .images .heading").click(function() {
		var name = $j(this).html();
		var tmpName = $j(this).html();
		$j(".konfigurator .images .heading").each(function() {
			if ($j(this).html() != name) {
				$j(this).next(".kategorie").hide(speed / 2);
				$j(this).children("img").attr("src", iconDown);
			}
		});
		//$j(this).next(".kategorie").show(speed);
		if ($j(this).next(".kategorie").css("display") == "block") {
			$j(this).next(".kategorie").hide(speed / 2);
			$j(this).children("img").attr("src", iconDown);
		} else {
			$j(this).next(".kategorie").show(speed);
			$j(this).children("img").attr("src", iconUp);
			// Description Höhe anpassen - reagiert bei Auswahl Accordion-Header
			// Einmal durchlaufen um den höchsten Desc-Tag zu ermitteln
			// nimmt immer nur die Tags, zu dem zugehörigen Header
			var tmp = $j(this).next(".kategorie").children(".img").children(".desc").children("p");
			var myHeight = 0;
			$j.each(tmp, function() {
				var tmpHeight = $j(this).height();
				if (tmpHeight > myHeight) {
					myHeight = tmpHeight;
				}
			});
			//alert("Der höchste ist: " + myHeight);
			// Nochmal durchlaufen, um alle gleich hoch zu setzen
			$j.each(tmp, function() {
				$j(this).css("height", myHeight);
			});
		}
	});
	
	// Tabelle Desc Konfigurator
	$j(".desc table tbody tr td:even").css("background", "#ccc").css("font-weight", "bold").css("color", "#fff");
	$j(".desc table tbody tr td:odd").css("text-align", "center");
	
	// Produkte / Futter
	$j("table.attr").each(function(index) {
		$j(this).children("tbody").children("tr:first").children("td").css("background", "#7BA428").css("font-weight", "bold").css("color", "#fff");
	});
	$j("table.details").each(function(index) {
		$j(this).children("tbody").children("tr").children("td:even").css("background", "#7BA428").css("font-weight", "bold").css("color", "#fff");
	});
	$j("div.desc_produkt table").each(function(index) {
		$j(this).children("tbody").children("tr:first").children("td").css("background", "#7BA428").css("font-weight", "bold").css("color", "#fff");
	});
	// Ausblenden leere Tabellen
	$j("table.attr").each(function(index) {
		var tmp = $j(this).children("tbody").children("tr").length;
		if (tmp == 1) {
			$j(this).hide();
			$j(this).prev("p").hide();
		}
	});
	// Abstand anpassen, wenn kein Slogan da ist
	$j("div.list_produkt").each(function(index) {
		var tmp = $j(this).children("h3").html();
		if (tmp != "") {
			$j(this).children("table.details").css("margin-top", "20px");
		}
	});
});
