if (typeof(version) == 'undefined'){
	var version=parseFloat(navigator.appVersion);
	var agent=navigator.userAgent.toLowerCase();

	var opera =(agent.indexOf('opera') != -1) ? true : false;
	var safari=(agent.indexOf('safari')!= -1) ? true : false;
	var gecko =(agent.indexOf('gecko') != -1) ? true : false;
	var khtml =(agent.indexOf('khtml') != -1) ? true : false;
	var konqueror=(agent.indexOf('konqueror')!= -1) ? true : false;

	var ie=((document.all)&&(version>=4.0)&&(!opera)) ? true : false;
	var ie5=(ie && (agent.indexOf('msie 5') >= 0)) ? true : false;
	var ie6=(ie && (agent.indexOf('msie 6') >= 0)) ? true : false;
	var ie7=(ie && (agent.indexOf('msie 7') >= 0)) ? true : false;
	var ie8=(ie && (agent.indexOf('msie 8') >= 0)) ? true : false;

	var ff=(gecko && (agent.indexOf('Firefox') >= 0)) ? true : false;
	var ff2=(ff && (version <  3)) ? true : false;
	var ff3=(ff && (version >= 3)) ? true : false;

	var nn4=document.layers ? true : false;
	var nn7=(agent.indexOf('Netscape/7') >= 0) ? true : false;
	var dom=(document.getElementById && !document.all) ? true : false;
	var moz5=((navigator.appCodeName=='Mozilla')&&(version >= 5.0)) ? true : false;
}

function set_cursor(mode)	{
	document.body.style.cursor = mode;
}

function reset_cursor()	{
	document.body.style.cursor = 'default';
}


function repos_oben()	{
	var div_oben = window.top.document.getElementById("div4oben");

	if (div_oben)	{
//  		alert('repos_oben()');
		div_oben.scrollIntoView();
	}
}

function repos_left(yoffset)	{
	var div_left = window.top.document.getElementById("div4left");

	if (div_left)	{
//  		alert('repos_left('+yoffset+')');
		div_left.style.position = 'absolute';
		div_left.style.top = yoffset + 'px';
		div_left.style.left = '0px';
		repos_main(div_left.clientWidth, yoffset);
 		div_left.style.position = 'static';
	}

}

function repos_main(xoffset, yoffset)	{
	var div_main = window.top.document.getElementById("div4main");

	if (div_main)	{
//   		alert('repos_main('+xoffset+', '+yoffset+')');
		div_main.style.position = 'absolute';
		div_main.style.top  = xoffset + 'px';
		div_main.style.left = yoffset + 'px';
		div_main.style.position = 'static';
	}
}


function repaint_main(repos)	{
	var div_main = window.top.document.getElementById("div4main");

	if (div_main)	{
//  		alert('repaint_main('+repos+')');
		var c = div_main.className;
		div_main.className += 'just4repaint' + parseInt(Math.random()*1000);
		div_main.className = c;
		if (repos)	{
			repos_oben();
		}
	}

}

function scrollto(id)	{
	if (ie || konqueror || safari)	{
// 		set_cursor('progress');

		if (document.all)	{
			if (document.all.id)	{
				document.all.id.scrollIntoView(true);
				repaint_main(ie);
				reset_cursor();
				return false;
			}

			if (document.all[id])	{
				document.all[id].scrollIntoView(true);
				repaint_main(ie);
				reset_cursor();
				return false;
			}
		}

		var a = document.getElementById(id);
		if (!a)	{
			a = document.getElementsByName(id);
			if (a)	{
				a = a[0];
			}
		}
		if (a)	{
			if (a.scrollIntoView)	{
// 				alert(a.name+'='+a.id);
				if (konqueror || safari)	{
					scroll_main(a);
				} else	{
					a.scrollIntoView(true);
					repaint_main(ie);
				}
			}
			reset_cursor();
			return false;
		}
		reset_cursor();
	}
	return true;
}

function scroll_main(node)	{
	var main = document.getElementById('div4main');
	if (main)	{
		main.scrollTop = Math.min(main.scrollHeight - main.clientHeight, node.offsetTop);
	}
}

var hash_done = new Array();

function scroll_if_anchor()	{
	if (!ie && window.location && (window.location.href.indexOf('#') != -1))	{
		for (var i = 0; i < hash_done.length; i++)	{
			if (hash_done[i] == window.location.hash)	{
				return;
			}
		}
		hash_done.push(window.location.hash);
// 		alert(window.location.hash);
		scrollto(window.location.hash.substr(1));
	}
}

function move_bg(div_id, bgpos)	{

	var div = document.getElementById(div_id);
	var ox = 0;
	var oy = 0;
	var nx = 0;
	var ny = 0;

/*	var cstyle = get_currentStyle(div);
	var bgpos = '0 0';
	if (typeof(cstyle.backgroundPosition) != 'undefined')	{
		bgpos = cstyle.backgroundPosition;
	}


	alert('move_bg(main) @ '+bgpos);
*/
	var pos = bgpos.split(" ");
	ox = parseInt(pos[0]);
	oy = parseInt(pos[1]);

	var x = get_left(div.offsetLeft);
	var y = get_top(div.offsetTop);

	var xdiff = x - ox;
	var ydiff = y - oy;

	if (xdiff > 0 || ydiff > 0)	{
		if (xdiff < ydiff)	{
			nx = ox + 3;
			ny = oy + 3 * Math.ceil(xdiff/ydiff);
		} else	{
			nx = ox + 3 * Math.ceil(ydiff/xdiff);
			ny = oy + 3;
		}
		nx = Math.min(nx, x);
		ny = Math.min(ny, y);

		if (nx != ox || ny != oy)	{
			bgpos = nx + "px " + ny  + "px";
			div.style.backgroundPosition = bgpos;
			window.setTimeout("move_bg('"+div_id+"','"+bgpos+"')", 20);
		}
	}
}

