//==================================================================
// JSRTF ViewWrapper Template (Java Script Real Time Forms)
//
//
//
//
//
//
//  
//  JSRTF ViewWrapper Template (Java Script Real Time Forms)
//  © 2006 - "Lucas Fonzalida" <contacto@lucasfonzalida.com.ar>
//==================================================================


// Ultima modificación: 08/04/2007 08:13:32 p.m.


/**
* View Wrapper Class
*
*
*
* @version 1.0
* @author "Lucas Fonzalida" <contacto@lucasfonzalida.com.ar>
*/
function ViewWrapper(){

    //
    // Declaraciones de atributos
    //

    // Variables objeto
    this.fom                           = new FormObjectsManager(); // Gestionador de objetos HTML
    this.winManager                    = new WindowsManager();     // Gestionador de ventanas
    this.siteConfig                    = new SiteConfig();         // Parámetros de configuración del sitio
    this.positionFinder                = new PositionFinder();     // Helper de posicionamiento

    this.isPlayerInstalled             = false;
    
    //
    // Declaraciones de métodos
    //
    // Generales
    this.init                          = init;
    this.destroy                       = destroy;
    
    // Específicos
    // this.initRadioPlayer               = initRadioPlayer;

    /**
    * Inicializa el objeto
    *
    * @access public
    * @return void
    */
    function init(){
        // Verifica si esta instalado el objeto player
        if(player.BufferStatus){
            // Anota que el player esta instalado
            this.isPlayerInstalled = true;
            // Esta instalado, ejecuta el radioplayer.
            this.fom.setObjectVisibility("instructivo", false);  // Oculta el instructivo
            this.fom.setObjectVisibility("radioplayer", true);  // Descoculta el Radio Player
            // Inicializa el radioplayer
            init_player();
            // Ajusta el volumen del RadioPlayer
            volchange(7);
            // Agrega el item al Playlist (Utiliza variables globales declaradas e inicializadas en el HTML)
            playlist(server_host + ":" + server_port + server_rsrc);
            // Pone en estado de Play el RadioPlayer
            setTimeout(playitnow,50);
        }else{
            // No está instalado, muestra el instructivo.
            this.fom.setObjectVisibility("radioplayer", false); // Oculta el radioplayer
            this.fom.setObjectVisibility("instructivo", true);  // Desoculta el instructivo
        }
    }

    /**
    * Ejecuta tareas de destruccion del objeto
    *
    * @access public
    * @return void
    */
    function destroy(){
        // Verifica si 
        if(this.isPlayerInstalled){
            // Operación de salida del reproductor
            DeInit();
        }
    }
}



//
//
// FUNCIONES DE INICIALIZACION
//
//



/**
* Variable objeto
* Define una variable objeto global, que será utilizada en todo el formulario
* para referirse al objeto wrapper instanciado.
* NOTA: Se sugiere no cambiar el nombre de esta variable
*
* @author "Lucas Fonzalida" <contacto@lucasfonzalida.com.ar>
*/
var view = null;


/**
* Funcion de inicialización
* Instancia e inicializa el objeto wrapper correspondiente.
* Esta fuunción debe ser llamada por el evento "onload" del formulario
*
* @author "Lucas Fonzalida" <contacto@lucasfonzalida.com.ar>
*/
function init(){
    // Inicializa la variable objeto
    view = new ViewWrapper();
    view.init();
}
        
/**
* Funcion de destrucción
* Ejecuta rutinas de destruccion en el view wrapper
* Esta fuunción debe ser llamada por el evento "onunload" del formulario
*
* @author "Lucas Fonzalida" <contacto@lucasfonzalida.com.ar>
*/
function destroy(){
    // Ejecuta tareas de destrucción
    view.destroy();
}