function onCheckBoxChange(field, className) {
	var display = (field.checked);
	
	var isChild = $(field).getParent().hasClass('checkbox-children-visible');
	var isAllSelector = $(field).hasClass('tx-sremailsubscribe-pi1-checkall');
	
	if(isAllSelector && !isChild) 	{ checkallBoxes(className, display, false); }
	if(isAllSelector && isChild) 	{ checkallBoxes(className, display, false); }
	if(!isChild) 		{ var hasChildren = showHideChildBoxes(className, display); }
	
	
	//var checkBoxList = $(field).getParent().getParent('dl');
	
	/*
	if(checkBoxList.hasClass('multiple-checkboxes-singlelimit')){
		checkBoxList.getChildren('dt').each(function(el){
			var input = $(el).getChildren('input');
			if(input.getProperty('name')!='' && $(field).getProperty('name')!=input.getProperty('name')) {
				//input.removeProperty('checked');
				//input.setProperty('checked', 'checked');
				input.removeProperty('disabled');
				var childClass = input.getProperty('id');
				//alert(childClass);
				showHideChildBoxes(childClass, false);
			}
		});
	}
	*/
	
	if(hasChildren){
		//$(field).setProperty('disabled', 'disabeld');
	}
	else {
		//$(field).removeProperty('disabled');
	}
}


function checkallBoxes(className, check, preventUncheck) {
	
	//alert(className);
	
	$$("."+className).each(function(el){
		if(check) {
			var input = $(el).getChildren('input');
			input.setProperty('checked', 'checked');
			var x = input.hasClass('tx-sremailsubscribe-pi1-checkall');
			
			if(input.hasClass('tx-sremailsubscribe-pi1-checkall')=="true") { /* do nothing */ }
			else { input.setProperty('disabled', 'disabled'); }
		}
		else {
			//$(el).removeClass('checkbox-children-visible');
			var input = $(el).getChildren('input');
			input.removeProperty('checked');
			input.removeProperty('disabled');
		}
	});
	
}

function showHideChildBoxes(className, display) {
	
	var hasChildren = false;
	
	$$("."+className).each(function(el){
		if(display) {
			$(el).addClass('checkbox-children-visible');
			hasChildren = true;
		}
		else {
			$(el).removeClass('checkbox-children-visible');
			var input = $(el).getChildren('input');
			input.removeProperty('checked');
		}
	});
	
	return hasChildren;
}

function journalistsubscribeStep(stepNum){
	
	var hideStep = (stepNum==2)? 1 : 2;
	$('tx-sremailsubscribe-step'+hideStep).addClass('hidden');
	$('tx-sremailsubscribe-step'+stepNum).removeClass('hidden');
	$('tx-sremailsubscribe-step'+stepNum).setStyle('opacity', 0);
	$('tx-sremailsubscribe-step'+stepNum).fade('in');
	
}
