var theInputTable, theInputTableBody, inputCount=0, theOutputTable, theOutputTableBody, outputCount=0, theScreenTable, theScreenTableBody, screenCount=0, theCommentsTable, theCommentsTableBody, commentsCount=0
function init(){
	theInputTable = (document.all) ? document.all.myTABLE : document.getElementById("myTABLE")
	theInputTableBody = theInputTable.tBodies[0]
	
	theOutputTable = (document.all) ? document.all.myTABLE2 : document.getElementById("myTABLE2")
	theOutputTableBody = theOutputTable.tBodies[0]
	
	theScreenTable = (document.all) ? document.all.screenTable : document.getElementById("screenTable")
	theScreenTableBody = theScreenTable.tBodies[0] 
	
	theCommentsTable = (document.all) ? document.all.commentsTable : document.getElementById("commentsTable")
	theCommentsTableBody = theCommentsTable.tBodies[0]
}

function insertInput(form, where) {

	var newRow = theInputTableBody.insertRow(where)
	var cellArray = new Array(9)
	for(var i=0; i<cellArray.length; i++){
		cellArray[i] = newRow.insertCell()
	}
	for(var i=1; i<(cellArray.length - 1); i++){
		cellArray[i].style.backgroundColor = "#ffffe0"
	}

	cellArray[0].style.backgroundColor = "black"
	cellArray[0].width="1"
	cellArray[1].width="20"	
	cellArray[2].innerHTML = "Voltage 3:"
	cellArray[2].width="118"	
	cellArray[3].width="156"	
	cellArray[3].innerHTML = "<input type='text'name='inputVoltage3' id='inputVoltage3'>"
	cellArray[4].width="15"	
	cellArray[5].innerHTML = "Voltage 4:"
	cellArray[5].width="86"	
	cellArray[6].width="161"
	cellArray[6].innerHTML = "<input type='text'name='inputVoltage4' id='inputVoltage4'>"	
	cellArray[7].width="11"	
	cellArray[8].style.backgroundColor = "black"
	cellArray[8].width="1"
	
}
function insertInput2(form, where) {

	var newRow = theInputTableBody.insertRow(where)
	var cellArray = new Array(9)
	for(var i=0; i<cellArray.length; i++){
		cellArray[i] = newRow.insertCell()
	}
	for(var i=1; i<(cellArray.length - 1); i++){
		cellArray[i].style.backgroundColor = "#ffffe0"
	}

	cellArray[0].style.backgroundColor = "black"
	cellArray[0].width="1"
	cellArray[1].width="20"	
	cellArray[2].innerHTML = "Voltage 5:"
	cellArray[2].width="118"	
	cellArray[3].width="156"	
	cellArray[3].innerHTML = "<input type='text'name='inputVoltage5' id='inputVoltage5'>"
	cellArray[4].width="15"	
	cellArray[5].innerHTML = "Voltage 6:"
	cellArray[5].width="86"	
	cellArray[6].width="161"
	cellArray[6].innerHTML = "<input type='text'name='inputVoltage6' id='inputVoltage6'>"	
	cellArray[7].width="11"	
	cellArray[8].style.backgroundColor = "black"
	cellArray[8].width="1"
	
}
function removeExtraInputs(form){
	form.inputVoltage2.disabled = "disabled"
	if(inputCount!=0){
		theInputTableBody.deleteRow()
		theInputTableBody.deleteRow()
		inputCount=0
	}
}

