// ----------------------------------------------------------------
// QUOTES - Zitate
// Copyright by Marcus Ollas. All Rights Reserved.
// ----------------------------------------------------------------
var QUOTES = {
	// ------------------------------------------------------------
	container : null,
	inner : null,
	current : null,
	opacity : 255,
	step : 4,
	delay : 25,
	appearance : 5000,
	pause : 2000,
	// ------------------------------------------------------------
	init : function(id) {
		QUOTES.container = document.getElementById(id);
		if (QUOTES.container) {
//			QUOTES.container.style.visibility = 'hidden';
			QUOTES.inner = QUOTES.container.firstChild.firstChild;
			QUOTES.current = QUOTES.inner.firstChild;
		}
		if (QUOTES.current)
			QUOTES.start();
	},
	start : function() {
		QUOTES.container.style.visibility = 'visible';
		QUOTES.fadeIn();
	},
	fadeIn : function() {
		if (QUOTES.opacity == 255)
			QUOTES.current.style.display = 'block';
		if (QUOTES.opacity > 52) {
			QUOTES.opacity -= QUOTES.step;
			QUOTES.apply();
			window.setTimeout("QUOTES.fadeIn()",QUOTES.delay);
		}
		else {
			QUOTES.container.filter = '';
			window.setTimeout("QUOTES.fadeOut()",QUOTES.appearance);
		}
	},
	fadeOut : function() {
		if (QUOTES.opacity < 255) {
			QUOTES.opacity += QUOTES.step;
			QUOTES.apply();
			window.setTimeout("QUOTES.fadeOut()",QUOTES.delay);
		}
		else {
			QUOTES.current.style.display = 'none';
			QUOTES.opacity = 255;

			// Next element
			if (QUOTES.current.nextSibling)
				QUOTES.current = QUOTES.current.nextSibling;
			else
				QUOTES.current = QUOTES.current.parentNode.firstChild;

			window.setTimeout("QUOTES.fadeIn()",QUOTES.pause);
		}
	},
	apply : function() {
		r = QUOTES.dec2hex(Math.max(54,QUOTES.opacity));
		g = QUOTES.dec2hex(Math.max(57,QUOTES.opacity));
		b = QUOTES.dec2hex(Math.max(52,QUOTES.opacity));
		QUOTES.inner.style.color = '#' + r + g + b;
	},
	dec2hex : function(dec) {
		var digits = new Array(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F');
		var high = parseInt(dec/16);
		return digits[high] + '' + digits[dec-high*16];
	}
};
// ----------------------------------------------------------------
// END OF quotes.js
// ----------------------------------------------------------------
