var thumbs_dir = './thumbs/';
var images_dir = './images/';
var pix = new Array(
	'01.jpg',
	'02.jpg',
	'03.jpg',
	'04.jpg',
	'05.jpg',
	'06.jpg',
	'07.jpg',
	'08.jpg',
	'09.jpg',
	'10.jpg',
	'11.jpg',
	'12.jpg',
	'13.jpg',
	'14.jpg',
	'15.jpg',
	'16.jpg',
	'17.jpg',
	'18.jpg',
	'19.jpg',
	'20.jpg',
	'21.jpg',
	'22.jpg',
	'23.jpg',
	'24.jpg',
	'25.jpg',
	'26.jpg',
	'27.jpg',
	'28.jpg',
	'29.jpg',
	'30.jpg',
	'31.jpg',
	'32.jpg',
	'33.jpg',
	'34.jpg',
	'35.jpg',
	'36.jpg',
	'37.jpg',
	'38.jpg',
	'39.jpg',
	'40.jpg',
	'41.jpg',
	'42.jpg',
	'43.jpg',
	'44.jpg',
	'45.jpg',
	'46.jpg',
	'47.jpg',
	'48.jpg',
	'49.jpg',
	'50.jpg',
	'51.jpg',
	'52.jpg',
	'53.jpg',
	'54.jpg',
	'55.jpg',
	'56.jpg',
	'57.jpg',
	'58.jpg',
	'999.jpg');
// images_dir, thumbs_dir and pix array above!

//
// image and thumbnail display
// ----- --- --------- -------

var disp_id = 'display'; // id of display
var brow_id = 'browser'; // id of browser


// display image
function set_image(pic) {
	var div = document.getElementById(disp_id);
	var img = document.createElement('img');
	var src = document.createAttribute('src');
	src.nodeValue = images_dir + pic;
	img.setAttributeNode(src);
	div.replaceChild(img, div.firstChild);

	// ie weirdness
	if (navigator.userAgent.indexOf("MSIE") >= 0)
		div.innerHTML = div.innerHTML;
}

// add thumbnail
function add_thumb(pic) {
	var div = document.getElementById(brow_id);
	var img = document.createElement('img');
	var src = document.createAttribute('src');
	src.nodeValue = thumbs_dir + pic;
	img.setAttributeNode(src);
	img.setAttribute('title', 'Klick zum Ansehen');
	img.setAttribute('onclick', "set_image('" + pic + "');");
	img.setAttribute('alt','');
	div.appendChild(img);
}

// setup show
function init() {
	// browser check
	if (!document.createAttribute) {
		location.href = bail;
		return;
	}
	// set display
	set_image(pix[0]);
	// make thumbs
	for (var i=0; i<pix.length; i++)
		add_thumb(pix[i]);
	// ie weirdness
	if (navigator.userAgent.indexOf("MSIE") >= 0) {
		var div = document.getElementById(brow_id);
		div.innerHTML = div.innerHTML;
	}
	// iemac weirdness
	if (navigator.userAgent.indexOf("MSIE") >= 0
		&& navigator.platform.indexOf("Mac") >= 0) {
		document.body.style.height = "740px";
		var dsp = document.getElementById('display')
		dsp.style.top = "10px";
	}
}

window.onload = init;

//
// simple side scroller
// ------ ---- --------

var inc = 3;
var pos = 0;
var delay = 10;
var mutex;

// scroll backward
function scrollb() {
	if (mutex != 1) return;
	if (pos >= 0) return;
	pos += inc;
	var div = document.getElementById(brow_id);
	div.style.left = pos + 'px';
	setTimeout('scrollb()', delay);
}

// scroll forward
function scrollf() {
	if (mutex != 2) return;
	pos -= inc;
	var div = document.getElementById(brow_id);
	div.style.left = pos + 'px';
	setTimeout('scrollf()', delay);
}

// start/stop scrolling
function scroll(dir) {
	mutex = dir;
	if (mutex == 1) scrollb();
	else if (mutex == 2) scrollf();
}
