window.addEvent('domready', function(){
	// Show strike-through for disabled (non-checked) radiobuttons
	$$('.settings p input[type=radio]').addEvent('click', function(){
		// Disable all radiobuttons with the same name
		$$('input[type=radio][name=' + this.name + ']').getParent('p').addClass('disabled');
		// Check if current radiobutton is checked
		if (this.checked){
			this.getParent('p').removeClass('disabled');
			// Focus next input field
			if (this.getNext('input[type=text]')){
				this.getNext('input[type=text]').focus();
			}
		}
	}).each(function(el){
		// Initialize states
		if (!el.checked){
			el.getParent('p').addClass('disabled');
		}
	});
	
	// Check radiobutton if text field is focussed
	$$('.settings input[type=text]').addEvent('focus', function(){
		if (this.getPrevious('input')){
			this.getPrevious('input').checked = true;
			this.getPrevious('input').fireEvent('click');
		}
	});
	
	// Show strike-through for disabled (non-checked) checkboxes
	$$('.settings p input[type=checkbox]').addEvent('click', function(){
		// Check if current checkboxes is checked
		if (this.checked){
			this.getParent('p').removeClass('disabled');
			// Focus next input field
			if (this.getNext('input[type=text]')){
				this.getNext('input[type=text]').focus();
			}
		}
		else {
			this.getParent('p').addClass('disabled');
		}
	}).each(function(el){
		// Initialize states
		if (!el.checked){
			el.getParent('p').addClass('disabled');
		}
	});
});
