/**
 * zwobNewsRotator v1.0
 *
 * Michael Wohlers
 * 21.05.2009 09:42:00
 */
var zwobNewsRotator = {

	interval:8000,

	init:function () {

		this.switchRotate(true);

		$("#News1").bind("mouseover", function() {zwobNewsRotator.switchRotate(false);} ).bind("mouseout", function() {zwobNewsRotator.switchRotate(true);} )
		$("#News2").bind("mouseover", function() {zwobNewsRotator.switchRotate(false);} ).bind("mouseout", function() {zwobNewsRotator.switchRotate(true);} )
		$("#News3").bind("mouseover", function() {zwobNewsRotator.switchRotate(false);} ).bind("mouseout", function() {zwobNewsRotator.switchRotate(true);} )
		$("#News4").bind("mouseover", function() {zwobNewsRotator.switchRotate(false);} ).bind("mouseout", function() {zwobNewsRotator.switchRotate(true);} )

		$("#RotationQueue1").bind("mouseover", function() {
			zwobNewsRotator.switchRotate(false);

			$("#News1").show(); $("#News2").hide();	$("#News3").hide();	$("#News4").hide();
			
			$("#RotationQueue1").removeClass('tab1-3').addClass('tab1-3hover');
			$("#RotationQueue2").removeClass('tab1-3hover').addClass('tab1-3');
			$("#RotationQueue3").removeClass('tab1-3hover').addClass('tab1-3');
			$("#RotationQueue4").removeClass('tab4hover').addClass('tab4');
		}).bind("mouseout", function() { zwobNewsRotator.switchRotate(true); } );

		$("#RotationQueue2").bind("mouseover", function() {
			zwobNewsRotator.switchRotate(false);

			$("#News2").show(); $("#News3").hide(); $("#News4").hide(); $("#News1").hide();

			$("#RotationQueue2").removeClass('tab1-3').addClass('tab1-3hover');
			$("#RotationQueue3").removeClass('tab1-3hover').addClass('tab1-3');
			$("#RotationQueue4").removeClass('tab4hover').addClass('tab4');
			$("#RotationQueue1").removeClass('tab1-3hover').addClass('tab1-3');
		}).bind("mouseout", function() { zwobNewsRotator.switchRotate(true); } );

		$("#RotationQueue3").bind("mouseover", function() {
			zwobNewsRotator.switchRotate(false);

			$("#News3").show(); $("#News4").hide(); $("#News1").hide(); $("#News2").hide();

			$("#RotationQueue3").removeClass('tab1-3').addClass('tab1-3hover');
			$("#RotationQueue4").removeClass('tab4hover').addClass('tab4');
			$("#RotationQueue1").removeClass('tab1-3hover').addClass('tab1-3');
			$("#RotationQueue2").removeClass('tab1-3hover').addClass('tab1-3');
		}).bind("mouseout", function() { zwobNewsRotator.switchRotate(true); } );

		$("#RotationQueue4").bind("mouseover", function() {
			zwobNewsRotator.switchRotate(false);

			$("#News4").show(); $("#News1").hide(); $("#News2").hide(); $("#News3").hide();

			$("#RotationQueue4").removeClass('tab4').addClass('tab4hover');
			$("#RotationQueue1").removeClass('tab1-3hover').addClass('tab1-3');
			$("#RotationQueue2").removeClass('tab1-3hover').addClass('tab1-3');
			$("#RotationQueue3").removeClass('tab1-3hover').addClass('tab1-3');
		}).bind("mouseout", function() { zwobNewsRotator.switchRotate(true); } );


		// Starten mit News1
		this.activate(1);

	},
	activate:function(n) {

		if (!this.bRotate) return;

		if (n==1) {
			$("#News1").fadeIn("slow");
			$("#News2").fadeOut("slow");
			$("#News3").fadeOut("slow");
			$("#News4").fadeOut("slow");
			
			$("#RotationQueue1").removeClass('tab1-3').addClass('tab1-3hover');
			$("#RotationQueue2").removeClass('tab1-3hover').addClass('tab1-3');
			$("#RotationQueue3").removeClass('tab1-3hover').addClass('tab1-3');
			$("#RotationQueue4").removeClass('tab4hover').addClass('tab4');
		}
		else if (n==2) {
			$("#News2").fadeIn("slow");
			$("#News3").fadeOut("slow");
			$("#News4").fadeOut("slow");
			$("#News1").fadeOut("slow");

			$("#RotationQueue2").removeClass('tab1-3').addClass('tab1-3hover');
			$("#RotationQueue3").removeClass('tab1-3hover').addClass('tab1-3');
			$("#RotationQueue4").removeClass('tab4hover').addClass('tab4');
			$("#RotationQueue1").removeClass('tab1-3hover').addClass('tab1-3');
		}
		else if (n==3) {
			$("#News3").fadeIn("slow");
			$("#News4").fadeOut("slow");
			$("#News1").fadeOut("slow");
			$("#News2").fadeOut("slow");

			$("#RotationQueue3").removeClass('tab1-3').addClass('tab1-3hover');
			$("#RotationQueue4").removeClass('tab4hover').addClass('tab4');
			$("#RotationQueue1").removeClass('tab1-3hover').addClass('tab1-3');
			$("#RotationQueue2").removeClass('tab1-3hover').addClass('tab1-3');
		}
		else if (n==4) {
			$("#News4").fadeIn("slow");
			$("#News1").fadeOut("slow");
			$("#News2").fadeOut("slow");
			$("#News3").fadeOut("slow");

			$("#RotationQueue4").removeClass('tab4').addClass('tab4hover');
			$("#RotationQueue1").removeClass('tab1-3hover').addClass('tab1-3');
			$("#RotationQueue2").removeClass('tab1-3hover').addClass('tab1-3');
			$("#RotationQueue3").removeClass('tab1-3hover').addClass('tab1-3');
		}
	},
	switchRotate:function(b) {
		this.bRotate = b;
	},

	// Hilfsvariabel:Aktive News
	nc:0,	
	// Rotation durch Timeout-Steuerung
	doRotate:function() {
		this.nc++;
		if(this.nc>4) this.nc=1;
		
		zwobNewsRotator.activate(this.nc);
		setTimeout( "zwobNewsRotator.doRotate()", this.intervall );
	},
	// Rotationsintervall im Millisekunden setzen
	setIntervall:function(ms) {
		this.intervall = ms;
	}
}

/*Steuerung der Karten*/
var switcher={start:function(){var loadmap=$('a.active').attr('href');$("#divkarte").load(loadmap,function(){$("#divloader").hide();$("#divkarte").fadeIn("slow");});switcher.toggleMap();switcher.mapIt();},mapIt:function(){$("map > area").tooltip({opacity:0.9,positionLeft:false,showURL:false,left:5,showBody:" | ",track:false,fade:250});},toggleMap:function(){$(".link1,.link2,.link3,.link4,.link5,.link6").click(function(){$('a.active').removeClass("active");$(this).addClass("active");$("#divkarte").hide();$("#divloader").show();var urlmap=$(this).attr('href');$("#divkarte").load(urlmap,function(){$("#divloader").hide();$("#divkarte").fadeIn("slow");});return false;})}}

jQuery(
	function($) {
		zwobNewsRotator.init();
		zwobNewsRotator.setIntervall(8000);
		zwobNewsRotator.doRotate();
		switcher.start();
	});


