var orderCurrentLine = 0;

function orderAddLine(){
	var head = $('#order-body').html();
	var _body = "";
	for (i=0; i<orderCurrentLine; i++){
		_body += '<tr>\n<td class="n"><input type="text" id="post_value_'+i+'_0" name="post_value['+i+'][0]" value="'+$('#post_value_'+i+'_0').val()+'" /></td>\n';
		_body += '<td class="s"><input type="text" id="post_value_'+i+'_1" name="post_value['+i+'][1]" value="'+$('#post_value_'+i+'_1').val()+'" /></td>\n';
		_body += '<td class="q"><input type="text" id="post_value_'+i+'_2" name="post_value['+i+'][2]" value="'+$('#post_value_'+i+'_2').val()+'" /></td>\n';
		_body += '<td class="t"><input type="text" id="post_value_'+i+'_3" name="post_value['+i+'][3]" value="'+$('#post_value_'+i+'_3').val()+'" /></td>\n</tr>\n';
		_body += '<tr>\n<td class="hr" colspan="4">&nbsp;</td>\n</tr>\n'
	}
	i = orderCurrentLine;
	_body += '<tr>\n<td class="n"><input type="text" id="post_value_'+i+'_0" name="post_value['+i+'][0]" /></td>\n';
	_body += '<td class="s"><input type="text" id="post_value_'+i+'_1" name="post_value['+i+'][1]" /></td>\n';
	_body += '<td class="q"><input type="text" id="post_value_'+i+'_2" name="post_value['+i+'][2]" /></td>\n';
	_body += '<td class="t"><input type="text" id="post_value_'+i+'_3" name="post_value['+i+'][3]" /></td>\n</tr>\n';
	_body += '<tr>\n<td class="hr" colspan="4">&nbsp;</td>\n</tr>\n';
	orderCurrentLine++;
	$('#order-body').html(_body);
}

var mechanismBodyLine = 0;

function mechanismAddLine(title){
	if (!title) title = '';
	var head = $('#mechanism-body').html();
	var _body = "";
	for (i=0; i<mechanismBodyLine; i++){
		_body += '<tr>\n<td class="n"><input align="left" type="text" class="w0" id="post_value_mech_'+i+'_0" name="post_value_mech_['+i+'][0]" value="'+$('#post_value_mech_'+i+'_0').val()+'" /></td>\n';
		_body += '<td><input type="text" class="w15" id="post_value_mech_'+i+'_1" name="post_value_mech_['+i+'][1]" value="'+$('#post_value_mech_'+i+'_1').val()+'" /></td>\n';
		_body += '<td><input type="text" class="w3" id="post_value_mech_'+i+'_2" name="post_value_mech_['+i+'][2]" value="'+$('#post_value_mech_'+i+'_2').val()+'" /></td>\n';
		_body += '<td><input type="text" class="w15" id="post_value_mech_'+i+'_3" name="post_value_mech_['+i+'][3]" value="'+$('#post_value_mech_'+i+'_3').val()+'" /></td>\n';
		_body += '<td><input type="text" class="w15" id="post_value_mech_'+i+'_4" name="post_value_mech_['+i+'][4]" value="'+$('#post_value_mech_'+i+'_4').val()+'" /></td>\n';
		_body += '<td><input type="text" class="w2" id="post_value_mech_'+i+'_5" name="post_value_mech_['+i+'][5]" value="'+$('#post_value_mech_'+i+'_5').val()+'" /></td>\n';
		_body += '<td align="right"><input type="text" class="w1" id="post_value_mech_'+i+'_6" name="post_value_mech_['+i+'][6]" value="'+$('#post_value_mech_'+i+'_6').val()+'" /></td>\n</tr>\n';
		_body += '<tr>\n<td class="hr" colspan="7">&nbsp;</td>\n</tr>\n';
	}
	i = mechanismBodyLine;
	_body += '<tr>\n<td class="n"><input align="left" type="text" class="w0" id="post_value_mech_'+i+'_0" name="post_value_mech_['+i+'][0]" value="'+title+'" /></td>\n';
	_body += '<td><input type="text" class="w15" id="post_value_mech_'+i+'_1" name="post_value_mech_['+i+'][1]" value="" /></td>\n';
	_body += '<td><input type="text" class="w3" id="post_value_mech_'+i+'_2" name="post_value_mech_['+i+'][2]" value="" /></td>\n';
	_body += '<td><input type="text" class="w15" id="post_value_mech_'+i+'_3" name="post_value_mech_['+i+'][3]" value="" /></td>\n';
	_body += '<td><input type="text" class="w15" id="post_value_mech_'+i+'_4" name="post_value_mech_['+i+'][4]" value="" /></td>\n';
	_body += '<td><input type="text" class="w2" id="post_value_mech_'+i+'_5" name="post_value_mech_['+i+'][5]" value="" /></td>\n';
	_body += '<td align="right"><input type="text" class="w1" id="post_value_mech_'+i+'_6" name="post_value_mech_['+i+'][6]" value="" /></td>\n</tr>\n';
	_body += '<tr>\n<td class="hr" colspan="7">&nbsp;</td>\n</tr>\n';
	mechanismBodyLine++;
	$('#mechanism-body').html(_body);
}

