
var userAgent = navigator.userAgent.toLowerCase();
var isIE = ((userAgent.indexOf("msie") != -1) && (userAgent.indexOf("opera") == -1));
var image_repeater=null;
var image_direction=0;
var image_clip=null;
var max_left=0;
function images_scroll(direction) {
	image_direction=direction;
	images_scroll_stop();
	
	if (image_clip==null) {
		image_clip=String($('bilder').style.clip).substr(5).replace(/,/g, "").split(" ");
		image_clip[0]=parseInt(image_clip[0]);
		image_clip[1]=parseInt(image_clip[1]);
		image_clip[2]=parseInt(image_clip[2]);
		image_clip[3]=parseInt(image_clip[3]);
		var breite=0;
		if (isIE) {
			breite=$('bilder').offsetWidth;
		} else {
			for(var i=0; i<$('bilder').firstChild.childNodes.length; i++) {
				breite+=$('bilder').firstChild.childNodes[i].offsetWidth;
			}
		}
		max_left=breite-image_clip[1]-image_clip[3];
	}
	
	image_repeater=window.setInterval("images_scroll_repeat()", 1);
}
function images_scroll_repeat() {
	if (image_direction<0 && image_clip[3]>0) {
		image_clip[1]+=image_direction;
		image_clip[3]+=image_direction;
	} else if (image_direction<0) {
		images_scroll_stop();
	}
	if (image_direction>0 && image_clip[3]<max_left) {
		image_clip[1]+=image_direction;
		image_clip[3]+=image_direction;
	}
	document.getElementById('bilder').style.left="-"+image_clip[3]+"px";
	document.getElementById('bilder').style.clip="rect("+image_clip[0]+"px, "+image_clip[1]+"px, "+image_clip[2]+"px, "+image_clip[3]+"px)";
}
function images_scroll_stop() {
	if (image_repeater!=null) {
		window.clearInterval(image_repeater);
		image_repeater=null;
		image_repeater=null;
	}
}

function predefined_input_focus(what, term) {
	if (what.value==term) { what.value=""; }
}
function predefined_input_blur(what, term) {
	if (what.value=="" || what.value==" " || what.value=="  " || what.value=="   ") { what.value=term; }
}
function predefined_input_submit(what, term) {
	if (what.value==term) { what.value=""; }
}

function scrollToPos(y_pos) {
	if (scroller) {
		var x=document.documentElement.scrollLeft || window.pageXOffset || 0;
		var y=($(y_pos) ? $(y_pos).getTop() : y_pos);
		scroller.scrollTo(x, y);
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function MM_findObj(n, d) {
	var p,i,x;
	if (!d) {
		d=document;
	}
	if ((p=n.indexOf("?"))>0 && parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if (!(x=d[n]) && d.all) {
		x=d.all[n];
	}
	for (i=0; !x && i<d.forms.length; i++) {
		x=d.forms[i][n];
	}
	for (i=0; !x && d.layers && i<d.layers.length; i++) {
		x=MM_findObj(n,d.layers[i].document);
	}
	if (!x && d.getElementById) {
		x=d.getElementById(n);
	}
	return x;
}

function MM_swapImage() {
	var i;
	var j=0;
	var x;
	var a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for (i=0; i<(a.length-2); i+=3) {
		if ((x=MM_findObj(a[i]))!=null) {
			document.MM_sr[j++]=x;
			if (!x.oSrc) {
				x.oSrc=x.src;
			}
			x.src=a[i+2];
		}
	}
}

function MM_swapImgRestore() {
	var i,x,a=document.MM_sr;
	for (i=0; a && i<a.length && (x=a[i]) && x.oSrc; i++) {
		x.src=x.oSrc;
	}
}

function autofill_search(search, within, sd, sm, sy, ed, em, ey) {
	$('autofill_search').value=search;
	$('autofill_within_navi').value=within;
	$('autofill_start_day').value=sd;
	$('autofill_start_month').value=sm;
	$('autofill_start_year').value=sy;
	$('autofill_end_day').value=ed;
	$('autofill_end_month').value=em;
	$('autofill_end_year').value=ey;
	$('sidebar_searchform').submit();
}

function addBookmark() {
	var userAgent = navigator.userAgent.toLowerCase();
	var isIE = ((userAgent.indexOf("msie") != -1) && (userAgent.indexOf("opera") == -1));
	var isOpera = (userAgent.indexOf("opera") != -1);
	var isMac = (userAgent.indexOf("mac") != -1);
	var isMacIE = (isIE && isMac);
	var isWinIE = (isIE && !isMac);
	var isSafari = (userAgent.indexOf("safari") != -1);
	var isGecko = (navigator.product == "Gecko" && !isSafari);
	var isNetscape = ((navigator.appName == "Netscape") && (userAgent.indexOf("opera") == -1));
	
	var url=window.location.href;
	var title=document.title;
	
	if (isIE) {
		window.external.AddFavorite(url, title);
	} else {
		if (isNetscape) {
			if ((typeof window.sidebar=="object") && (typeof window.sidebar.addPanel=="function")) {
				window.sidebar.addPanel(title, url, "");
			} else {
				alert("Sie Nutzen eine veralterte Netscape Version!\nLesezeichen hinzufügen ist nicht möglich!");
			}
		} else if (isGecko) {
			window.sidebar.addPanel(title, url, '');
		} else {
			alert("Mit ihrem Browser ist es leider nicht möglich mit einem Klick ein Lesezeichen zu setzen.\nSie können jedoch das Lesezeichen manuell anlegen. (Siehe Browser-Hilfe)");
		}
	}
}

function MM_showHideLayers() { //v6.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) {
		if ((obj=MM_findObj(args[i]))!=null) {
			v=args[i+2];
			if (obj.style) {
				obj=obj.style;
				v=(v=='show') ? 'visible': (v=='hide') ? 'hidden' : v;
			}
			obj.visibility=v;
		}
	}
}

function show_subnavi(caller, welches, was, pos_setzen) {
	welches=welches.split(",");
	for (var i=0; i<welches.length; i++) {
		if (document.getElementById("subnavi"+welches[i])) {
			var subnavi=document.getElementById("subnavi"+welches[i]);
			if (pos_setzen && i==welches.length-1) {
				var pos=get_pos(caller);
				subnavi.style.left=pos['x']+"px";
				if (isIE) {
					subnavi.style.top=(pos['y']+36)+"px";
				} else {
					subnavi.style.top=(pos['y']+20)+"px";
				}
			}
			subnavi.style.visibility=was;
		}
	}
}

function get_pos(which_div) {
	var y_start=0;
	var positionen=new Array();
	document.body ? y_scrollposition=document.body.scrollTop+y_start : y_scrollposition=window.pageYOffset+y_start;
	// die x-position definieren
	var aktuelles=which_div;
	var x_position=0;
	while(aktuelles!=null) {
		x_position+=aktuelles.offsetLeft;
		aktuelles=aktuelles.offsetParent;
	}
	positionen['x']=x_position;
	// die y-position definieren
	var aktuelles=which_div;
	var y_position=y_start;
	while(aktuelles!=null) {
		y_position+=aktuelles.offsetTop;
		aktuelles=aktuelles.offsetParent;
	}
	positionen['y']=y_position;
	return positionen;
}

