--- inc/interface.php	2013-06-17 07:40:16.341132554 +0200
+++ inc/interface.php	2013-06-19 08:59:39.573195984 +0200
@@ -277,16 +277,26 @@
 
 		foreach ($subtree as $location_id => $location)
 		{
-			echo "<tr><td class=tagbox style='padding-left: " . ($level * 16) . "px;'><label>";
+
+			echo "<div class=tagbox style='text-align:left; padding-left: " . ($level * 8) . "px;'><label>";
+
 			$checked = (in_array ($location['id'], $_SESSION['locationFilter'])) ? 'checked' : '';
-			echo "<label><input type=checkbox name='location_id[]' class=${level} value='${location['id']}'${checked} onClick=checkAll(this)>";
+			echo "<input type=checkbox name='location_id[]' class=${level} value='${location['id']}' ${checked} onClick=checkAll(this)>";
 
      echo "<a class=nolink title='" .getLocationTooltip($location['id']) . "'>${location['name']}</a>";
      echo "</label>";
+
 			if ($location['kidc'])
+			{
+				echo "<a id='lfa" .$location['id'] . "' onclick=\"expand('${location['id']}')\" href\"#\" > - </a>";
+				echo "<div id='lfd" . $location['id'] . "'>";
 				$self ($location['kids'], $level + 1);
+				echo "</div>";
 		}
+			echo "</div>\n";
 	}
+	}
+
 
 	addJS(<<<END
 		function checkAll(bx){
@@ -311,13 +321,63 @@
 						else if(parseInt(bxs[j].className) <= parseInt(bx.className))
 							in_tree = false;
 
-						
 						if (bxs[j].type=="checkbox" && in_tree == true)
 							bxs[j].checked = bx.checked;
+					}
+				}
+		}
 
+		function collapseAll(bx){
+			for (var tbls=document.getElementsByTagName("table"), i=tbls.length; i--; )
+				if (tbls[i].id=="locationFilter")
+				{	
+					var bxs=tbls[i].getElementsByTagName("div");
+					//loop through divs to hide unchecked
+					for (var j=0; j<bxs.length; j++ )
+					{
+						var is_checked = -1;
+						var in_div=bxs[j].getElementsByTagName("input");
+						//loop through input to find if any is checked
+						for (var k=0; k<in_div.length; k++)
+						{
+							if(in_div[k].type="checkbox")
+							{
+								if (in_div[k].checked == true)
+								{
+									is_checked = true;
+									break;
                             		}
+								else
+									is_checked = false;
+							}
+						}
+						//nothing selected and element id is lfd...
+						if (is_checked == false && !bxs[j].id.indexOf("lfd"))
+						{
+							//collapse
+							expand(bxs[j].id.substr(3));
+						}
+					}
+				}
+		}
+
+
+		function expand(id)
+		{
+			var divid = document.getElementById("lfd" + id);
+			var iconid = document.getElementById("lfa" + id);
+			if (divid.style.display == 'none') 
+			{
+				divid.style.display = 'block';
+				iconid.innerHTML = ' - ';
                             	}
+			else 
+			{
+				divid.style.display = 'none';
+				iconid.innerHTML = ' + ';
                 }
+		}
+
 END
 	,TRUE);
 	
@@ -338,13 +398,18 @@
 	{
 		echo "<tr><td class=tagbox><hr></td></tr>\n";
 		
-		echo "<tr><td class=tagbox style='padding-left: 0px' ><label>";
+		echo "<tr><td class=tagbox style='padding-left: 0px' >";
 		echo "<label><input type=checkbox name='location'  onClick=checkAll(this)>";
+		echo "<img src=pix/1x1t.gif onLoad=collapseAll(this)>";  //dirty hack to collapse all when page is displayed
 		echo "</label></td></tr>\n";
 		
+		echo "<tr><td>";
 		renderLocationCheckbox (treeFromList ($locationlist));
+		echo "</td></tr>";
+		
 		echo "<tr><td class=tagbox><hr></td></tr>\n";
 		echo "<tr><td>";
+
 		printImageHREF ('setfilter', 'set filter', TRUE);
 		echo "</td></tr>\n";
 	}
