// globales Object initialisieren
var nl;

// Grundfunktionen starten
Event.observe(window, 'load', init);

function init() {
	//DokuTeaserRoll = window.setInterval('DokuTeaser.Roll()', 5000);
	//TopDokuList laden
	
	nl = new BBB;

	if(location.hash.length > 1)
		nl.URL = location.hash.substring(1);
	else
		nl.URL = '';
	nl.LoadPage();
	
	window.setInterval(
		function() {
			if(location.hash.length > 1 && location.hash != '#' + escape(nl.URL)) {
				nl.URL = unescape(location.hash.substring(1));
				nl.LoadPage();
			}
		},
		250
	)
}
function ListSmall() {
	$A($('flexbox').getElementsByClassName('list_big')).each(function(elm) {
		elm.className = 'list_small';
		$A(elm.getElementsByTagName('img')).each(function(img) {
			img.src = 'images/blende_80x54.gif';
			img.style.background = img.style.background.replace(/xxmedium/, 'small');
		});
	});
	Settings.ListSize = 'list_small';
}

function ListBig() {
	$A($('flexbox').getElementsByClassName('list_small')).each(function(elm) {
		elm.className = 'list_big';
		$A(elm.getElementsByTagName('img')).each(function(img) {
			img.src = 'images/blende_150x100.gif';
			img.style.background = img.style.background.replace(/small/, 'xxmedium');
		});
	});
	Settings.ListSize = 'list_big';
}

function ContentLoader(Script, StartValue) {
	Settings[Script].Start = StartValue;
		
	target = $('flexbox').getElementsByClassName('flex')[0]
		
	new Ajax.Updater(target, 'ajax/'+ Script +'.php', {
		parameters : { 
			ListSize : Settings.ListSize,
			Start : Settings[Script].Start
		}
	});
}

var Settings = {
	ListSize : 'list_big',
	dokuliste : { Start : 0 },
	dokuarchiv : { Start : 0 }
}

function debug() {
	alert(Settings.dokuliste.Start);
}

// BrowserBackBookmark
function BBB() {

	this.IE = function() {
		if(location.hash != '#' + escape(this.URL)) {
			location.hash = '#' + escape(this.URL);
			if(window.ActiveXObject) {
				window.frames['ieworkaround'].window.location.search = '?' + escape(this.URL);
			}
		}	
	}
	this.Link = function(value) {
		this.URL = value;
		this.LoadPage();
	}
	this.LoadPage = function() {
		att = this.URL.split('+');
		att[1]++;
		att[1]--;
		switch(att[0]) {
			case 'dokuliste' 	:	ContentLoader('dokuliste', att[1]); 	break;
			case 'dokuarchiv' : ContentLoader('dokuarchiv', att[1]); 	break;
			case 'DokuStart' 	: doku.DokuStart(att[1]); 							break;
			case 'Slideshow' 	: doku.Slideshow(att[1]); 							break;
			case 'PicDetail' 	: doku.picDetail(att[1]); 							break;
			case 'PicList' 		: doku.picList(att[1]); 								break;
			case 'PF'					:	doku.picFunction(att[1], att[2]);			break;
		}
//		$('test').innerHTML = this.URL;
		this.IE();
	}
}

function TopDokuList(StartValue) {
	new Ajax.Updater('topdokulist', 'ajax/topdokulist.php', {
		parameters : { Start : StartValue }
	});
}
