//File Name: formhandler.js
//This generated by vm_builder.pl
//var vm_vers_species = {'5.0_HS':['rat','human','mouse'],'4.4.3_HS':['rat','human','mouse'],'4.4.2_HS':['rat','human','mouse'],'4.4.1_HS':['rat','human','mouse']};
var gcm_vers_species = {'1.0_SEQBASD':['rat','human','mouse']};
var gcm_chrs = {human:['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','X'],mouse:['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','X'],rat:['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','X'],pig:['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','X']};
var vm_vers_species = { '1.0_SEQBASD':['rat','human','mouse'], '9.2_HS':['rat','human','mouse'],'8.6_HS':['rat','human','mouse'],'5.0_HS':['rat','human','mouse']};
var vm_chrs = {human:['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','X'],mouse:['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','X'],rat:['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','X'],pig:['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','X'],dog:['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','X']};
var rh_species_vers = {'rat':['V3.4','V2.1','Oxford'],
                       'human':['GeneMap99'],
		       'mouse':['mit/R9']
                      };
var genome_species_vers =  {'rat':['V2.1/Gene_STS','V3.1/Gene_STS'],
                            'human':['May04/Gene_STS'],'mouse':['May04/Gene_STS']};

var g_species_vers = {'rat':['mit00/FHH_X_ACI','mit00/SHRSP_X_BN'],
                      'human':['genethon/nature95', 'marshfield/sex-ave', 'marshfield/female', 'marshfield/male'],'mouse':['mit/may99']
	             };

var cyto_species_vers  =  {'rat':['V1.0'], 'human':['V1.0']};

var qtl_strains = {'rat':['V1.2/RGD_Genome_Gene','V1.2/RGD_Genome_sslp','V1.1/RGD_RH'],'human':['May04/RGD_Genome'],'mouse':['May04/MGI_Genome']};
var add_strains = {'rat':['V1.0/Rat_Bacs']};
var chrs = {human:['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','X'],
	    rat:['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','X'],
	    mouse:['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','X'],
	    dog:['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','X', 'Y']
            };
