(function($) {
	$('.checkboxGraph').each(function (numSet) {
		var form = $(this);
		var set = form.find('input:checkbox:not(.nochange)').checkbox();
		if (form.hasClass('js-linked')) {
			var all = set.eq(0);
			var rest = set.slice(1);
			set.each(function (numBox) {
				$(this).click(function (e) {
					// jquery-checkbox.js binds to click-event only
					this.checked = !this.checked;
					var active = set.filter('[checked]');
					if (this.checked) {
						if (numBox == 0) {
							rest.attr('checked', false);
						} else {
							all.attr('checked', false);
						}
					}
					if (!active.length) {
						all.attr('checked', true);
					}
					return false;
				});
			});
		} else if (form.hasClass('js-single')) {
			set.each(function (numBox) {
				$(this).click(function (e) {
					this.checked = !this.checked;
					var active = set.filter('[checked]');
					if (this.checked) {
						set.attr('checked', false);
						$(this).attr('checked', true);
					}
					return false;
				});
			});
		}
	});
	$('a.code').each(function() {
		$(this).click(function(){
			eval($(this).text());
			return false;
		})
	});
})(jQuery);

displayForm = function (elementId) {
	var content = [];
	$('#' + elementId + ' input').each(function(){
		var el = $(this);
		if ( (el.attr('type').toLowerCase() == 'radio')) {
			if ( this.checked )
				content.push([
				'"', el.attr('name'), '": ',
				'value="', ( this.value ), '"',
				( this.disabled ? ', disabled' : '' )
				].join(''));
			}
		else
			content.push([
			'"', el.attr('name'), '": ',
			( this.checked ? 'checked' : 'not checked' ), 
			( this.disabled ? ', disabled' : '' )
			].join(''));
		});
	alert(content.join('\n'));
}

changeStyle = function(skin) {
	jQuery('#pGruppenAuswahl :checkbox').checkbox((skin ? {cls: skin} : {}));
	jQuery('.checkboxGraph :checkbox').checkbox((skin ? {cls: skin} : {}));
}
