// JavaScript Document
function createRequestObject()
{
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function handleResponse()
{
    if(http.readyState == 4)
	{
        var response = http.responseText;
		document.getElementById("myGallery").innerHTML = response;
		window.scrollBy(0, -10);
		startGallery();
//		alert (response);
    }
}

function ShowGallery(GalleryPath, Title, Subtitle)
{
	var i;
	var Page;
	i = Math.random(0,1000000);
	Page = "showgallery.php?r=" +i + "&Path=" + GalleryPath + "&Title=" + Title + "&Subtitle=" + Subtitle;
    http.open("GET", Page);	
    http.onreadystatechange = handleResponse;
    http.send(null);
	window.scrollBy(0, -100000);
}

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;
}
