var wi = [ ];
var path = '/pic';
var delay = 5000;
var time = 5;
var alpha = 100;
var min = 0, max = 3, nr_of_pic = 0;

function Random( ile ) 
{
    var nr = null;
    nr_of_pic = ile;
    while( nr <= min || nr >= max ) 
      nr = Math.floor( Math.random( ) * max );
    for( var i = 0; i < nr_of_pic; i++ ) 
    {   
        if( nr + i > max ) nr = min - i;
        wi[ i ] = new Image( );
        wi[ i ].src = path + '/logo_' + ( nr + i + 1 ) + '.jpg';
    }   
    return 0;
}

function Hide( actual ) 
{
    document.getElementById( 'logo' ).style.filter = 'Alpha(Opacity=' + alpha + ')';
    document.getElementById( 'logo' ).style.opacity = ( alpha / 100 );
    document.getElementById( 'logo' ).style.MozOpacity = ( alpha / 100 );
    
    alpha-=2;
    
    if( alpha >= 10 ) 
        setTimeout( 'Hide( ' + actual + ' )', time );
    else 
    {   
        if( actual < nr_of_pic - 1 ) 
        actual++;
        else 
        actual = 0;
     
        document.getElementById( 'logo' ).src = wi[ actual ].src;
        Show( actual );
    }   
}

function Show( actual ) 
{
    document.getElementById( 'logo' ).style.filter = 'Alpha(Opacity=' + alpha + ')';
    document.getElementById( 'logo' ).style.opacity = ( alpha / 100 );
    document.getElementById( 'logo' ).style.MozOpacity = ( alpha / 100 );
    
    alpha+=2;

    if( alpha <= 100 )
        setTimeout( 'Show( ' + actual + ' )', time );
    else
        Draw( actual );
}

function Draw( actual )
{
    document.getElementById( 'logo' ).src = wi[ actual ].src;
    setTimeout( 'Hide( ' + actual + ' )', delay );
}



