function jSMAlbum() {

	var SELF = null;
	var ID = '';
	var TIME = 5000;
	var IMG = new Image();
	var IMG_LIST = new Array();
	var IMG_LIST_COUNT = 0;
	var OBJ_ENABLE = null;
	var OBJ_SLIDESHOW = null;
	var OBJ_WAIT = null;
	var OBJ_IMAGE = null;
	var OBJ_IMAGE_TEXT = null;
	var TIMER_SLIDESHOW = null;

	this.Event = function() {
		if (document.all && !window.opera) {
			//document.attachEvent('onkeypress', this.Keypress);
			document.attachEvent('onkeydown', this.Keydown);
			document.attachEvent('onscroll', this.Scroll);
			window.attachEvent('onresize', this.Resize);

		}
		else {
			//document.addEventListener('keypress', this.Keypress, true);
			document.addEventListener('keydown', this.Keydown, true);
			document.addEventListener('scroll', this.Scroll, true);
			window.addEventListener('resize', this.Resize, true);
		}
	};

	// ID setzen
	this.SetID = function(id) {
		ID = id;
	};

	// ID zurückgeben
	this.GetID = function() {
		return ID;
	};

	// Slideshow-Zeit setzen
	this.SetTime = function(time) {
		TIME = time;
	};

	// Slideshow-Zeit zurückgeben
	this.GetTime = function() {
		return TIME;
	};

	// Neuen Menüpunkt unzufügen
	this.Add = function(src, text) {
		IMG_LIST.push({'src': src, 'text': text});
	};

	// Bilddatei anzeigen
	this.Show = function(src, text) {
		IMG_LIST_COUNT = 0;

		OBJ_ENABLE = document.getElementById('album_enable');
		OBJ_SLIDESHOW = document.getElementById('album_slideshow_info');
		OBJ_WAIT = document.getElementById('album_wait');
		OBJ_IMAGE = document.getElementById('album_image');
		OBJ_IMAGE_TEXT = document.getElementById('album_image_text');

		if (document.all && !window.opera) {
			document.attachEvent('onscroll', this.Scroll);
		}
		else {
			document.addEventListener('scroll', this.Scroll, true);
		}

		this.SetImageText(text);
		this.Enable(false);
		this.EnableSlideshow(false);
		this.ResizeEnable();

		this.ShowWait();
		IMG = new Image();
		IMG.onload = this.ShowImage;
		IMG.src = src;

		// Aktuelle Bilddatei in der Bildliste suchen
		for (i = 0; IMG_LIST.length; i++) {
			if (IMG_LIST[i]['src'] == src && IMG_LIST[i]['text'] == text) {
				IMG_LIST_COUNT = i;
				break;
			}
		}
	};

	// Nächste Bilddatei anzeigen
	this.ShowNext = function(src, text) {
		if (document.all && !window.opera) {
			document.attachEvent('onscroll', this.Scroll);
		}
		else {
			document.addEventListener('scroll', this.Scroll, true);
		}

		if (OBJ_WAIT) { OBJ_WAIT.style.display = 'block'; }
		if (OBJ_IMAGE) { OBJ_IMAGE.style.display = 'none'; }
		if (OBJ_IMAGE_TEXT) { OBJ_IMAGE_TEXT.style.display = 'none'; }
		
		this.SetImageText(text);

		this.ShowWait();
		IMG = new Image();
		IMG.onload = this.ShowImage;
		IMG.src = src;
	};

	// Slideshow anzeigen
	this.ShowSlideshow = function(src, text) {
		if (this.IsEnable() && this.IsEnableSlideshow()) {
			if (document.all && !window.opera) {
				document.attachEvent('onscroll', this.Scroll);
			}
			else {
				document.addEventListener('scroll', this.Scroll, true);
			}

			if (OBJ_WAIT) { OBJ_WAIT.style.display = 'block'; }
			if (OBJ_IMAGE) { OBJ_IMAGE.style.display = 'none'; }
			if (OBJ_IMAGE_TEXT) { OBJ_IMAGE_TEXT.style.display = 'none'; }
			
			this.SetImageText(text);

			this.ShowWait();
			IMG = new Image();
			IMG.onload = this.ShowImage;
			IMG.src = src;

			if (IMG_LIST.length <= 1) { return; }

			IMG_LIST_COUNT++;
			if (IMG_LIST_COUNT >= IMG_LIST.length || !IMG_LIST[IMG_LIST_COUNT]) { IMG_LIST_COUNT = 0; }
		}
	};

	this.Keydown = function(e) {
		e = (e) ? e : ((event) ? event : null);
		//alert(e.keyCode);

		// Album beenden
		if (SELF.IsEnable()) {

			// "ESC"-Taste
			if (e.keyCode == 27) {
				SELF.Enable(true);
			}
		}

		// Slideshow starten / beenden
		if (SELF.IsEnable() && e.keyCode == 83) {
			if (SELF.IsEnableSlideshow()) { SELF.EnableSlideshow(false); }
			else {
				SELF.EnableSlideshow(true);
			}
		}

		// Tastaturabfrage
		if (SELF.IsEnable() && !SELF.IsEnableSlideshow()) {

			// "Links"-, "Unten" und "Minus"-Taste
			if (e.keyCode == 37 || e.keyCode == 40 || e.keyCode == 109) {
				if (IMG_LIST.length <= 1) { return; }

				IMG_LIST_COUNT--;
				if (!IMG_LIST[IMG_LIST_COUNT]) { IMG_LIST_COUNT = IMG_LIST.length-1; }

				SELF.ShowNext('' + IMG_LIST[IMG_LIST_COUNT]['src'] + '', '' + IMG_LIST[IMG_LIST_COUNT]['text'] + '');
			}

			// "Rechts"-, "Oben" und "Plus"-Taste
			if (e.keyCode == 38 || e.keyCode == 39 || e.keyCode == 107) {
				if (IMG_LIST.length <= 1) { return; }

				IMG_LIST_COUNT++;
				if (!IMG_LIST[IMG_LIST_COUNT]) { IMG_LIST_COUNT = 0; }

				SELF.ShowNext('' + IMG_LIST[IMG_LIST_COUNT]['src'] + '', '' + IMG_LIST[IMG_LIST_COUNT]['text'] + '');
			}
		}
	};

	this.Scroll = function(e) {
		if (SELF.IsEnable()) {
			SELF.SetImagePosition();
		}
	};

	// Warte-Animation anzeigen
	this.ShowWait = function() {
		if (this.GetWindowHeight() >= this.GetBodyHeight()) { var h = this.GetWindowHeight(); }
		else { var h = this.GetClientHeight(); }

		if (OBJ_WAIT != null) {
			OBJ_WAIT.style.display = 'block';
			OBJ_WAIT.style.top = (h/2) - (parseInt(OBJ_WAIT.offsetHeight)/2) + this.GetScrollTop() + 'px';
			OBJ_WAIT.style.left = (this.GetClientWidth()/2) - (parseInt(OBJ_WAIT.offsetWidth)/2) + 'px';
		}
	};

	// Warte-Animation nicht anzeigen
	this.CLoseWait = function() {
		if (OBJ_WAIT != null) { OBJ_WAIT.style.display = 'none'; }
	};

	// Bilddatei anzeigen
	this.ShowImage = function() {
		if (SELF.IsEnable()) {
			document.images["album_image"].src = IMG.src;
			SELF.SetImagePosition();
			SELF.ResizeEnable();

			// Slideshow
			if (SELF.IsEnableSlideshow()) {
				window.setTimeout(function() {
					SELF.ShowSlideshow(IMG_LIST[IMG_LIST_COUNT]['src'], IMG_LIST[IMG_LIST_COUNT]['text']);
				}, SELF.GetTime());
			}
		}
	};

	// Bild positionieren
	this.SetImagePosition = function() {

		if (this.GetWindowHeight() >= this.GetBodyHeight()) { var h = this.GetWindowHeight(); }
		else { var h = this.GetClientHeight(); }

		if (OBJ_WAIT != null) { OBJ_WAIT.style.display = 'none'; }
		if (OBJ_IMAGE != null) { OBJ_IMAGE.style.display = 'block'; }
		if (OBJ_IMAGE_TEXT != null) { OBJ_IMAGE_TEXT.style.display = 'block'; }

		if (OBJ_IMAGE != null && OBJ_IMAGE_TEXT != null) {
			OBJ_IMAGE.style.top = (h/2) - 20 - (parseInt(IMG.height)/2) + this.GetScrollTop() + 'px';
			
			if (parseInt(OBJ_IMAGE.style.top) < 0) {
				OBJ_IMAGE.style.top = '0px';

				if (document.all && !window.opera) {
					document.detachEvent('onscroll', this.Scroll);
				}
				else {
					document.removeEventListener('scroll', this.Scroll, true);
				}
			}
			
			OBJ_IMAGE.style.left = (this.GetClientWidth()/2) - (parseInt(IMG.width)/2)  + this.GetScrollLeft() + 'px';
			OBJ_IMAGE_TEXT.style.width = IMG.width + 'px';
		}
	};

	// Bilddatei nicht anzeigen
	this.CloseImage = function() {
		if (OBJ_IMAGE != null) { OBJ_IMAGE.style.display = 'none'; }
	};

	// Bildtext setzen
	this.SetImageText = function(text) {
		if (OBJ_IMAGE_TEXT != null) { OBJ_IMAGE_TEXT.innerHTML = text; }
	};

	// Bildtext anzeigen
	this.ShowImageText = function(text) {
		if (OBJ_IMAGE_TEXT != null) { OBJ_IMAGE_TEXT.style.display = 'block'; }
	};

	// Bildtext nicht anzeigen
	this.CloseImageText = function(text) {
		if (OBJ_IMAGE_TEXT != null) { OBJ_IMAGE_TEXT.style.display = 'none'; }
	};

	// Fenster aktiv/ inaktiv
	this.Enable = function(b) {
		if (OBJ_ENABLE) {
			if (b) {
				OBJ_ENABLE.style.display = 'none';
				this.EnableSlideshow(false);
				this.CLoseWait();
				this.CloseImage();
				this.CloseImageText();
			}
			else {
				OBJ_ENABLE.style.display = 'block';
			}
		}
	};

	// Fenster aktiv/ inaktiv ?
	this.IsEnable = function() {
		if (OBJ_ENABLE) {
			if (OBJ_ENABLE.style.display == 'block') { return true; }
			else { return false; }
		}
	};

	// Slideshow aktiv/ inaktiv
	this.EnableSlideshow = function(b) {
		if (OBJ_SLIDESHOW) {
			if (!b) {
				if (TIMER_SLIDESHOW) { window.clearTimeout(TIMER_SLIDESHOW); }
				OBJ_SLIDESHOW.style.display = 'none';
			}
			else {
				OBJ_SLIDESHOW.style.display = 'block';
				IMG_LIST_COUNT++;
				if (IMG_LIST_COUNT >= IMG_LIST.length || !IMG_LIST[IMG_LIST_COUNT]) { IMG_LIST_COUNT = 0; }
				TIMER_SLIDESHOW = window.setTimeout(function() {
					SELF.ShowSlideshow(IMG_LIST[IMG_LIST_COUNT]['src'], IMG_LIST[IMG_LIST_COUNT]['text']);
				}, SELF.GetTime());
			}
		}
	};

	// Slideshow aktiv/ inaktiv ?
	this.IsEnableSlideshow = function() {
		if (OBJ_SLIDESHOW) {
			if (OBJ_SLIDESHOW.style.display == 'block') { return true; }
			else { return false; }
		}
	};

	// Zeichnen
	this.Paint = function(id) {
		SELF = this;
		this.SetID(id);

		document.write('<div id="album_enable" class="album_enable" onclick="' + this.GetID() + '.Enable(true);"></div>'
						+ '<div id="album_slideshow_info" class="album_slideshow_info">Slideshow</div>'
						+ '<div id="album_wait" class="album_wait" onclick="' + this.GetID() + '.Enable(true);"></div>'
						+ '<div id="album_image" class="album_image" onclick="' + this.GetID() + '.OnClick();">'
						+ '<img src="" name="album_image" />'
						+ '<div id="album_image_text" class="album_image_text"></div>'
						+ '</div>');
	};

	// Nächste Bilddatei anzeigen
	this.OnClick = function() {
		if (IMG_LIST.length <= 1) { return; }

		IMG_LIST_COUNT++;
		if (IMG_LIST_COUNT >= IMG_LIST.length || !IMG_LIST[IMG_LIST_COUNT]) { IMG_LIST_COUNT = 0; }

		SELF.ShowNext('' + IMG_LIST[IMG_LIST_COUNT]['src'] + '', '' + IMG_LIST[IMG_LIST_COUNT]['text'] + '');
	};

	this.ResizeEnable = function() {
		if (OBJ_ENABLE != null) {
			if (this.GetWindowHeight() >= this.GetBodyHeight()) { OBJ_ENABLE.style.height = this.GetWindowHeight() + 'px'; }
			else { OBJ_ENABLE.style.height = this.GetBodyHeight() + 'px'; }
			OBJ_ENABLE.style.width = this.GetBodyWidth() + 'px';
		}
	};

	this.Resize = function(e) {
		if (SELF.IsEnable()) {
			SELF.ResizeEnable();
			SELF.SetImagePosition();
		}
	};

	this.GetWindowHeight = function() {
		var h = 0;

		if (self.innerHeight) {
			h = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight) {
			h = document.documentElement.clientHeight;
		}
		else if (document.body) {
			h = document.body.clientHeight;
		}

		return h;
	};

	this.GetBodyHeight = function() {
		return document.getElementsByTagName('body')[0].scrollHeight;
	};

	this.GetBodyWidth = function() {
		return document.getElementsByTagName('body')[0].clientWidth;
	};

	this.GetClientWidth = function() {
		return this.GetFilterResults(
			window.innerWidth ? window.innerWidth : 0,
			document.documentElement ? document.documentElement.clientWidth : 0,
			document.body ? document.body.clientWidth : 0
		);
	};

	this.GetClientHeight = function() {
		return this.GetFilterResults(
			window.innerHeight ? window.innerHeight : 0,
			document.documentElement ? document.documentElement.clientHeight : 0,
			document.body ? document.body.clientHeight : 0
		);
	};

	this.GetScrollLeft = function() {
		return this.GetFilterResults(
			window.pageXOffset ? window.pageXOffset : 0,
			document.documentElement ? document.documentElement.scrollLeft : 0,
			document.body ? document.body.scrollLeft : 0
		);
	};

	this.GetScrollTop = function() {
		return this.GetFilterResults(
			window.pageYOffset ? window.pageYOffset : 0,
			document.documentElement ? document.documentElement.scrollTop : 0,
			document.body ? document.body.scrollTop : 0
		);
	};

	this.GetFilterResults = function(n_win, n_docel, n_body) {
		var n_result = n_win ? n_win : 0;
		if (n_docel && (!n_result || (n_result > n_docel))) { n_result = n_docel; }
		return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
	};
};
