+$site_id=$node['site_id'];
+
+$can_update= plc_is_admin() || ( plc_in_site ($site_id) && ( plc_is_pi() || plc_is_tech()));
+
+drupal_set_title($title . " on " . $node['hostname']);
+
+// include javacsript helpers
+require_once 'prototype.php';
+drupal_set_html_head ('
+<script type="text/javascript" src="/planetlab/nodes/interface.js"></script>
+');
+
+$nifty_id = ($mode == 'add' ) ? 'add-interface' : 'interface';
+$toggle = new PlekitToggle ($nifty_id,"Details",
+ array('bubble'=>'Display and modify details for that interface',
+ 'visible'=>get_arg('show_details')));
+$toggle->start();
+
+$details=new PlekitDetails($can_update);
+
+// xxx hardwire network type for now
+$form_variables = array('node_id'=>$node_id,'type'=>"ipv4");
+if ($mode == "update") $form_variables['interface_id']=$interface_id;
+$form=$details->form_start(l_actions(),$form_variables,
+ array('onSubmit'=>'return interfaceSubmit()'));
+
+$details->start();
+
+if ($mode == 'add')
+ $method_default = 'dhcp';
+else
+ $method_default = $interface['method'];
+$method_select = $form->select_html ("method",
+ interface_method_selectors($api,$method_default,false),
+ array('id'=>'method','onChange'=>'updateMethodFields()'));
+$details->th_td("Method",$method_select,"method",array('input_type'=>'select','value'=>$interface['method']));
+
+// dont display the 'type' selector as it contains only ipv4
+//>>> GetNetworkTypes()
+//[u'ipv4']
+
+$details->th_td("IP",$interface['ip'],"ip",array('width'=>15,
+ 'onKeyup'=>'networkHelper()',
+ 'onChange'=>'networkHelper()'));
+$details->th_td("Netmask",$interface['netmask'],"netmask",array('width'=>15,
+ 'onKeyup'=>'networkHelper()',
+ 'onChange'=>'networkHelper()'));
+$details->th_td("Network",$interface['network'],"network",array('width'=>15));
+$details->th_td("Broadcast",$interface['broadcast'],"broadcast",array('width'=>15));
+$details->th_td("Gateway",$interface['gateway'],"gateway",array('width'=>15,
+ 'onChange'=>'subnetChecker("gateway",false)'));
+$details->th_td("DNS 1",$interface['dns1'],"dns1",array('width'=>15,
+ 'onChange'=>'subnetChecker("dns1",false)'));
+$details->th_td("DNS 2",$interface['dns2'],"dns2",array('width'=>15,
+ 'onChange'=>'subnetChecker("dns2",true)'));
+$details->space();
+$details->th_td("BW limit (bps)",$interface['bwlimit'],"bwlimit",array('width'=>11));
+$details->th_td("Hostname",$interface['hostname'],"hostname");
+$details->th_td("Mac address",$interface['mac'],"mac", array('onChange'=>'macChecker("mac", true)'));
+
+// the buttons
+$update_button = $form->submit_html ("update-interface","Update");
+$add_button = $form->submit_html ("add-interface","Add as new",
+ array('onSubmit'=>'interfaceSubmit()'));
+switch ($mode) {
+ case 'add':
+ // primary interfaces can't be virtual
+ $is_primary = (count($node['interface_ids']) == 0);
+ if ( ! $is_primary) {
+ // default is to create virtual interfaces
+ $details->th_th("Virtual Interface",
+ $form->checkbox_html('is-virtual','yes',array('id'=>'virtual',
+ 'checked'=>'checked',
+ 'onChange'=>'updateVirtualArea()')));
+ $details->th_td("Interface name","eth0",'ifname');
+ $details->th_td("alias (leave empty if unsure)","",'alias');
+ }
+ $details->tr($add_button,"right");
+ break;
+ case 'update':
+ $details->tr($update_button . " " . $add_button,"right");
+ break;
+ }