// Radiobuttons, als Option für Fieldsets
$(function() {
	$("input.option").each(function(i) {
		var radio = $(this);
		
		radio.click(function(e) {
			e.stopPropagation();
		})

		radio.parents("fieldset").click(function(e) {
			radio.attr('checked', 'checked');
		})
		
		/*
			TODO focus über tastatur zb in textfeld dann mit enter formualr absenden -> radio button wird nicht geändert
		*/
		// label = $("label[for='" + this.id + "']")
	})
})

$(function() {
	if (document.styleSheets[0].disabled == true) {
		return
	}
	
	$("fieldset").each(function(index) {
		var cls = $(this).hasClass("field") ? "field" : 'fieldset';
		$(this).wrap('<div class="' + cls + '"></div>');
		
		cls = cls == 'field' ? 'label' : 'legend';
		$(this).children().filter("legend").wrapInner('<span class="' + cls + '"></span>');
	});
	
	// IE7, IE6
	$("div.fieldset > fieldset > p:last-child").addClass("last-child");
})