function insertExtraInputs(form){
	form.inputVoltage2.disabled = ""
	if(inputCount==0){
		insertInput(form, -1)
		insertInput2(form, -1)
		inputCount=1
	}
}
function insertOutput2(form, where) {

	var newRow = theOutputTableBody.insertRow(where)
		var cellArray = new Array(9)
		for(var i=0; i<cellArray.length; i++){
			cellArray[i] = newRow.insertCell()
		}
		for(var i=1; i<(cellArray.length - 1); i++){
			cellArray[i].style.backgroundColor = "#ffffe0"
	}

	cellArray[0].style.backgroundColor = "black"
	cellArray[0].width="1"
	cellArray[1].width="20"	
	cellArray[2].innerHTML = "Voltage 2:"
	cellArray[2].width="118"	
	cellArray[3].width="156"	
	cellArray[3].innerHTML = "<input type='text'name='outputVoltage2' id='outputVoltage2'>"
	cellArray[4].width="15"	
	cellArray[5].innerHTML = "Rating:"
	cellArray[5].width="86"	
	cellArray[6].width="161"
	cellArray[6].innerHTML = "<input type='text'name='rating2' id='rating2'>"	
	cellArray[7].width="11"	
	cellArray[8].style.backgroundColor = "black"
	cellArray[8].width="1"
	
}
function insertOutput3(form, where) {

	var newRow = theOutputTableBody.insertRow(where)
	var cellArray = new Array(9)
	for(var i=0; i<cellArray.length; i++){
		cellArray[i] = newRow.insertCell()
	}
	for(var i=1; i<(cellArray.length - 1); i++){
		cellArray[i].style.backgroundColor = "#ffffe0"
	}

	cellArray[0].style.backgroundColor = "black"
	cellArray[0].width="1"
	cellArray[1].width="20"	
	cellArray[2].innerHTML = "Voltage 3:"
	cellArray[2].width="118"	
	cellArray[3].width="156"	
	cellArray[3].innerHTML = "<input type='text'name='outputVoltage3' id='outputVoltage3'>"
	cellArray[4].width="15"	
	cellArray[5].innerHTML = "Rating:"
	cellArray[5].width="86"	
	cellArray[6].width="161"
	cellArray[6].innerHTML = "<input type='text'name='rating3' id='rating3'>"	
	cellArray[7].width="11"	
	cellArray[8].style.backgroundColor = "black"
	cellArray[8].width="1"
	
}
function insertOutput4(form, where) {

	var newRow = theOutputTableBody.insertRow(where)
		var cellArray = new Array(9)
		for(var i=0; i<cellArray.length; i++){
			cellArray[i] = newRow.insertCell()
		}
		for(var i=1; i<(cellArray.length - 1); i++){
			cellArray[i].style.backgroundColor = "#ffffe0"
	}

	cellArray[0].style.backgroundColor = "black"
	cellArray[0].width="1"
	cellArray[1].width="20"	
	cellArray[2].innerHTML = "Voltage 4:"
	cellArray[2].width="118"	
	cellArray[3].width="156"	
	cellArray[3].innerHTML = "<input type='text'name='outputVoltage4' id='outputVoltage4'>"
	cellArray[4].width="15"	
	cellArray[5].innerHTML = "Rating:"
	cellArray[5].width="86"	
	cellArray[6].width="161"
	cellArray[6].innerHTML = "<input type='text'name='rating4' id='rating4'>"	
	cellArray[7].width="11"	
	cellArray[8].style.backgroundColor = "black"
	cellArray[8].width="1"
	
}

function insertOutput5(form, where) {

	var newRow = theOutputTableBody.insertRow(where)
		var cellArray = new Array(9)
		for(var i=0; i<cellArray.length; i++){
			cellArray[i] = newRow.insertCell()
		}
		for(var i=1; i<(cellArray.length - 1); i++){
			cellArray[i].style.backgroundColor = "#ffffe0"
	}

	cellArray[0].style.backgroundColor = "black"
	cellArray[0].width="1"
	cellArray[1].width="20"	
	cellArray[2].innerHTML = "Voltage 5:"
	cellArray[2].width="118"	
	cellArray[3].width="156"	
	cellArray[3].innerHTML = "<input type='text'name='outputVoltage5' id='outputVoltage5'>"
	cellArray[4].width="15"	
	cellArray[5].innerHTML = "Rating:"
	cellArray[5].width="86"	
	cellArray[6].width="161"
	cellArray[6].innerHTML = "<input type='text'name='rating5' id='rating5'>"	
	cellArray[7].width="11"	
	cellArray[8].style.backgroundColor = "black"
	cellArray[8].width="1"
	
}

