<!--<HTML>
//
//    New version to operate Inglenook Sidings, 02Jan2002
//
//    14Apr2004  Fix to clear counter when New button pressed.
//
//    XYZ
//     |
//     +-- TrackFree()
//     |
//     +-- MoveTrain2()
//     |   |
//     |   +-- MoveStock()
//     |   |   |
//     |   |   +-- DisplayStock()
//     |   |       |
//     |   |       +-- ScreenPosX()
//     |   |       |
//     |   |       +-- ScreenPosY()
//     |   |
//     |   +-- SplitTrain2()
//     |
//     +-- CheckCoupling()
//         |
//         +-- AddToTrain()
//             |
//             +-- DisplayStock()
//
//    TrainDetails()
//
//    Uncouple()
//
//    ChangePoint()
//    |
//    +-- CheckPointFree()
//
//    SetUp()
//

var TrackL1   = new Array(255);
var TrackR1   = new Array(255);
var TrackP    = new Array(255);
var TrackL2   = new Array(255);
var TrackR2   = new Array(255);
var TrackX    = new Array(255);
var TrackY    = new Array(255);
var StockL    = new Array(10);
var StockR    = new Array(10);
var StockTL   = new Array(10);
var StockTR   = new Array(10);
var StockCL   = new Array(10);
var StockCR   = new Array(10);
var CoupImglc = new Array(10);
var CoupImglu = new Array(10);
var CoupImgrc = new Array(10);
var CoupImgru = new Array(10);
var StockImg  = new Array(200);
var Point     = new Array(10);
var PointAt   = new Array(10);
var PointOffY = new Array(10);
var PointImg0 = new Array(10);
var PointImg1 = new Array(10);
var PointClrA = new Array(10);
var PointClrB = new Array(10);
var PointClrC = new Array(10);
var PointClrD = new Array(10);
var Unc       = new Array(10);
var UncImg    = new Array(10);
var TrainPos  = new Array(10);
var MarkImg   = new Array(10);

var HighTrack, MaxTrack = 250;
var HighPoint, MaxPoint = 10;
var HighStock, MaxStock = 10;
var HighUnc,   MaxUnc   = 10;

var WaitTime = 175;
var myint;

var ThisDir = -1;
var LastDir = 0;
var MoveCount = 0;

function Go()
   {SetUp();
   }



function XYZ(Dir)
   {var intFirst;

    document.all.txtWarn.value = "";
    intFirst = TrainDetails("END", "", 1, Dir);
    if (TrackFree(intFirst, Dir) == "Y")
       {if (LastDir != 0 && LastDir != Dir)
           {MoveCount = MoveCount + 1;
            document.all.txtMoveCount.value = MoveCount;
            LastDir = 0;
           }
        ThisDir = Dir;
        MoveTrain2(Dir);
        CheckCoupling(intFirst, Dir, "Y");
       }
    else
       {document.all.txtWarn.value = "No free track";
       }
   }



function MoveTrain2(inDir)
//
//    Move whole train in selected direction. Move from front;
//      Find head of train
//      Move lead stock until loco
//      Move loco
//      Move stock after loco if coupled
//      Any uncoupled stock behind loco to be split from train
//
   {var i;
    var intLead, intThis;
    var intCoupledLeading, intStockTrailing;
    var strLoco;
 
    strLoco = "N";
    intLead = 1;

    intLead = TrainDetails("END", "BEFORE", 1, inDir);
    
    intThis = intLead;
    while (intThis != 0)
       {intCoupledLeading = TrainDetails("COUPLED", "BEFORE", intThis, inDir);
        intStockTrailing = TrainDetails("TRAIN", "AFTER", intThis, inDir);
        
        if (strLoco == "N")
           {MoveStock2(intThis, inDir);
            if (intThis == 1) strLoco = "Y";
           }
        else
           {if (intCoupledLeading != 0)
               {MoveStock2(intThis, inDir);
               }
            else
               {SplitTrain2(intThis, inDir);
                intStockTrailing = 0; 
               }
           }

        intThis = intStockTrailing;
       }
   }



