/* This notice must be untouched at all times.

wc_FamilyChart6b.js    v. 6.02
The latest version is available at
http://freepages.genealogy.rootsweb.com/~nansemondcolemans/

Copyright (c) 2008, 2009 Wesley Coleman. All rights reserved.
Created 4. 20. 2008 by Wesley Coleman
Last modified: 3. 10. 2009
*/

var FontFamily = "arial";
var FontSize = "12px";
var FontStyle = Font.BOLD;
var ColorOL = "#000000";
//var ColorBG = "#E0D8C0"; 
var ColorBG = "#E0E0E0"; 
var ColorBGBox = "#B0D0FF";
var ColorText = "#141414"
var ColorBorder = "#DC143C"; // Crimson
var TextBoxHeight = 28;
var TextBoxWidth = 280;
var vertSpacing = 40;
var vertPictMargin = 24;
var iStubL = 6;
var iBotMarg = 15;
var iBoxMargin = 2;
var iBoxLoff = 6;
var iBoxToff = 6;
var iBoxRoff = 8;
var iBoxBoff = 8;
var ScaleHeight = 600;
var ScaleWidth  = 960;
var IC;
var IG;
var debugFindChild =0;
var debugFindGChild = 0;
var debugChartChild = 0;
var debugChartGChild = 0;
var debugLayoutChild = 0;
var debugLayoutGChild = 0;
var debugLayoutPatriarchLines = 0;
var debugMaxRows = 0;
var maxChildCount = 30;
var MaxPersonNdx;
var Person = new Array(2000);
var Parent = new Array(2000);
var SecParent = new Array(2000);
var File = new Array(2000);
// var birth = new Array(2000);
// var death = new Array(2000);
var Children = new Array(1000);
var GChildren = new Array(900);
// var GChildren [childndx,gchildndx]; /* double subscripted! */

var NC = new Array(30);
var NG = new Array(900);
// var NG is new array; /* is double subscripted! */
var Rowc = new Array(30);
var Rowg = new Array(900); /* is double subscripted! */
var ndx2, ndx3, ndx4;
var thisGChildRow =0;
var thisChildRow =0;
var PatriarchRow =2;
var mde = " onMouseDown=mouseEventHandler(event,";
var maxRectCount=100;
var displayError=1;
var CX, CY;
var PosX = new Array(6);
var PosY = new Array(6);
var Y1, Y2;
var gTextBoxNdx;
var i2 = 1;
var halfTextBoxHeight = parseInt(TextBoxHeight/2);
var iMaxRows;
var MyScaleHeight;

// for (icnt=1; icnt<25; icnt++)
// {
//   GChildren[icnt] = new Array(25);
//   NG[icnt] = new Array(25);
//   Rowg[icnt] = new Array(25);
// }

var RectVerts = new Array(maxRectCount);
for (icnt=1; icnt<=maxRectCount; icnt++)
{
   RectVerts[icnt] = new Array(2);
}

// var ColorBGC = "#FFD0D0";
var ColorBGC = ColorBorder; 
var xStr = "WC Computing - Genealogy Scripts<br/>" +
           "Copyright (c) 2008, 2009 Wesley Coleman.<br/>" +
           "All rights reserved.";


function mouseEventHandler(e,Patriarch)
{
}