function init(stat) {
   // init genome comparative map
  /* if(stat ==1) {	
	for(i = 0; i < document.vcmap_form.elements.length; i++) {
           document.vcmap_form.elements[i].checked = false;
        }	
   }
   i = 0;
   idx = document.vcmap_form.gcmver.selectedIndex;
   if(stat ==1) idx = 0;
   document.vcmap_form.gcmver.options.length = 0;   
   for(ver in gcm_vers_species) {
      document.vcmap_form.gcmver.options[i++] = new Option(ver,ver, 0,0);
   }
   if(idx > i-1) idx = i-1;
   document.vcmap_form.gcmver.selectedIndex = idx;
   versionChanged0(document.vcmap_form.gcmver.options[idx].text);*/
   
   //init vm
   i = 0;
   idx = document.vcmap_form.vmver.selectedIndex;
   if(stat ==1) idx = 0;
   document.vcmap_form.vmver.options.length = 0;
   
   for(ver in vm_vers_species) {
      document.vcmap_form.vmver.options[i++] = new Option(ver,ver, 0,0);
   }
   if(idx > i-1) idx = i-1;
   document.vcmap_form.vmver.selectedIndex = idx;
   versionChanged(document.vcmap_form.vmver.options[idx].text);

   //init rh map
   i = 0;
   idx1 = document.vcmap_form.rhsp1.selectedIndex;
   idx2 = document.vcmap_form.rhsp2.selectedIndex;
   if(stat ==1) idx1 = 0;
   if(stat ==1) idx2 = 0;
   document.vcmap_form.rhsp1.options.length = 0;
   document.vcmap_form.rhsp2.options.length = 0;
   //sp = 'species';
   //document.vcmap_form.rhsp1.options[i] = new Option(sp,sp.toLowerCase(), 0,0);
   //document.vcmap_form.rhsp2.options[i] = new Option(sp,sp.toLowerCase(), 0,0);
   //i++;
   for(sp in rh_species_vers) {
      document.vcmap_form.rhsp1.options[i] = new Option(sp,sp.toLowerCase(), 0,0);
      document.vcmap_form.rhsp2.options[i] = new Option(sp,sp.toLowerCase(), 0,0);
      i++;
   }
   if(idx1 > i-1) idx1 = i-1;
   if(idx2 > i-1) idx2 = i-1;
   document.vcmap_form.rhsp1.selectedIndex = idx1;
   document.vcmap_form.rhsp2.selectedIndex = idx2;
   speciesChanged(document.vcmap_form.rhsp1.options[idx1].text, 2, 1);
   speciesChanged(document.vcmap_form.rhsp2.options[idx2].text, 2, 2);

   //init genome map
   i = 0;
   idx1 = document.vcmap_form.genomesp1.selectedIndex;
   idx2 = document.vcmap_form.genomesp2.selectedIndex;
   if(stat ==1) idx1 = 0;
   if(stat ==1) idx2 = 0;
   document.vcmap_form.genomesp1.options.length = 0;
   document.vcmap_form.genomesp2.options.length = 0;
   for(sp in genome_species_vers) {
      document.vcmap_form.genomesp1.options[i] = new Option(sp,sp.toLowerCase(), 0,0);
      document.vcmap_form.genomesp2.options[i] = new Option(sp,sp.toLowerCase(), 0,0);
      i++;
   }
   if(idx1 > i-1) idx1 = i-1;
   if(idx2 > i-1) idx2 = i-1;
   document.vcmap_form.genomesp1.selectedIndex = idx1;
   document.vcmap_form.genomesp2.selectedIndex = idx2;
   speciesChanged(document.vcmap_form.genomesp1.options[idx1].text, 5, 1);
   speciesChanged(document.vcmap_form.genomesp2.options[idx2].text, 5, 2); 
   
   //init cyto map
   i = 0;
   idx1 = document.vcmap_form.cytosp1.selectedIndex;
   idx2 = document.vcmap_form.cytosp2.selectedIndex;
   if(stat ==1) idx1 = 0;
   if(stat ==1) idx2 = 0;
   document.vcmap_form.cytosp1.options.length = 0;
   document.vcmap_form.cytosp2.options.length = 0;
   for(sp in cyto_species_vers) {
      document.vcmap_form.cytosp1.options[i] = new Option(sp,sp.toLowerCase(), 0,0);
      document.vcmap_form.cytosp2.options[i] = new Option(sp,sp.toLowerCase(), 0,0);
      i++;
   }
   if(idx1 > i-1) idx1 = i-1;
   if(idx2 > i-1) idx2 = i-1;
   document.vcmap_form.cytosp1.selectedIndex = idx1;
   document.vcmap_form.cytosp2.selectedIndex = idx2;
   speciesChanged(document.vcmap_form.cytosp1.options[idx1].text, 6, 1);
   speciesChanged(document.vcmap_form.cytosp2.options[idx2].text, 6, 2); 

   //init genetic map
   i = 0;
   idx1 = document.vcmap_form.gsp1.selectedIndex;
   idx2 = document.vcmap_form.gsp2.selectedIndex;
   if(stat ==1) idx1 = 0;
   if(stat ==1) idx2 = 0;
   document.vcmap_form.gsp1.options.length = 0;
   document.vcmap_form.gsp2.options.length = 0;
   for(sp in g_species_vers) {
      document.vcmap_form.gsp1.options[i] = new Option(sp,sp.toLowerCase(), 0,0);
      document.vcmap_form.gsp2.options[i] = new Option(sp,sp.toLowerCase(), 0,0);
      i++;
   }
   if(idx1 > i-1) idx1 = i-1;
   if(idx2 > i-1) idx2 = i-1;
   document.vcmap_form.gsp1.selectedIndex = idx1;
   document.vcmap_form.gsp2.selectedIndex = idx2;
   speciesChanged(document.vcmap_form.gsp1.options[idx1].text, 3, 1);
   speciesChanged(document.vcmap_form.gsp2.options[idx2].text, 3, 2);

   //init additional map
   i = 0;
   idx1 = document.vcmap_form.addsp1.selectedIndex;
   idx2 = document.vcmap_form.addsp2.selectedIndex;
   if(stat ==1) idx1 = 0;
   if(stat ==1) idx2 = 0;
   document.vcmap_form.addsp1.options.length = 0;
   document.vcmap_form.addsp2.options.length = 0;
    for(sp in add_strains) {
      document.vcmap_form.addsp1.options[i] = new Option(sp,sp.toLowerCase(), 0,0);
      document.vcmap_form.addsp2.options[i] = new Option(sp,sp.toLowerCase(), 0,0);
      i++;
   }
   if(idx1 > i-1) idx1 = i-1;
   if(idx2 > i-1) idx2 = i-1;
   document.vcmap_form.addsp1.selectedIndex = idx1;
   document.vcmap_form.addsp2.selectedIndex = idx2;
   speciesChanged(document.vcmap_form.addsp1.options[idx1].text,7, 1);
   speciesChanged(document.vcmap_form.addsp2.options[idx2].text, 7, 2);

  //init qtl map
   i = 0;
   idx1 = document.vcmap_form.qtlsp1.selectedIndex;
   idx2 = document.vcmap_form.qtlsp2.selectedIndex;
   if(stat ==1) idx1 = 0;
   if(stat ==1) idx2 = 0;
   document.vcmap_form.qtlsp1.options.length = 0;
   document.vcmap_form.qtlsp2.options.length = 0;
    for(sp in qtl_strains) {
      document.vcmap_form.qtlsp1.options[i] = new Option(sp,sp.toLowerCase(), 0,0);
      document.vcmap_form.qtlsp2.options[i] = new Option(sp,sp.toLowerCase(), 0,0);
      i++;
   }
   if(idx1 > i-1) idx1 = i-1;
   if(idx2 > i-1) idx2 = i-1;
   document.vcmap_form.qtlsp1.selectedIndex = idx1;
   document.vcmap_form.qtlsp2.selectedIndex = idx2;
   speciesChanged(document.vcmap_form.qtlsp1.options[idx1].text, 4, 1);
   speciesChanged(document.vcmap_form.qtlsp2.options[idx2].text, 4, 2);


}