function TrainDetails(inType, inMove, inStockNo, inDir)
//
//   Get details about the current train
//
   {var intReturn = -1;
    var strParm;

    strParm = inType + "." + inMove + "." + inDir;

    if (inType == "END")
       {intReturn = 1;    
        if (inDir == 1) while (StockTR[intReturn] != 0) intReturn = StockTR[intReturn];
        else            while (StockTL[intReturn] != 0) intReturn = StockTL[intReturn];
       }

    if (strParm == "TRAIN.BEFORE.1")    intReturn = StockTR[inStockNo];
    if (strParm == "TRAIN.BEFORE.-1")   intReturn = StockTL[inStockNo];
    if (strParm == "TRAIN.AFTER.1")     intReturn = StockTL[inStockNo];
    if (strParm == "TRAIN.AFTER.-1")    intReturn = StockTR[inStockNo];

    if (strParm == "COUPLED.BEFORE.1")  intReturn = StockCR[inStockNo];
    if (strParm == "COUPLED.BEFORE.-1") intReturn = StockCL[inStockNo];
    if (strParm == "COUPLED.AFTER.1")   intReturn = StockCL[inStockNo];
    if (strParm == "COUPLED.AFTER.-1")  intReturn = StockCR[inStockNo];

    if (intReturn == -1)
       {document.write("Invalid function call: TrainDetails(" + inType + ", " + inMove + ", " + inStockNo + ", " + inDir + ")");
       }

    return intReturn
   }



function TrackFree(inStockNo, inDir)
//
//   Check if track exists for selected stock to move in 
//   selected direction.
//   Extra processing included to detect an incorrectly set trailing point, and
//   if found set it for the direction of travel.
//
   {var strReturn;

    strReturn = "N";
    var intNext;
    var intDiff1, intDiff2; 

    document.all.txtWarn.value = "";
    if (inDir==1) intNext = TrackR1[StockR[inStockNo]]
    else          intNext = TrackL1[StockL[inStockNo]]

    if (intNext > 0)
       {strReturn = "Y"
        if (TrackP[intNext] != 0)
           {intDiff1 = 0;
            intDiff2 = 0;
            if (inDir == 1  && TrackL1[intNext] != TrackL2[intNext])
               {intDiff1 = TrackL1[intNext] - StockL[inStockNo];
                intDiff2 = TrackL2[intNext] - StockL[inStockNo];
               }
            if (inDir == -1 && TrackR1[intNext] != TrackR2[intNext])
               {intDiff1 = StockR[inStockNo] - TrackR1[intNext];
                intDiff2 = StockR[inStockNo] - TrackR2[intNext];
               }
            if (intDiff1==6 && Point[TrackP[intNext]]==1) ChangePoint(TrackP[intNext], "Y");
            if (intDiff2==6 && Point[TrackP[intNext]]==0) ChangePoint(TrackP[intNext], "Y");
           }
       }

    return strReturn;
   } 



function CheckCoupling(inStockNo, inDir, inAutoCouple)
//
//   Check front of train in selected direction to find if 
//   further stock to be added.
//   If any then call AddToTrain, then recall self to check if more.
//
   {var i;
    var intNextLocation;

    strReturn = "N";

    if (inDir==1)
       {intNextLocation = TrackR1[StockR[inStockNo]]
        if (intNextLocation > 0)
           {for (i=0 ; i <= 10 ; i++)
               {if (i!=inStockNo && intNextLocation==StockL[i])
                   {AddToTrain(i, inDir, inAutoCouple);
                    CheckCoupling(i, inDir, "N");
                    LastDir = ThisDir;
                   }
               }
           }
       }
    else
       {intNextLocation = TrackL1[StockL[inStockNo]]
        if (intNextLocation > 0)
           {for (i=0 ; i <= 10 ; i++)
               {if (i!=inStockNo && intNextLocation==StockR[i])
                   {AddToTrain(i, inDir, inAutoCouple);
                    CheckCoupling(i, inDir, "N");
                    LastDir = ThisDir;
                   }
               }
           }
       }

    return strReturn;
   } 



