// Initialisiere jQuery im noConflict-Modus.
var $j = jQuery.noConflict();
// Initialisiere Steuer-Variablen.
var hT_animationSpeed = 250;	// Geschwindigkeit der Animation
var hT_buttonOutHeight = 53;	// Hoehe eines Buttons im Mouseout-Zustand
var hT_buttonOverHeight = 78;	// Hoehe eines Buttons beim Mouseover-Zustands
var hT_clickedTopic = 0;	// Angeklicktes Thema.
var hT_currentTopic = 0;	// Derzeit angezeigtes Thema.
var hT_fadeInSpeed = 750;	// Geschwindigkeit des Einblendens des austauchbaren Bereichs
var hT_fadeOutSpeed = 750;	// Geschwindigkeit des Ausblendens des austauchbaren Bereichs
var hT_initialTopic = 0;	// Welches Thema zuerst angezeigt wird (0 = Zufall).
var hT_totalTopics = 4;		// Gesamtanzahl der dargestellten Themen.
// Initialisiere Container, Klassen und ID-Variablen.
var hT_buttonsContainer = 0;
var hT_buttonsClass = "button";
var hT_buttonsId = "dynamicTeaserButton";
var hT_teaserContainer = 0;
var hT_teaserClass = "teaser";
var hT_teaserId = "dynamicTeaserContentArea";
$j(document).ready(function(){
	hT_buttonsContainer = $j(".dynamicTeaserButtons");
	hT_teaserContainer = $j(".dynamicTeaserContent");
	hT_updateTriggers();
	if (hT_initialTopic == 0) {
		hT_getRandomTopic(1, hT_totalTopics);
	} else {
		hT_showInitialTopic();
	}
	hT_buttonsContainer.find("a").hover(function() {
		hT_mouseoverAnimation(hT_buttonsContainer.find("a").index(this), 'mouseover');
	}, function(){
		hT_mouseoutAnimation(hT_buttonsContainer.find("a").index(this), 'mouseout');
	});
});
function hT_getRandomTopic(min, max) {
	if (min > max) {
		hT_initialTopic = max;
	} else if (min == max) {
		hT_initialTopic = max;
	} else {
		hT_initialTopic = min + parseInt(Math.random() * (max-min+1));
	}
	hT_showInitialTopic();
}
function hT_mouseoverAnimation(overId, type) {
	if (hT_currentTopic != overId || type == "initial") {
		if (overId == 0) {
			hT_buttonsContainer.find("#"+hT_buttonsId+overId).css("background-position", "right -78px");
		} else if (overId == hT_totalTopics) {
			hT_buttonsContainer.find("#"+hT_buttonsId+overId).css("background-position", "left -78px");
		} else {
			hT_buttonsContainer.find("#"+hT_buttonsId+overId).css("background-position", "center -78px");
		}
		hT_buttonsContainer.find("#"+hT_buttonsId+overId).animate({height: hT_buttonOverHeight+"px"},{queue:false,duration:hT_animationSpeed});
	}
}
function hT_mouseoutAnimation(outId, type) {
	if (hT_currentTopic != outId || type == "clicked") {
		hT_buttonsContainer.find("#"+hT_buttonsId+outId).animate({height: hT_buttonOutHeight+"px"},{queue:false,duration:hT_animationSpeed});
		if (outId == 0) {
			hT_buttonsContainer.find("#"+hT_buttonsId+outId).css("background-position", "right top");
		} else if (outId == hT_totalTopics) {
			hT_buttonsContainer.find("#"+hT_buttonsId+outId).css("background-position", "left top");
		} else {
			hT_buttonsContainer.find("#"+hT_buttonsId+outId).css("background-position", "center top");
		}
	}
}
function hT_showClickedTopic(clickedTopic) {
	hT_clickedTopic = clickedTopic;
	if (hT_clickedTopic != hT_currentTopic) {
		hT_mouseoutAnimation(hT_currentTopic, 'clicked');
		hT_mouseoverAnimation(hT_clickedTopic, 'clicked');
		hT_currentTopic = hT_clickedTopic;
		hT_transitionTopics();
	}
}
function hT_showInitialTopic() {
	hT_initialTopic = hT_initialTopic-1;
	hT_totalTopics = hT_totalTopics-1;
	hT_currentTopic = hT_initialTopic;
	hT_mouseoverAnimation(hT_currentTopic, 'initial');
	hT_transitionTopics();
}
function hT_transitionTopics() {
	hT_teaserContainer.find("."+hT_teaserClass).fadeOut(hT_fadeOutSpeed);
	hT_teaserContainer.find("#"+hT_teaserId+hT_currentTopic).fadeIn(hT_fadeInSpeed);
}
function hT_updateTriggers() {
	hT_buttonsContainer.find("a").each(function(buttonsIndex) {
		$j(this).attr("href", "javascript:hT_showClickedTopic("+buttonsIndex+");");
	});
}