
/********************************************************************/
//** 
//* <descripcion>
//* @param <name> -> <valor>
//* ...
//* @param <name> -> <valor>
//* @return <retorno>
/********************************************************************/

    core.loadUnit("animate");
    core.loadUnit("color");
    core.loadUnit("drag");
    core.loadUnit("window");
    core.loadUnit("shadow");



 Fdata = new Object();
 Fdata['0'] = new Object();  
 Fdata['0'].logo		= 'null.gif';  
 Fdata['0'].titulo		= '';  
 Fdata['0'].imagen		= '/imagenes/null.gif';
 Fdata['0'].biografia 	= ''  
 Fdata['0'].video		= '';  
 Fdata['0'].ficha		= '';  
 Fdata['0'].descripcion		= '';  


window.focus();

HOSTNAME = window.location.hostname;
FSBASE = "carrusel";

/********************************************************************/


















/********************************************************************/
//* Funciones de control sobre el plugin de destacados
/********************************************************************/

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

var topvideoList = new Array();
var currTopvideo = 0;
var Ntop = 0;
var UserIsSliding = false;
var PLAYERISOUT = true;

var middleScreenX = 0;
var topScreenY	= 60;

var SLDTIMERID = null;
var lastcurrTopvideo = 0;


// Gestionar todos los mensajes de FSCommand de una película Flash
function preview_DoFSCommand(command, args) {
	var previewObj = isInternetExplorer ? document.all.preview : document.preview;
	document.title = "Biblioteca Básica de historia";   ///???

	switch (command)
	{
		case 'CLICKED':
			setTimeout("openTopvideo()",100);
		break;
		
		case 'CLICKACTION':
			if (args!=currTopvideo)
			{
				currTopvideo = args;
				viewInfo(0);
				if (currTopvideo!=-1)
				{
					
					setTimeout("viewInfo(1)",100);
					
					SLIDER_gotoPosIx(currTopvideo);
					SLIDER_resumeSlideshow();
				}
			}

		break;
		
		//Esta llamada desde al pelicula flash  se la pasa la lista de links de todos los objetos.
		case 'SETOBJLIST':

			lista = args.split('#');
			NSteps = lista.length/3;
			
			for (var i=0; i<NSteps; i++)
			{
				topvideoList[i] = new Object();
				topvideoList[i].title = lista[i*3];
				topvideoList[i].image = lista[i*3+1];
				topvideoList[i].link = lista[i*3+2];
				
			}
			
		break;
		
	}

}
// Ancla para Internet Explorer
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub preview_FSCommand(ByVal command, ByVal args)\n');
	document.write('Call preview_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}
//-->


/********************************************************************/



/********************************************************************/

function init()
{

	
	

	TopPreviewer = window.document["preview"];
	

	SLIDER_init();

	
	setTimeout('SLIDER_listReady()',1000);
	setTimeout("viewInfo(1)",1500);
	
	
}







function viewInfo(mode)
{

	obj = document.getElementById('info');
	if (mode==1)
		obj.style.visibility = 'visible';
	else
		obj.style.visibility = 'hidden';

ix = currTopvideo;
if ( typeof topvideoList[ix].title!='undefined') 
	document.getElementById('Ttitulo').innerHTML = topvideoList[ix].title ;

}







function openVideo(vcodcom)
{

		if (vcodcom!='0')
		{
			if (typeof Fdata[vcodcom]=='undefined' )
					document.getElementById('frmvars').contentWindow.location ="/fstreaming/genera_fstdata.php?codcom="+vcodcom;
			else
			{
					document.getElementById('FPL2_logo').innerHTML = '<img src="/imagenes/logos/' + Fdata[vcodcom].logo + '" border=0>&nbsp;&nbsp;';
					document.getElementById('FPL2_titulo').innerHTML = '"' + Fdata[vcodcom].titulolibro + '". <b>' + Fdata[vcodcom].autorlibro + '</b>';
					
					urlname = Fdata[vcodcom].ficha.indexOf('FichaElige')!=-1 ? "<br>  ver ficha del libro " : "<br> <br>  acceder al sitio ";
					
					document.getElementById('FPL2_ficha').innerHTML = 	'<a class=verficha href=# onclick=verFicha("' + vcodcom + '")>' +
					'<img src="/videos/cubiertas/' + Fdata[vcodcom].imagen + '" border=0 >' + urlname + ' <img src="/imagenes/link.gif" border=0></a>';
					document.getElementById('FPL2_bio').innerHTML = (Fdata[vcodcom].biografia!='') ? '<B>Biografía del autor</b>' + 
					'<br><div style="width:360px; height:100px; overflow:auto"  class="biografia" align=left >' + Fdata[vcodcom].biografia + '</div>' 	: '';
	
					document.getElementById('FPL2_descripcion').innerHTML = "<font class=texto><div align=right>" + Fdata[vcodcom].fecalta + "</font></div>" +
																			"<font class=texto>" + Fdata[vcodcom].descripcion  + "</font>" +
								 "" ;
	
					//embval = document.getElementById('FPL2_embeded').innerHTML;
					document.getElementById('FPL2_valEmbed').value = Fdata[vcodcom].youtube;
					document.getElementById('FPL2_valUrl').value = "http://fstreaming.anaya.es/index.html?videoid="+ vcodcom;;

					player.sendEvent('LOAD',  Fdata[vcodcom].video);
					

			}
					
		}
	
}












function openTopvideo()
{
	url = topvideoList[currTopvideo].link;
	
	vcodcom = String(url).slice(1*url.indexOf('=')+1);
	
	window.location = url;

	//document.getElementById('destacados').style.display="none";

	//setTimeout("player.sendEvent('PLAY')",100);
	
}



codcom = '0';
player = null;


function verFicha(vcodcom)
{
	url = Fdata[vcodcom].ficha;

	params = url.indexOf('FichaElige')!=-1 ? "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=820,height=1080,screenX=1,screenY=1" : "";
	window.open (url, "ficha", params );



}


function vFilter(editorial, keyword)
{

	if (typeof (keyword)=='undefined')
	{
		parent.document.getElementById('Tkey').value = "";
		parent.document.forms.sellistfull.keyword.value = "";
		
	}
	else
	{
		parent.document.forms.sellistfull.keyword.value = keyword;
		
	}

	parent.document.forms.sellistfull.editorial.value 	= unescape(editorial);
	parent.document.forms.sellistfull.config.value 	= "fstreaming/lista_video";
	
	parent.document.forms.sellistfull.submit();

}


function vByEditoriales()
{
	
	myVerticalSlide.toggle();
	if (!fEDITORIALES)	
	{
		document.getElementById('frmvars').contentWindow.location ="/fstreaming/genera_editoriales.php";	
	}
	
}
















/********************************************************************/
//* Funciones de control el deslizador
/********************************************************************/


function SLIDER_init()
{

	
	SLCONTAINER = core.getElm("Tdestacados");
	SLIDERW = String(SLCONTAINER.style.width).slice(0,-2)-50;
	SLIDERY = 58;
  

		Mslider = core.createElm(SLCONTAINER,0,SLIDERY,46,30);
      	Mslider.turnOnDrag(null,core.drag.dtCustom,0,null,SLIDER_boundH ,null);
		Mslider.setText('<img src="/imagenes/slider.gif" border=0 >');
		Mslider.setZ(8);
		Mslider.style.cursor=core.cursors.hand;
		Mslider.onmousedown = function () {SLIDER_resetSlideshow(); UserIsSliding=true; MsliderLabel.show();}
		Mslider.onmouseup = function () { UserIsSliding=false; MsliderLabel.hide(); SLIDER_resumeSlideshow();}
		Mslider.hide();
		
		
		MsliderLabel = core.createElm(SLCONTAINER,0,SLIDERY-30,46,18);
		MsliderLabel.setText('');
		MsliderLabel.style.border = "1px solid black";
		MsliderLabel.style.backgroundColor = "#FFFFE1";
		MsliderLabel.setZ(8);
		MsliderLabel.hide();

}



function SLIDER_boundH(x,y,dX,dY){

	SLIDER_resetSlideshow();

	if(x>=SLIDERW)x=SLIDERW; 
	if(x<=0)x=0;
	Mslider.moveTo(x,SLIDERY);	
  	MsliderLabel.moveTo(x,SLIDERY-30);  
	
	slidertop =  Math.floor(x * (NSteps-1) / SLIDERW);
  	MsliderLabel.setText("<div style='font-family:arial;font-size: 11px;color:black;text-align:center;vertical-align:center;'>" + (1*slidertop+1) + " / " + NSteps + "</div>");
	
	if (slidertop != currTopvideo )
		TopPreviewer.hiliteItem(slidertop);
	
	lastcurrTopvideo = slidertop;
	SLIDER_resumeSlideshow();
		
	
}


function SLIDER_gotoPosIx(ix)
{
	if ( ix<0 || ix>NSteps-1 || UserIsSliding)
		return;
		
	pospx = Math.floor(ix*(SLIDERW/(NSteps-1)));

	Mslider.glideTo( pospx,SLIDERY,2,40,1,  null);
  	MsliderLabel.setX(pospx);

	lastcurrTopvideo = ix;

}






function SLIDER_resumeSlideshow()
{
	if (SLDTIMERID!=null)
		SLIDER_resetSlideshow();
		
		
  if (!UserIsSliding)  
	SLDTIMERID = setTimeout('SLIDER_nextSlide()',5000);
	
}
	


function SLIDER_resetSlideshow()
{
	if (SLDTIMERID!=null)
		clearTimeout(SLDTIMERID);

}


function SLIDER_nextSlide()
{

	nextix = 1*lastcurrTopvideo + 1;
	
	if (nextix >= NSteps)
		nextix = 0;
	
	SLIDER_gotoPosIx(nextix);
	TopPreviewer.hiliteItem(nextix);
	


	SLIDER_resumeSlideshow();

	lastcurrTopvideo = nextix;
	
}


// Esta funcion es llamada desde el onload 
function SLIDER_listReady()
{
			
	Mslider.show();
	// Cuando la lista completa se cargue se muestra el slider y se incia el desplazamiento
	TopPreviewer.getObjectList();
	

	SLIDER_resumeSlideshow();
	

	
}