function MoveStock2(inStockNo, inDir)
//
//   Move selected piece of stock in selected direction.
//   Left and right ends move seperately
//
   {var i;
    var intRight, intLeft;

    intLeft  = StockL[inStockNo];
    intRight = StockR[inStockNo];

    if (inDir==1)
       {if (TrackP[intRight] == 0)
           {intRight = TrackR1[intRight];
           }
        else
           {if (Point[TrackP[intRight]] == 0) intRight = TrackR1[intRight];
            else                              intRight = TrackR2[intRight];
           }

        if (TrackP[intLeft] == 0)
           {intLeft = TrackR1[intLeft];
           }
        else
           {if (Point[TrackP[intLeft]] == 0) intLeft = TrackR1[intLeft];
            else                             intLeft = TrackR2[intLeft];
           }
       }
    else // (inDir == -1)
       {if (TrackP[intRight] == 0)
           {intRight = TrackL1[intRight];
           }
        else
           {if (Point[TrackP[intRight]] == 0) intRight = TrackL1[intRight];
            else                              intRight = TrackL2[intRight];
           }

        if (TrackP[intLeft] == 0)
           {intLeft = TrackL1[intLeft];
           }
        else
           {if (Point[TrackP[intLeft]] == 0) intLeft = TrackL1[intLeft];
            else                             intLeft = TrackL2[intLeft];
           }
       }

    StockL[inStockNo] = intLeft;
    StockR[inStockNo] = intRight;
    DisplayStock(inStockNo);
   }



function DisplayStock(inStockNo)
//
//   Display selected piece of stock.
//   NB also updates test box for testing.
//
   {var i;
    var strTrain;
    var intSpanX, inSpanY;
    var intStartX, intStartY;
    var intThisX, intThisY;
    var intScreenX, intScreenY;
    var intStockImg;

    if (inStockNo < 1)  document.write("Invalid function call: DisplayStock(" + inStockNo + ")");
    if (inStockNo > 10) document.write("Invalid function call: DisplayStock(" + inStockNo + ")");

    intSpanX = TrackX[StockR[inStockNo]] - TrackX[StockL[inStockNo]];
    intSpanX = (intSpanX + 1) / 7;
    intSpanY = TrackY[StockR[inStockNo]] - TrackY[StockL[inStockNo]];
    if (intSpanY != 0)
       {intSpanY = (intSpanY + 0) / 7;
       }

    intStartX = TrackX[StockL[inStockNo]];
    intStartY = TrackY[StockL[inStockNo]];
    intStockImg = 10 * (inStockNo - 1);

    for (i=1 ; i <= 7 ; i++)
       {intThisX = intStartX + (intSpanX * (i-1));
        intThisY = intStartY + (intSpanY * (i-1));

        intScreenX = ScreenPosX(intThisX);
        intScreenY = ScreenPosY(intThisY);

        StockImg[intStockImg + i].style.pixelLeft   = intScreenX;
        StockImg[intStockImg + i].style.pixelTop    = intScreenY;
       }

    if (StockCR[inStockNo] == 0 )
       {CoupImgrc[inStockNo].style.pixelLeft  = 50;
        CoupImgrc[inStockNo].style.pixelTop   = 300;
        CoupImgru[inStockNo].style.pixelLeft  = 8 + (ScreenPosX(TrackX[StockR[inStockNo]]));
        CoupImgru[inStockNo].style.pixelTop   = ScreenPosY(TrackY[StockR[inStockNo]]);
       }
    else
       {CoupImgru[inStockNo].style.pixelLeft  = 50;
        CoupImgru[inStockNo].style.pixelTop   = 300;
        CoupImgrc[inStockNo].style.pixelLeft  = 8 + (ScreenPosX(TrackX[StockR[inStockNo]]));
        CoupImgrc[inStockNo].style.pixelTop   = ScreenPosY(TrackY[StockR[inStockNo]]);
       }

    if (StockCL[inStockNo] == 0)
       {CoupImglc[inStockNo].style.pixelLeft  = 50;
        CoupImglc[inStockNo].style.pixelTop   = 300;
        CoupImglu[inStockNo].style.pixelLeft  = ScreenPosX(TrackX[StockL[inStockNo]]);
        CoupImglu[inStockNo].style.pixelTop   = ScreenPosY(TrackY[StockL[inStockNo]]);
       }
    else
       {CoupImglu[inStockNo].style.pixelLeft  = 50;
        CoupImglu[inStockNo].style.pixelTop   = 300;
        CoupImglc[inStockNo].style.pixelLeft  = ScreenPosX(TrackX[StockL[inStockNo]]);
        CoupImglc[inStockNo].style.pixelTop   = ScreenPosY(TrackY[StockL[inStockNo]]);
       }
   }



