var alignGroupsData = null;

function alignGroupsSetup() {
  	var f = document.forms['parameterForm'];
  	clearForm(f);
   	
  	var div = document.createElement('DIV');
  	f.appendChild(div);
  	
	var tb = createTable(div, 4);   	
	   	
  	tb.rows[0].appendChild(buildCell(1, buildLabel('Target:')));
  	tb.rows[0].appendChild(buildCell(1, buildText('alignGroupsTarget')));
  	tb.rows[1].appendChild(buildCell(2, buildRadio('alignGroupsJustify', '1', true),
  													buildLabel('Left Justify   '),
  													buildRadio('alignGroupsJustify', '0', false),
  													buildLabel('Right Justify')));
  	tb.rows[2].appendChild(buildCell(2, buildRadio('alignGroupsCount', '1', true),
  													buildLabel('First Group   '),
  													buildRadio('alignGroupsCount', '0', false),
  													buildLabel('All Groups')));  													
  	tb.rows[3].appendChild(buildCell(1, buildButton('Run', alignGroupsRun)));
  	tb.rows[3].appendChild(buildCell(-1, buildButton('Help', alignGroupsHelp),
  	                                     buildButton('Example 1', alignGroupsExample1)));  	
	if (alignGroupsData) {  		                                     
		alignGroupsSet(alignGroupsData);
	}
	
	return alignGroupsTearDown;
}
   
function alignGroupsTearDown() {
	alignGroupsData = alignGroupsGet();
}

function alignGroupsGet() {
  	var o = new Object();
  	o.target = document.forms['parameterForm'].alignGroupsTarget.value;
  	o.left = getRadioChoice(document.forms['parameterForm'].alignGroupsJustify);
  	o.first = getRadioChoice(document.forms['parameterForm'].alignGroupsCount);
  	return o;
}

function alignGroupsSet(o) {
  	document.forms['parameterForm'].alignGroupsTarget.value = o.target;
  	setRadioChoice(document.forms['parameterForm'].alignGroupsJustify, o.left);
  	setRadioChoice(document.forms['parameterForm'].alignGroupsCount, o.first);
}
   
function alignGroupsRun() {
  	makeEditorRequest('alignGroups', alignGroupsGet());
}
   
function alignGroupsHelp() {
	window.frames['docFrame'].document.location = "html/alignGroups.html";
}
   
function alignGroupsExample1() {
	document.forms['parameterForm'].alignGroupsTarget.value = '(,)';
	document.forms['parameterForm'].alignGroupsJustify[0].checked = true;
	document.forms['parameterForm'].alignGroupsCount[1].checked = true;
	window.frames['docFrame'].document.location = "html/alignGroupsExample1.html";
	document.forms['inputForm'].inputText.value = 
			'Sirius,Canis Major,8.7 ly,A0,-1.42\n' +
	      'Canopus,Carina,230.0 ly,F0,-0.72\n' +
	      'Rigil Kent,Centaurus,4.3 ly,G0,-0.27\n' +
	      'Arcturus,Bootes,38.1 ly,K0,-0.06\n' +
	      'Vega,Lyra,26.9 ly,A0,0.04\n';	
	document.forms['outputForm'].outputText.value = '';	
}   