var installedBodyLine = 0;

function installedAddLine(title){
	if (!title) title = '';
	var head = $('#installed-body').html();
	var _body = "";
	for (i=0; i<installedBodyLine; i++){
		_body += '<tr>\n<td class="n"><input align="left" type="text" class="w1" id="post_value_inst_'+i+'_0" name="post_value_inst_['+i+'][0]" value="'+$('#post_value_inst_'+i+'_0').val()+'" /></td>\n';
		_body += '<td><input type="text" class="w1" id="post_value_inst_'+i+'_1" name="post_value_inst_['+i+'][1]" value="'+$('#post_value_inst_'+i+'_1').val()+'" /></td>\n';
		_body += '<td><input type="text" class="w2" id="post_value_inst_'+i+'_2" name="post_value_inst_['+i+'][2]" value="'+$('#post_value_inst_'+i+'_2').val()+'" /></td>\n';
		_body += '<td><input type="text" class="w2" id="post_value_inst_'+i+'_3" name="post_value_inst_['+i+'][3]" value="'+$('#post_value_inst_'+i+'_3').val()+'" /></td>\n';
		_body += '<td><input type="text" class="w2" id="post_value_inst_'+i+'_4" name="post_value_inst_['+i+'][4]" value="'+$('#post_value_inst_'+i+'_4').val()+'" /></td>\n';
		_body += '<td><input type="text" class="w6" id="post_value_inst_'+i+'_5" name="post_value_inst_['+i+'][5]" value="'+$('#post_value_inst_'+i+'_5').val()+'" /></td>\n';
		_body += '<td><input type="text" class="w4" id="post_value_inst_'+i+'_6" name="post_value_inst_['+i+'][6]" value="'+$('#post_value_inst_'+i+'_6').val()+'" /></td>\n';
		_body += '<td><input type="text" class="w2" id="post_value_inst_'+i+'_7" name="post_value_inst_['+i+'][7]" value="'+$('#post_value_inst_'+i+'_7').val()+'" /></td>\n';
		_body += '<td align="right"><input type="text" class="w1" id="post_value_inst_'+i+'_8" name="post_value_inst_['+i+'][8]" value="'+$('#post_value_inst_'+i+'_8').val()+'" /></td>\n</tr>\n';
		_body += '<tr>\n<td class="hr" colspan="9">&nbsp;</td>\n</tr>\n';
	}
	i = installedBodyLine;
	_body += '<tr>\n<td class="n"><input align="left" type="text" class="w1" id="post_value_inst_'+i+'_0" name="post_value_inst_['+i+'][0]" value="'+title+'" /></td>\n';
	_body += '<td><input type="text" class="w1" id="post_value_inst_'+i+'_1" name="post_value_inst_['+i+'][1]" value="" /></td>\n';
	_body += '<td><input type="text" class="w2" id="post_value_inst_'+i+'_2" name="post_value_inst_['+i+'][2]" value="" /></td>\n';
	_body += '<td><input type="text" class="w2" id="post_value_inst_'+i+'_3" name="post_value_inst_['+i+'][3]" value="" /></td>\n';
	_body += '<td><input type="text" class="w2" id="post_value_inst_'+i+'_4" name="post_value_inst_['+i+'][4]" value="" /></td>\n';
	_body += '<td><input type="text" class="w6" id="post_value_inst_'+i+'_5" name="post_value_inst_['+i+'][5]" value="" /></td>\n';
	_body += '<td><input type="text" class="w4" id="post_value_inst_'+i+'_6" name="post_value_inst_['+i+'][6]" value="" /></td>\n';
	_body += '<td><input type="text" class="w2" id="post_value_inst_'+i+'_7" name="post_value_inst_['+i+'][7]" value="" /></td>\n';
	_body += '<td align="right"><input type="text" class="w1" id="post_value_inst_'+i+'_8" name="post_value_inst_['+i+'][8]" value="" /></td>\n</tr>\n';
	_body += '<tr>\n<td class="hr" colspan="9">&nbsp;</td>\n</tr>\n';
	installedBodyLine++;
	$('#installed-body').html(_body);
}