function ChartTheFamily(Patriarch, thisCanvas)
{
  thisGChildRow =0;
  thisChildRow =0;
  PatriarchRow =2;
//  alert("Charting the Family");
//  NC[0] = 0;
//  NG[0][0] = 0;
//  NG[1][0] = 0;
  NC[1] = 0;
  for (IC = 2; IC<=MaxPersonNdx; IC++)
  {
    if (Parent[IC] == Patriarch) {
      NC[1] = NC[1] + 1;
      Children[NC[1]] = IC;
      if (debugFindChild) {
        alert("Found Child for Patriarch " + Person[Patriarch] + "; NC=" +
             NC[1] + "; Child's Name=" + Person[Children[NC[1]]]);
      }
    }
  }
//  alert("Number of children of patriarch is: " + NC[1]);
//  for (IC = 1; IC<=2; IC++)
  for (IC = 1; IC<=NC[1]; IC++)
  {
    if(IC == 1) {
      Rowc[IC] = IC;
    }
    else
    {
      Rowc[IC] = Rowc[IC-1]+1;
    }  
      if (debugLayoutChild) {
        alert ("Rowc[" + IC + "]=" + Rowc[IC]);
      }
    NG[IC] = 0;
    
    // Find the number of grandchildren born to child indexed by IC.
    for (IG = 2; IG<=MaxPersonNdx; IG++)
    {
      if (Parent[IG] == Children[IC]) {
        NG[IC] = NG[IC] + 1;
        ndx2 = (IC-1) * maxChildCount + NG[IC];
        GChildren[ndx2] = IG;
        if (debugFindGChild) {
          alert("Found GChild for Child " + Person[Children[IC]] + "; NC=" +
             NC[1] + "; GChild's Name=" + Person[GChildren[ndx2]]);
        }
      }
    }
    // Found the number of grandchildren born to each child indexed by IC.
    
    
    if (NG[IC] > 0) 
    {
      for (IG = 1; IG<=NG[IC]; IG++)
      {
          ndx2 = (IC-1) * maxChildCount + IG;
          thisGChildRow = thisGChildRow + 1;
          Rowg[ndx2] = thisGChildRow;
          if (debugChartGChild) {
            alert ("GChild Row for Child " + IC + " GChild "+IG+"=" + Rowg[ndx2]);
          }
      }
      ndx2=NG[IC];
      ndx3=(IC-1)*maxChildCount+1;
      ndx4=ndx3+ndx2-1;
      if (debugChartGChild) {
        alert("DBG CHRT GCHILD A IC:" +
             IC + ", NG[IC]=ndx2:" + ndx2 + ", (IC-1)*maxChildCount+1=ndx3:" + 
             ndx3 + ", (IC-1)*maxChildCount+1+NG[IC]=ndx4:" + ndx4);
      }
      Rowc[IC] = biMax(Rowc[IC], parseInt((Rowg[ndx3] + Rowg[ndx4]) / 2));
      if (debugChartGChild) {
        alert ("DBG CHRT CHILD B Row for Child " + IC + " reset (A) to " + Rowc[IC]);
      }  
    } else {
      if (debugChartChild) {
        alert("DBG CHRT GCHILD C IC: " + IC +   
                 " last gchild row used=" + thisGChildRow);
      }
      if(IC==1) {
          Rowc[IC] = biMax(1, thisGChildRow + 1);
      } else {
          Rowc[IC] = biMax(Rowc[IC - 1] + 1, thisGChildRow + 1);
      }    
      if (debugChartChild) {
        alert ("DBG CHRT CHILD D Row for Child " + IC + " reset (B) to " + Rowc[IC]);
      }  
//        alert ("36 Rowc[" + IC + "]=" + Rowc[IC]);
    }
  }
//  alert(" The Family is Charted");
//}
//function LayoutFamilyChart(Patriarch)
//{
//  alert("Lay out FamilyChart");
    iMaxRows = biMax(thisGChildRow,Rowc[NC[1]]);
    PatriarchRow = parseInt(iMaxRows/2);
    if (PatriarchRow<2) {
        PatriarchRow = 2;
    }
    MyScaleHeight = iMaxRows * vertSpacing + vertPictMargin * 2 + iBotMarg;
    if(debugMaxRows) {
      alert("MyScaleHeight, ChildRows, GChildRows, MaxRows, vertSpacing=" + 
          MyScaleHeight + ", " +
          thisGChildRow + ", " + Rowc[NC[1]] + ", " +
         iMaxRows + ", " + vertSpacing)
    }
//    MyScaleHeight = biMax(ScaleHeight,MyScaleHeight);
    var ns4 = (document.layers) ? true : false;
    var ie4 = (document.all && !document.getElementById) ? true : false;
    var ie5 = (document.all && document.getElementById) ? true : false;
    var ns6 = (!document.all && document.getElementById) ? true : false;
    var ie6 = navigator.appVersion.indexOf('MSIE 6')!=-1 ? true : false;
    var ie7 = navigator.appVersion.indexOf('MSIE 7')!=-1 ? true : false;
    if (ie7) {
      ie5 = false;
    }
 //    alert("navigator.appName + navigator.appVersion = "+navigator.appName +", "+navigator.appVersion+
 //    "  navigator.userAgent=" + navigator.userAgent);
 //   alert("ns4="+ns4+", ie4="+ie4+", ie5="+ie5+", ns6="+ns6);
    if(debugMaxRows) {
      alert("ns4:" + ns4 + "  ie4:" + ie4 + "  ie5:" + ie5 + "  ns6:" + ns6);
    }
    if (ie4 || ie5) {
      // IE6 & 7 passed the ie5 test as true, so let IE6 users take this path
      myCanvas.style.height=MyScaleHeight+"px";
    } else {
      if(ns4) {
        document.layers[thisCanvas].height=MyScaleHeight.toString()+"px;";
      } else {
        // This worked for Netscape 6, later for IE 7, so let this be the default
        // for all unrecognized browsers. They may have adopted this standard method.
        document.getElementById(thisCanvas).style.height=MyScaleHeight.toString()+"px";
      }
    } 
//    var cnv=document.GetElementById(thisCanvas);
//    cnv.style="position:relative;width:100%;height:"+MyScaleHeight+";";
    wc_canvas = new jsGraphics(thisCanvas);
    wc_canvas.setStroke(2); 
    wc_canvas.setColor(ColorBG);
    wc_canvas.fillRect(0,0,ScaleWidth,MyScaleHeight);
    CX = parseInt(0.5 * ScaleWidth); // ' Get horizontal center.
    PosX[1] = parseInt(CX / 24);
    PosX[2] = PosX[1] + TextBoxWidth;
    PosX[3] = CX - parseInt(TextBoxWidth/2);
    PosX[4] = ScaleWidth - PosX[3];
    PosX[5] = ScaleWidth - PosX[2];
    PosX[6] = ScaleWidth - PosX[1];
    
    Y1 = vertPictMargin + (PatriarchRow-1) * vertSpacing; //' Get vertical center.
    Y2 = Y1 + TextBoxHeight;
 //    alert( "Scale width, height=" + Format(ScaleWidth) + ", " + Format(ScaleHeight));
 //    alert ("CX, CY=" + Format(CX) + ", " + Format(CY));
    wc_canvas.setStroke(2); //   ' Set DrawWidth.
 //   wc_canvas.BackColor = RGB(200, 220, 250)
    wc_canvas.setColor(ColorBGC);
    wc_canvas.drawString(xStr,14,10,320);
 // Set Up Grandparent
    wc_canvas.setColor("#DCDCDC"); //  Set foreground color.
    drawBoxFill (PosX[1] - iBoxMargin + iBoxLoff, Y1 - iBoxMargin + iBoxToff, PosX[2] + iBoxMargin + iBoxRoff, Y2 + iBoxMargin + iBoxBoff, Patriarch);
    wc_canvas.setColor("#141414");  // Set foreground color.
    drawBox (PosX[1] - iBoxMargin - i2-2, Y1 - iBoxMargin - i2-2, PosX[2] + iBoxMargin + i2, Y2 + iBoxMargin + i2);
    if (debugLayoutPatriarchLines) {
      wc_canvas.paint();
      alert("1");
    }
    RectSetup2(1, PosX[1], Y1, PosX[2], Y2);
    if (debugLayoutPatriarchLines) {
      wc_canvas.paint();
      alert("2");
    }
    RectText(1, Patriarch, Person[Patriarch]); // Set the name of the person
    if (debugLayoutPatriarchLines) {
      wc_canvas.paint();
      alert("3");
    }
    if (NC[1] > 0) {
 //  Stub out a line towards the children
    if (debugLayoutPatriarchLines) {
      wc_canvas.paint();
      alert("4");
    }
    CY = Y1+halfTextBoxHeight;
    wc_canvas.drawLine (PosX[2] + iBoxMargin + i2, CY, PosX[2] + iBoxMargin + iStubL + i2, CY);
    
    if (debugLayoutPatriarchLines) {
      wc_canvas.paint();
      alert("5");
    }
    gTextBoxNdx = NC[1] + 2;
//   Set Up Children
    for (IC = 1; IC<=NC[1]; IC++)
    {
        if (debugLayoutPatriarchLines) {
          wc_canvas.paint();
          alert("6");
        }
        if (debugLayoutChild) {
          alert ("Laying out child " + IC + " on Row " + Rowc[IC]);
        }  
        wc_canvas.setColor(ColorBGBox);  //  Set foreground color.
        if (debugLayoutPatriarchLines) {
          wc_canvas.paint();
          alert("8");
        }
        PosY[1] = vertPictMargin + (Rowc[IC]-1) * vertSpacing; //  Top of Text1[] TextBox Control
        PosY[2] = PosY[1] + TextBoxHeight; //  Bottom of Text1(] TextBox Control
        PosY[3] = PosY[1] + halfTextBoxHeight; //  Vertical Center of Text1[] TextBox Control
        if (debugLayoutPatriarchLines) {
          wc_canvas.paint();
          alert("10");
        }
        wc_canvas.setColor(ColorBGBox); //  Set foreground color.
        drawBoxFill (PosX[3] - iBoxMargin + iBoxLoff, PosY[1] - iBoxMargin + iBoxToff, PosX[4] + iBoxMargin + iBoxRoff, PosY[2] + iBoxMargin + iBoxBoff, Children[IC]);
        if (debugLayoutPatriarchLines) {
          wc_canvas.paint();
          alert("12");
        }
        wc_canvas.setColor(ColorText);  // Set foreground color.
        drawBox (PosX[3] - iBoxMargin - i2-2, PosY[1] - iBoxMargin - i2-2, PosX[4] + iBoxMargin + i2, PosY[2] + iBoxMargin + i2);
        if (debugLayoutPatriarchLines) {
          wc_canvas.paint();
          alert("14");
        }
        RectSetup2(IC+1, PosX[3], PosY[1], PosX[4], PosY[2]);
        RectText(IC+1, Children[IC], Person[Children[IC]]); // Set the name of the person
        if (debugLayoutPatriarchLines) {
          wc_canvas.paint();
          alert("16");
        }
    //    ' Draw the Line from parent to child
        wc_canvas.setColor(ColorText);  // Set foreground color.
        wc_canvas.drawLine (PosX[2] + iBoxMargin + iStubL + i2, CY, PosX[3] - iBoxMargin - iStubL - i2, PosY[3]);
        wc_canvas.drawLine (PosX[3] - iBoxMargin - iStubL - i2, PosY[3], PosX[3] - iBoxMargin - i2, PosY[3]);
    
        wc_canvas.paint();
        if (debugLayoutPatriarchLines) {
          wc_canvas.paint();
          alert("18");
        }
    //    ' Set Up Grandchildren
        if (NG[IC] > 0) {
      //     Stub out a line towards the grandchildren
          wc_canvas.setColor(ColorText);  // Set foreground color.
          wc_canvas.drawLine (PosX[4] + iBoxMargin + i2, PosY[3], PosX[4] + iBoxMargin + iStubL + i2, PosY[3]);
          if (debugLayoutPatriarchLines) {
            wc_canvas.paint();
            alert("20");
          }
          for (IG = 1; IG <= NG[IC]; IG++)
          {
      //      if (Rowg[IC] [IG) < 9) {
              ndx2 = (IC-1) * maxChildCount + IG;
              if (debugLayoutGChild) {
                alert ("Laying out gchild " + IG + " for Child " + IC + " on Row " + Rowg[ndx2]);
              }  
              PosY[4] = vertPictMargin + (Rowg[ndx2]-1) * vertSpacing; // Top of Text1[] TextBox Control
              PosY[5] = PosY[4] + TextBoxHeight; // Bottom of Text1[] TextBox Control
              PosY[6] = PosY[4] + halfTextBoxHeight; // Vertical Center of Text1[] TextBox Control
              wc_canvas.setColor(ColorBGBox);  // Set foreground color.
              drawBoxFill (PosX[5] - iBoxMargin + iBoxLoff, PosY[4] - iBoxMargin + iBoxToff, PosX[6] + iBoxMargin + iBoxRoff, PosY[5] + iBoxMargin + iBoxBoff, GChildren[ndx2]);
              wc_canvas.setColor(ColorText);  // Set foreground color.
              drawBox (PosX[5] - iBoxMargin - i2-2, PosY[4] - iBoxMargin - i2-2, PosX[6] + iBoxMargin + i2, PosY[5] + iBoxMargin + i2);
              RectSetup2(gTextBoxNdx, PosX[5], PosY[4], PosX[6], PosY[5]);
              RectText(gTextBoxNdx, GChildren[ndx2], Person[GChildren[ndx2]]); // Set the name of the person
              gTextBoxNdx = gTextBoxNdx + 1;
              // Draw the Line from parent to child
              wc_canvas.setColor(ColorText);  // Set foreground color.
              wc_canvas.drawLine (PosX[4] + iBoxMargin + iStubL + i2, PosY[3], PosX[5] - iBoxMargin - iStubL - i2, PosY[6]);
              wc_canvas.drawLine (PosX[5] - iBoxMargin - iStubL - i2, PosY[6], PosX[5] - iBoxMargin - i2, PosY[6]);
      //      }
          }
        }
  //    }
    }
    }
    wc_canvas.paint();
    if (debugLayoutPatriarchLines) {
      alert("100");
    }
   // alert("Done!");
  return 1;
}
function Draw_Pedigree()
{
  var PPosX = new Array(5); 
  var PPosY = new Array(25);
  var Pwidth = new Array(8);
  var Pheight = new Array(8);
  PPosX[1] = 12;
  PPosX[2] = 312;
  PPosX[3] = 624;
  PPosX[4] = 1008;
  PPosY[1] = 372;
  PPosY[2] = 72;
  PPosY[3] = 672;
  PPosY[4] = 24;
  PPosY[5] = 264;
  PPosY[6] = 504;
  PPosY[7] = 744;
  PPosY[8] = 144;
  PPosY[9] = 384;
  PPosY[10] = 624;
  PPosY[11] = 864;
  PPosY[12] = 12;
  PPosY[13] = 132;
  PPosY[14] = 192;
  PPosY[15] = 252;
  PPosY[16] = 312;
  PPosY[17] = 432;
  PPosY[18] = 492;
  PPosY[19] = 552;
  PPosY[20] = 612;
  PPosY[21] = 732;
  PPosY[22] = 792;
  PPosY[23] = 852;
  PPosY[24] = 912;
    // Text1 Control Array Attributes
    // Call,Index,Left,Top,Width,Height
    RectSetup(1,  PPosX[1], PPosY[1], 2535, 2655);
    RectSetup(2,  PPosX[1], PPosY[2], 2535, 2655);
    RectSetup(3,  PPosX[1], PPosY[3], 2535, 2655);
    RectSetup(4,  PPosX[2], PPosY[4], 2775, 2175);
    RectSetup(5,  PPosX[2], PPosY[5], 2775, 2175);
    RectSetup(6,  PPosX[2], PPosY[6], 2775, 2175);
    RectSetup(7,  PPosX[2], PPosY[7], 2775, 2175);
    RectSetup(8,  PPosX[3], PPosY[4], 3495, 1095);
    RectSetup(9,  PPosX[3], PPosY[8], 3495, 975);
    RectSetup(10, PPosX[3], PPosY[5], 3495, 1095);
    RectSetup(11, PPosX[3], PPosY[9], 3495, 975);
    RectSetup(12, PPosX[3], PPosY[6], 3495, 1095);
    RectSetup(13, PPosX[3], PPosY[10], 3495, 975);
    RectSetup(14, PPosX[3], PPosY[7], 3495, 1095);
    RectSetup(15, PPosX[3], PPosY[11], 3495, 975);
    RectSetup(16, PPosX[4], PPosY[12], 3375, 495);
    RectSetup(17, PPosX[4], PPosY[2], 3375, 495);
    RectSetup(18, PPosX[4], PPosY[13], 3375, 495);
    RectSetup(19, PPosX[4], PPosY[14], 3375, 495);
    RectSetup(20, PPosX[4], PPosY[15], 3375, 495);
    RectSetup(21, PPosX[4], PPosY[16], 3375, 495);
    RectSetup(22, PPosX[4], PPosY[1], 3375, 495);
    RectSetup(23, PPosX[4], PPosY[17], 3375, 495);
    RectSetup(24, PPosX[4], PPosY[18], 3375, 495);
    RectSetup(25, PPosX[4], PPosY[19], 3375, 495);
    RectSetup(26, PPosX[4], PPosY[20], 3375, 495);
    RectSetup(27, PPosX[4], PPosY[3], 3375, 495);
    RectSetup(28, PPosX[4], PPosY[21], 3375, 495);
    RectSetup(29, PPosX[4], PPosY[22], 3375, 495);
    RectSetup(30, PPosX[4], PPosY[23], 3375, 495);
    RectSetup(31, PPosX[4], PPosY[24], 3375, 495);

      // Call,Index,Width,X1,X2,Y1,Y2,
    wc_canvas.setStroke(8);   // Set DrawWidth.,,,,,,
    wc_canvas.drawLine (1320, 6840, 1320, 3240);
    wc_canvas.setStroke(6);   // Set DrawWidth.,,,,,,
    wc_canvas.drawLine (2520, 2040, 2880, 2040);
    wc_canvas.drawLine (2520, 7920, 2880, 7920);
    wc_canvas.drawLine (2880, 1320, 3240, 1320);
    wc_canvas.drawLine (2880, 1320, 2880, 3600);
    wc_canvas.drawLine (2880, 3600, 3240, 3600);
    wc_canvas.drawLine (2880, 6120, 3240, 6120);
    wc_canvas.drawLine (2880, 6120, 2880, 8400);
    wc_canvas.drawLine (2880, 8400, 3360, 8400);
    wc_canvas.drawLine (5520, 8280, 6120, 8280);
    wc_canvas.drawLine (5760, 1200, 6120, 1200);
    wc_canvas.drawLine (5760, 3600, 6120, 3600);
    wc_canvas.drawLine (5760, 6000, 6120, 6000);
    wc_canvas.drawLine (9600, 720, 9960, 720);
    wc_canvas.drawLine (9600, 1920, 9960, 1920);
    wc_canvas.drawLine (9600, 3120, 9960, 3120);
    wc_canvas.drawLine (9600, 4320, 9960, 4320);
    wc_canvas.drawLine (9600, 5520, 9960, 5520);
    wc_canvas.drawLine (9600, 6720, 9960, 6720);
    wc_canvas.drawLine (9600, 7800, 9960, 7800);
    wc_canvas.drawLine (9600, 9120, 9960, 9120);
    wc_canvas.setStroke(4);   // Set DrawWidth.,,,,
    wc_canvas.drawLine (6120, 720, 6480, 720);
    wc_canvas.drawLine (6120, 720, 6120, 1800);
    wc_canvas.drawLine (6120, 1800, 6480, 1800);
    wc_canvas.drawLine (6120, 3120, 6480, 3120);
    wc_canvas.drawLine (6120, 3120, 6120, 4200);
    wc_canvas.drawLine (6120, 4200, 6480, 4200);
    wc_canvas.drawLine (6120, 5520, 6480, 5520);
    wc_canvas.drawLine (6120, 5520, 6120, 6600);
    wc_canvas.drawLine (6120, 6600, 6480, 6600);
    wc_canvas.drawLine (6120, 7800, 6480, 7800);
    wc_canvas.drawLine (6120, 7800, 6120, 8880);
    wc_canvas.drawLine (6120, 8880, 6480, 8880);
    wc_canvas.drawLine (9960, 360, 9960, 960);
    wc_canvas.drawLine (9960, 360, 10320, 360);
    wc_canvas.drawLine (9960, 960, 10320, 960);
    wc_canvas.drawLine (9960, 1680, 9960, 2160);
    wc_canvas.drawLine (9960, 1680, 10320, 1680);
    wc_canvas.drawLine (9960, 2160, 10320, 2160);
    wc_canvas.drawLine (9960, 2760, 9960, 3360);
    wc_canvas.drawLine (9960, 2760, 10320, 2760);
    wc_canvas.drawLine (9960, 3360, 10320, 3360);
    wc_canvas.drawLine (9960, 4080, 9960, 4560);
    wc_canvas.drawLine (9960, 4080, 10320, 4080);
    wc_canvas.drawLine (9960, 4560, 10320, 4560);
    wc_canvas.drawLine (9960, 5160, 9960, 5760);
    wc_canvas.drawLine (9960, 5160, 10320, 5160);
    wc_canvas.drawLine (9960, 5760, 10320, 5760);
    wc_canvas.drawLine (9960, 6480, 9960, 6960);
    wc_canvas.drawLine (9960, 6480, 10320, 6480);
    wc_canvas.drawLine (9960, 6960, 10320, 6960);
    wc_canvas.drawLine (9960, 7560, 9960, 8160);
    wc_canvas.drawLine (9960, 7560, 10320, 7560);
    wc_canvas.drawLine (9960, 8160, 10320, 8160);
    wc_canvas.drawLine (9960, 8880, 9960, 9360);
    wc_canvas.drawLine (9960, 8880, 10320, 8880);
    wc_canvas.drawLine (9960, 9360, 10320, 9360);
}
function RectSetup(idx,rectLeft,rectTop,rectWidth,rectHeight)
{
  if(idx>maxRectCount-1) {
    wc_canvas.paint();
    if(displayError) {
      alert("Maximum number of persons displayed on a chart was exceeded. Max="+
        maxRectCount);
      displayError=0;
    }
    return;
  }
  RectVerts[idx][1]=rectLeft;
  RectVerts[idx][2]=rectTop;
//  RectVerts[idx][3]=rectWidth;
//  RectVerts[idx][4]=rectHeight;
  wc_canvas.setColor(ColorBGBox);
  wc_canvas.fillRect(rectLeft+1,rectTop+1,rectWidth,rectHeight);
    wc_canvas.paint();
//    alert("Text Box #" + idx);
  return 1;
}
function RectSetup2(idx,rectLeft,rectTop)
{
  if(idx>maxRectCount-1) {
    wc_canvas.paint();
    if(displayError) {
      alert("Maximum number of persons displayed on a chart was exceeded. Max="+
        maxRectCount);
      displayError=0;
    }
    return;
  }
//  alert("Box index number: "+idx);
  RectVerts[idx][1]=rectLeft;
  RectVerts[idx][2]=rectTop;
//  RectVerts[idx][3]=rectRight-rectLeft;
//  RectVerts[idx][4]=rectBot-rectTop;
  wc_canvas.setColor(ColorBGBox);
//  wc_canvas.fillRect(rectLeft,rectTop,rectRight-rectLeft,rectBot-rectTop);
  wc_canvas.fillRect(rectLeft,rectTop,TextBoxWidth,TextBoxHeight);
    wc_canvas.paint();
//    alert("Text Box #" + idx);
  return 1;
}
function drawBoxFill(rectLeft,rectTop,ndxPerson)
{
//  wc_canvas.fillRect(rectLeft,rectTop,rectRight-rectLeft,rectBot-rectTop,mde+
//     ndxPerson+")");
//  wc_canvas.fillRect(rectLeft,rectTop,rectRight-rectLeft,rectBot-rectTop);
  wc_canvas.fillRect(rectLeft,rectTop,TextBoxWidth,TextBoxHeight);
  return 1;
}
function drawBox(rectLeft,rectTop,rectRight,rectBot)
{
  wc_canvas.setColor(ColorBorder);  // Set foreground color.
  wc_canvas.fillRect(rectLeft,rectTop,rectRight-rectLeft,rectBot-rectTop);
  wc_canvas.setColor(ColorText);  // Set foreground color.
  wc_canvas.drawRect(rectLeft,rectTop,rectRight-rectLeft,rectBot-rectTop);
  return 1;
}
function RectText(idx,ndxPerson,rectTextString)
{
  if(idx>maxRectCount-1) {
    wc_canvas.paint();
    if(displayError) {
      alert("Maximum number of persons displayed on a chart was exceeded. Max="+
        maxRectCount);
      displayError=0;
    }
    return;
  }
//  var strDisplay = "<a href=\"javascript:redisplayFamily(" + ndxPerson + ")\">" +
//      "[" + ndxPerson + "]</a> " + rectTextString;
  var strDisplay = "<a href=\"nameindex.htm#I" + ndxPerson + "\">" +
      "[" + ndxPerson + "]</a> " + rectTextString;
  wc_canvas.setColor(ColorText)
  wc_canvas.setFont(FontFamily,FontSize,FontStyle);
  wc_canvas.drawStringRect(strDisplay,
       RectVerts[idx][1]+2,RectVerts[idx][2]-1,
       TextBoxWidth-4,"left");
  return 1;
}
function LoadTestData()
{
//  alert("loading test data");
PersonCount = 15
MaxPersonNdx = 193
FirstPersonNdx = 7
Person[7]="Moses Coleman<br/>" +
" b.<br/>" +
" d.";
Parent[7]=0;
Person[180]="Amos Coleman<br/>" +
" b.<br/>" +
" d.";
Parent[180]=7;
Person[181]="John Coleman<br/>" +
" b.<br/>" +
" d.";
Parent[181]=7;
Person[182]="Moses Coleman, II<br/>" +
" b.<br/>" +
" d.";
Parent[182]=7;
Person[184]="John Coleman<br/>" +
" b.c1760 [based on brother, Theophilus].<br/>" +
" d.";
Parent[184]=182;
Person[185]="Theophilus Coleman<br/>" +
" b.1761<br/>" +
" d.1845, m. Keziah";
Parent[185]=182;
Person[186]="Amos Coleman, married Winnifred<br/>" +
" b.<br/>" +
" d.";
Parent[186]=182;
Person[187]="Phillip Coleman married Sarah Stephens<br/>" +
" b.<br/>" +
" d.";
Parent[187]=182;
Person[188]="Moses Coleman, III<br/>" +
" b.c1765 [based on year of first marriage - 25]<br/>" +
" d.";
Parent[188]=182;
Person[189]="Dempsey Coleman<br/>" +
" b.c1778<br/>" +
" d.1823";
Parent[189]=182;
Person[190]="Henry Coleman<br/>" +
" b.c1780<br/>" +
" d.";
Parent[190]=182;
Person[191]="Lucretia Coleman<br/>" +
" b.1783<br/>" +
" d.1840";
Parent[191]=182;
Person[192]="Charity Coleman, married Elijah Worley<br/>" +
" b.<br/>" +
" d.";
Parent[192]=182;
Person[193]="Polly Coleman<br/>" +
" b.<br/>" +
" d.";
Parent[193]=182;
Person[183]="Christian Coleman<br/>" +
" b.<br/>" +
" d.";
Parent[183]=7;
return 1;
}

function biMax(x,y)
{
  if(x<y) {
    return(y);
  } else  {
    return(x);
  }
}
