<!--<HTML>
//
//    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 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);
    return intReturn;
   }



function ScreenPosY(inY)
   {var intReturn;

    intReturn = 70 + (inY * 40);
    return intReturn;
   }



function SetUp()
   {var i;
//
//  Set array high VALUEs
//
HighTrack = 255;
HighPoint = 6;
HighStock = 7;
HighUnc = 4;

//
//  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 <= 60)    {TrackL1[i] = i-1; TrackR1[i] = i+1; TrackX[i] = i;     TrackY[i] = 2};
        if (i >= 61 && i <= 120)  {TrackL1[i] = i-1; TrackR1[i] = i+1; TrackX[i] = i-60;  TrackY[i] = 3};
        if (i >= 121 && i <= 140) {TrackL1[i] = i-1; TrackR1[i] = i+1; TrackX[i] = i-112};
        if (i >= 141 && i <= 160) {TrackL1[i] = i-1; TrackR1[i] = i+1; TrackX[i] = i-110};
        if (i >= 161 && i <= 180) {TrackL1[i] = i-1; TrackR1[i] = i+1; TrackX[i] = i-139};
        if (i >= 181 && i <= 225) {TrackL1[i] = i-1; TrackR1[i] = i+1; TrackX[i] = i-167; TrackY[i] = 1};
        if (i >= 226 && i <= 255) {TrackL1[i] = i-1; TrackR1[i] = i+1; TrackX[i] = i-255; TrackY[i] = 2};
       }

    TrackL1[1]   = 255;
    TrackL1[61]  = 0;
    TrackL1[181] = 0;
    TrackL1[226] = 0;
    

    TrackR1[60]  = 0;
    TrackR1[120] = 0;
    TrackR1[225] = 0;
    TrackR1[255] = 1;
 
    TrackY[121] = 2;
    TrackY[122] = 2.07;
    for (i=123 ; i<=138 ; i++) TrackY[i] = TrackY[i-1] + .05;
    TrackY[139] = 2.95;
    TrackY[140] = 3;

    TrackL2[8]   = 7;
    TrackR2[8]   = 121;
    TrackL1[121] = 8;

    TrackL2[89]  = 140;
    TrackR2[89]  = 90;
    TrackR1[140] = 89;


    TrackY[141] = 3;
    TrackY[142] = 2.95;
    for (i=143 ; i<=158 ; i++) TrackY[i] = TrackY[i-1] - .05;
    TrackY[159] = 2.07;
    TrackY[160] = 2;

    TrackL2[90]  = 89;
    TrackR2[90]  = 141;
    TrackL1[141] = 90;

    TrackL2[51]  = 160;
    TrackR2[51]  = 52;
    TrackR1[160] = 51;


    TrackY[161] = 2;
    TrackY[162] = 1.95;
    for (i=163 ; i<=178 ; i++) TrackY[i] = TrackY[i-1] - .05;
    TrackY[179] = 1.07;
    TrackY[180] = 1;

    TrackL2[21]  = 20;
    TrackR2[21]  = 161;
    TrackL1[161] = 21;

    TrackL2[209] = 180;
    TrackR2[209] = 210;
    TrackR1[180] = 209;


//
//  Set up array locations
//

//  Points
    TrackP[8]   = 1;  PointAt[1]  = 8;
    TrackP[89]  = 2;  PointAt[2]  = 129; PointOffY[2] = +4;
    TrackP[90]  = 3;  PointAt[3]  = 91;  PointOffY[3] = -20;
    TrackP[51]  = 4;  PointAt[4]  = 40;
    TrackP[21]  = 5;  PointAt[5]  = 21;  PointOffY[5] = -20;
    TrackP[209] = 6;  PointAt[6]  = 197;

    PointClrA[1] = 8;   PointClrB[1] = 20;  PointClrC[1] = 121; PointClrD[1] = 130;
    PointClrA[2] = 77;  PointClrB[2] = 89;  PointClrC[2] = 129; PointClrD[2] = 140;
    PointClrA[3] = 91;  PointClrB[3] = 103; PointClrC[3] = 141; PointClrD[3] = 153;
    PointClrA[4] = 40;  PointClrB[4] = 52;  PointClrC[4] = 151; PointClrD[4] = 160;
    PointClrA[5] = 21;  PointClrB[5] = 33;  PointClrC[5] = 161; PointClrD[5] = 172;
    PointClrA[6] = 198; PointClrB[6] = 209; PointClrC[6] = 169; PointClrD[6] = 180;


// Uncouplers
    Unc[1] = 7;
    Unc[2] = 89;
    Unc[3] = 52;
    Unc[4] = 196;

// Stock
    StockL[1] = 21;  StockR[1] = 27;  StockCL[1] = 3; StockTL[1] = 3;
    StockL[2] = 110; StockR[2] = 116;
    StockL[3] = 14;  StockR[3] = 20;  StockCL[3] = 7; StockTL[3] = 7; StockCR[3] = 1; StockTR[3] = 1;
    StockL[4] = 182; StockR[4] = 188;
    StockL[5] = 1;   StockR[5] = 7;                                   StockCR[5] = 7; StockTR[5] = 7;
    StockL[6] = 62;  StockR[6] = 68;
    StockL[7] = 8;   StockR[7] = 13;  StockCL[7] = 5; StockTL[7] = 5; StockCR[7] = 3; StockTR[7] = 3;

//
//  Build image arrays
//

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

//  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);
       }

//  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');
       }

//
//  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[61]);
    document.all.Track2.style.pixelTop  = ScreenPosY(TrackY[61]);
    document.all.Track3.style.pixelLeft = ScreenPosX(TrackX[181]);
    document.all.Track3.style.pixelTop  = ScreenPosY(TrackY[181]);
    document.all.Track4.style.pixelLeft = ScreenPosX(TrackX[226]);
    document.all.Track4.style.pixelTop  = ScreenPosY(TrackY[226]);

//  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;
       }

//  Spot markers
    document.all.MarkTank.style.pixelLeft    = ScreenPosX(TrackX[182]);
    document.all.MarkTank.style.pixelTop     = ScreenPosY(TrackY[182]) - 10;
    document.all.MarkReefer.style.pixelLeft  = ScreenPosX(TrackX[110]);
    document.all.MarkReefer.style.pixelTop   = ScreenPosY(TrackY[110]) + 25;
    document.all.MarkGondola.style.pixelLeft = ScreenPosX(TrackX[62]);
    document.all.MarkGondola.style.pixelTop  = ScreenPosY(TrackY[62]) + 25;

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

// -->
