var pagina = 'http://www.planetaras.tv/rebuild.php?video=0&fecha=inicio';
var Configuracion =
{
    Estilos:
    {
        Generico:
        {
            clip: {
                autoBuffering: true,
                autoPlay: true,
                scaling: 'fit'
            },

            play: {
                replayLabel: ''
            },

            screen: {
                bottom: 0
            },

            plugins:
            {
                controls:
                {
                    all: false,
                    play: true,
                    mute: true,
                    volume: true,
                    scrubber: true,
                    display: 'hidden',

                    //Colores de los botones
                    volumeSliderColor: '#B4B4B4',
                    sliderColor: '#B4B4B4',

                    tooltips:
                    {
                        buttons: true,
                        play: 'Reproducir Video',
                        pause: 'Parar Video',
                        mute: 'Activar Silencio',
                        unmute:	'Desactivar Silencio',
                        stop: 'Detener Video',
                        fullscreen: 'Activar modo de pantalla completa',
                        fullscreenExit: 'Desctivar modo de pantalla completa',
                        next: 'Siguiente',
                        previous: 'Anterior'
                    }
                },

                gatracker: {
                    url: "flowplayer.analytics-3.1.5.swf",
                    labels: {
                    start: "Start",
                    play: "Play",
                    pause: "Pause",
                    resume: "Resume",
                    seek: "Seek",
                    stop: "Stop",
                    finish: "Finish",
                    mute: "Mute",
                    unmute: "Unmute",
                    fullscreen: "Full Screen",
                    fullscreenexit: "Full Screen Exit"
                    },
                    debug: false,
                    trackingMode: "AS3",
                    googleId: "UA-13028866-1" // your Google Analytics id here
                },
                
                content:
                {
                    url: 'flowplayer.content-3.1.0.swf',

                    html: '<a href="#">Saltar >>></a>',
                    height: 25,
                    width: 80,

                    backgroundColor: '#112233',
                    opacity: 0.7,
                    bottom: 30,
                    right: 10,
                    borderRadius: 0,

                    //Oculto por defecto
                    display: 'none',

                    style: {
                        body: {
                            fontSize: 14,
                            fontFamily: 'Arial',
                            textAlign: 'center',
                            color: '#ffffff'
                        }
                    },

                    onClick: function(){
                        SaltarAlSiguiente();
                    }
                }
            }
        }
    }
};

function ConfigurarReproductor(SegundosPublicidad)
{
    if ($f("Reproductor").getClip(1) == null)
    {
        //Solo tenemos el video original. Sin publicidad
        ConfigurarVideo($f("Reproductor").getClip(0))
    }else{
        // Tenemos dos videos. Publicidad y orginal
        ConfigurarPublicidad($f("Reproductor").getClip(0), SegundosPublicidad) //Publicidad
        ConfigurarVideo($f("Reproductor").getClip(1)) //Original
    }

}

function ConfigurarVideo (Video)
{
     Video.onBeforeBegin(function()
    {
        //$f().getControls().enable({all: true});
        MostrarControles();
        OcultarBotonSiguiente();        
    });

    Video.onBeforeSeek(function(Clip, Tiempo)
    {
        //return ($f().getTime() > Tiempo);
        return ($f().getStatus().bufferEnd > Tiempo);
    });

    Video.onFinish(function()
    {
        document.location.href=pagina;
    });
}

function ConfigurarPublicidad (VideoPublicidad, SegundosPublicidad)
{
    VideoPublicidad.onBeforeBegin(function()
    {
        $f().setVolume(80);
        $f().getControls().hide();
    });

    VideoPublicidad.onBeforeFinish(function()
    {
        SaltarAlSiguiente();
    });

    VideoPublicidad.onBeforePause(function() {return false;});
    VideoPublicidad.onCuepoint(SegundosPublicidad * 1000, MostrarBotonSiguiente);
}

function MostrarBotonSiguiente()
{
    $f().getPlugin('content').show();
}

function OcultarBotonSiguiente()
{
    $f().getPlugin('content').hide();
}

function SaltarAlSiguiente()
{
    OcultarBotonSiguiente();
    $f().play(1);
}

function MostrarControles()
{
    //configuro que aparezca la barra
    $f().onMouseOver(function() {
       $f().getControls().fadeIn();
    });

    //configuro que aparezca la barra
    $f().onMouseOut(function() {
        $f().getControls().fadeOut();
    });
}

function OcultarControles()
{
    //configuro que aparezca la barra
    $f().onMouseOver(null);

    //configuro que aparezca la barra
    $f().onMouseOver(null);
}