/*
** interfaz_publica_generica.js
** Este archivo contiene la implementacion de la interfaz publica entre el player y la plataforma
** Autor: Rodrigo Nicolás Uroz <ruroz@claxson.com>
** Fecha: 17/11/2005
** NOTA: ESTE ARCHIVO NO FUNCIONA POR SI SOLO, SINO QUE ES LEIDO POR EL ARCHIVO INTERFAZ.PHP PARA GENERAR
** LAS FUNCIONES. LEER DOCUMENTACION TECNICA
*/

/*
** VARIABLES GLOBALES
** ------------------
*/

/*
** Referencia al document donde está el player
*/
//02102006-rceles-esto se ve que es viejo
//var goPlayer = top.document.getElementById("player");

/*
** FUNCIONES PRINCIPALES
** ---------------------
*/

/*
** setPosicion
** Esta funcion setea la posicion para referenciar el player por javascript
** Recibe:
**					sPosicion		string		Posicion del player
** Devuelve:
**					Nada
*/
function setPosicion(sPosicion)
{
	//goPlayer = sPosicion;
}
/*
** player_ReproducirAlbum
** Esta funcion se encarga de reproducir un album entero
** Recibe:
**					iIdAlbum		integer		Identificador del album
** Devuelve:
**					1 si pudo reproducir, 0 otherwise
*/
function player_ReproducirAlbum(iIdAlbum,bAgregar)
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.reproducirMaterial(iIdAlbum,true,bAgregar,false);
		return reproducirMaterial(iIdAlbum,true,bAgregar,false);
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_PreviewAlbum
** Esta funcion se encarga de hacer preview de un album entero
** Recibe:
**					iIdAlbum		integer		Identificador del album
** Devuelve:
**					1 si pudo reproducir, 0 otherwise
*/
function player_PreviewAlbum(iIdAlbum,bAgregar)
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.reproducirMaterial(iIdAlbum,true,bAgregar,true);
		return reproducirMaterial(iIdAlbum,true,bAgregar,true);
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_ReproducirAlbumLocal
** Esta funcion se encarga de reproducir un album entero local
** Recibe:
**					iIdAlbum		integer		Identificador del album
** Devuelve:
**					1 si pudo reproducir, 0 otherwise
*/
function player_ReproducirAlbumLocal(iIdAlbum)
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.reproducirLocal(iIdAlbum,true);
		return reproducirLocal(iIdAlbum,true);
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_ReproducirTema
** Esta funcion se encarga de reproducir un material
** Recibe:
**					iIdMaterial		integer		Identificador del material
**					bAgregar			boolean		Indica si se debe agregar al playlist o no
** Devuelve:
**					1 si pudo reproducir, 0 otherwise
*/
function player_ReproducirTema(iIdMaterial,bAgregar)
{
	try
	{		
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.reproducirMaterial(iIdMaterial,false,bAgregar,false);
		return reproducirMaterial(iIdMaterial,false,bAgregar,false);
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_PreviewTema
** Esta funcion se encarga de hacer preview de un material
** Recibe:
**					iIdMaterial		integer		Identificador del material
**					bAgregar			boolean		Indica si se debe agregar al playlist o no
** Devuelve:
**					1 si pudo reproducir, 0 otherwise
*/
function player_PreviewTema(iIdMaterial,bAgregar)
{
	try
	{		
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.reproducirMaterial(iIdMaterial,false,bAgregar,true);
		return reproducirMaterial(iIdMaterial,false,bAgregar,true);
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_ReproducirTemaLocal
** Esta funcion se encarga de reproducir un material local
** Recibe:
**					iIdMaterial		integer		Identificador del material
**					bGrupo				boolean		Indica si se va a reproducir una tanda
**					bPrimero			boolean		Indica si es el primer tema de la tanda
** Devuelve:
**					1 si pudo reproducir, 0 otherwise
*/
function player_ReproducirTemaLocalDump(iIdMaterial,bGrupo,bPrimero)
{
	try
	{		
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.reproducirLocal(iIdMaterial,false,bGrupo,bPrimero);
		return reproducirLocal(iIdMaterial,false,bGrupo,bPrimero);
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_ReproducirTemaLocal
** Esta funcion se encarga de reproducir un material local
** Recibe:
**					iIdMaterial		integer		Identificador del material
** Devuelve:
**					1 si pudo reproducir, 0 otherwise
*/
function player_ReproducirTemaLocal(iIdMaterial)
{
	try
	{		
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.reproducirLocal(iIdMaterial,false,false,false);
		return reproducirLocal(iIdMaterial,false,false,false);
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_Anterior
** Esta funcion se encarga de llamar al metodo de material anterior del player
** Recibe:
**					Nada
** Devuelve:
**					1 si pudo cambiar, 0 otherwise
*/
function player_Anterior()
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.materialAnterior();
		return materialAnterior();
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_Siguiente
** Esta funcion se encarga de llamar al metodo de material siguiente del player
** Recibe:
**					Nada
** Devuelve:
**					1 si pudo cambiar, 0 otherwise
*/
function player_Siguiente()
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.materialSiguiente();
		return materialSiguiente();
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_Stop
** Esta funcion se encarga de llamar al metodo de detener del player
** Recibe:
**					Nada
** Devuelve:
**					1 si pudo detener, 0 otherwise
*/
function player_Stop()
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.detener();
		return detener();
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_Pause
** Esta funcion se encarga de llamar al metodo de pausar del player
** Recibe:
**					Nada
** Devuelve:
**					1 si pudo pausar, 0 otherwise
*/
function player_Pause()
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.pausar();
		return pausar();
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_Play
** Esta funcion se encarga de llamar al metodo de reproducir del player
** Recibe:
**					Nada
** Devuelve:
**					1 si pudo reproducir, 0 otherwise
*/
function player_Play()
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.play();
		return play();
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_Retroceso
** Esta funcion se encarga de llamar al metodo de rebobinar del player
** Recibe:
**					Nada
** Devuelve:
**					1 si pudo rebobinar, 0 otherwise
*/
function player_Retroceso()
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.rebobinar();
		return rebobinar();
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_FForward
** Esta funcion se encarga de llamar al metodo de avance rapido del player
** Recibe:
**					Nada
** Devuelve:
**					1 si pudo avanzar, 0 otherwise
*/
function player_FForward()
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.avanzar();
		return avanzar();
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_CambiarPosicion
** Esta funcion se encarga de llamar al metodo de cambiar posicion del player
** Recibe:
**					iSegundos		integer		Posicion en segundos en donde se quiere ubicar
** Devuelve:
**					1 si pudo cambiar, 0 otherwise
*/
function player_CambiarPosicion(iSegundos)
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.cambiarPosicion(iSegundos);
		return cambiarPosicion(iSegundos);
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_Ocultar
** Esta funcion se encarga de llamar al metodo de ocultar del player
** Recibe:
**					Nada
** Devuelve:
**					1 si pudo ocultar, 0 otherwise
*/
function player_Ocultar()
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.ocultarPlayer();
		return ocultarPlayer();
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_Mostrar
** Esta funcion se encarga de llamar al metodo de mostrar del player
** Recibe:
**					Nada
** Devuelve:
**					1 si pudo mostrar, 0 otherwise
*/
function player_Mostrar()
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.mostrarPlayer();
		return mostrarPlayer();
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_AbrirPlaylistManager
** Esta funcion se encarga de llamar al metodo de abrir el playlist manager
** Recibe:
**					Nada
** Devuelve:
**					1 si pudo abrir, 0 otherwise
*/
function player_AbrirPlaylistManager()
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.abrirPlaylistManager();
		return abrirPlaylistManager();
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_ShufflePlaylist
** Esta funcion se encarga de llamar al metodo de shuffle de la playlist
** Recibe:
**					Nada
** Devuelve:
**					1 si pudo cambiar, 0 otherwise
*/
function player_ShufflePlaylist()
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.shuffle();
		return shuffle();
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_RepeatPlaylist
** Esta funcion se encarga de llamar al metodo de repeat de la playlist
** Recibe:
**					Nada
** Devuelve:
**					1 si pudo cambiar, 0 otherwise
*/
function player_RepeatPlaylist()
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.repeat();
		return repeat();
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_ObtenerPlaylist
** Esta funcion se encarga de llamar al metodo de obtener playlist de la playlist
** Recibe:
**					Nada
** Devuelve:
**					string		XML con los datos de la playlist pedida
*/
function player_ObtenerPlaylist()
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.obtenerPlaylist();
		return obtenerPlaylist();
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_CargarPlaylist
** Esta funcion se encarga de llamar al metodo de cargar playlist de la playlist
** Recibe:
**					iIdPlaylist		integer		Identificador de la playlist
** Devuelve:
**					1 si pudo cargar, 0 otherwise
*/
function player_CargarPlaylist(iIdPlaylist)
{
	try
	{
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.cargarPlaylist(iIdPlaylist);
		return cargarPlaylist(iIdPlaylist);
	}
	catch(e)
	{
		return 0;
	}
}
/*
** player_EstaAbierto
** Esta funcion indica si el player esta abierto o no
** Recibe:
**					Nada
** Devuelve:
**					true si esta abierto, false otherwise
*/
function player_EstaAbierto()
{
	try
	{		
		//02102006-rceles-esto se ve que es viejo
//		return goPlayer.gbVisible;
		return gbVisible;
	}
	catch(e)
	{
		return false;
	}
}
/*
** player_CambiarEstado
** Esta funcion cambia el estado del player entre Show o Hidden
** Recibe:
**					Nada
** Devuelve:
**					
*/
function player_CambiarEstado() {
	if (player_EstaAbierto()) {
		player_Ocultar();
	} else {
		player_Mostrar();
	}
}