document.write('<link href="/_/styles/lightbox.css" type="text/css" rel="stylesheet">');
document.write('<script type="text/javascript" src="/scripts/ext/adapter/ext/ext-base.js"></script>');
document.write('<script type="text/javascript" src="/scripts/ext/ext-all.js"></script>');
if (document.location.href != 'http://www.espresso-tm.de/index.html' && document.location.href != 'http://www.espresso-tm.de/' && document.location.href != 'http://www.espresso-tm.de') {
	document.write('<script type="text/javascript" src="/scripts/lightbox.js"></script>');
}
var runOnLoad = function(f) {
	if (runOnLoad.loaded) {
		f(); /* If already loaded, just invoke f() now. */
	} else {
		runOnLoad.funcs.push(f); /* Otherwise, store it for later */
	}
};
runOnLoad.funcs = []; /* The array of functions to call when the document */
runOnLoad.loaded = false; /* The functions have not been run yet. */
/*
 * Run all registered functions in the order in which they were registered. It is safe to call runOnLoad.run() more than
 * once: invocations after the first do nothing. It is safe for an initialization function to call runOnLoad() to
 * register another function.
 */
runOnLoad.run = function() {
	if (runOnLoad.loaded) {
		return;
	};
	for ( var i = 0; i < runOnLoad.funcs.length; i++) {
		try {
			runOnLoad.funcs[i]();
		} catch (e) {
			/* An exception in one function shouldn't stop the rest */
		}
	};
	runOnLoad.loaded = true;
	delete runOnLoad.funcs;
	delete runOnLoad.run;
};
if (window.addEventListener) {
	window.addEventListener("load", runOnLoad.run, false);
} else if (window.attachEvent) {
	window.attachEvent("onload", runOnLoad.run);
} else {
	window.onload = runOnLoad.run;
};
var dx;
runOnLoad(function() {
	Ext.ux.Lightbox.register('a.lightbox', true);
	var info = Ext.get('info');
	info.on('mouseover', function() {
		this.setY(101, true);
	});
	info.on('mouseout', function() {
		this.setY(161, true);
	});
	var dias = Ext.select('a.lightbox');
	var cnt = Ext.get('diacontainer');
	var num = dias.getCount();
	if (num > 0 && cnt) {
		dx = Ext.get('diacontainer').down('table').getX();
		var html = '';
		var links = [];
		var pos = 0;
		var count = 1;
		dias.each(function(el) {
			links.push('<a href="#" onclick="setScroll(' + pos + '); return(false);"><span style="padding:0 5px;" class="linktext">' + (count) + '</span></a>');
			var box = el.getBox();
			pos += box.width;
			count++;
		});
		html += links.join('|');
		cnt.insertHtml('afterEnd', html);
	};
	Ext.get('foot').alignTo(Ext.get('maincontent'), 'tl-bl');
});
var setScroll = function(z) {
	var el = Ext.get('diacontainer').down('table');
	el.setX(dx - z, true);
};
var sound;
var soundbtn;
var initBtn = function() {
	if (typeof top.sound == 'undefined') {
		window.setTimeout("initBtn()", 50);
		return;
	};
	try {
		var stat = top.sound.swf.GetVariable("stat");
		if (stat == 'false') {
			stat = 'on';
		}
	} catch (e) {
		window.setTimeout("initBtn()", 50);
		return;
	};
	var nav = Ext.get('sndbtn');
	if (typeof soundbtn == 'undefined') {
		var soundon = Ext.DomHelper.append(nav, {
			id : 'sndbtnon',
			tag : 'a',
			href : '#',
			style : 'margin-left:10px',
			html : '<span class="linktext">on</span>'
		}, true);
		var soundoff = Ext.DomHelper.append(nav, {
			id : 'sndbtnoff',
			tag : 'a',
			href : '#',
			style : 'margin-left:10px',
			html : '<span class="linktext">off</span>'
		}, true);
		soundon.on('click', function(e, el) {
			var stat = top.sound.swf.GetVariable("stat");
			if (stat == 'off') {
				top.sound.swf.SetVariable("stat", "on");
			}
		});
		soundoff.on('click', function(e, el) {
			top.sound.swf.SetVariable("stat", "off");
		});
		soundbtn = true;
	}
};
runOnLoad(function() {
	if (top.frames.length == 0) {
		document.location.href = '/index.html';
		return;
	};
	var nav = Ext.get('sndbtn');
	if (nav && top.frames.length > 0) {
		sound = new Ext.FlashComponent({
			renderTo : nav,
			height : 9,
			width : 33,
			hideMode : 'offsets',
			hidden : true,
			url : 'sound.swf'
		});
	};
	if (nav && top.frames.length > 0 && document.location.href != 'http://www.espresso-tm.de/index.html' && document.location.href != 'http://www.espresso-tm.de/' && document.location.href != 'http://www.espresso-tm.de') {
		initBtn();
	};
});
