

// =============================== Variables globales ================================

/**
 * Ruta hacia el reproductor flowPlayer
 * @var flowPlayerPath ( String )
 */

var flowPlayerPath = "lib/swf/flowplayer-3.1.5.swf";

/**
 * Ruta hacia la ubicación de los vídeos
 * @var flowPlayerVideoPath ( String )
 */

var flowPlayerVideoPath = "http://www.vivacemultimedia.com/videos/distform/";

/**
 * Listado de vídeos existentes
 * @var flowPlayerVideoList ( Array )
 */

var flowPlayerVideoList = new Array();

// ============================ Configuración por defecto ============================

/**
 * Cualquier característica cuyo valor no haya sido definido para el vídeo en cuestión,
 * será cargada desde los valores por defecto
 *
 * - title: título del vídeo
 * - filename: nombre del archivo asociado al vídeo ( con extensión )
 * - width: anchura del vídeo
 * - height: altura del vídeo
 * - duration: tiempo en milisegundos empleado para desplegar el vídeo
 * - scaling: formato de visualización
 * - backgroundColor: color de fondo asociado al vídeo
 * - backgroundGradient: define si el fondo del vídeo tendrá degradado
 */

flowPlayerVideoList[ -1 ] = 
{ 
 title: 'DistForm',
 filename: 'las_ideas.flv',
 width: 600,
 height: 471,
 duration: 300,
 scaling: 'fit',
 backgroundColor: '#000000',
 backgroundGradient: 'none',
 imatge:"images/videos/ideaCocina.jpg",
 visible:'true'
}

// ========================== Configuración personalizada ============================

//flowPlayerVideoList[ 0 ]  = { title: 'Ejemplos de modulares', filename: 'Ejemplos_modulares.flv', imatge:'images/videos/ejModulares.jpg', visible:'true'}
//flowPlayerVideoList[ 1 ]  = { title: 'Montaje de un fregadero', filename: 'Montaje_fregadero.flv', imatge:'images/videos/fregaderos.jpg', visible:'true' }
//flowPlayerVideoList[ 2 ]  = { title: 'Montaje de una mesa', filename: 'Montaje_mesa.flv', imatge:'images/videos/mesas.jpg', visible:'true' }
//flowPlayerVideoList[ 3 ]  = { title: 'Montaje de modulares', filename: 'Montaje_modulares.flv', imatge:'images/videos/modulares.jpg', visible:'true'}
//flowPlayerVideoList[ 1 ]  = { title: 'Distform premi cambra 2007 a la industria', filename: 'distform_premi.flv', imatge:'images/videos/.jpg', visible:'false' }
//flowPlayerVideoList[ 2 ]  = { title: 'Distform Self Service', filename: 'self_service.flv', imatge:'images/videos/self_service.jpg', visible:'true' }
//flowPlayerVideoList[ 3 ]  = { title: 'Distform TV1', filename: 'distform_tv1.flv', imatge:'images/videos/tve.jpg', visible:'true' }
//flowPlayerVideoList[ 4 ]  = { title: 'Distform', filename: 'distform_sessosb.flv', imatge:'images/videos/guerraSessos.jpg', visible:'true' }
//flowPlayerVideoList[ 5 ]  = { title: 'Hormiguero', filename: 'hormiguero.flv', imatge:'images/videos/', visible:'false' }
//flowPlayerVideoList[ 6 ]  = { title: 'Buffet distform', filename: 'Buffet_distform.flv', imatge:'images/videos/janus.jpg', visible:'true' }
//flowPlayerVideoList[ 7 ] = { title: 'Ferran Adri&agrave; en El Hormiguero', filename: 'hormiguero_270110.flv', imatge:'images/videos/ferranAdria.jpg', visible:'true' }
//flowPlayerVideoList[ 8 ] = { title: 'Las Ideas', filename: 'las_ideas.flv', width: 845, height: 600, duration: 1000 , imatge:'images/videos/ideaCocina.jpg', visible:'true'}

// ========================== Funciones de visualización ============================

/**
 * Devuelve la configuración del vídeo solicitado, aplicando los valores por defecto
 * en aquellos índices cuyo valor no haya sido especificado 
 *
 * @function flowPlayerVideoInfo
 * @param sVideoId ( String )
 * @return ( Object )
 */

function flowPlayerVideoInfo( sVideoId )
{
 var oVideoInfo = typeof( flowPlayerVideoList[ sVideoId ] ) == "object" ? flowPlayerVideoList[ sVideoId ] : new Object();

 for( var i in flowPlayerVideoList[ -1 ] )
 {
  if( typeof( oVideoInfo[ i ] ) == "undefined" )
   oVideoInfo[ i ] = flowPlayerVideoList[ -1 ][ i ];
 }
 
 return( oVideoInfo );
}

/**
 * Muestra el vídeo según el identificativo especificado
 *
 * @function flowPlayerShow
 * @param sVideoId ( String )
 * @return ( undefined )
 */

function flowPlayerShow( id ){
	  
  var effct = new fx.Height( "divVideo" , {duration: flowPlayerVideoInfo( id ).duration, onComplete: function()
   {
		var sv = document.getElementById( "showVid" );
		
		if( sv )
		{ 
		 sv.href = "javascript: flowPlayerHide( "+id+" );";
		 sv.id = "hideVid";
		}
		
   		flowPlayerInsert( id);
   }});
	effct.custom( 0 , flowPlayerVideoInfo( id ).height );
	effct.toggle();
}


/**
 * Oculta el vídeo según el identificativo especificado
 *
 * @function flowPlayerHide
 * @param sVideoId ( String )
 * @return ( undefined )
 */

function flowPlayerHide( id ){
	
	var effct = new fx.Height( "divVideo" , {duration: flowPlayerVideoInfo( id ).duration, onComplete: function()
   {
		this.el.innerHTML = '';   	
   }});
	effct.custom( flowPlayerVideoInfo( id ).width , 0 );
	effct.toggle();
	var sv = document.getElementById( "hideVid" );
	sv.href = "javascript: flowPlayerShow( "+id+");";
	sv.id = "showVid";
}


/**
 * Cambia el vídeo actual
 *
 * @function flowPlayerInsert
 * @param sVideoId ( String )
 * @return ( undefined )
 */

function flowPlayerInsert( id ){

	var oVideoInfo = flowPlayerVideoInfo( id );
	var oVideoContainer = document.getElementById( "divVideo" );
	
	if( !oVideoContainer.style.width ) 
     oVideoContainer.style.width = oVideoInfo.width + "px";

	if( !oVideoContainer.firstChild )
	{
	 oVideoContainer.appendChild( document.createElement( "a" ) );
	 oVideoContainer.firstChild.id = "video";
	}
	
	oVideoContainer.firstChild.href = flowPlayerVideoPath + oVideoInfo.filename
	
	flowplayer( "video", flowPlayerPath, 
					     { 
					      clip: { scaling: oVideoInfo.scaling },
					      canvas: { backgroundColor: oVideoInfo.backgroundColor, backgroundGradient: oVideoInfo.backgroundGradient }
					     } );	
}