function insertOutput6(form, where) {

	var newRow = theOutputTableBody.insertRow(where)
		var cellArray = new Array(9)
		for(var i=0; i<cellArray.length; i++){
			cellArray[i] = newRow.insertCell()
		}
		for(var i=1; i<(cellArray.length - 1); i++){
			cellArray[i].style.backgroundColor = "#ffffe0"
	}

	cellArray[0].style.backgroundColor = "black"
	cellArray[0].width="1"
	cellArray[1].width="20"	
	cellArray[2].innerHTML = "Voltage 6:"
	cellArray[2].width="118"	
	cellArray[3].width="156"	
	cellArray[3].innerHTML = "<input type='text'name='outputVoltage6' id='outputVoltage6'>"
	cellArray[4].width="15"	
	cellArray[5].innerHTML = "Rating:"
	cellArray[5].width="86"	
	cellArray[6].width="161"
	cellArray[6].innerHTML = "<input type='text'name='rating6' id='rating6'>"	
	cellArray[7].width="11"	
	cellArray[8].style.backgroundColor = "black"
	cellArray[8].width="1"
	
}
function removeExtraOutputs(form){
	if(outputCount !=0){
		for(var i=0; i<5; i++){
			theOutputTableBody.deleteRow()
		}
		outputCount =0
	}
}

function insertExtraOutputs(form){
	if(outputCount ==0){
		insertOutput2(form, -1)
		insertOutput3(form, -1)
		insertOutput4(form, -1)
		insertOutput5(form, -1)
		insertOutput6(form, -1)
		outputCount =1
	}
}	



function insertScreen(form, where){
	var newRow = theScreenTableBody.insertRow(where)
	var cellArray = new Array(8)
	for(var i=0; i<cellArray.length; i++){
		cellArray[i] = newRow.insertCell()
	}
	for(var i=1; i<(cellArray.length - 1); i++){
		cellArray[i].style.backgroundColor = "#ffffe0"
	}
	
	
	cellArray[0].style.backgroundColor = "black"
	cellArray[0].width="1"
	cellArray[1].width="20"	
	cellArray[2].innerHTML = "Screen:"
	cellArray[2].width="113"	
	cellArray[3].width="161"	
	cellArray[3].innerHTML = "<input type='radio'name='screen' id='screen'> Yes"
	cellArray[4].width="10"	
	cellArray[5].innerHTML = "<input type='radio' name='screen' id='screen'> No"
	cellArray[5].width="252"	
	cellArray[6].width="11"	
	cellArray[7].style.backgroundColor = "black"
	cellArray[7].width="1"
}
	
function removeScreenOption(form){
	if(screenCount != 0){
		theScreenTableBody.deleteRow()
	screenCount=0
	}
}

function insertScreenOption(form){
	if(screenCount == 0){
		insertScreen(form, -1)
	screenCount=1
	}
}

function createCommentsTable(form, where){
	var newRow = theCommentsTableBody.insertRow(where)
	var cellArray = new Array(5)
	for(var i=0; i<cellArray.length; i++){
		cellArray[i] = newRow.insertCell()
	}
	for(var i=1; i<(cellArray.length-1); i++){
		cellArray[i].style.backgroundColor = "#ffffe0"
	}

	cellArray[0].style.backgroundColor="black"
	cellArray[0].width="1"
	cellArray[1].width="20"
	cellArray[2].width="536"
	cellArray[2].innerHTML = "<textArea rows='10' cols='63' name='commentsText' id='commentsText'></textArea>"
	cellArray[3].width="11"
	cellArray[4].width="1"
	cellArray[4].style.backgroundColor = "black"
}

function insertComments(form){
	if(commentsCount == 0){
		createCommentsTable(form, -1)
		commentsCount=1
	}
}

function removeComments(from){
	if(commentsCount != 0){
		theCommentsTableBody.deleteRow()
		commentsCount=0
	}
}