function win_height()	{
	if (window.innerHeight)	{
		return window.innerHeight;
	}
	if (document.documentElement.clientHeight)	{
		return document.documentElement.clientHeight;
	}
	if (document.body.clientHeight)	{
		return document.body.clientHeight;
	}
	return false;
}

function win_width()	{
	if (window.innerWidth)	{
		return window.innerWidth;
	}
	if (document.documentElement.clientWidth)	{
		return document.documentElement.clientWidth;
	}
	if (document.body.clientWidth)	{
		return document.body.clientWidth;
	}
	return false;
}

function size_iframe(h)	{
	var iframe = document.getElementById('iframe');
	if (iframe && iframe.contentDocument && iframe.contentDocument.body)	{
		iframe.contentDocument.body.style.height = h;
		iframe.contentDocument.body.style.overflowY = 'auto';
	}
}

function get_currentStyle(elem)	{
	if (typeof(document.defaultView) != 'undefined')	{
		return document.defaultView.getComputedStyle(elem, '');
	}
	return elem.currentStyle;
}

function get_left(def)	{
	var _left = document.getElementById("div4left");
	if (_left)	{
		return _left.offsetWidth;
	}
	return def;
}

function get_top(def)	{
	var _oben = document.getElementById("div4oben");
	if (_oben)	{
		return _oben.offsetHeight;
	}
	return def;
}

function size_main()        {
	set_cursor('wait');
	var window_height = win_height();
	if (window_height)	{
		var main = document.getElementById("div4main");
		if (main && main.offsetTop)	{
			var x, y, h, w;
			var window_width = win_width();
			x = get_left(main.offsetLeft);
			y = get_top(main.offsetTop);

			h = window_height - y;
			w = window_width  - x;

			if (h < 0)	{
// 				alert(h+" = "+window_height+" - "+y+'\n'+ w+" = "+window_width +" - "+x+'\n');
				reset_cursor();
				return;
			}
// 			main.style.width  = Math.max(100, w) + "px";

			h = Math.max(100, h) + "px";
			main.style.height = h;

// 			if (safari) size_iframe(h);

// 			alert(main.offsetLeft + '/' + main.offsetTop + '/' + main.style.height + '/' + main.clientWidth);

			var trans = document.getElementById("bg_trans");
			if (trans)	{
// 				alert('size_main() h='+main.scrollTop+' w='+main.scrollLeft);
				trans.style.left = Math.max(0, x) + "px";
				trans.style.top  = Math.max(0, y) + "px";
				trans.style.display = "block";
			}

			if (typeof(resetmarquee) == 'function')	{
				resetmarquee();
			}

			if (!ie6)	{
				var cstyle = get_currentStyle(main);

				var move = ((cstyle.backgroundAttachment &&
							(cstyle.backgroundAttachment == 'fixed')) ||
							(cstyle.background &&
							(cstyle.background.indexOf('fixed') != -1)));

				var bgpos = '0 0';
				if (typeof(cstyle.backgroundPosition) != 'undefined')	{
					bgpos = cstyle.backgroundPosition;
					bgpos = bgpos.replace(/'/g, '');
				}
				if (move)	{
// 					alert(agent + '\nie=' + ie + '\nie6=' + ie6);

					var pos = bgpos.split(" ");
// 					alert('size_main() ' + pos[0] + ' ' + pos[1]);
					switch (pos[0])	{
					case 'center':
					case 'right':
						move = false;
						break;
					case '0':
					case 'left':
						bgpos  = '0px '+pos[1];
						pos[0] = '0px';
						break;
					default:
// 						alert(pos[0]);
						break;
					}
					switch (pos[1])	{
					case '0':
					case 'top':
						bgpos = pos[0] + ' 0px';
						break;
					case 'middle':
					case 'bottom':
						move = false;
						break;
					default:
// 						alert(pos[1]);
						break;
					}
				}
				if (move)	{
// 					alert(bgpos);
					main.style.backgroundPosition = bgpos;
					move_bg("div4main", bgpos);
				}
			}
			scroll_if_anchor();
		}
	}
	reset_cursor();
}

function print_main()	{
	var main = document.getElementById('div4main');
	if (main)	{
		document.body.innerHTML = main.innerHTML;
		window.print();
		window.location.reload();
	}
}


function add_alert(txt)	{
	if (typeof(window.onload) != 'function') {
		window.onload = function() { alert(txt); };
	} else {
		var oldOnLoad = window.onload;
		window.onload = function() { oldOnLoad(); alert(txt); };
	}
}

function resize_frame4me() {
	var framefenster = document.getElementById('iframe');
	var framefenster_size = '0';
	if(framefenster.contentWindow.document.body) {
		framefenster_size = framefenster.contentWindow.document.body.offsetHeight;
		framefenster.style.height = 20 + framefenster_size + 'px';
	}
}

