<!-- $Id: public.js,v 1.7 2006/07/10 15:19:57 nichols Exp $ -->
<!-- Based on SPMd's public.js,v 1.3 2004/09/08 20:04:02 huizhang  -->
<!-- Software property -->

<!-- title, name, authors -->
var SW_title = "SnPM";
var SW_name  = "Statistical Nonparametric Mapping";
var authors        = "Jun Ding, Andrew Holmes &amp; Thomas Nichols";

<!-- url for this software -->
var url_SW   = "http://www.sph.umich.edu/~nichols/SnPM/snpmreg.html";
var url_download1   = "http://www.sph.umich.edu/ni-stat/SnPM/download-99";
var url_download2   = "http://www.sph.umich.edu/ni-stat/SnPM/download-2";
var url_download3   = "http://www.sph.umich.edu/ni-stat/SnPM/download-3";
var url_download4   = "http://www.sph.umich.edu/ni-stat/SnPM/download-5";
var url_action     = "http://www.sph.umich.edu/cgi-bin/htmail/snpm-req@umich.edu";

<!-- keyword, username, email address, subject of the email -->
var SWname1  = "snpm99";
var SWname2  = "snpm2";
var SWname3  = "snpm3";
var SWname4  = "snpm5";
var SW_key1   = "gander";
var SW_key2   = "michy";
var SW_key3   = "henne";
var SW_key4   = "randomise";
var SW_email = "snpm-req@umich.edu";
var emailsubject   = "SnPM Registration Form";

<!-- ======================================================================= -->
<!-- Form variables -->
<!-- username, email address, institute, country -->
var username;
var email;
var institute;
var country;

<!-- snpm version -->
var SWver;
var SWver1 = "SnPM99";
var SWver2 = "SnPM2";
var SWver3 = "SnPM3";
var SWver4 = "SnPM5b";

<!-- imaging modalities -->
var mod_spect;
var mod_pet;
var mod_fmri;
var mod_meeg;
var mod_other;
var mod_other_txt;

<!-- number of users -->
var num ;

<!-- user previous snpm version -->
var userSWver;
var userSWvername = "SnPM99";
var userSWvername2 = "SnPM2";
var userSWvername3 = "SnPM3";
var userSWvername4 = "SnPM5b";
var userSWver_string = "";

<!-- comments from user-->
var comments;

<!-- ========================================================================== -->
<!-- counter -->
var i=0;


<!-- function name: checkFields  -->
<!-- purpose: checking form information when a user click the submit button                            -->
<!-- result : 1. when a user does not input his/her name, institute name and country name,             -->
<!--             error message will show up and remind him/her to refill the form.                     -->
<!--          2. when a user input correct information, he/she will be allowed to download the zip file -->

