<!--
function DailyImage($inScale)
//
//    Generates HTML image tag for daily rotating jpg image
//        inNum      Number of images available
//        inScale    Scale of image required
//
{
    var $dtCurrent;
    var $dtRef = new Date("01 March 2004 17:00:00 GMT");
    var intDaysDiff;
    var Div;
    var Index;
    var $Tag;
    var $ImgNum;
    var $ImgNumDisp;
    var $ImgDescr;
    var $NumDescr;
    var $DepValues;
    var $DepChar;
    var $DepType;
    var $Path;
    var DepImgCount;
    var DepWidth;
    var DepHeight;
    var $AltText;


    //  Get values which are variable on scale
    if ($inScale == "009")   {$DepValues = StockDetails009[0];   $Path = "http://i22.photobucket.com/albums/b343/mbox4uk/";}
    if ($inScale == "HOn30") {$DepValues = StockDetailsHOn30[0]; $Path = "http://i22.photobucket.com/albums/b343/mbox4uk/";}
    if ($inScale == "1n20")  {$DepValues = StockDetails1n20[0];  $Path = "http://i22.photobucket.com/albums/b343/mbox4uk/";}
    DepImgCount = $DepValues.substr(0,2) * 1;
    DepWidth    = $DepValues.substr(2,3);
    DepHeight   = $DepValues.substr(5,3);
    $DepChar    = $DepValues.substr(8,1);
    $DepType    = $DepValues.substr(9);

    //  Calculate rolling number for image, using total count of images
    $dtCurrent   = new Date();
    intDaysDiff = Math.round(($dtCurrent - $dtRef) / (1000*60*60*24));
    Div         = Math.round((intDaysDiff / DepImgCount) - 0.5);
    Index       = intDaysDiff - (Div * DepImgCount) + 1;

    //  Look up details for the image at this index
    if ($inScale == "009")   {$NumDescr=StockDetails009[Index];}
    if ($inScale == "HOn30") {$NumDescr=StockDetailsHOn30[Index];}
    if ($inScale == "1n20")  {$NumDescr=StockDetails1n20[Index];}
    $ImgNum = $NumDescr.substr(0,2);
    $ImgDescr = $NumDescr.substr(2);
    $ImgNumDisp = $ImgNum * 1;

    //  If a passenger vehicle then change the text from 'wagon' to 'coach'
    if ($DepType == "wagon")
       {if ($ImgDescr.indexOf("coach") > -1)
           {$DepType = "coach";
           }
       }
 
    //  Create alt text for image
    $AltText = $inScale + " daily image " + Index + " of " + DepImgCount + " : " + $DepType + " #" + $ImgNumDisp + ", " + $ImgDescr; 

    //  Create and output complete image tag
    $Tag = "<IMG SRC='" + $Path + "k" + $DepChar + "g" + $ImgNum + "xxm.jpg' BORDER=1 WIDTH=" + DepWidth + " HEIGHT=" + DepHeight + " ALT='" + $AltText + "'>";
    document.write($Tag);
}
// -->
