function Show($which, $zoom, $detail)
{
    global $pid, $eid, $uid, $TBSUEXEC_PATH, $TBADMINGROUP;
    global $template, $isadmin;
    $html = "";
    if ($which == "vis") {
        if ($zoom == 0) {
            # Default is whatever we have; to avoid regen of the image.
            list($zoom, $detail) = $template->CurrentVisDetails();
        } else {
            # Sanity check but lets not worry about throwing an error.
            if (!TBvalid_float($zoom)) {
                $zoom = 1.25;
            }
            if (!TBvalid_integer($detail)) {
                $detail = 1;
            }
        }
        ob_start();
        $template->ShowVis($zoom, $detail);
        $html = ob_get_contents();
        ob_end_clean();
        $zoomout = sprintf("%.2f", $zoom / 1.25);
        $zoomin = sprintf("%.2f", $zoom * 1.25);
        $html .= "<button name=viszoomout type=button value={$zoomout}";
        $html .= " onclick=\"VisChange('{$zoomout}', {$detail});\">";
        $html .= "Zoom Out</button>\n";
        $html .= "<button name=viszoomin type=button value={$zoomin}";
        $html .= " onclick=\"VisChange('{$zoomin}', {$detail});\">";
        $html .= "Zoom In</button>\n";
        if ($detail) {
            $html .= "<button name=hidedetail type=button value=0";
            $html .= " onclick=\"VisChange('{$zoom}', 0);\">";
            $html .= "Hide Details</button>\n";
        } else {
            $html .= "<button name=showdetail type=button value=1";
            $html .= " onclick=\"VisChange('{$zoom}', 1);\">";
            $html .= "Show Details</button>\n";
        }
    } elseif ($which == "graph") {
        ob_start();
        $template->ShowGraph();
        $html = ob_get_contents();
        ob_end_clean();
        if (!$template->IsRoot()) {
            if ($template->IsHidden()) {
                $html .= "<button name=showtemplate type=button value=Show";
                $html .= " onclick=\"GraphChange('showtemplate');\">";
                $html .= "Show Template</button>&nbsp";
            } else {
                $html .= "<button name=hidetemplate type=button value=Hide";
                $html .= " onclick=\"GraphChange('hidetemplate');\">";
                $html .= "Hide Template</button>&nbsp";
            }
            $html .= "<input id=showexp_recursive type=checkbox value=Yep> ";
            $html .= "Recursive? &nbsp &nbsp &nbsp &nbsp ";
        }
        $root = Template::LookupRoot($template->guid());
        # We overload the hidden bit on the root.
        if ($root->IsHidden()) {
            $html .= "<button name=showhidden type=button value=showhidden";
            $html .= " onclick=\"GraphChange('showhidden');\">";
            $html .= "Show Hidden Templates</button>&nbsp &nbsp &nbsp &nbsp ";
        } else {
            $html .= "<button name=hidehidden type=button value=hidehidden";
            $html .= " onclick=\"GraphChange('hidehidden');\"> ";
            $html .= "Hide Hidden Templates</button>&nbsp &nbsp &nbsp &nbsp ";
        }
        $html .= "<button name=zoomout type=button value=out";
        $html .= " onclick=\"GraphChange('zoomout');\">Zoom Out</button>\n";
        $html .= "<button name=zoomin type=button value=in";
        $html .= " onclick=\"GraphChange('zoomin');\">Zoom In</button>\n";
        # A delete button with a confirm box right there.
        if ($isadmin) {
            $html .= "<br><br>\n";
            $html .= "<button name=deletetemplate type=button value=Delete";
            $html .= " onclick=\"DeleteTemplate();\">";
            $html .= "<font color=red>Delete</font></button>&nbsp";
            $html .= "<input id=confirm_delete type=checkbox value=Yep> ";
            $html .= "Confirm";
        }
    } elseif ($which == "nsfile") {
        $nsdata = "";
        $input_list = $template->InputFiles();
        for ($i = 0; $i < count($input_list); $i++) {
            $nsdata .= htmlentities($input_list[$i]);
            $nsdata .= "\n\n";
        }
        $html = "<pre><div align=left class=\"showexp_codeblock\">" . "{$nsdata}</div></pre>\n";
        $html .= "<button name=savens type=button value=1";
        $html .= " onclick=\"SaveNS();\">";
        $html .= "Save</button>\n";
    }
    return $html;
}