function AddToTrain(inStockNo, inDir, inAutoCouple)
//
//  Add piece of stock to beginning of train in current direction.
//  Automatic coupling depened on input parameter(3), otherwise
//  current coupling status is retained.
//
   {var i;
    var intLeadStock;

    if (inDir == 1)
       {intCurrentStock = 1;
        while (StockTR[intCurrentStock] != 0)
           {intCurrentStock = StockTR[intCurrentStock];
           }
        StockTR[intCurrentStock] = inStockNo;
        StockTL[inStockNo]       = intCurrentStock;
        if (inAutoCouple == "Y" )
           {StockCR[intCurrentStock] = inStockNo;
            StockCL[inStockNo]       = intCurrentStock;
            DisplayStock(intCurrentStock);
            DisplayStock(inStockNo);
           }
       }
    else
       {intCurrentStock = 1;
        while (StockTL[intCurrentStock] != 0)
           {intCurrentStock = StockTL[intCurrentStock];
           }
        StockTL[intCurrentStock] = inStockNo;
        StockTR[inStockNo]       = intCurrentStock;
        if (inAutoCouple == "Y" )
           {StockCL[intCurrentStock] = inStockNo;
            StockCR[inStockNo]       = intCurrentStock;
            DisplayStock(intCurrentStock);
            DisplayStock(inStockNo);
           }
       }
   }



function SplitTrain2(inStockNo, inDir)
//
//   Seperate train from this point.
//
   {var intThisStock;

    if (inDir == 1)
       {intThisStock = inStockNo;
        while (intThisStock != 0)
           {StockTL[StockTR[intThisStock]] = 0;
            StockTR[intThisStock]          = 0;
            intThisStock = StockTL[intThisStock];
           }
       }
    else
       {intThisStock = inStockNo;
        while (intThisStock != 0)
           {StockTR[StockTL[intThisStock]] = 0;
            StockTL[intThisStock]          = 0;
            intThisStock = StockTR[intThisStock];
           }
       }
   }



function ChangePoint(inPointNum, inOverRide)
//
//   Change selected point. 
//   A test will be made to check that no stock is over the point, if so the 
//   change will not be allowed.
//   The above check will not be performed if the second parameter = "Y".

   {document.all.txtWarn.value = "";
    if (inOverRide != "Y" && CheckPointFree(inPointNum, 0) == "N")
       {document.all.txtWarn.value = "Point is not free";
       }
    else
       { 
    if (Point[inPointNum] == 0)
       {Point[inPointNum] = 1
        PointImg1[inPointNum].style.pixelLeft = ScreenPosX(TrackX[PointAt[inPointNum]]);
        PointImg1[inPointNum].style.pixelTop  = ScreenPosY(TrackY[PointAt[inPointNum]]) + PointOffY[inPointNum];
        PointImg0[inPointNum].style.pixelLeft = 50;
        PointImg0[inPointNum].style.pixelTop  = 300;
       }
    else
       {Point[inPointNum] = 0
        PointImg0[inPointNum].style.pixelLeft = ScreenPosX(TrackX[PointAt[inPointNum]]);
        PointImg0[inPointNum].style.pixelTop  = ScreenPosY(TrackY[PointAt[inPointNum]]) + PointOffY[inPointNum];
        PointImg1[inPointNum].style.pixelLeft = 50;
        PointImg1[inPointNum].style.pixelTop  = 300;
       }
       }
    LastDir = ThisDir;
   }



