var pivotData = null;

function pivotSetup() {
  	var f = document.forms['parameterForm'];
  	clearForm(f);
   	
  	var div = document.createElement('DIV');
  	f.appendChild(div);

	var tb = createTable(div, 3);   	
	   	
  	tb.rows[0].appendChild(buildCell(1, buildLabel('Columns:')));
  	tb.rows[0].appendChild(buildCell(1, buildText('pivotColumns')));
  	tb.rows[1].appendChild(buildCell(1, buildLabel('Interpose:')));
  	tb.rows[1].appendChild(buildCell(1, buildText('pivotInterpose')));
  	tb.rows[2].appendChild(buildCell(1, buildRunButton(pivotRun)));  	
  	tb.rows[2].appendChild(buildCell(-1, buildButton('Help', pivotHelp),
  	                                     buildButton('Example 1', pivotExample1)));
	if (pivotData) {  		                                     
		pivotSet(pivotData);
	}
	
	return pivotTearDown;
}
   
function pivotTearDown() {
	pivotData = pivotGet();
}

function pivotGet() {
  	var o = new Object();
  	o.columns = document.forms['parameterForm'].pivotColumns.value;
  	o.interpose = document.forms['parameterForm'].pivotInterpose.value;
  	return o;
}

function pivotSet(o) {
  	document.forms['parameterForm'].pivotColumns.value = o.columns;
  	document.forms['parameterForm'].pivotInterpose.value = o.interpose;
}
   
function pivotRun() {
  	makeEditorRequest('pivot', pivotGet());
}
   
function pivotHelp() {
	window.frames['docFrame'].document.location = "html/pivot.html";
}
   
function pivotExample1() {
	document.forms['parameterForm'].pivotColumns.value = '2';
	document.forms['parameterForm'].pivotInterpose.value = ' / ';
	window.frames['docFrame'].document.location = "html/pivotExample1.html";
	document.forms['inputForm'].inputText.value = 
			'Sirius\n' +      
			'Canopus\n' +     
			'Rigil Kent\n' +  
			'Arcturus\n' +    
			'Vega\n' +        
			'Canis Major\n' +
	      'Carina\n' +
	      'Centaurus\n' +
	      'Bootes\n' +
	      'Lyra\n';
	document.forms['outputForm'].outputText.value = '';	
}   
   
