function trim(zeichenkette) {
  // Erst führende, dann Abschließende Whitespaces entfernen
  // und das Ergebnis dieser Operationen zurückliefern
  return zeichenkette.replace (/^\s+/, '').replace (/\s+$/, '');
}

function PositionLayerLeft(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	} else if (obj.x) curleft += obj.x;
	return curleft;
}

function PositionLayerTop(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y) curtop += obj.y;
	return curtop;
}

function Rating(img_id_prefix, max_rate, img_src_hot, img_src_cold) {
	this.img_id_prefix = img_id_prefix;
	this.max_rate = max_rate;
	this.img_src_hot = img_src_hot;
	this.img_src_cold = img_src_cold;
	this.ratings = new Array();
	this.self = this;

	this.init = function() {
		for(var i = 1; i <= this.max_rate; i++) {
			this.ratings.push($(this.img_id_prefix + i).src);
		}
	};

	this.setRating = function(position) {
		for(var i = 0; i < this.ratings.length; i++) {
			if(i + 1  <= position) {
				$(this.img_id_prefix + (i + 1)).src = this.img_src_hot;
			} else {
				$(this.img_id_prefix + (i + 1)).src = this.img_src_cold;
			}
		}
	};

	this.restore = function() {
		for(var i = 0; i < this.ratings.length; i++) {
			$(this.img_id_prefix + (i + 1)).src = this.ratings[i];
		}
	};
}

function checkAll(form_name, checkbox_name, chb_status) {
	for(var i = 0; i < document.forms[form_name].elements.length; i++) {
		var obj = document.forms[form_name].elements[i];
		if(obj.name.indexOf(checkbox_name) == 0)
		{
			obj.checked = chb_status;
		}
	}
}

function confirmCommand(message) {
	return confirm(unescape(message));
}

function openPopupWindow(url, windowname) {
	var _with = screen.width - 50;
	var _height = screen.height - 50;
	var _posx = (screen.width / 2) - (_with / 2);
	var _posy = (screen.height / 2) - (_height / 2);
		
	w = window.open(url, windowname, 'width=' + _with + ',height=' + _height +',top=' + _posy + ',left='  + _posx + ',depentent=true,resizable=yes,scrollbars=yes');
	w.focus();

	return false;
}