var copyData = null;

function copySetup() {
  	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('Copies:')));  	
	tb.rows[0].appendChild(buildCell(1, buildText('copyCount')));  	
	tb.rows[1].appendChild(buildCell(1, buildLabel('Mode:')));
	tb.rows[1].appendChild(buildCell(1, buildRadio('copyMode', '1', true),
													buildLabel('Line   '),
													buildRadio('copyMode', '0', false),
													buildLabel('Block')));
	tb.rows[2].appendChild(buildCell(1, buildRunButton(copyRun)));
  	tb.rows[2].appendChild(buildCell(-1, buildButton('Help', copyHelp),
  	                                     buildButton('Example 1', copyExample1),
  	                                     buildButton('Example 2', copyExample2)));
	if (copyData) {  		                                     
		copySet(copyData);
	}
	
	return copyTearDown;
}
   
function copyTearDown() {
	copyData = copyGet();
}

function copyGet() {
  	var o = new Object();
  	o.count = document.forms['parameterForm'].copyCount.value;
  	o.line = getRadioChoice(document.forms['parameterForm'].copyMode);
  	return o;
}

function copySet(o) {
  	document.forms['parameterForm'].copyCount.value = o.count;
  	setRadioChoice(document.forms['parameterForm'].copyMode, o.line);
}
   
function copyRun() {
  	makeEditorRequest('copy', copyGet());
}
   
function copyHelp() {
	window.frames['docFrame'].document.location = "html/copy.html";
}
   
function copyExample1() {
	document.forms['parameterForm'].copyCount.value = '100';
	document.forms['parameterForm'].copyMode[0].checked = true;
	window.frames['docFrame'].document.location = "html/copyExample1.html";
	document.forms['inputForm'].inputText.value = '  var# = 0;';
	document.forms['outputForm'].outputText.value = '';	
}   
  
function copyExample2() {
	document.forms['parameterForm'].copyCount.value = '3';
	document.forms['parameterForm'].copyMode[1].checked = true;
	window.frames['docFrame'].document.location = "html/copyExample2.html";
	document.forms['inputForm'].inputText.value = '     sb.append("<input type=\'hidden\' name=\'");\n' +
	                                              '     sb.append();\n' +
	                                              '     sb.append("\' value=\'");\n' +
	                                              '     sb.append();\n' +
	                                              '     sb.append("\'/>");\n\n';
	document.forms['outputForm'].outputText.value = '';	
}   
  
  