function CheckPointFree(inPointNo, inStockNo)
//   Check the selected point is free from stock. If second parameter
//   is passed then excluded that item of stock from the test.
   {var i;
    var strReturn;

    strReturn = 'Y';
    for (i=1 ; i <= MaxStock ; i++)
       {if (i != inStockNo)
          {if (StockL[i] >= PointClrA[inPointNo] && StockL[i] <= PointClrB[inPointNo]) strReturn = 'N';
           if (StockR[i] >= PointClrA[inPointNo] && StockR[i] <= PointClrB[inPointNo]) strReturn = 'N';
           if (StockL[i] >= PointClrC[inPointNo] && StockL[i] <= PointClrD[inPointNo]) strReturn = 'N';
           if (StockR[i] >= PointClrC[inPointNo] && StockR[i] <= PointClrD[inPointNo]) strReturn = 'N';
          }
       }

    return strReturn;
   }



function Uncouple(inUncNo)
//
//  Uncouple any stock coupled over selected uncoupler
//  coding will allow one space either side for flexibility
//
   {var i;
    var intLeft, intRight;
    var intUncLeft, intUncRight;

    intLeft  = Unc[inUncNo];
    intRight = TrackR1[intLeft];
    intUncLeft  = 0;
    intUncRight = 0;

    for (i=1 ; i <= HighStock ; ++i)
       {if (StockL[i] == intLeft || StockL[i] == intRight)
           {if (StockCL[i] != 0)
               {intUncLeft  = i;
                intUncRight = StockCL[i];
                i = HighStock + 1;
               }
           }
        else
           {if (StockR[i] == intLeft || StockR[i] == intRight)
               {if (StockCR[i] != 0)
                   {intUncLeft  = StockCR[i];
                    intUncRight = i;
                    i = HighStock + 1;
                   }
               }
           }
       }

    if (intUncLeft != 0)
       {StockCL[intUncLeft]  = 0;
        StockCR[intUncRight] = 0; 
        DisplayStock(intUncLeft);
        DisplayStock(intUncRight);
        MoveCount = MoveCount + 1;
        document.all.txtMoveCount.value = MoveCount;
        LastDir = 0;
       }
   }


function ScreenPosX(inX)
   {var intReturn;

//    intReturn = 150 + (inX * 10);
    intReturn = (inX * 10) - 10;
    return intReturn;
   }



function ScreenPosY(inY)
   {var intReturn;

//    intReturn = 20 + (inY * 40);
    intReturn = 110 + (inY * 40);
    return intReturn;
   }



function NewTrain()
//
//  Select a new train and display using markers
//
   {var Loop;
    var ILoop;
    var Rnd;

    for(Loop=1 ; Loop<=8 ; ++Loop)
       {TrainPos[Loop]=0;}

    for(Loop=1 ; Loop<=5 ; ++Loop)
        {for (ILoop=1 ; ILoop<=999 ; ++ILoop)
            {Rnd = 1+Math.round(Math.random()*7);
             if (TrainPos[Rnd] == 0)
                {TrainPos[Rnd] = Loop; 
                 ILoop = 1000;
                }
            }
        }

    for(Loop=1 ; Loop<=8 ; ++Loop)
       {if(TrainPos[Loop] ==0)
           {MarkImg[Loop].style.pixelLeft = 50;
            MarkImg[Loop].style.pixelTop  = 600;
           }
        else 
           {MarkImg[Loop].style.pixelLeft = 410 + ((TrainPos[Loop]-1) * 70);
            MarkImg[Loop].style.pixelTop  = 220;
           }
       }

        MoveCount = 0;
        document.all.txtMoveCount.value = MoveCount;
   }