function speciesChanged(sp, map, target) {
   if(map == 8) { // gc
      idx = document.vcmap_form.gcmbbchr.selectedIndex;
      document.vcmap_form.gcmbbchr.options.length = 0;
      for(i = 0; i < gcm_chrs[sp].length; i++) {
        document.vcmap_form.gcmbbchr.options[i] = new Option(gcm_chrs[sp][i],gcm_chrs[sp][i], 0,0);
      }
      if(idx > i-1) idx = i-1;
      document.vcmap_form.gcmbbchr.selectedIndex = idx;     
      document.vcmap_form.gcmnbbsp.options.length = 0;
      var j = 0;
      var selectedVer = document.vcmap_form.gcmver.options[document.vcmap_form.gcmver.selectedIndex].text;
      for(i = 0; i < gcm_vers_species[selectedVer].length; i++) {
        if(sp != gcm_vers_species[selectedVer][i]) {
          document.vcmap_form.gcmnbbsp.options[j] = new Option(gcm_vers_species[selectedVer][i],
	                                                    gcm_vers_species[selectedVer][i].toLowerCase(), 0,0);
          j++;
        }
      }
   }
   if(map == 1) { // vm
      idx = document.vcmap_form.vmbbchr.selectedIndex;
      document.vcmap_form.vmbbchr.options.length = 0;
      for(i = 0; i < vm_chrs[sp].length; i++) {
        document.vcmap_form.vmbbchr.options[i] = new Option(vm_chrs[sp][i],vm_chrs[sp][i], 0,0);
      }
      if(idx > i-1) idx = i-1;
      document.vcmap_form.vmbbchr.selectedIndex = idx;     
      document.vcmap_form.vmnbbsp.options.length = 0;
      var j = 0;
      var selectedVer = document.vcmap_form.vmver.options[document.vcmap_form.vmver.selectedIndex].text;
      for(i = 0; i < vm_vers_species[selectedVer].length; i++) {
        if(sp != vm_vers_species[selectedVer][i]) {
          document.vcmap_form.vmnbbsp.options[j] = new Option(vm_vers_species[selectedVer][i],
	                                                    vm_vers_species[selectedVer][i].toLowerCase(), 0,0);
          j++;
        }
      }
   }
   if(map == 2) { //rh map
      if(target == 1) {
      	//rh ver
      	document.vcmap_form.rhver1.options.length = 0;
        if(rh_species_vers[sp] != null) {
      	    for(i = 0; i < rh_species_vers[sp].length; i++) {
        	document.vcmap_form.rhver1.options[i] = new Option(rh_species_vers[sp][i],
                                                         rh_species_vers[sp][i], 0,0);
		//document.vcmap_form.rhver1.options[2*i+1] = new Option(rh_species_vers[sp][i]+"/Reverse",
                //                                         rh_species_vers[sp][i]+"/Reverse", 0,0);
      	    }
        }
	else {
            ver = '             ';
	    document.vcmap_form.rhver1.options[0] = new Option(ver, ver, 0,0);
        }
      	document.vcmap_form.rhver1.selectedIndex = 0;
        //chr
        idx = document.vcmap_form.rhchr1.selectedIndex;
      	document.vcmap_form.rhchr1.options.length = 0;
      	for(i = 0; i < chrs[sp].length; i++) {
        	document.vcmap_form.rhchr1.options[i] = new Option(chrs[sp][i],chrs[sp][i], 0,0);
      	}
        if(idx > i-1) idx = i-1;
      	document.vcmap_form.rhchr1.selectedIndex = idx;

      }	
      if(target == 2) {
        idx = document.vcmap_form.rhchr2.selectedIndex;
      	document.vcmap_form.rhchr2.options.length = 0;
      	for(i = 0; i < chrs[sp].length; i++) {
        	document.vcmap_form.rhchr2.options[i] = new Option(chrs[sp][i],chrs[sp][i], 0,0);
      	}
        if(idx > i-1) idx = i-1;
      	document.vcmap_form.rhchr2.selectedIndex = idx;
      	//rh ver
      	document.vcmap_form.rhver2.options.length = 0;
      	for(i = 0; i < rh_species_vers[sp].length; i++) {
        	document.vcmap_form.rhver2.options[i] = new Option(rh_species_vers[sp][i],
                                                         rh_species_vers[sp][i], 0,0);
		//document.vcmap_form.rhver2.options[2*i+1] = new Option(rh_species_vers[sp][i]+"/Reverse",
                //                                         rh_species_vers[sp][i]+"/Reverse", 0,0);
      	}
      	document.vcmap_form.rhver2.selectedIndex = 0;
      }	
   }
  if(map == 6) { //cyto map
      if(target == 1) {
      	//cyto ver
      	document.vcmap_form.cytover1.options.length = 0;
      	//idx = document.vcmap_form.cytochr1.selectedIndex;
      	//document.vcmap_form.cytochr1.options.length = 0;
        if(cyto_species_vers[sp] != null) {
      	    for(i = 0; i < cyto_species_vers[sp].length; i++) {
        	document.vcmap_form.cytover1.options[i] = new Option(cyto_species_vers[sp][i],
                                                         cyto_species_vers[sp][i], 0,0);
		//document.vcmap_form.cytover1.options[2*i+1] = new Option(cyto_species_vers[sp][i]+"/Reverse",
                //                                         cyto_species_vers[sp][i]+"/Reverse", 0,0);
      	    }
        }
	else {
            ver = '             ';
	    document.vcmap_form.cytover1.options[0] = new Option(ver, ver, 0,0);
        }
      	document.vcmap_form.cytover1.selectedIndex = 0;
        //chr
        idx = document.vcmap_form.cytochr1.selectedIndex;
      	document.vcmap_form.cytochr1.options.length = 0;
      	for(i = 0; i < chrs[sp].length; i++) {
        	document.vcmap_form.cytochr1.options[i] = new Option(chrs[sp][i],chrs[sp][i], 0,0);
      	}
        if(idx > i-1) idx = i-1;
      	document.vcmap_form.cytochr1.selectedIndex = idx;

      }	
      if(target == 2) {
        idx = document.vcmap_form.cytochr2.selectedIndex;
      	document.vcmap_form.cytochr2.options.length = 0;
      	for(i = 0; i < chrs[sp].length; i++) {
        	document.vcmap_form.cytochr2.options[i] = new Option(chrs[sp][i],chrs[sp][i], 0,0);
      	}
        if(idx > i-1) idx = i-1;
      	document.vcmap_form.cytochr2.selectedIndex = idx;
      	//rh ver
      	document.vcmap_form.cytover2.options.length = 0;
      	for(i = 0; i < cyto_species_vers[sp].length; i++) {
        	document.vcmap_form.cytover2.options[i] = new Option(cyto_species_vers[sp][i],
                                                         cyto_species_vers[sp][i], 0,0);
		//document.vcmap_form.cytover2.options[2*i+1] = new Option(cyto_species_vers[sp][i]+"/Reverse",
                //                                         cyto_species_vers[sp][i]+"/Reverse", 0,0);
      	}
      	document.vcmap_form.cytover2.selectedIndex = 0;
      }	
   }

   if(map == 5) { //genome map
      if(target == 1) {
      	//genome ver
      	document.vcmap_form.genomever1.options.length = 0;
      	//idx = document.vcmap_form.genomechr1.selectedIndex;
      	//document.vcmap_form.genomechr1.options.length = 0;
        if(genome_species_vers[sp] != null) {
      	    for(i = 0; i < genome_species_vers[sp].length; i++) {
        	document.vcmap_form.genomever1.options[i] = new Option(genome_species_vers[sp][i],
                                                         genome_species_vers[sp][i], 0,0);
		//document.vcmap_form.genomever1.options[2*i+1] = new Option(genome_species_vers[sp][i]+"/Reverse",
                //                                         genome_species_vers[sp][i]+"/Reverse", 0,0);
      	    }
        }
	else {
            ver = '             ';
	    document.vcmap_form.genomever1.options[0] = new Option(ver, ver, 0,0);
        }
      	document.vcmap_form.genomever1.selectedIndex = 0;
        //chr
        idx = document.vcmap_form.genomechr1.selectedIndex;
      	document.vcmap_form.genomechr1.options.length = 0;
      	for(i = 0; i < chrs[sp].length; i++) {
        	document.vcmap_form.genomechr1.options[i] = new Option(chrs[sp][i],chrs[sp][i], 0,0);
      	}
        if(idx > i-1) idx = i-1;
      	document.vcmap_form.genomechr1.selectedIndex = idx;

      }	
      if(target == 2) {
        idx = document.vcmap_form.genomechr2.selectedIndex;
      	document.vcmap_form.genomechr2.options.length = 0;
      	for(i = 0; i < chrs[sp].length; i++) {
        	document.vcmap_form.genomechr2.options[i] = new Option(chrs[sp][i],chrs[sp][i], 0,0);
      	}
        if(idx > i-1) idx = i-1;
      	document.vcmap_form.genomechr2.selectedIndex = idx;
      	//rh ver
      	document.vcmap_form.genomever2.options.length = 0;
      	for(i = 0; i < genome_species_vers[sp].length; i++) {
        	document.vcmap_form.genomever2.options[i] = new Option(genome_species_vers[sp][i],
                                                         genome_species_vers[sp][i], 0,0);
		//document.vcmap_form.genomever2.options[2*i+1] = new Option(genome_species_vers[sp][i]+"/Reverse",
                //                                         genome_species_vers[sp][i]+"/Reverse", 0,0);
      	}
      	document.vcmap_form.genomever2.selectedIndex = 0;
      }	
   }
   if(map == 3) { //genetic map
      //chr
      if(target == 1) {
        idx = document.vcmap_form.gchr1.selectedIndex;
      	document.vcmap_form.gchr1.options.length = 0;
      	for(i = 0; i < chrs[sp].length; i++) {
        	document.vcmap_form.gchr1.options[i] = new Option(chrs[sp][i],chrs[sp][i], 0,0);
      	}
	if(idx > i-1) idx = i-1;
      	document.vcmap_form.gchr1.selectedIndex = idx;
      	//g ver
      	document.vcmap_form.gver1.options.length = 0;
      	for(i = 0; i < g_species_vers[sp].length; i++) {
        	document.vcmap_form.gver1.options[i] = new Option(g_species_vers[sp][i],
                                                         g_species_vers[sp][i], 0,0);
		//document.vcmap_form.gver1.options[2*i+1] = new Option(g_species_vers[sp][i]+"/Reverse",
                //                                         g_species_vers[sp][i]+"/Reverse", 0,0);
      	}
      	document.vcmap_form.gver1.selectedIndex = 0;
      }	
      if(target == 2) {
	idx = document.vcmap_form.gchr2.selectedIndex;
      	document.vcmap_form.gchr2.options.length = 0;
      	for(i = 0; i < chrs[sp].length; i++) {
        	document.vcmap_form.gchr2.options[i] = new Option(chrs[sp][i],chrs[sp][i], 0,0);
      	}
        if(idx > i-1) idx = i-1;
      	document.vcmap_form.gchr2.selectedIndex = idx;
      	//g ver
      	document.vcmap_form.gver2.options.length = 0;
      	for(i = 0; i < g_species_vers[sp].length; i++) {
        	document.vcmap_form.gver2.options[i] = new Option(g_species_vers[sp][i],
                                                         g_species_vers[sp][i], 0,0);
		//document.vcmap_form.gver2.options[2*i+1] = new Option(g_species_vers[sp][i]+"/Reverse",
                //                                         g_species_vers[sp][i]+"/Reverse", 0,0);
      	}
      	document.vcmap_form.gver2.selectedIndex = 0;
      }	
   }

  if(map == 4) { //qtl map
      if(target == 1) {
        //chr
        idx = document.vcmap_form.qtlchr1.selectedIndex;
      	document.vcmap_form.qtlchr1.options.length = 0;
      	for(i = 0; i < chrs[sp].length; i++) {
        	document.vcmap_form.qtlchr1.options[i] = new Option(chrs[sp][i],chrs[sp][i], 0,0);
      	}
        if(idx > i-1) idx = i-1;
      	document.vcmap_form.qtlchr1.selectedIndex = idx;
      	//qtl strain
      	document.vcmap_form.qtlstrain1.options.length = 0;
      	for(i = 0; i < qtl_strains[sp].length; i++) {
        	document.vcmap_form.qtlstrain1.options[i] = new Option(qtl_strains[sp][i],
                                                         qtl_strains[sp][i], 0,0);
		//document.vcmap_form.qtlstrain1.options[2*i+1] = new Option(qtl_strains[sp][i]+"/Reverse",
                //                                         qtl_strains[sp][i]+"/Reverse", 0,0);
      	}
      	document.vcmap_form.qtlstrain1.selectedIndex = 0;
      }	
      if(target == 2) {
	idx = document.vcmap_form.qtlchr2.selectedIndex;
      	document.vcmap_form.qtlchr2.options.length = 0;
      	for(i = 0; i < chrs[sp].length; i++) {
        	document.vcmap_form.qtlchr2.options[i] = new Option(chrs[sp][i],chrs[sp][i], 0,0);
      	}
	if(idx > i-1) idx = i-1;
      	document.vcmap_form.qtlchr2.selectedIndex = idx;
      	//qtl ver
      	document.vcmap_form.qtlstrain2.options.length = 0;
      	for(i = 0; i < qtl_strains[sp].length; i++) {
        	document.vcmap_form.qtlstrain2.options[i] = new Option(qtl_strains[sp][i],
                                                         qtl_strains[sp][i], 0,0);
		//document.vcmap_form.qtlstrain2.options[2*i+1] = new Option(qtl_strains[sp][i]+"/Reverse",
                //                                         qtl_strains[sp][i]+"/Reverse", 0,0);
      	}
      	document.vcmap_form.qtlstrain2.selectedIndex = 0;
      }	
   }
   
    if(map == 7) { //additional map
      if(target == 1) {
        //chr
        idx = document.vcmap_form.addchr1.selectedIndex;
      	document.vcmap_form.addchr1.options.length = 0;
      	for(i = 0; i < chrs[sp].length; i++) {
        	document.vcmap_form.addchr1.options[i] = new Option(chrs[sp][i],chrs[sp][i], 0,0);
      	}
        if(idx > i-1) idx = i-1;
      	document.vcmap_form.addchr1.selectedIndex = idx;
      	//qtl strain
      	document.vcmap_form.addstrain1.options.length = 0;
      	for(i = 0; i < add_strains[sp].length; i++) {
        	document.vcmap_form.addstrain1.options[i] = new Option(add_strains[sp][i],
                                                         add_strains[sp][i], 0,0);
		//document.vcmap_form.addstrain1.options[2*i+1] = new Option(add_strains[sp][i]+"/Reverse",
                //                                         add_strains[sp][i]+"/Reverse", 0,0);
      	}
      	document.vcmap_form.addstrain1.selectedIndex = 0;
      }	
      if(target == 2) {
	idx = document.vcmap_form.addchr2.selectedIndex;
      	document.vcmap_form.addchr2.options.length = 0;
      	for(i = 0; i < chrs[sp].length; i++) {
        	document.vcmap_form.addchr2.options[i] = new Option(chrs[sp][i],chrs[sp][i], 0,0);
      	}
	if(idx > i-1) idx = i-1;
      	document.vcmap_form.addchr2.selectedIndex = idx;
      	//qtl ver
      	document.vcmap_form.addstrain2.options.length = 0;
      	for(i = 0; i < add_strains[sp].length; i++) {
        	document.vcmap_form.addstrain2.options[i] = new Option(add_strains[sp][i],
                                                         add_strains[sp][i], 0,0);
		//document.vcmap_form.qtlstrain2.options[2*i+1] = new Option(qtl_strains[sp][i]+"/Reverse",
                //                                         qtl_strains[sp][i]+"/Reverse", 0,0);
      	}
      	document.vcmap_form.addstrain2.selectedIndex = 0;
      }	
   }
}
function versionChanged0(ver) {
      idx = document.vcmap_form.gcmbbsp.selectedIndex;
      document.vcmap_form.gcmbbsp.options.length = 0;
      for(i= 0; i< gcm_vers_species[ver].length; i++) {
         document.vcmap_form.gcmbbsp.options[i] = new Option(gcm_vers_species[ver][i],gcm_vers_species[ver][i].toLowerCase(), 0,0);
      }
      if(idx > i-1) idx = i-1;
      document.vcmap_form.gcmbbsp.selectedIndex = idx;
      speciesChanged(gcm_vers_species[ver][idx], 8, 0);
}

