filter images in sliver-add inline by deployment
diff --git a/planetstack/templates/admin/core/slice/change_form.html b/planetstack/templates/admin/core/slice/change_form.html
index 424a41b..31f09c0 100644
--- a/planetstack/templates/admin/core/slice/change_form.html
+++ b/planetstack/templates/admin/core/slice/change_form.html
@@ -14,20 +14,36 @@
 {% endfor %}
 ];
 
+deployment_images = [
+{% for dn in deployment_images %}
+   [{{ dn.0 }}, {{ dn.1 }} , "{{ dn.2 }}"],
+{% endfor %}
+];
+
 site_login_bases = [
 {% for s in site_login_bases %}
   [{{ s.0 }}, "{{ s.1 }}"],
 {% endfor %}
 ];
 
+function option_html(val, text, selected) {
+    if (selected) {
+        return '<option value="' + val + '" selected>' + text + '</option>\n';
+    } else {
+        return '<option value="' + val + '">' + text + '</option>\n';
+    }
+}
+
 function update_nodes(deployment_select, flavor_select, node_select) {
     deployment_id = $(deployment_select).val();
+    node_id = $(node_select).val();
     flavor_name = $(flavor_select).children(":selected").text()
     html="";
     for (i in deployment_nodes) {
+        // this is for EC2, where the node hostnames imply the flavor.
         dn = deployment_nodes[i];
         if ((dn[0] == deployment_id) && (dn[2].lastIndexOf(flavor_name,0) === 0)) {
-            html = html + '<option value="' + dn[1] + '">' + dn[2] + '</option>\n'
+            html = html + option_html(dn[1], dn[2], dn[1]==node_id);
         }
     }
     if (!html) {
@@ -35,28 +51,40 @@
         for (i in deployment_nodes) {
             dn = deployment_nodes[i];
             if (dn[0] == deployment_id) {
-                html = html + '<option value="' + dn[1] + '">' + dn[2] + '</option>\n'
+                html = html + option_html(dn[1], dn[2], dn[1]==node_id);
             }
         }
     }
     html = "<option value=''>---------</option>\n" + html;
-    //console.log(html);
     node_select.empty().append(html);
 }
 
 function update_flavors(deployment_select, flavor_select) {
     deployment_id = $(deployment_select).val();
+    flavor_id = $(flavor_select).val();
     html = "<option value=''>---------</option>\n";
     for (i in deployment_flavors) {
         dn = deployment_flavors[i];
         if (dn[0] == deployment_id) {
-            html = html + '<option value="' + dn[1] + '">' + dn[2] + '</option>\n'
+            html = html + option_html(dn[1], dn[2], dn[1] == flavor_id);
         }
     }
-    //console.log(html);
     flavor_select.empty().append(html);
 }
 
+function update_images(deployment_select, image_select) {
+    deployment_id = $(deployment_select).val();
+    image_id = $(image_select).val();
+    html = "<option value=''>---------</option>\n";
+    for (i in deployment_images) {
+        dn = deployment_images[i];
+        if (dn[0] == deployment_id) {
+            html = html + option_html(dn[1], dn[2], dn[1] == image_id);
+        }
+    }
+    image_select.empty().append(html);
+}
+
 function sliver_deployment_changed(any_control) {
    /* This function handles someone changing the deploymentNetwork control
       in the add-sliver line. It updats the flavors and nodes dialogs
@@ -73,8 +101,10 @@
     deployment_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-deploymentNetwork select')[0].id);
     node_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-node select')[0].id);
     flavor_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-flavor select')[0].id);
+    image_select = $("#" + $($(any_control).closest('tr')[0]).find('.field-image select')[0].id);
     update_nodes(deployment_select, flavor_select, node_select);
     update_flavors(deployment_select, flavor_select);
+    update_images(deployment_select, image_select);
 }
 
 function sliver_flavor_changed(any_control) {