function updateDropDowns() {

	firstmls = "";
	finalmls = "";
	
	for(i=1; i<=5; i++) {
		mlsid = document.getElementById('mls' + i).value;
		if (firstmls == "") { firstmls = mlsid; }
		if (mlsid != "") { finalmls = mlsid; }
	}
	
	var startDD = document.getElementById('startGUID');
	for(i=1;i<startDD.options.length;i++) {
		if (startDD.options[i].text == firstmls) {
			startDD.options[i].selected = true;
		}
	}
	
	var finalDD = document.getElementById('finalGUID');						
	for(i=1;i<finalDD.options.length;i++) {
		if (finalDD.options[i].text == finalmls) {
			finalDD.options[i].selected = true;
		}
	}
}

function swapRows(row1, row2) {
	if (row1 >= 1 && row1 <= 5 && row2 >= 1 && row2 <= 5) {
		var row1lbl = document.getElementById('lbl' + row1);
		var row1mls = document.getElementById('mls' + row1);
		var row1uid = document.getElementById('uid' + row1);
		
		var row2lbl = document.getElementById('lbl' + row2);
		var row2mls = document.getElementById('mls' + row2);
		var row2uid = document.getElementById('uid' + row2);
				
		templbl = row2lbl.innerHTML;
		row2lbl.innerHTML = row1lbl.innerHTML;
		row1lbl.innerHTML = templbl
		
		tempMLS = row2mls.value;
		row2mls.value = row1mls.value;
		row1mls.value = tempMLS;
		
		tempuid = row2uid.value;
		row2uid.value = row1uid.value;
		row1uid.value = tempuid;
		
		updateDropDowns();
	}
}

function rebuildDropDowns() {

	var numIDs = 5;

	var startDD = document.getElementById('startGUID');
	var finalDD = document.getElementById('finalGUID');

	var curStart = startDD.options[startDD.selectedIndex].text;
	var curFinal = finalDD.options[finalDD.selectedIndex].text;
	
	<!--- Remove all options but the first from the drop downs --->
	for (i=startDD.options.length; i>=1; i--) { startDD.remove(i); }
	for (i=finalDD.options.length; i>=1; i--) { finalDD.remove(i); }
	
	<!--- Repopulate the drop downs --->
	for (i=1; i<=numIDs; i++) {
		mlsid = document.getElementById('mls' + i).value;
		uidid = document.getElementById('uid' + i).value;

		if (mlsid != "") {
			var len = startDD.options.length++;
			startDD.options[len].value = i;
			startDD.options[len].text = mlsid;

			var len = finalDD.options.length++;
			finalDD.options[len].value = i;
			finalDD.options[len].text = mlsid;
		}
	}

	updateDropDowns();
	
}

function PopulateAddress() {
	document.frmPlanner.endadd.value = document.frmPlanner.startadd.value;
	document.frmPlanner.endcity.value = document.frmPlanner.startcity.value;
	document.frmPlanner.endstate.value = document.frmPlanner.startstate.value;
}


function toggle(boxid) {
	var box = document.getElementById(boxid);
	if (box) {
		if (box.style.display == "block") { box.style.display = "none"; }
		else { 
			box.style.display = "block"; 
		}
	}
}

arrowsEnabled = false;

function enableArrows() {
	if (arrowsEnabled == false) {
		for (i=1; i<=5; i++) {
			toggle('arr' + i + '_on');
			toggle('arr' + i + '_off');
		}
	}
	arrowsEnabled = true;
}

function disableArrows() {
	if (arrowsEnabled == true) {
		for (i=1; i<=5; i++) {
			toggle('arr' + i + '_on');
			toggle('arr' + i + '_off');
		}
	}
	arrowsEnabled = false;
}