function checkFields(f)
{
     username  = f.realname.value;
     email     = f.email.value;
     institute = f.institute.value;
     country   = f.country.value;
     
     <!-- get software version -->
     if (f.SWver[0].checked)
        SWver = SWver1;
     else if (f.SWver[1].checked)
	SWver = SWver2;
     else if (f.SWver[2].checked)
	SWver = SWver3;
     else
	SWver = SWver4;
     		

     <!-- get imaging modalities -->
     mod_spect     = f.MOD_SPECT.checked;
     mod_pet       = f.MOD_PET.checked;
     mod_fmri      = f.MOD_fMRI.checked;
     mod_meeg      = f.MOD_MEEG.checked;
     mod_other     = f.MOD_OTHER.checked;
     mod_other_txt = f.MOD_OTHER_TXT.value;
              
     <!-- get number of users -->
     for (i ; i < f.NumUser.length; i++)
     {
       if (f.NumUser[i].checked)
       {
         num =  f.NumUser[i].value;
         break;
       }
     }
     
     <!-- to check whether this user has previous software version  -->
     <!-- if he/she clicked the checkbox, userSWver = OFF    -->
     
     i=0;
     for (i ; i < f.USR_SWver.length; i++)
     {
       if (f.USR_SWver[i].checked)
       {
        userSWver = true;
          if (i==0)
             userSWver_string += userSWvername + " ";
          else if (i==1) 
             userSWver_string += userSWvername2 + " ";
          else if (i==2) 
             userSWver_string += userSWvername3 + " ";
          else if (i==3) 
             userSWver_string += userSWvername4;
       } 
     }

     <!-- get user's comments -->
     comments    = f.comments.value;
  
     <!-- begin to print out web page -->
     document.write(" <HTML><HEAD><TITLE>" + SW_title + "</TITLE></HEAD><BODY>\n");
     document.write("<IMG SRC='SnPM_Central.gif' ALIGN=left WIDTH=180 HEIGHT=160 BORDER=0 HSPACE=9 ALT='SnPMcentral'>\n");
     document.write("<H2 ALIGN=CENTER>" + SW_title + "</H2>\n");
     document.write("<HR SIZE='4' WIDTH='80%'>\n");
     document.write("<H1 ALIGN=CENTER> " +SW_name + "</H1>\n");
     document.write("<HR SIZE='4' WIDTH='80%'>\n");
     document.write("<H2 ALIGN=CENTER>Registration</H2>\n");
     document.write("<HR SIZE='4' WIDTH='80%'>\n");
     document.write("<H2 ALIGN=CENTER>A toolbox for SPM</H2>\n");
     document.write("<BR CLEAR=all>\n");
     document.write("<P ALIGN=CENTER><em>...to obtain the " + SW_title + " toolbox developed by\n");
     document.write(authors+ "</em></P> \n");
     document.write("<HR><H2><A NAME='RegForm'>Download registration form</A></H2><HR>\n");
    
         
     if (  (username != "") && (institute != "") && (country != ""))
      {
        <!-- this user inputs required informaiton -->
      	document.write("<H2>Thanks...</H2>\n");
        document.write("<P>...for registering to download the <STRONG>" + SW_title + "</STRONG> software.\n");
        
        <!-- download different version of software -->  
        document.write("<P>You should therefore download "+ SW_title+" using the following URL: \n");
        document.write("<UL>\n");
     
        if (SWver == SWver1) 
        {
          document.write("<LI><A href='" + url_download1 + "'>\n");
          document.write( url_download1 + "</A>(60Kb)</LI>\n");
          document.write("<LI>Username:   <CODE><STRONG>" + SWname1+"</STRONG></CODE></LI>");
          document.write("<LI>Password:   <CODE><STRONG>" + SW_key1 + "</STRONG></CODE></LI>\n");
        }
        else
        {
          if (SWver == SWver2)
	  {
          document.write("<LI><A href='" + url_download2 + "'>\n");
          document.write( url_download2 + "</A>(60Kb)</LI> \n");
          document.write("<LI>Username:   <CODE><STRONG>" + SWname2+"</STRONG></CODE></LI>");
          document.write("<LI>Password:   <CODE><STRONG>" + SW_key2 + "</STRONG></CODE></LI>\n");
          }
	  else 
          {
            if (SWver == SWver3)
            {
            document.write("<LI><A href='" + url_download3 + "'>\n");
            document.write( url_download3 + "</A>(60Kb)</LI>\n");
            document.write("<LI>Username:   <CODE><STRONG>" + SWname3+"</STRONG></CODE></LI>");
            document.write("<LI>Password:   <CODE><STRONG>" + SW_key3 + "</STRONG></CODE></LI>\n");
            }
	    else
            {
            document.write("<LI><A href='" + url_download4 + "'>\n");
            document.write( url_download4 + "</A>(76Kb)</LI>\n");
            document.write("<LI>Username:   <CODE><STRONG>" + SWname4+"</STRONG></CODE></LI>");
            document.write("<LI>Password:   <CODE><STRONG>" + SW_key4 + "</STRONG></CODE></LI>\n");
            }
          }
	}
        document.write("</UL>");
        document.write("<P>This keyword (&amp; URLs) will be valid for at least the next 14 days</P>");
      }
      else
      {
         <!-- this user does not input required informaiton -->

         document.write("<H2>Thanks...</H2>\n");
         document.write("<P>...for trying to register to download a version of " + SW_title+ ". \n");
         document.write("<P>Unfortunately you did specify all the required fields (highlit in <FONT \n");
         document.write("color=red>red</FONT> below) \n");
         document.write("<P>Please return to the <A href='" + url_SW + "'>\n");
         document.write(SW_title + " registration form</A> and fill \n");
         document.write("in at least your name, institution and location!\n");
         document.write("<P>If these problems persist, please contact the "+ SW_title + " manager &lt;<A \n");
         document.write("href='mailto:nichols.umich.edu'>" + SW_email+ "</A>&gt;</P>\n");                 
      }
      
      document.write("<H2>Your registration:</H2>\n");
      document.write("<CENTER>\n");
      document.write("<TABLE cellSpacing=4 width='80%' align=center border=0>\n");
              
      document.write("<TR><TH align=right>name: </TH> \n");
      document.write("<TD bgColor=lightgoldenrodyellow>");
      if (username== "") 
           document.write("<FONT color=red><STRONG><EM>unspecified</EM></STRONG></FONT>");
      else  
           document.write(username);
         
      document.write("</TD></TR>\n");
      document.write("<TR>\n");
      document.write("<TH align=right><I>e</I>mail: </TH>\n");
      document.write("<TD bgColor=lightgoldenrodyellow>");
         
      if (email == "")
           document.write("<EM>unspecified</EM>");
      else
           document.write(email);      
      document.write("</TD></TR>");
               
      document.write("<TR>\n");
      document.write("<TH align=right>institution: </TH>\n");
      document.write("<TD bgColor=lightgoldenrodyellow>\n");
        
      if (institute == "")
           document.write("<FONT color=red><STRONG><EM>unspecified</EM></STRONG></FONT>\n");
      else
           document.write(institute);
          
      document.write("</TD></TR>");
         
      document.write("<TR>\n");
      document.write("<TH align=right>country: </TH>\n");
      document.write("<TD bgColor=lightgoldenrodyellow>\n");
        
      if (country == "")
           document.write("<FONT color=red><STRONG><EM>unspecified</EM></STRONG></FONT>\n");
      else
           document.write(country);
          
      document.write("</TD></TR>\n");
      document.write("<TR>\n");
      document.write("<TH align=right>" + SW_title + " versions used: </TH>\n");
      document.write("<TD bgColor=lightgoldenrodyellow>\n");
       
      if (userSWver == true)
      {
          document.write(userSWver_string);
      }
      else
          document.write("none\n");
      document.write("</TD></TR>\n");
         
      document.write("<TR>\n");
      document.write("<TH align=right>Imaging modalities: </TH>");
      document.write("<TD bgColor=lightgoldenrodyellow>\n");
       
    
      if ( mod_spect == true) 
      { 
          document.write("SPECT ");
      }
   
      if (mod_pet == true)
      {
          document.write("PET ");
       }
   
      if (mod_fmri == true)
      {
          document.write("fMRI ");
      }
   
      if (mod_meeg == true)
      {
          document.write("M/EEG ");
      }
   
      if (mod_other == true)
      {
          document.write(mod_other_txt);
      }
         
      document.write("<TR>\n");
      document.write("<TD align=middle bgColor=lightgoldenrodyellow colSpan=2>You requested ");
      document.write("<STRONG>");
               
      document.write(SWver );
      document.write("</STRONG></STRONG> for use by <EM>");
      document.write(num);
      document.write("</EM>.</TD></TR>\n");
      document.write("<TR>\n");
      document.write("<TH align=right>Comments: </TH>\n");
      document.write("<TD bgColor=lightgoldenrodyellow>");
      if (comments == "") 
      	document.write("N/A");
      else
        document.write(comments);
      document.write("</TD></TR>");
      document.write("</TABLE>\n");
      document.write("<HR>\n");
      document.write("</CENTER>\n");
        
      document.write("<ADDRESS>" + SW_title + " authors</ADDRESS>\n");
      document.write("<!--=================================================================-->");
      document.write("<ADDRESS><I>"+ SW_title + " web</I> by <A href='mailto:nichols@umich.edu'>"+ SW_title+ " manager</A></ADDRESS>");
      
      if (  (username!= "") && (institute != "") && (country != ""))
      {
        
        /*This is for HTmail!*/
        
        var value = "                 Name:   " + username + "\n";
        value    += "                Email:   " + email + "\n";
        value    += "            Institute:   " + institute + "\n";
        value    += "              Country:   " + country + "\n";
        value    += SW_title +" version required:   " + SWver + "\n";
        value    += "   Imaging modalities:   "
        
        if (mod_spect == true)
         {
            value += "SPECT ";
         }   
            
        
        if (mod_pet == true)
         {
            value += "PET ";
         }
         
         
        if (mod_fmri == true)
         { 
            value += "fMRI ";
         }
          
        if (mod_meeg == true)
         { 
            value += "M/EEG ";
         }
          
        if ((mod_other == true) && (mod_other_txt != ""))
           {
                 value += " and " + mod_other_txt + " ";
           }
            
        value += "\n"
        
        value    += "      Number of users:   " + num +"\n";
        
              
        if (userSWver == true)
           value += "   "+ SW_title + " versions used:   " + userSWver_string + "\n";
        else
           value += "   "+ SW_title +" versions used:   None\n";

        if (comments == "") comments = "N/A";
        value += "\nComments:\n" + comments + "\n";
		
		document.write("<form method=POST target='_blank' ");
        
        document.write("name=formail action='" + url_action + "'");
               
        document.write("<input name='name' type=hidden value='"+ username+ "'>");
                
        document.write("<input name='from' type=hidden value='" + SW_email + "'>");
        
        document.write("<input name='subject' type=hidden value='" + emailsubject + "'>");
        document.write("<input type='hidden' name='body' value='" + value + "'>");
          
        document.write("</form>");
        document.formail.submit();
      }     
}   
 

function turnon()
{
  if ( document.frm.MOD_OTHER.checked)
     document.frm.MOD_OTHER_TXT.disabled = false;
  else
     document.frm.MOD_OTHER_TXT.disabled = true;
}

















