var TOTAL_DESIRED_DISTANCE_COUNT = 1;
var distance_array = new Array(5,10,15,20,25,30,35,40,45,50,60,75,100,125,150,175,200,250,300,400,500);
function do_add_employee(num){
	for(var i=1;i<=num;i++){
		var newTR = document.createElement("tr");
		
		var newTD = document.createElement("td");
		
		newTD.setAttribute("width","20%");
		newTD.setAttribute("align","right");
		newTD.setAttribute("valign","top");
		
		var newSelect = document.createElement("select");
		newSelect.setAttribute("name","select_distance_"+TOTAL_DESIRED_DISTANCE_COUNT);
		newSelect.setAttribute("size",1);
		
		for(var j=0;j<distance_array.length;j++){
			var newOption = document.createElement("option");
			newOption.setAttribute("value",distance_array[j]);
			if(distance_array[j] == DEFAULT_DESIRED_DISTANCE_FROM_ZIP)
				newOption.setAttribute("selected",true);
			var optionLabel = document.createTextNode(distance_array[j]);
			newOption.appendChild(optionLabel);
			newSelect.appendChild(newOption);
		}
		newTD.appendChild(newSelect);					
		newTR.appendChild(newTD);

		newTD = document.createElement("td");
		textNode = document.createTextNode("miles from");
		newTD.setAttribute("align","center");
		newTD.setAttribute("width","10%");
		newTD.appendChild(textNode);
		newTR.appendChild(newTD);

		newTD = document.createElement("td");
		newTD.setAttribute("align","left");
		newTD.setAttribute("width","70%");
		var inputNode = document.createElement("input");
		inputNode.setAttribute("type","text");
		inputNode.setAttribute("value",new_user_zip);
		inputNode.setAttribute("name","from_zip_"+TOTAL_DESIRED_DISTANCE_COUNT);
		newTD.appendChild(inputNode);
		newTR.appendChild(newTD);
		
		existingTRobject = document.getElementById("employee_distance");
		existingTRobject.insertBefore(newTR);
		TOTAL_DESIRED_DISTANCE_COUNT++;
	}
}

function add_employee(num){
	num = num - TOTAL_DESIRED_DISTANCE_COUNT;
	if(num < 0) 
		do_remove_employee(num);
	else
		do_add_employee(num);
}

function do_remove_employee(num){
	existingTRobject = document.getElementById("employee_distance");
	while(num<0){
		var children = existingTRobject.childNodes;
		num_employees = children.length;
		existingTRobject.removeChild(children[num_employees-1]);
		num++;TOTAL_DESIRED_DISTANCE_COUNT--;			
	}
}

