$(document).ready(function() {
	
	var _active = 1;
	var _count = 1;
	var _max = 0;
	var _width = $('#slideWrap').width();
	
	// HIDE ALL SLIDESHOW TEXT EXCEPT FIRST ONE
	$('.slideContent').not(":first").hide();
	
	// CREATE SLIDESHOW STATUS DOTS
	$('.slide').each(function(){
		_max++;
		$('#slideStatus').append('<img src="images/dot.gif" id="status'+_max+'" />');
	});
	$('#slideStatus img:first').attr("src", "images/dot_active.gif");
	
	// ROTATE FUNCTION (HORIZONTAL SLIDE)
	function rotateSlides() {
		$('#slides').animate({ opacity: "1" }, 5000, function(){
			var _left = -(_width*_count)+"px";
			$(this).animate({ left: _left }, 1000, "swing", function(){
				_count++;
				var _nextText = "#slideContent_"+_count;
				var _nextStatus = "#status"+_count;
				checkCount();
				$('.slideContent:visible').fadeOut("fast", function(){
					$("#slideStatus img").attr("src", "images/dot.gif");
					$(_nextStatus).attr("src", "images/dot_active.gif");
					$(_nextText).fadeIn("fast");
				});
			});
		});
	}
	
	// CHECK TO SEE IF WE NEED TO CYCLE BACK TO SLIDE 1
	function checkCount() {
		if(_count == _max) {
			_count = 0;
		}
		
		if(_active == 1) {
			rotateSlides();
		}
	}
	
	// START SLIDESHOW
	checkCount();
	
	// CLICK FUNCTION FOR SLIDESHOW DOTS
	$('#slideStatus img').click(function(){
		var _id = $(this).attr("id");
		_id = _id.replace("status", "");
		
		_active = 0;
		if (_count != _id) {
			//alert(_id);
			var _left = -(_width*(_id-1))+"px";
			$('#slides').stop().animate({ left: _left }, 1000, "swing",function(){
				var _nextText = "#slideContent_"+_id;
				var _nextStatus = "#status"+_id;
				$('.slideContent:visible').fadeOut("fast", function(){
					$("#slideStatus img").attr("src", "images/dot.gif");
					$(_nextStatus).attr("src", "images/dot_active.gif");
					$(_nextText).fadeIn("fast");
				});
			});
			_count = 0;
		}
		
	});
	
	
	/*
		Produkte Image Replace Script...
	
	*/
	
	
	$("a.prodThumb").click(function(){
		
		var _id = $(this).attr("id");
		
		var _imgHolder = _id.replace("thumb_","proWrap");
		
		$(".proWrapp:visible").fadeOut("normal",function(){
			
			$("#" + _imgHolder).fadeIn("normal");
			
		});
		
		return false;
		
	});
	
	$("a.qlink").click(function(){
		
		var _id = $(this).attr("id");
		
		var _answerHolder = _id.replace("qlink","answer");
		
		$("div.answer:visible").fadeOut("normal",function(){
			
			$("#" + _answerHolder).fadeIn("normal");
			
		});
		
		return false;
		
	});
	
	/*$("#cta3").hover(function(){
		
		$(this).find("a").slideUp();
		
	},function(){
		
		$(this).find("a").slideDown();
		
	});
	
	$("#onlineKaufenLink").click(function(){
		
		return false;
		
	})*/
	
});



Cufon.replace("h1,h2", { hover:true });

