/**
 * zwobNewsRotator v1.0
 *
 * Michael Wohlers
 * 21.05.2009 09:42:00
 */
var zwobNewsRotator = {

	interval:10000,

	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);} )

		$("#RotationQueue1").bind("mouseover", function() {
			zwobNewsRotator.switchRotate(false);

			$("#News1").show(); $("#News2").hide();	$("#News3").hide();
			
			$("#RotationQueue1").css("background-color", "#dbdfef");
			$("#RotationQueue2").css("background-color", "#edeff7");
			$("#RotationQueue3").css("background-color", "#edeff7");
		}).bind("mouseout", function() { zwobNewsRotator.switchRotate(true); } );

		$("#RotationQueue2").bind("mouseover", function() {
			zwobNewsRotator.switchRotate(false);

			$("#News2").show(); $("#News3").hide(); $("#News1").hide();

			$("#RotationQueue2").css("background-color", "#dbdfef");
			$("#RotationQueue3").css("background-color", "#edeff7");
			$("#RotationQueue1").css("background-color", "#edeff7");
		}).bind("mouseout", function() { zwobNewsRotator.switchRotate(true); } );

		$("#RotationQueue3").bind("mouseover", function() {
			zwobNewsRotator.switchRotate(false);

			$("#News3").show(); $("#News1").hide(); $("#News2").hide();

			$("#RotationQueue3").css("background-color", "#dbdfef");
			$("#RotationQueue1").css("background-color", "#edeff7");
			$("#RotationQueue2").css("background-color", "#edeff7");
		}).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");
			
			$("#RotationQueue1").css("background-color", "#dbdfef");
			$("#RotationQueue2").css("background-color", "#edeff7");
			$("#RotationQueue3").css("background-color", "#edeff7");
		}
		else if (n==2) {
			$("#News2").fadeIn("slow");
			$("#News3").fadeOut("slow");
			$("#News1").fadeOut("slow");

			$("#RotationQueue2").css("background-color", "#dbdfef");
			$("#RotationQueue3").css("background-color", "#edeff7");
			$("#RotationQueue1").css("background-color", "#edeff7");
		}
		else if (n==3) {
			$("#News3").fadeIn("slow");
			$("#News1").fadeOut("slow");
			$("#News2").fadeOut("slow");

			$("#RotationQueue3").css("background-color", "#dbdfef");
			$("#RotationQueue1").css("background-color", "#edeff7");
			$("#RotationQueue2").css("background-color", "#edeff7");
		}
	},
	switchRotate:function(b) {
		this.bRotate = b;
	},

	// Hilfsvariabel:Aktive News
	nc:0,	
	// Rotation durch Timeout-Steuerung
	doRotate:function() {
		this.nc++;
		if(this.nc>3) this.nc=1;
		
		zwobNewsRotator.activate(this.nc);
		setTimeout( "zwobNewsRotator.doRotate()", this.intervall );
	},
	// Rotationsintervall im Millisekunden setzen
	setIntervall:function(ms) {
		this.intervall = ms;
	}
}
