destinationCount = 0;

function checkFields(){
	for(var x=1; x < 10; x++){
		var zip 	= document.getElementById('zipDestination'+x).value;
		var city 	= document.getElementById('cityDestination'+x).value;
		var state 	= document.getElementById('stateDestination'+x).value;
		
		if(zip != '' || city != '' || state != ''){
			destinationCount = x;
		}
	}
	for(var x=1; x <= destinationCount; x++){
		displayRow(x);
	}
	if(destinationCount == 9){
		document.getElementById('addButton').style.display = 'none';
	}
	if(destinationCount > 0){
		document.getElementById('removeButton').style.display = 'block';
	}
}

function displayRow(x){
	document.getElementById('displayCounty'+x).style.display = 'block';
	document.getElementById('displayCityStateZip'+x).style.display = 'block';
	document.getElementById('displayShipmentDate'+x).style.display = 'inline';
}

function hideRow(x){
	document.getElementById('displayCounty'+x).style.display = 'none';
	document.getElementById('displayCityStateZip'+x).style.display = 'none';
	document.getElementById('displayShipmentDate'+x).style.display = 'none';
	document.getElementById('zipDestination'+x).value = '';
	document.getElementById('cityDestination'+x).value = '';
	document.getElementById('stateDestination'+x).value = '';
	document.getElementById('shipmentDate'+x).value = '';
}

function addRowsClick(){
	displayRow(++destinationCount);
	if(destinationCount < 9){
		displayRow(++destinationCount);
	}
	if(destinationCount == 9){
		document.getElementById('addButton').style.display = 'none';
	}
	document.getElementById('removeButton').style.display = 'inline';
}

function removeRowClick(){
	hideRow(destinationCount--);
	if(destinationCount > 0){
		hideRow(destinationCount--);
	}
	if(destinationCount == 0){
		document.getElementById('removeButton').style.display = 'none';
	}
	document.getElementById('addButton').style.display = 'inline';
}
