var sp2_spotlight_current = 1;
var sp2_spotlight_interval = null;
var sp2_spotlight_interval_show = null;
var sp2_spotlight_timeout = null;
        
function sp2_spotlight_show( sp2_id, status)
{
    try
    {
        var sp_img_x = Crossbrowser.prototype.FindObj( "sp_img_" + sp2_id, document);
        var sp_info_x = Crossbrowser.prototype.FindObj( "sp_info_" + sp2_id, document);
        var sp_thumb_x = Crossbrowser.prototype.FindObj( "sp_thumb_" + sp2_id, document);

        Crossbrowser.prototype.Display( sp_img_x, status);
        Crossbrowser.prototype.Display( sp_info_x, status);
        sp_thumb_x.style.border = status ? '1px solid white' : '1px solid #e88080';
		
                    
        return true;
    }
    catch( e)
    {
        return false;
    }
}

function sp2_spotlight_swap( sp2_out_id, sp2_in_id)
{
    try
    {
        var sp_out_img_x = Crossbrowser.prototype.FindObj( "sp_img_" + sp2_out_id, document);
        var sp_out_info_x = Crossbrowser.prototype.FindObj( "sp_info_" + sp2_out_id, document);
        var sp_out_thumb_x = Crossbrowser.prototype.FindObj( "sp_thumb_" + sp2_out_id, document);

        var sp_in_img_x = Crossbrowser.prototype.FindObj( "sp_img_" + sp2_in_id, document);
        var sp_in_info_x = Crossbrowser.prototype.FindObj( "sp_info_" + sp2_in_id, document);
        var sp_in_thumb_x = Crossbrowser.prototype.FindObj( "sp_thumb_" + sp2_in_id, document);
        
        var opacity = 10;
        var swap_count = 0;

        if ( sp2_spotlight_interval_show)
            return false;

        sp2_spotlight_interval_show = setInterval(
            function( )
            {
                if ( opacity <= 0 || opacity >= 10)
                {
                    if ( swap_count == 0)
                    {
                        Crossbrowser.prototype.Display( sp_out_img_x, false);
                        Crossbrowser.prototype.Display( sp_out_info_x, false);
                        sp_out_thumb_x.style.border = '1px solid #e88080';

                        Crossbrowser.prototype.Opacity( sp_in_img_x, 0);
                        Crossbrowser.prototype.Opacity( sp_in_info_x, 0);
                        Crossbrowser.prototype.Display( sp_in_img_x, true);
                        Crossbrowser.prototype.Display( sp_in_info_x, true);

                        opacity = 1;
                        swap_count = 1;
                    }
                    else
                    {
                        Crossbrowser.prototype.Opacity( sp_in_img_x, opacity);
                        Crossbrowser.prototype.Opacity( sp_in_info_x, opacity);
                        sp_in_thumb_x.style.border = '1px solid white';
                    
                        sp2_spotlight_current = sp2_in_id;
                    
                        clearInterval( sp2_spotlight_interval_show);
                        sp2_spotlight_interval_show = null;
                    }
                }
                else
                {
                    if ( swap_count == 0)
                    {
                        Crossbrowser.prototype.Opacity( sp_out_img_x, opacity);
                        Crossbrowser.prototype.Opacity( sp_out_info_x, opacity);
                        opacity --;
                    }
                    else
                    {
                        Crossbrowser.prototype.Opacity( sp_in_img_x, opacity);
                        Crossbrowser.prototype.Opacity( sp_in_info_x, opacity);
                        opacity ++;
                    }
                }
            },
        50);

        return true;
    }
    catch( e)
    {
        return false;
    }
}

function sp2_spotlight_thumb_over( sp2_id)
{
    try
    {
        if ( sp2_id == sp2_spotlight_current)
            return true;

        var sp_thumb_x = Crossbrowser.prototype.FindObj( "sp_thumb_" + sp2_id, document);
        sp_thumb_x.style.border = '1px solid white';

        return true;
    }
    catch( e)
    {
        return false;
    }
}

function sp2_spotlight_thumb_out( sp2_id)
{
    try
    {
        if ( sp2_id == sp2_spotlight_current)
            return true;

        var sp_thumb_x = Crossbrowser.prototype.FindObj( "sp_thumb_" + sp2_id, document);
        sp_thumb_x.style.border = '1px solid #e88080';

        return true;
    }
    catch( e)
    {
        return false;
    }
}

function sp2_spotlight_thumb_click( sp2_id)
{
    try
    {
        if ( sp2_id == sp2_spotlight_current)
            return true;

        sp2_spotlight_stop( );
        sp2_spotlight_swap( sp2_spotlight_current, sp2_id);
        sp2_spotlight_rotate( );

        return true;
    }
    catch( e)
    {
        return false;
    }
}

function sp2_spotlight_reset( )
{
    try
    {
        sp2_spotlight_stop( );
        sp2_spotlight_rotate( );
    }
    catch( e)
    {
        return false;
    }
}

function sp2_spotlight_rotate( )
{
    try
    {
        var sp2_spotlight_next = null;
        
        sp2_spotlight_interval = setInterval(
            function( )
            {
                if ( sp2_spotlight_current == 10)
                    sp2_spotlight_next = 1;
                else
                    sp2_spotlight_next = sp2_spotlight_current + 1;

                sp2_spotlight_swap( sp2_spotlight_current, sp2_spotlight_next);
            }
        , 25000);
        
        return true;
    }
    catch( e)
    {
        return false;
    }
}

function sp2_spotlight_stop( )
{
    try
    {
        if ( sp2_spotlight_interval)
        {
            clearInterval( sp2_spotlight_interval);
            sp2_spotlight_interval = null;
        }
    }
    catch( e)
    {
        return false;
    }
}

function sp2_spotlight_overall_over( )
{
    try
    {
        if ( sp2_spotlight_timeout)
        {
            clearTimeout( sp2_spotlight_timeout);
            sp2_spotlight_timeout = null;
        }
    
        sp2_spotlight_stop( );
        return true;
    }
    catch( e)
    {
        return false;
    }
}

function sp2_spotlight_overall_out( )
{
    try
    {
        sp2_spotlight_timeout = setTimeout(
            function( )
            {
                clearTimeout( sp2_spotlight_timeout);
                sp2_spotlight_timeout = null;

                sp2_spotlight_rotate( );
            },
        10000
        );
        return true;
    }
    catch( e)
    {
        return false;
    }
}


