var incrementData = null;

function incrementSetup() {
  	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('Pattern:')));
  	tb.rows[0].appendChild(buildCell(1, buildText('incrementPattern')));
  	tb.rows[1].appendChild(buildCell(1, buildLabel('Start:')));
  	tb.rows[1].appendChild(buildCell(1, buildText('incrementStart')));
  	tb.rows[2].appendChild(buildCell(1, buildLabel('Increment:')));
  	tb.rows[2].appendChild(buildCell(1, buildText('incrementIncrement')));
  	tb.rows[3].appendChild(buildCell(1, buildRunButton(incrementRun)));  	
  	tb.rows[3].appendChild(buildCell(-1, buildButton('Help', incrementHelp),
  	                                     buildButton('Example 1', incrementExample1)));
	if (incrementData) {  		                                     
		incrementSet(incrementData);
	}
	
	return incrementTearDown;
}
   
function incrementTearDown() {
	incrementData = incrementGet();
}

function incrementGet() {
  	var o = new Object();
  	o.pattern = document.forms['parameterForm'].incrementPattern.value;
  	o.start = document.forms['parameterForm'].incrementStart.value;
  	o.increment = document.forms['parameterForm'].incrementIncrement.value;
  	return o;
}

function incrementSet(o) {
  	document.forms['parameterForm'].incrementPattern.value = o.pattern;
  	document.forms['parameterForm'].incrementStart.value = o.start;
  	document.forms['parameterForm'].incrementIncrement.value = o.increment;
}
   
function incrementRun() {
  	makeEditorRequest('increment', incrementGet());
}
   
function incrementHelp() {
	window.frames['docFrame'].document.location = "html/increment.html";
}
   
function incrementExample1() {
	document.forms['parameterForm'].incrementPattern.value = '#';
	document.forms['parameterForm'].incrementStart.value = '0';
	document.forms['parameterForm'].incrementIncrement.value = 1;
	window.frames['docFrame'].document.location = "html/incrementExample1.html";
	document.forms['inputForm'].inputText.value = '  array[#] = var#\n' +
	                                              '  array[#] = var#\n' +
	                                              '  array[#] = var#\n' +
	                                              '  array[#] = var#\n' +
	                                              '  array[#] = var#\n' +
	                                              '  array[#] = var#\n' +
	                                              '  array[#] = var#\n';
	document.forms['outputForm'].outputText.value = '';	
}   
   