function versionChanged(ver) {
      idx = document.vcmap_form.vmbbsp.selectedIndex;
      document.vcmap_form.vmbbsp.options.length = 0;
      for(i= 0; i< vm_vers_species[ver].length; i++) {
         document.vcmap_form.vmbbsp.options[i] = new Option(vm_vers_species[ver][i],vm_vers_species[ver][i].toLowerCase(), 0,0);
      }
      if(idx > i-1) idx = i-1;
      document.vcmap_form.vmbbsp.selectedIndex = idx;
      speciesChanged(vm_vers_species[ver][idx], 1, 0);
}

function bbspChanged(bbsp) {
   document.vcmap_form.bbchr.options.length = 0;
   for(i = 0; i < chrs[bbsp].length; i++) {
      document.vcmap_form.bbchr.options[i] = new Option(chrs[bbsp][i],chrs[bbsp][i], 0,0);
   }
   document.vcmap_form.bbchr.selectedIndex = 0;
   document.vcmap_form.nbbsp.options.length = 0;
   var j = 0;
   var selectedVer = document.vcmap_form.ver.options[document.vcmap_form.ver.selectedIndex].text;
   for(i = 0; i < vers_species[selectedVer].length; i++) {
      if(bbsp != vers_species[selectedVer][i]) {
         document.vcmap_form.nbbsp.options[j] = new Option(vers_species[selectedVer][i],vers_species[selectedVer][i].toLowerCase(), 0,0);
         j++;
      }
   }
}

function checkSpecies(stat, target) {
    if(stat) target.checked = true;
}

function checkMap(stat, target1, target2) {
    if(!stat) {
	target1.checked = false;
	target2.checked = false;
    }
    else {
	target1.checked = true;
    }
}

