// browser test:
   
   agt=navigator.userAgent.toLowerCase();
   var gecko = (agt.indexOf('gecko') != -1);
   ns4 = (document.layers)? true:false
   ie4 = (document.all)? true:false

   a3n = new Image();
   a3n.src = "image/a3_on.gif";
   
   a3f = new Image();
   a3f.src = "image/a3.gif";

   b3n = new Image();
   b3n.src = "image/b3_on.gif";
   
   b3f = new Image();
   b3f.src = "image/b3.gif";

   wcn = new Image();
   wcn.src = "image/wc_on.gif";
   
   wcf = new Image();
   wcf.src = "image/wc.gif";

   wdn = new Image();
   wdn.src = "image/wd_on.gif";
   
   wdf = new Image();
   wdf.src = "image/wd.gif";

// SETUP STUFF   
   var rx="a3";
   function setup() {
      document.theform.receiver.value = rx;
      document.objsel.object.selectedIndex = 0;
      if (ns4) {
         document.molsel.document.molform.molecule.selectedIndex = 0;
      } else if (ie4) {
         document.molform.molecule.selectedIndex = 0;
      }
   }

// UPDATE THE RECEIVER SELECTION AND ASSOCIATED ENTRYBOXES

function new_receiver(rx_name)
{
   document["a3"].src=eval("a3f.src");
   document["b3"].src=eval("b3f.src");
   document["wc"].src=eval("wcf.src");
   document["wd"].src=eval("wdf.src");
   document[rx_name].src=eval(rx_name+"n.src");
   rx=rx_name;

// CREATE A NEW SELECTION FORM BASED ON THE CHOICE OF RECEIVER

   var msg = "<CENTER><FORM NAME=\"molform\">"
   msg += "<FONT SIZE=\"+2\" COLOR=\"#0000FF\">Select transition:</FONT>"
   msg += "<SELECT NAME=\"molecule\" SIZE=\"1\">"
   if (ns4 || gecko) {
      if (rx_name == "a3") {
         msg += "<OPTION VALUE=\"h2co32\">H2CO 3(0,3)->2(0,2)\n"
         msg += "<OPTION VALUE=\"c18o21\">C18O 2->1\n"
         msg += "<OPTION VALUE=\"13co21\">13CO 2->1\n"
         msg += "<OPTION VALUE=\"co21\">CO 2->1\n"
         msg += "<OPTION VALUE=\"ch3oh54\">CH3OH 5(0)->4(0)A\n"
         msg += "<OPTION VALUE=\"cs54\">CS 5->4\n"
         msg += "<OPTION VALUE=\"hcn32\">HCN 3->2\n"
         msg += "<OPTION VALUE=\"hco32\">HCO+ 3->2\n"
      } else if (rx_name == "b3") {
         msg += "<OPTION VALUE=\"c18o32\">C18O 3->2\n"
         msg += "<OPTION VALUE=\"13co32\">13CO 3->2\n"
         msg += "<OPTION VALUE=\"ch3oh76\">CH3OH 7(0)->6(0)A\n"
         msg += "<OPTION VALUE=\"cs76\">CS 7->6\n"
         msg += "<OPTION VALUE=\"co32\">CO 3->2\n"
         msg += "<OPTION VALUE=\"hcn43\">HCN 4->3\n"
         msg += "<OPTION VALUE=\"hco43\">HCO+ 4->3\n"
         msg += "<OPTION VALUE=\"h2co54\">H2CO 5(0,5)->4(0,4)\n"
      } else if (rx_name == "wc") {
         msg += "<OPTION VALUE=\"c34s98\">C34S 9->8\n"
         msg += "<OPTION VALUE=\"h2co65\">H2CO 6(0,6)->5(0,5)\n"
         msg += "<OPTION VALUE=\"c18o43\">C18O 4->3\n"
         msg += "<OPTION VALUE=\"13co43\">13CO 4->3\n"
         msg += "<OPTION VALUE=\"h2s\">H2S 1(1,1)->0(0,0)\n"
         msg += "<OPTION VALUE=\"co43\">CO 4->3\n"
         msg += "<OPTION VALUE=\"hdo\">HDO 1(0,1)->0(0,0)\n"
         msg += "<OPTION VALUE=\"cs109\">CS 10->9\n"
         msg += "<OPTION VALUE=\"c1\">CI\n"
      } else if (rx_name == "wd") {
         msg += "<OPTION VALUE=\"hco76\">HCO+ 7->6\n"
         msg += "<OPTION VALUE=\"cs1312\">CS 13->12\n"
         msg += "<OPTION VALUE=\"h2co98\">H2CO 9(0,9)->8(0,8)\n"
         msg += "<OPTION VALUE=\"c18o65\">C18O 6->5\n"
         msg += "<OPTION VALUE=\"13co65\">13CO 6->5\n"
         msg += "<OPTION VALUE=\"so2\">SO2 6(6,0)->5(5,1)\n"
         msg += "<OPTION VALUE=\"co65\">CO 6->5\n"
         msg += "<OPTION VALUE=\"hcn87\">HCN 8->7\n"
         msg += "<OPTION VALUE=\"hco87\">HCO+ 8->7\n"
      }
      msg += "</SELECT>\n"
      msg += "</FORM></CENTER>\n"
   }
   if (ns4) {
      document.layers["molsel"].document.open()
      document.layers["molsel"].document.write(msg)
      document.layers["molsel"].document.close()
   } else if (gecko) {
      document.getElementById('molsel').innerHTML=msg
   }
}

// PATCH THE FORM TOGETHER AND SUBMIT IT

function submitit()
{
     if (ns4) {
        open("/jac-bin/jcmt_stds/stin_web.pl?js1=yes&object="+document.objsel.object.selectedIndex+"&molecule="+document.molsel.document.molform.molecule.selectedIndex+"&receiver="+rx, "standards", "SCREENX=1,SCREENY=1,WIDTH=600,HEIGHT=470,SCROLLBARS=no")    
     } else if (gecko) {
        open("/jac-bin/jcmt_stds/stin_web.pl?js1=yes&object="+document.forms['objsel'].object.selectedIndex+"&molecule="+document.forms['molform'].molecule.selectedIndex+"&receiver="+rx, "standards", "SCREENX=1,SCREENY=1,WIDTH=620,HEIGHT=500,SCROLLBARS=no")    
     } else if (ie4) {
        open("/jac-bin/jcmt_stds/stin_web.pl?js1=yes&object="+document.objsel.object.selectedIndex+"&molecule="+document.molsel.molecule.selectedIndex+"&receiver="+rx, "standards", "SCREENX=1,SCREENY=1,WIDTH=600,HEIGHT=470,SCROLLBARS=no")    
     }
     return false
}

// DEFINE THE HIDE AND SHOW LAYERS FUNCTIONS

function show(id) {
      if (ns4) document.layers[id].visibility = "show"
      else if (ie4) document.all[id].style.visibility = "visible"
}

function hide(id) {
      if (ns4) document.layers[id].visibility = "hide"
      else if (ie4) document.all[id].style.visibility = "hidden"
}
