/*  ********  Venter Surname DNA Project JavaScript sheet ******** */


   addLoadEvent(bubble)


/*  *****************   This is the bubble function   *****************  */

// This function is run "on load". 
// It sets up the mouse events which create and then clear the def bubbles.
// It also supresses the 'click' function.

   function bubble()
     {
        var anchor_list = document.getElementsByTagName("a");

                                       // Find all of the anchor elements.
        for ( var i=0; i < anchor_list.length-1; i+=1)
               {
                                       // Find only those anchors of class = "def".
              if (anchor_list[i].className == "def")
                     {
                                       // Define the necessary events.
                         var this_node = anchor_list[i];
                         this_node.onmouseover = function()
                                  {
                                      gloss_word = this.firstChild.nodeValue
                                      make_bubble(this,gloss_word);
                                  }
                         this_node.onmouseout = function()
                                  {
                                      cleardef(this);
                                  }
                         this_node.onclick = function()
                                  {
                                      return false;
                                  }
                     }
               }
     }

/*  ********************************************************************  */
                    
/*  ***   This is the Glossary Array for the definitions of terms.   ***  */

 var glossary= new Array();
     glossary["allele"]= "One of several possible values that may exist for a genetic marker. Here it means the specific number of repeats at a given STR location on the Y-chromosome.";
     glossary["base"]= "One of four molecules that, in combination with a phosphate, are the building blocks of DNA.  They are adenine (A), cytosine (C), guanine (G), and thymine (T) and, when paired with their complements (A with T and C with G), form the ladder rungs of the DNA molecule. Each segment of genetic code is represented by a specific arrangement of a group of these molecules.";
     glossary["chromosome"]= "An arrangement of DNA that contains the coded information cells need to function. The human cell contains 46 chromosomes, 22 pairs of which half of each pair is received from each parent, plus two sex chromosomes which are either two X-chromosomes in females, or an X- and a Y-chromosome in males.";
     glossary["DNA"]= "DeoxyriboNucleic Acid - The double stranded molecule that encodes genetic information. It is made-up of phosphate, deoxyribose and four bases; adenine(A), cytosine (C), guanine (G), and thymine (T).";
     glossary["haplogroup"]= "A cluster of people who share the same mutation and whose ancestry will converge to single individual known as the founder. In the analysis of Y-chromosomes, haplogroups are generally defined by SNPs. Haplogroups are also know as clades.";
     glossary["haplotype"]= "An individual's complete set of test results for the markers which were tested. In Y-chromosome analysis, a haplotype is expressed as a series of numbers, where each number represents the allele value for a  specific STR, which may then be compared to other haplotypes to determine relatedness.  In cases where individuals are shown to be related, it can be used to statistically estimate the number of generations between them and their Most Recent Common Ancestor (MRCA).";
     glossary["marker"]= "A specific location on the Y-chromosome with known characteristics, where genetic variation is present (e.g., the location of a SNP or STR). These markers can then be used for comparison purposes.";
     glossary["mitochondria"]= " An ancient parasitic bacteria, present in all human cells, that produces energy for the cell. It has its own DNA which is passed, via the human egg, from mother to child without recombining. Because recombination does not take place, mitochondria DNA is very stable, a characteristic which makes it ideal for tracing genetic histories.";
     glossary["modal"]= "The most common, and therefore usually the oldest, haplotype which represents a set of marker values that defines a specific genetic line, along with its later descendant variations. Because of our limited number of samples, we are using the term to represent the probable haplotype of the Most Recent Common Ancestor (MRCA). Consequently, none of our test results may actually match the indicated modal.";
     glossary["MRCA"]= "Most Recent Common Ancestor - The most recent ancestor common to two individuals, such as a shared grandparent or great-grandparent, from which the two individual's separate lines diverged.";
     glossary["nucleotide"]= "a combination of one of the four DNA bases (i.e., adenine, cytosine, guanine, and thymine) plus a phosphate. Nucleotides are the building blocks of the DNA molecule.";
     glossary["Single Nucleotide Polymorphism"]= "(SNP) A type of polymorphism that takes place at a single nucleotide at a specific location on the Y-chromosome. This mutation is the result of a replacement, deletion, or insertion of a single nucleotide. It occurs so infrequently that it is used to define haplogroups.";
     glossary["Short Tandem Repeat"]= "(STR) - a type of polymorphism where a short pattern of nucleotides, usually 1 to 6 in length, in the non-coding region of the Y-chromosome, is repeated a number of times in tandem. The number of repeats is the allele value for that STR.";
     glossary["Y-chromosome"]= "One of the two so-called sex chromosomes, which determines the gender of a human fetus. Females have two X-chromosomes, while males have an X and a Y. Only males have a Y-chromosome and if an egg is fertilized which a sperm containing a Y-chromosome, it too will be male. If not, it will be female. Since the Y-chromosome is thus passed from father to son, it is ideal for tracing male genetic histories.";

/*  ********************************************************************  */
                    
/*  ******   This is the make_bubble function   ******  */

 function make_bubble(the_elem,theword)
    {

// This function creates a 'bubble' containing the definition of a selected word.
// The bubble is place at the 'xleft' and 'ytop' position relative to the selected word.
 
      var xleft = the_elem.offsetLeft;
      var ytop = 0;
      var xleftprime = xleft;
      var this_event = the_elem;
      var width = this_event.offsetWidth     // determines the width of the element in pixels,
                                             // so def box can be positioned relative to it, 
                                             // and to assure that it will not extend off the 
                                             // page on the right side.
   
      if (pageWidth()-xleft < 400)
                    { xleft= -330;
                    }
          else
                    { xleft= 0;  //width + 5;
                    }


// Clear the previous text for this event.

                                // Determines if a node has previously 
                                // been inserted, and, if so, removes it 
                                // from the parent node.

          if (document.getElementById("insert"))
                    {
                      var clear_this = document.getElementById("insert");
                      clear_this.parentNode.removeChild(clear_this);
                      
                    }

// Build definition with a bold key word.

        var new_text1 = document.createElement("p");
        var new_text2 = document.createElement("p");
        var new_text = document.createElement("p");

        var bold_part = document.createTextNode(theword);
        bold_part.nodeValue = bold_part.nodeValue+": ";
        new_text1.appendChild(bold_part);
        new_text1.style.fontWeight = "bold";
        new_text1.style.fontSize = "14pt";
        new_text1.style.marginTop = "10px";

        var def_part = document.createTextNode(glossary[theword]);
        new_text2.appendChild(def_part);
        new_text2.style.marginTop = "-10px";

        new_text.appendChild(new_text1);
        new_text.appendChild(new_text2);
        new_text.setAttribute("id","insert");
        this_event.appendChild(new_text);

                                 // Determine the height of the definition box and adds 20.

        var bubble_height = new_text.offsetHeight+20;

        ytop = -bubble_height;

        new_text.style.left=xleft+"px";
        new_text.style.top= ytop+"px";

    }

/*  ***********************************************************  */
                    
/*  ************   This is the cleardef function   ************  */

 function cleardef(the_elem)
        {
          document.getElementById("insert").style.display="none";			
        }


/*  ***********************************************************  */