function SetUp()
   {var i;
//
//  Set array high VALUEs
//
HighTrack = 255;
HighPoint = 2;
HighStock = 9;
HighUnc = 3;

//
//  Initialise all arrays
//
    for (i=0 ; i <= HighTrack ; i++)
       {TrackL1[i] = 0;
        TrackR1[i] = 0;
        TrackP[i]  = 0;
        TrackL2[i] = 0;
        TrackR2[i] = 0;
        TrackX[i]  = 0;
        TrackY[i]  = 0;
       }
    for (i=0 ; i <= HighUnc ; i++)
       {Unc[i]   = 0;
       }
    for (i=0 ; i <= HighPoint ; i++)
       {Point[i]     = 0;
        PointAt[i]   = 0;
        PointOffY[i] = 0;
        PointClrA[i] = 0;
        PointClrB[i] = 0;
        PointClrC[i] = 0;
        PointClrD[i] = 0;

       }
    for (i=0 ; i <= HighStock ; i++)
       {StockL[i]  = 0;
        StockR[i]  = 0;
        StockTL[i] = 0;
        StockTR[i] = 0;
        StockCL[i] = 0;
        StockCR[i] = 0;
       }

//  Build track
    for (i=1 ; i <= HighTrack ; i++)
       {if (i >= 1 && i <= 81)    {TrackL1[i] = i-1; TrackR1[i] = i+1; TrackX[i] = i-5;   TrackY[i] = 1};
        if (i >= 83 && i <= 120)  {TrackL1[i] = i-1; TrackR1[i] = i+1; TrackX[i] = i-55;  TrackY[i] = 2};
        if (i >= 121 && i <= 156) {TrackL1[i] = i-1; TrackR1[i] = i+1; TrackX[i] = i-80;  TrackY[i] = 0};
        if (i >= 160 && i <= 170) {TrackL1[i] = i-1; TrackR1[i] = i+1; TrackX[i] = i-94;  TrackY[i] = 2};
       }

    TrackL1[1]   = 0;
    TrackL1[160] = 120;
    

    TrackR1[81]  = 0;
    TrackR1[120] = 160;
    TrackR1[156] = 0;
    TrackR1[170] = 0;
 
    TrackY[83] = 1;
    TrackY[84] = 1.07;
    for (i=85 ; i<=100 ; i++) TrackY[i] = TrackY[i-1] + .05;
    TrackY[101] = 1.95;
    TrackY[102] = 2;

    TrackL2[32] = 31;
    TrackR2[32] = 83;
    TrackL1[83] = 32;

    TrackY[121] = 1;
    TrackY[122] = 0.95;
    for (i=123 ; i<=138 ; i++) TrackY[i] = TrackY[i-1] - .05;
    TrackY[139] = 0.07;
    TrackY[140] = 0;

    TrackL2[45]  = 44;
    TrackR2[45]  = 121;
    TrackL1[121] = 45;

//
//  Set up array locations
//

//  Points
    TrackP[32]   = 1;  PointAt[1]  = 32;
    TrackP[45]  = 2;  PointAt[2]  = 45; PointOffY[2] = -20;

    PointClrA[1] = 32;   PointClrB[1] = 44;  PointClrC[1] = 83; PointClrD[1] = 92;
    PointClrA[2] = 45;  PointClrB[2] = 57;  PointClrC[2] = 121; PointClrD[2] = 130;


// Uncouplers
    Unc[1] = 133;
    Unc[2] = 59;
    Unc[3] = 95;

// Stock
    StockL[1] =  20; StockR[1] =  26;
    StockL[2] =  97; StockR[2] = 103;                   StockCR[2] = 3;
    StockL[3] = 104; StockR[3] = 110;  StockCL[3] = 2;  StockCR[3] = 4; 
    StockL[4] = 111; StockR[4] = 117;  StockCL[4] = 3;  StockCR[4] = 5;
    StockL[5] = 118; StockR[5] = 163;  StockCL[5] = 4;  StockCR[5] = 6;
    StockL[6] = 164; StockR[6] = 170;  StockCL[6] = 5;
    StockL[7] =  61; StockR[7] =  67;                   StockCR[7] = 8;
    StockL[8] =  68; StockR[8] =  74;  StockCL[8] = 7;  StockCR[8] = 9;
    StockL[9] =  75; StockR[9] =  81;  StockCL[9] = 8;

//
//  Build image arrays
//

//  Uncoupler
    UncImg[1] = eval('document.all.UC1');
    UncImg[2] = eval('document.all.UC2');
    UncImg[3] = eval('document.all.UC3');

//  Stock
    for (i=1 ; i <= 7 ; i++)
       {StockImg[i]    = eval('document.all.Stock0' + i);
        StockImg[i+10] = eval('document.all.Stock1' + i);
        StockImg[i+20] = eval('document.all.Stock2' + i);
        StockImg[i+30] = eval('document.all.Stock3' + i);
        StockImg[i+40] = eval('document.all.Stock4' + i);
        StockImg[i+50] = eval('document.all.Stock5' + i);
        StockImg[i+60] = eval('document.all.Stock6' + i);
        StockImg[i+70] = eval('document.all.Stock7' + i);
        StockImg[i+80] = eval('document.all.Stock8' + i);
       }

//  Couplings
    for (i=1 ; i <= HighStock ; i++)
       {CoupImglc[i] = eval('document.all.Couplerlc' + i)
        CoupImglu[i] = eval('document.all.Couplerlu' + i)
        CoupImgrc[i] = eval('document.all.Couplerrc' + i)
        CoupImgru[i] = eval('document.all.Couplerru' + i)
       }

//  Points
    for (i=1 ; i <= MaxPoint ; i++)
       {PointImg0[i] = eval('document.all.Point' + i + '0');
        PointImg1[i] = eval('document.all.Point' + i + '1');
       }

//  Markers
    for (i=1 ; i <= 8 ; i++)
       {MarkImg[i] = eval('document.all.Mark' + i);
       }

//
//  Move to screen locations
//

//  Track
    document.all.Track1.style.pixelLeft = ScreenPosX(TrackX[1]);
    document.all.Track1.style.pixelTop  = ScreenPosY(TrackY[1]);
    document.all.Track2.style.pixelLeft = ScreenPosX(TrackX[104]);
    document.all.Track2.style.pixelTop  = ScreenPosY(TrackY[104]);
    document.all.Track3.style.pixelLeft = ScreenPosX(TrackX[142]);
    document.all.Track3.style.pixelTop  = ScreenPosY(TrackY[142]);
    document.all.TrackP1.style.pixelLeft = 370;
    document.all.TrackP1.style.pixelTop  = 172;
    document.all.TrackP2.style.pixelLeft = 500;
    document.all.TrackP2.style.pixelTop  = 110;

//  Points
    for (i=1 ; i <= HighPoint ; i++)
       {PointImg0[i].style.pixelLeft = ScreenPosX(TrackX[PointAt[i]]);
        PointImg0[i].style.pixelTop  = ScreenPosY(TrackY[PointAt[i]]) + PointOffY[i];
        PointImg1[i].style.pixelLeft = 50;
        PointImg1[i].style.pixelTop  = 300;
       }

//  Uncouplers
    for (i=1 ; i <=HighUnc ; i++)
       {UncImg[i].style.pixelLeft = ScreenPosX(TrackX[Unc[i]])+5;
        UncImg[i].style.pixelTop  = ScreenPosY(TrackY[Unc[i]])-5;
       }

//  Display stock
    for (i=1 ; i <= HighStock ; i++)
       {DisplayStock(i);
       }

//  Display first train sequence
    NewTrain();
   }

// -->
