// JavaScript Document
// Custom
var _imgHost = "http:\/\/fsi.dmmotion.com\/30\/img\/";
//var _imgHost = "img\/";
// Interface congif
var _destaDelay = 8;
var text_MoreChannels = "MÁS CANALES";
var text_Searching = "Buscando...";
var text_Results = "Resultados de la búsqueda:";
var text_NotFound = "No se encontraron resultados.";

function genSWFcode(id, width, height, file, fv, wmode, bgcolor) {
	if (typeof(fv)=="undefined") fv="";
	if (typeof(wmode)=="undefined") wmode="window";
	var h = '';
	h+= '<object id="'+id+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'"><param name=movie value="'+file+'" \/><param name=quality value=high \/><param name=menu value=false \/>';
	if (typeof(bgcolor)!="undefined") h+= '<param name="bgcolor" value="'+bgcolor+'" \/>';
	h+= '<param name="wmode" value="'+wmode+'" \/>';
	h+= '<param name=FlashVars value="'+fv+'" \/>';
	h+= '<param name="allowScriptAccess" value="always" \/><param name="allowFullScreen" value="true" \/>';
	h+= '<embed name="'+id+'" src="'+file+'" menu=false quality=high width="'+width+'" height="'+height+'" type="application\/x-shockwave-flash" pluginspace="http:\/\/www.macromedia.com\/go\/getflashplayer" wmode="'+wmode+'"';
	if (typeof(bgcolor)!="undefined") h+= ' bgcolor="'+bgcolor+'"';
	h+= ' FlashVars="'+fv+'"';
	h+= ' allowScriptAccess="always" allowFullScreen="true"><\/embed>';
	h+= '<\/object>';
	return h;
}
function showCategory(PyIndex, id) {
	var mov = "SWFselector";
	var swfObj = (navigator.appName.indexOf("Microsoft") != -1) ? window[mov] : document[mov];
	swfObj.setCanalera("MCcanales", id);
}
function getCategories(indX) {
	
	var channels = admtv.Players[indX].Content.Channels;
	var tempArray = new Array();
	var it = channels.length;
	//alert(it+ " cantidad chanels");
	for (var i = 0; i<it; i++) {
		var jt = channels[i].Categories.length;
	
		for (var j = 0; j<jt; j++) {
			tempArray.push(channels[i].Categories[j]);
		}
	}
	return tempArray;
}

function onPlayerInit(PyIndex) {
	// Inicializacion
	var player = admtv.Players[PyIndex];
	// Defino eventos
	player.onContentChange = function (evObj) {
		estasViendo(this.Index);
	}
	player.onSearchFinished = function (evObj) {
		var mov = "SWFcanalera";
		var swfObj = (navigator.appName.indexOf("Microsoft") != -1) ? window[mov] : document[mov];
		swfObj.showSearch(evObj);
	}
	// Canalera
	document.getElementById("ADM_canalera").innerHTML=genSWFcode("SWFcanalera", 354, 472, _imgHost+"canalera.swf", "PyIndex="+PyIndex+"&t_mch="+text_MoreChannels+"&t_ldn="+text_Searching+"&t_rst="+text_Results+"&t_nfv="+text_NotFound, "transparent");
	// Destacados
	document.getElementById("ADM_Destacados").innerHTML=genSWFcode("SWFdesta", 400, 65, _imgHost+"destacados.swf", "PyIndex="+PyIndex+"&destaDelay="+_destaDelay, "null");
	document.getElementById("ADM_misc").innerHTML=genSWFcode("SWFmisc", 345, 24, _imgHost+"miscelaneas.swf", null, "transparent");
	// Muestro solapas
	//document.getElementById("ADM_selectorCanalera").innerHTML=genSWFcode("SWFselector", 363, 32, _imgHost+"canaleraSelector.swf", "PyIndex="+PyIndex, "transparent");
	//Muestro swf busqueda
	//document.getElementById("ADM_Buscar").innerHTML=genSWFcode("SWFbuscar", 280, 27, _imgHost+"buscar.swf", "PyIndex="+player.Index, "transparent");
	document.getElementById("ADM_EstasViendo").innerHTML=genSWFcode("SWFestasViendo", 400, 24, _imgHost+"estasviendo.swf", "PyIndex="+PyIndex, "transparent");
}
function obtenerProgramacion(PyIndex) {
	return admtv.Players[PyIndex].Content;
}

function estasViendo(PyIndex) {	
	var player = admtv.Players[PyIndex];
	var mov = "SWFestasViendo";
	var swfObj = (navigator.appName.indexOf("Microsoft") != -1) ? window[mov] : document[mov];
	var ItemId = player.getCurrentItemInfo();
	var Item = player.getItemById(ItemId[0], ItemId[1], ItemId[2]);	
	swfObj.update(player.Content.Id, ItemId[0], ItemId[1], Item);
}

// funciones miscelaneas
function cambiarPosY(quien){
	var e =document.getElementById(quien);
 	e.style.top = '58px';
  //t=setTimeout("changeheight();",0);
}

