// JavaScript Document



var i = 2;

window.onload = function() {

	i = 2;

}

function addCargo() {

	oTable = document.getElementById('cargo');

	lastRow = oTable.rows.length;

	oRow = oTable.insertRow(lastRow);

	oCell = document.createElement('td');

	oNum = document.createTextNode(i+'.');

						

	oRow.appendChild(oCell);

	oCell.appendChild(oNum);

						

	oCell2 = document.createElement('td');

	oLength = document.createElement('input');

	oLength.setAttribute('type','text');

	oLength.setAttribute('name','Cargo '+i+' Length');

	oLength.setAttribute('size','5');

	oRow.appendChild(oCell2);

	oCell2.appendChild(oLength);

						

	oCell3 = document.createElement('td');

	oHeight = document.createElement('input');

	oHeight.setAttribute('type','text');

	oHeight.setAttribute('name','Cargo '+i+' Height');

	oHeight.setAttribute('size','5');

	oRow.appendChild(oCell3);

	oCell3.appendChild(oHeight);

						

	oCell4 = document.createElement('td');

	oWidth = document.createElement('input');

	oWidth.setAttribute('type','text');

	oWidth.setAttribute('name','Cargo '+i+' Width');

	oWidth.setAttribute('size','5');

	oRow.appendChild(oCell4);

	oCell4.appendChild(oWidth);

						

	oCell5 = document.createElement('td');

	oUnit1 = document.createElement('select');

	oUnit1.setAttribute('name','Cargo '+i+' Dimensions Unit');

	oOption1 = document.createElement('option');

	oOption1Text = document.createTextNode('Unit');

	oOption1.appendChild(oOption1Text);

	oUnit1.appendChild(oOption1);

						

	oOption2 = document.createElement('option');

	oOption2.setAttribute('value', 'meter');

	oOption2Text = document.createTextNode('meter');

	oOption2.appendChild(oOption2Text);

	oUnit1.appendChild(oOption2);

						

	oOption3 = document.createElement('option');

	oOption3.setAttribute('value', 'inch');

	oOption3Text = document.createTextNode('inch');

	oOption3.appendChild(oOption3Text);

	oUnit1.appendChild(oOption3);

						

	oRow.appendChild(oCell5);

	oCell5.appendChild(oUnit1);

						

	oCell6 = document.createElement('td');

	oWeight = document.createElement('input');

	oWeight.setAttribute('type','text');

	oWeight.setAttribute('name','Cargo '+i+' Weight');

	oWeight.setAttribute('size','5');

	oRow.appendChild(oCell6);

	oCell6.appendChild(oWeight);

						

	oCell7 = document.createElement('td');

	oUnit2 = document.createElement('select');

	oUnit2.setAttribute('name','Cargo '+i+' Weight Unit');

	oOption4 = document.createElement('option');

	oOption4Text = document.createTextNode('Unit');

	oOption4.appendChild(oOption4Text);

	oUnit2.appendChild(oOption4);

						

	oOption5 = document.createElement('option');

	oOption5.setAttribute('value', 'kg.');

	oOption5Text = document.createTextNode('kg.');

	oOption5.appendChild(oOption5Text);

	oUnit2.appendChild(oOption5);

						

	oOption6 = document.createElement('option');

	oOption6.setAttribute('value', 'lbs.');

	oOption6Text = document.createTextNode('lbs.');

	oOption6.appendChild(oOption6Text);

	oUnit2.appendChild(oOption6);

						

	oRow.appendChild(oCell7);

	oCell7.appendChild(oUnit2);

						

	i++;

}



function checkForm() {

	oForm = document.request;

	oElements = oForm.elements;

	submitForm = true;

	message = "Your form is missing the following fields:\n";

			

	for (j = 0; j <= 4; j++) {

		if (oElements[j].value == '') {

			submitForm = false;

			message += oElements[j].name+"\n";

		}

	}

			

	oMove = oElements[5];

	oMoveIndex = oMove.selectedIndex;

	oMoveOption = oMove.options[oMoveIndex].text;

	if (oMoveOption == 'Select Move') {

		submitForm = false;

		message += oElements[5].name+"\n";

	}

			

	if (oElements[14].value == '') {

		submitForm = false;

		message += oElements[14].name+"\n";

	}

			

	if (oElements[15].value == '') {

		submitForm = false;

		message += oElements[15].name+"\n";

	}

			

	if ((oElements[16].value == '') && (oElements[17].value == '') && (oElements[19].value == '')) {

		submitForm = false;

		message += "Equipment Qty.\n";

	}

			

	if (submitForm) {

		oForm.submit();

	} else {

		alert(message);

	}			

}


