﻿var index = 1;        
function RightToLeft( )
{
    for ( i = 5; i > 0; i-- )
    {
        index++;
        setTimeout( "PicRotate( " + (6 - i) + "," + index + ", 7 )", i * 500 );
    }
    setTimeout( "LeftToRight()", 15000 );
}

function LeftToRight( )
{
    for ( i = 1; i < 6; i++ )
    {
        index++;
        setTimeout( "PicRotate( " + i + "," + index + ", 6 )", i * 500 );
    }
    setTimeout( "RightToLeft()", 15000 );
}        

function PicRotate( i, index, effect )
{
    var obj = $Get( "PicRotate" + i );
    var anc = $Get( "aPicLink" + i );
    var vTdImg = $Get( 'tdPicRotate' + i );
    if ( obj != null )
    {
        if ( vTdImg.filters && vTdImg.filters.length>0 )
            vTdImg.filters[ effect % 2 ].apply();
        obj.src = PicBaseUrl + MyImages[ index % MyImages.length ];
        obj.title  = MyMessages[ index % MyImages.length ];
        anc.href = BaseUrl + MyTargets[ index % MyImages.length ]
        if ( vTdImg.filters &&  vTdImg.filters.length>0 )
            vTdImg.filters[ effect % 2 ].play();
    }
}
if( typeof(PicBaseUrl) == 'string' && MyImages.length >= 5 )
    LeftToRight();
