
/**
* sosSystem Klasse
* author mor_dark
*/
function sosSystem(settings)
{
	this.settings = settings;

	var browser = navigator.userAgent.toLowerCase();
	this.isMSIE 		= (navigator.appName == "Microsoft Internet Explorer");
	this.isMSIE5 		= this.isMSIE && (navigator.userAgent.indexOf('MSIE 5') != -1);
	this.isMSIE5_0 		= this.isMSIE && (navigator.userAgent.indexOf('MSIE 5.0') != -1);
	this.isMSIE6 		= this.isMSIE && (navigator.userAgent.indexOf('MSIE 6') != -1);
	this.isMSIE7 		= navigator.userAgent.indexOf('MSIE 7') != -1;
	this.isGecko 		= browser.indexOf('gecko') != -1;
	this.isGecko18 		= browser.indexOf('Gecko') != -1 && browser.indexOf('rv:1.8') != -1;
	this.isSafari 		= browser.indexOf("safari") != -1;
	this.isKonqueror 	= browser.indexOf("konqueror") != -1;
	this.isOpera 		= browser.indexOf('Opera') != -1;
	this.isMac 			= browser.indexOf('Mac') != -1;
	this.isNS7 			= browser.indexOf('Netscape/7') != -1;
	this.isNS71 		= browser.indexOf('Netscape/7.1') != -1;
}

// px löschen
sosSystem.prototype.replaceEntity = function(ent)
{
	ent = ent.replace('p','');
	ent = ent.replace('x','');

	return ent;
}
// Max Höhe vom Windows
sosSystem.prototype.getMaxHeight = function()
{
	if (window.innerHeight)
	{
		return window.innerHeight;
	} else if(document.body.clientHeight)
	{
		return document.body.clientHeight;
	} else
	{
		return 768;
	}
}
// Max Höhe vom Windows
sosSystem.prototype.getMaxWidth = function()
{
	if (window.innerHeight)
	{
		return window.innerWidth;
	} else
	{
		return document.body.clientWidth;
	}
}

sosSystem.prototype.getScrollXY = function()
{
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' )
	{
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
	{
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
	{
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return [ scrOfX, scrOfY ];
}

 sosSystem.prototype.getMouseXY= function( evt ) {
	
	evt = (evt) ? evt : event;
	if (evt.pageX)
	return {x: evt.pageX, y: evt.pageY};
	else
	return {x: evt.clientX, y: evt.clientY};
	


}
sosSystem.prototype.encode_utf8 = function(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;
}

sosSystem.prototype.decode_utf8 = function(utftext) {
	var plaintext = ""; 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) {
			plaintext += String.fromCharCode(c);
			i++;}
			else if((c>191) && (c<224)) {
				c2 = utftext.charCodeAt(i+1);
				plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
				i+=2;}
				else {
					c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
					plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
					i+=3;}
	}
	return plaintext;
}

