var winpop;
var w='fenster';
function popup(url, winBreite, winHoehe, scroll, resize, posLinks, posTop){	
	var screenBreite = (screen.availWidth); 
	var screenHoehe = (screen.availHeight); 
	var screenMitteV = screenBreite/2;
	var screenMitteH = screenHoehe/2-100;
	/*alert("WinBreite: "+winBreite);
	alert("WinHoehe: "+winHoehe);
	alert("MitteV: "+screenMitteV);
	alert("MitteH: "+screenMitteH);*/
	posLinks=screenMitteV-(winBreite/2);
	posTop=screenMitteH-(winHoehe/2);
	// url = encodeURI(url);
	//alert(url);
	/*alert("posLinks: "+posLinks);
	alert("posTop: "+posTop);*/
	if (scroll == null) {scroll=1;} // Popups sollen manchmal eine Scrollbar bekommen....
	//scroll=1;
	resize = 0; // Nie resizeable
	//winBreite-=10;
	//winHoehe-=49;
	winpop = window.open(url,'w','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars='+scroll+',resizable='+resize+',width='+winBreite+',height='+winHoehe+',left='+posLinks+',top='+posTop);
	if(winpop)
		winpop.focus();
	return false;
}

function get_css(webapp)
	{
	i = 0;
	if (navigator.appName == "Microsoft Internet Explorer")
		{document.write("<link type='text/css' rel='StyleSheet' href='"+webapp+"/common/css/ie.css'>");i=1;}
	if (navigator.appName == "Netscape")
		{document.write("<link type='text/css' rel='StyleSheet' href='"+webapp+"/common/css/ns.css'>");i=1;}
	if (navigator.appName == "Opera")
		{document.write("<link type='text/css' rel='StyleSheet' href='"+webapp+"/common/css/op.css'>");i=1;}
	if (i != 1)
		{document.write("<link type='text/css' rel='StyleSheet' href='"+webapp+"/common/css/ie.css'>");}	
}

/*
function get_css(webapp,path)
	{
	i = 0;
	if (navigator.appName == "Microsoft Internet Explorer")
		{document.write("<link type='text/css' rel='StyleSheet' href='"+webapp+path+"/ie.css'>");i=1;}
	if (navigator.appName == "Netscape")
		{document.write("<link type='text/css' rel='StyleSheet' href='"+webapp+path+"/ns.css'>");i=1;}
	if (navigator.appName == "Opera")
		{document.write("<link type='text/css' rel='StyleSheet' href='"+webapp+path+"/op.css'>");i=1;}
	if (i != 1)
		{document.write("<link type='text/css' rel='StyleSheet' href='"+webapp+path+"/ie.css'>");}	
}
*/

function encode_utf8(rohtext) {
	// dient der Normalisierung des Zeilenumbruchs
	rohtext = rohtext.replace(/\r\n/g,"\n");
	var utftext = "";
	for(var n=0; n<rohtext.length; n++)
	{
		// ermitteln des Unicodes des  aktuellen Zeichens
		var c=rohtext.charCodeAt(n);
		// alle Zeichen von 0-127 => 1byte
		if (c<128)
			utftext += String.fromCharCode(c);
		// alle Zeichen von 127 bis 2047 => 2byte
		else if((c>127) && (c<2048))
		{
			utftext += String.fromCharCode((c>>6)|192);
			utftext += String.fromCharCode((c&63)|128);
		}
		// alle Zeichen von 2048 bis 66536 => 3byte
		else
		{
			utftext += String.fromCharCode((c>>12)|224);
			utftext += String.fromCharCode(((c>>6)&63)|128);
			utftext += String.fromCharCode((c&63)|128);}
		}
	return utftext;
 }
 
function decode_utf8(utftext) {
	var rohtext = ""; var i=0; var c=c1=c2=0;
	// while-Schleife, weil einige Zeichen uebersprungen werden
	while(i<utftext.length)
	{
		c = utftext.charCodeAt(i);
		if (c<128)
		{
			rohtext += String.fromCharCode(c);
			i++;
		}
		else if((c>191) && (c<224))
		{
			c2 = utftext.charCodeAt(i+1);
			rohtext += String.fromCharCode(((c&31)<<6) | (c2&63));
			i+=2;
		}
		else
		{
			c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
			rohtext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
			i+=3;
		}
	}
	return rohtext;
}