var safetyBodyLine = 0;

function safetyAddLine(title){
	if (!title) title = '';
	var head = $('#safety-body').html();
	var _body = "";
	for (i=0; i<safetyBodyLine; i++){
		_body += '<tr>\n<td class="n"><input align="left" type="text" class="w1" id="post_values_saf_'+i+'_0" name="post_values_saf_['+i+'][0]" value="'+$('#post_values_saf_'+i+'_0').val()+'" /></td>\n';
		_body += '<td><input type="text" class="w1" id="post_values_saf_'+i+'_1" name="post_values_saf_['+i+'][1]" value="'+$('#post_values_saf_'+i+'_1').val()+'" /></td>\n';
		_body += '<td><input type="text" class="w2" id="post_values_saf_'+i+'_2" name="post_values_saf_['+i+'][2]" value="'+$('#post_values_saf_'+i+'_2').val()+'" /></td>\n';
		_body += '<td><input type="text" class="w1" id="post_values_saf_'+i+'_3" name="post_values_saf_['+i+'][3]" value="'+$('#post_values_saf_'+i+'_3').val()+'" /></td>\n';
		_body += '<td align="right"><input type="text" class="w1" id="post_values_saf_'+i+'_4" name="post_values_saf_['+i+'][4]" value="'+$('#post_values_saf_'+i+'_4').val()+'" /></td>\n</tr>\n';
		_body += '<tr>\n<td class="hr" colspan="5">&nbsp;</td>\n</tr>\n';
	}
	i = safetyBodyLine;
	_body += '<tr>\n<td class="n"><input align="left" type="text" class="w15" id="post_values_saf_'+i+'_0" name="post_values_saf_['+i+'][0]" value="'+title+'" /></td>\n';
	_body += '<td><input type="text" class="w0" id="post_values_saf_'+i+'_1" name="post_values_saf_['+i+'][1]" value="" /></td>\n';
	_body += '<td><input type="text" class="w2" id="post_values_saf_'+i+'_2" name="post_values_saf_['+i+'][2]" value="" /></td>\n';
	_body += '<td><input type="text" class="w1" id="post_values_saf_'+i+'_3" name="post_values_saf_['+i+'][3]" value="" /></td>\n';
	_body += '<td align="right"><input type="text" class="w1" id="post_values_saf_'+i+'_4" name="post_values_saf_['+i+'][4]" value="" /></td>\n</tr>\n';
	_body += '<tr>\n<td class="hr" colspan="5">&nbsp;</td>\n</tr>\n';
	safetyBodyLine++;
	$('#safety-body').html(_body);
}