--- /var/www/racktables-prod/inc/interface.php	2013-04-30 10:01:27.449185928 +0200
+++ /var/www/racktables-bg-dev/inc/interface.php	2013-04-30 10:19:03.961882935 +0200
@@ -449,6 +449,21 @@
 	}
 }
 
+function locationSelectTree($selected = 0)
+{
+		echo "<option value=0>-- NONE --</option>";
+		foreach (treeFromList(listCells ('location')) as $location)
+		{
+			echo "<option value=${location['id']} style=\"font-weight: bold\" ";
+			if ($location['id'] == $selected )
+			    echo " selected ";
+			echo ">${location['name']}</option>";
+			printLocationChildren($location,0,$selected);
+		}
+		echo "</select>";
+}
+
+
 function renderRackspaceLocationEditor ()
 {
 	addJS
@@ -469,11 +484,9 @@
 		printOpFormIntro ('addLocation');
 		echo "<tr><td>";
 		printImageHREF ('create', 'Add new location', TRUE);
-		echo "</td><td><select name=parent_id tabindex=100>";
-		echo "<option value=0>-- NONE --</option>";
-		foreach (listCells ('location') as $location)
-			echo "<option value=${location['id']}>${location['name']}</option>";
-		echo "</select></td>";
+		echo "</td><td><select name=parent_id tabindex=100>";
+		locationSelectTree();
+		echo "</td>";
 		echo "<td><input type=text size=48 name=name tabindex=101></td><td>";
 		printImageHREF ('create', 'Add new location', TRUE, 102);
 		echo "</td></tr></form>\n";
@@ -496,16 +509,14 @@
 
 function renderRackspaceRowEditor ()
 {
-	function printNewItemTR ($locationlist)
+	function printNewItemTR ()
 	{
 		printOpFormIntro ('addRow');
 		echo "<tr><td>";
 		printImageHREF ('create', 'Add new row', TRUE);
 		echo "</td><td><select name=location_id tabindex=100>";
-		echo "<option value=0>-- NONE --</option>";
-		foreach ($locationlist as $location)
-			echo "<option value=${location['id']}>${location['name']}</option>";
-		echo "</select></td>";
+		locationSelectTree();
+		echo "</td>";
 		echo "<td><input type=text name=name tabindex=101></td><td>";
 		printImageHREF ('create', 'Add new row', TRUE, 102);
 		echo "</td></tr></form>";
@@ -516,7 +527,7 @@
 	echo "<table border=0 cellspacing=0 cellpadding=5 align=center class=widetable>\n";
 	echo "<tr><th>&nbsp;</th><th>Location</th><th>Name</th><th>&nbsp;</th></tr>\n";
 	if (getConfigVar ('ADDNEW_AT_TOP') == 'yes')
-		printNewItemTR($locationlist);
+		printNewItemTR();
 	foreach (getAllRows() as $row_id => $rowInfo)
 	{
 		echo "<tr><td>";
@@ -534,7 +545,8 @@
 		$selectlist['other'][0] = '-- NONE --';
 		foreach ($locationlist as $location_id => $locationdata)
 			$selectlist['other'][$location_id] = $locationdata['name'];
-		printNiftySelect ($selectlist, array ('name' => 'location_id'), $rowInfo['location_id']);
+		echo "<select name=location_id tabindex=100>";
+		locationSelectTree($rowInfo['location_id']);
 		echo "</td><td><input type=text name=name value='${rowInfo['name']}'></td><td>";
 		printImageHREF ('save', 'Save changes', TRUE);
 		echo "</form></td></tr>\n";
