function confirmDelete(str) {
	return confirm('Soll der Eintrag "' + str + '" unwiderruflich gelöscht werden?');
}

function niceRadio(obj) {
	obj.rel = 'radiobut_' + obj.id;
	var cap = (obj.title)? obj.title : '&nbsp;';
	$(obj).hide();
	if ($(obj).attr('type') == 'radio') {
		var cls = 'radio';
		var pre = 'r';
	} else {
		var cls = 'checkbox';
		var pre = 'c';
	}
	$('label').each(function() {
		if ($(this).attr("for") == obj.id) {
			$(this).attr("rel", $(this).attr("for"));
			$(this).attr("for", "");
			$(this).click(function() {
				var cover = $("a[id='radiobut_" + $(this).attr('rel') + "']").get(0);
				changeRadio(cover, true);
			});
		}
	});
	return '<a id="' + obj.rel + '" class="' + cls + ((obj.checked)? ' ' + pre + 'active' : ' ' + pre + 'inactive') + '" rel="' + obj.id + '" onclick="changeRadio(this, true)">' + cap + '</a>';
}

function changeRadio(obj, manual) {
	if (!obj) return;
	var radio = $("#" + obj.rel).get(0);
	if ($(radio).attr('type') == 'radio') {
		var pre = 'r';
	} else {
		var pre = 'c';
	}
	if ($(obj).hasClass("radio_disabled")) {
		if (manual && !radio.checked) {
			if (typeof(showAlertwin) == "function") showAlertwin(obj, parseInt(obj.rel.split("_")[1]), radio.alt);
		}
	} else { 
		radio.checked = !radio.checked;
		if ($("#" + obj.rel).attr("onchange")) {
			$("#" + obj.rel).attr("onchange")();
		}
		$(obj).toggleClass(pre + "active", radio.checked);
		$(obj).toggleClass(pre + "inactive", !radio.checked);
		$("input[type=radio]").each(function(i) {
			var cover = $("#" + this.rel);
			if (cover) {
				cover.toggleClass(pre + "active", this.checked);
				cover.toggleClass(pre + "inactive", !this.checked);
			}
		});
		if (typeof(updateProduct) == "function") updateProduct(parseInt(obj.rel.split("_")[1]));
	}
}

function printPage() {
	var ref = self.location.href.split('&print=1').join('');
	ref = self.location.href.split('?print=1').join('');
	ref += '&print=1';
	var win = window.open(ref, 'Druckansicht', 'width=640, height=800, scrollbars=yes, location=no, toolbars=no');
}

function initButtons() {
	$('a.button').each(function() {
		$(this).wrap('<a class="button_left"></a>');
		$(this).wrap('<a class="button_right"></a>');
		$(this).addClass('button_wrapped');
	})
}