// Version 1.0
var rs = {
	numf: function(a, b, c, d) {
		var b = (b == null) ? 2 : b;
		var c = (c == null) ? ',' : c;
		var d = (d == null) ? '.' : d;
		a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
		e = a + '';
		f = e.split('.');
		if (!f[0]) f[0] = '0';
		if (!f[1]) f[1] = '';
		if (f[1].length < b) {
			g = f[1];
			for (i=f[1].length + 1; i <= b; i++)
				g += '0';
			f[1] = g;
		}
		if(d != '' && f[0].length > 3) {
			h = f[0];
			f[0] = '';
			for(j = 3; j < h.length; j+=3) {
				i = h.slice(h.length - j, h.length - j + 3);
				f[0] = d + i +  f[0] + '';
			}
			j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
			f[0] = j + f[0];
		}
		c = (b <= 0) ? '' : c;
		return f[0] + c + f[1];
	},
	zeroPad: function(num,count) {
		var numZeropad = num + '';
		while(numZeropad.length < count) numZeropad = "0" + numZeropad;
		return numZeropad;
	},
	parseDouble: function(n){
		var s = "" + n //Umwandlung in eine Zeichenkette
		for (var i=0; i<s.length; i++)  //Kommata in Zahlen
			if (s.charAt(i)==",")
				s=s.substring(0,i)+"."+s.substring(i+1,s.length)
		// alle bis auf den letzten punkt entfernen
		var pmax = 0;
		for(var i=0; i<s.length; i++)
			if (s.charAt(i)==".") pmax++;
		if(pmax>1)
			for(var i=0; i<s.length; i++)
				if (s.charAt(i)=="." && pmax>1) {
					s=s.substring(0,i)+s.substring(i+1,s.length)
					pmax--;
				}
		return 1*s //Umwandlung in einen Zahlenwert
	},
	getRadioValue: function(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
	},
	op: function(url,opt) {
		if(!$chk(opt)) opt = {'width':640,'height':480,'scrollbars':'no'};
		if(!$chk(opt.width)) opt.width=640;
		if(!$chk(opt.height)) opt.height=480;
		if(!$chk(opt.scrollbars)) opt.scrollbars='no';
		var breite = screen.width;
		var hoehe = screen.height;
		var pos_x = (breite/2)-(opt.width/2);
		var pos_y = (hoehe/2)-(opt.height/2);

		//alert(url);
		//alert("-");
		//alert("width="+opt.width+",height="+opt.height+",left="+pos_x+",top="+pos_y+",scrollbars="+opt.scrollbars);
		var MeinFenster = window.open(url, "Details","width="+opt.width+",height="+opt.height+",left="+pos_x+",top="+pos_y+",scrollbars="+opt.scrollbars);
		MeinFenster.focus();
	},
	hex2rgb:function(h) {
		var ph = (h.charAt(0)=="#")?h.substring(1,7):h;
		var r = parseInt((ph).substring(0,2),16);
		var g = parseInt((ph).substring(2,4),16);
		var b = parseInt((ph).substring(4,6),16);
		return {red:r,green:g,blue:b};
	},
	rgb2hex:function(r,g,b) {return rs.toHex(r)+rs.toHex(g)+rs.toHex(b);},
	toHex:function(N) {
		if (N==null) return "00";
		N=parseInt(N); if (N==0 || isNaN(N)) return "00";
		N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
		return "0123456789ABCDEF".charAt((N-N%16)/16) + "0123456789ABCDEF".charAt(N%16);
	},
	getWindowScrollXY: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 {x:scrOfX,y:scrOfY};
	},
	getWindowSize:function() {
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
				//Non-IE
				myWidth = window.innerWidth;
				myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
				//IE 6+ in 'standards compliant mode'
				myWidth = document.documentElement.clientWidth;
				myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				//IE 4 compatible
				myWidth = document.body.clientWidth;
				myHeight = document.body.clientHeight;
		}
		return {x:myWidth,y:myHeight};
	}
}
