/* ----------------------------------------------------------------
	APP BROWSER
	JS -> FOLDERS
-------------------------------------------------------------------*/

var idInstalacion;

var var_tipo_contenido=false;

var browserOrden='ULT';

var nodo_ant=0;

nodo = new Array(1);

nodo.push(0);

nodoTxt = new Array(1);

nodoTxt.push("<span ONCLICK='video();'  style='cursor:pointer;'></span>");

var flagHijo=0;

var nodoAct=0;

var textoUlt;

var textoMas;

var tipoAudio;
var tipoVideo;


var textoBusqueda;

var msg_idioma=new Array();

var MENSAJE_NOENCONTRARON;

var textomi;

execCarpetaComunHabilitada=true;

function verVariables(){
	var tmp;
	
	tmp  = "nodo_ant:"+nodo_ant+"\n";
	tmp += "nodoAct:"+nodoAct+"\n";
	tmp += "flagHijo:"+flagHijo+"\n";
	tmp += "textoUlt:"+textoUlt+"\n";
	
	tmp += "tipoAudio:"+tipoAudio+"\n";
	tmp += "tipoVideo:"+tipoVideo+"\n";
	
	tmp += "textoMas:"+textoMas+"\n------------------\n";

	alert(tmp);
}

function refreshBrowser(){
	//buscando el elemento activo del arbolMod
	var tmpParametros = '';
	var tags = document.getElementById('nav').getElementsByTagName('li');
	for (var i=tags.length-1;i>=0;i--){
		if(tags[i].className.indexOf('_selected',0)!=-1){
			tags = tags[i].id;
			tags = tags.split("item");
			tmpParametros = "&parametro="+tags[1];
			break;
		}
	}
		
	var respuesta = FWK.loadApi("browser|browser|browser|principal","carpetas","&cmd=refreshBrowser"+tmpParametros);
	
	if(respuesta){

		if(window.debugBrowserAct) alert("refreshBrowser1 nodoTxt.length:"+nodoTxt.length+", nodoTxt:"+nodoTxt);
		if(window.debugBrowserAct) alert("refreshBrowser1 nodo.length:"+nodo.length+", nodo:"+nodo);
		nodoTxt.length=2;
		nodo.length=2;
		flagHijo=0;
		execCarpetaComunHabilitada=0;
		carpetaCero(true);
		execCarpetaComunHabilitada=1;
		if(window.debugBrowserAct) alert("refreshBrowser2 nodoTxt.length:"+nodoTxt.length+", nodoTxt:"+nodoTxt);
		if(window.debugBrowserAct) alert("refreshBrowser2 nodo.length:"+nodo.length+", nodo:"+nodo);

		var arrComando = respuesta.split('#|#');
		for(var i=0;i<arrComando.length;i++){
				execHijos(arrComando[i],arrComando.length-1,i,(i<arrComando.length-1)?arrComando[i+1]:undefined);
			//alert("temporizador...");
		}
	}else{
		nodoTxt.length=2;
		nodo.length=2;
		flagHijo=0;
		execCarpetaComunHabilitada=0;
		carpetaCero();
		execCarpetaComunHabilitada=1;
		//alert("No hubo respuesta del API");
	}
	execCarpetaComunHabilitada=true; //por las dudas...
}

function execHijos (comando, ultimo,posicion,siguiente){
	var arrParams = comando.split("\t");
	var arrParamsSiguiente;
	var llamarAPI=false;
    var siguienteSinHijos=0;
	if(siguiente){
			arrParamsSiguiente = siguiente.split("\t");
			if(arrParamsSiguiente[3] != '1') {
				siguienteSinHijos=1;
			}
	}
	if(ultimo==posicion){
		execCarpetaComunHabilitada=true;
	}else{
		execCarpetaComunHabilitada=false;
	}
	if(ultimo==posicion||siguienteSinHijos){
		llamarAPI=true;
	}
	//arrParams [3] indica si tiene o no Hijos
	if (arrParams[3] == '1') {
		if(window.debugBrowserAct) alert('Llamo a Hijo('+arrParams[0]+','+arrParams[1]+','+arrParams[2]+','+arrParams[3]+','+llamarAPI+')');
		hijo(arrParams[0],arrParams[1],arrParams[2],arrParams[3],llamarAPI);
	}else{
		if(window.debugBrowserAct) alert('Llamo a sinHijo('+arrParams[0]+','+arrParams[1]+','+arrParams[2]+','+arrParams[3]+','+llamarAPI+')');
		sinHijo(arrParams[0],arrParams[1],arrParams[2],arrParams[3]);
	}
}

/*---------------------------------------------------*/
// Llama a cargar la pantalla por primera vez t se autocarga
function carpetaCero(llamarApi)
{
	if(llamarApi)
		document.getElementById("carpetas").innerHTML=FWK.loadApi("browser|browser|browser|principal","carpetas","");
	else
		FWK.loadApiInto("carpetas","browser|browser|browser|principal","carpetas","");
}

/*---------------------------------------------------*/
// Carga la cinta
function carpetaComun(id_instalacion,id_nodo,refreshCinta,tipo_cont){
	if(!execCarpetaComunHabilitada) refreshCinta=1; //cuando se hace refreshBrowser solo le tenemos que dar bola al ultimo para cargar de ese unicamente la cinta
	tc=(browserOrden=='MASV')?tipo_cont:null;
	inodo=(id_nodo!=0)?id_nodo:null;
    
	//tipo_cont=(typeof tipo_cont=="undefined")?null:tipo_cont;
    if(!tipo_cont && var_tipo_contenido) tipo_cont=var_tipo_contenido;
    else var_tipo_contenido=tipo_cont;
    
	if (!id_nodo){
		id_nodo=0;
	}

	//alert("carpetaComun:\n\n ID_INSTALACION:"+id_instalacion+"\n\n ID_NODO:"+id_nodo+"\n\n REFRESH CINTA:"+refreshCinta+"\n\n TIPO_CONT:"+tc+"\n\n BROWSER ORDEN:"+browserOrden+"\n\n IDIOMA:"+idIdioma);
	
	switch(id_instalacion){
		case 8120:
		case 3:
			tipo = tipoAudio;
			break;
		default:
			tipo = tipoVideo;
			break;
	
	}
	//if (browserOrden=="MASV" || browserOrden=="MASE") browserOrden="MAS";
	//Autor: Hugo (lo de arriba es lo que estaba antes)
	//El siguiente cod. es para "MAS"(?), "MASV"(mas visto), "MAE"(mas escuchado), etc...
	var TMP_browserOrden;
	if(browserOrden.indexOf('MAS', 0)!=-1) TMP_browserOrden='MAS';
	
	//hugo
	//alert('id_instalacion:'+id_instalacion+'\nid_nodo:'+id_nodo+'\ntipo_cont: '+tipo_cont+'\nrefreshCinta:'+refreshCinta+'\nHugo ^_^');
	if(id_instalacion==3)	tipo_cont=null;
	//alert("instalacion:"+id_instalacion+"\nidnodo:"+id_nodo+"\ntipo_cont:"+tipo_cont+"\ncountrycode:"+countrycode+"\ntipo_consulta:"+browserOrden);
	aParametros={
					p_id_instalacion : id_instalacion,
					p_id_nodo : (id_nodo!=0)?id_nodo:null,
					p_id_genero : null,
					p_id_fuente : null,
					n_id_tipo_cont : tipo_cont,/*1*/
					p_id_formato : null,
					p_id_grupo_wg : null,
					p_id_reprod : null,
					p_adulto : null,
					p_estado : 'ACT',
					p_countrycode : countrycode,
					p_idioma : idIdioma,
					p_idioma_padre : idIdiomaPadre,
					p_idioma_default : idIdiomaDefault,
					p_camp_grp_orden : null,
					p_tipo_orden : null,
					p_tipo_consulta : TMP_browserOrden,
					desde_row : 0,
					cant_row : 12
				};

	idInstalacion = id_instalacion;

	if (refreshCinta!=1){
		//browserCinta.debug=true;
		
		if(id_instalacion==3 || id_instalacion==8120 || id_instalacion==8109 || id_instalacion==8113 || id_instalacion==8119 || id_instalacion==8116 || id_instalacion==8111  || id_instalacion==8107)
		{
			browserCinta.setCinta('PACK_LISTADOS','PR_LISTADOR_GENERICO',aParametros);
		}
		else
		{
			browserCinta.setCinta('PACK_LISTADOS','PR_LISTADOR_GENERICO_VH',aParametros);	
		}

		//------------------------------------PARA MANEJO DE PATH-------------------
		//alert("PASE! ["+PATH+"]");
		if(typeof(PATH)!="undefined") 
		{
			//alert("NODO="+aParametros.p_id_nodo);
			if(aParametros.p_id_nodo!=null)
			{
				li=document.getElementById("item"+aParametros.p_id_nodo);
				//alert("ENTRE! ::: "+li.outerHTML);
				if(li!=null)
				{
					a=li.getElementsByTagName("A")[0];	
					//alert("ENTRE! ::: "+a.outerHTML);
					a.click();
				}
			}
		}
		//------------------------------------PARA MANEJO DE PATH-------------------

		//browserCinta.setCinta('PACK_LISTADOS','PR_LISTADOR_GENERICO_VH',aParametros);
		
	}

	if (id_nodo){
		marcaSeleccion(id_nodo);
	}
		
	estadoClass();
}//end func


/*---------------------------------------------------*/
function raiz()
{
	FWK.loadApiInto("carpetas","browser|browser|browser|principal","carpetas","");
}//end func


/*---------------------------------------------------*/
// Carga en la pila los datos del nodo y hace ls llamada
// para cargar los datos de la cinta
function hijo(dato,anterior,nodoPath,mismoNivel,llamarAPI)
{
	if(typeof llamarAPI=="undefined"){
		llamarAPI=true;
	}else{
		if(llamarAPI)
			llamarAPI="sincronico";	
	}

	if (flagHijo==1){
	 	nodo.pop();
		nodoTextoDel();
	}
 	flagHijo=0;
 	nodo.push(dato);
 	ultimo = nodo.length-1;
 	parametro="&nodoPadre="+dato+"&anterior="+anterior+"&subir=0";
	nodo_ant=dato;
	if(llamarAPI){
		if(llamarAPI=="sincronico"){
			document.getElementById("carpetas").innerHTML=FWK.loadApi("browser|browser|browser|principal","carpetas","&cmd=setHijos"+parametro);
		}else{
			FWK.loadApiInto("carpetas","browser|browser|browser|principal","carpetas","&cmd=setHijos"+parametro);

		}
	}
	nodoTextoAdd(nodoPath,dato);

 	
}//end func


/*---------------------------------------------------*/
// Carga en la pila los datos del nodo y hace ls llamada
// para cargar los datos de la cinta para el caso
// que el nodo no tenga mas nodos dependientes
function sinHijo(dato,anterior,nodoPath,mismoNivel){


 	ultimo = nodo.length;

	nodo.push(dato);
	if (flagHijo==1){
	 	nodo.pop();
		nodoTextoDel();
	}
	nodoTextoAdd(nodoPath,dato);
	carpetaComun(idInstalacion,dato);
	flagHijo=1;
	nodo_ant=dato;
	nodoAct=dato;
}//end func



/*--------------------------------
		REGRESA al nodo anterior
-----------------------------------*/
function anterior(superior, llamarAPI)
{
	//alert("Anterior()");
	if(typeof llamarAPI=="undefined"){
		llamarAPI=true;
	}else{
		if(llamarAPI)
			llamarAPI="sincronico";
	}
	if(window.debugBrowserAct) alert("anterior llama a anterior 1");
 	if (nodo.length > 2){
		if(window.debugBrowserAct) alert("anterior llama a anterior2 flagHijo="+flagHijo);
		if (flagHijo==1){
			nodo.pop();
			nodoTextoDel();
		}
		flagHijo=0;
 		nodo.pop();
 		ultimo = nodo.length-1;
 		nodoTextoDel();
 		parametro="&nodoPadre=0&anterior="+nodo[ultimo]+"&subir=1";

		if(llamarAPI){
			if(llamarAPI=="sincronico"){
				document.getElementById("carpetas").innerHTML=FWK.loadApi("browser|browser|browser|principal","carpetas","&cmd=setHijos"+parametro);
			}else{
				FWK.loadApiInto("carpetas","browser|browser|browser|principal","carpetas","&cmd=setHijos"+parametro);
			}
		}
 	} else {
		if(llamarAPI){
			if(llamarAPI=="sincronico"){
				document.getElementById("carpetas").innerHTML=FWK.loadApi("browser|browser|browser|principal","carpetas","");
			}else{
				FWK.loadApiInto("carpetas","browser|browser|browser|principal","carpetas","");
			}
		}
	}
}//end func

/*---------------------------------------------------*/
// Setea el estado de tipo de consulta
function browserSetOrden(parametrOrden){
	browserOrden=parametrOrden;
}//end func

/*---------------------------------------------------*/
function browserLoMasVisto(dato){
	browserSetOrden('MASV');
	if (document.getElementById("lomasnuevo"))
		document.getElementById("lomasnuevo").className="";
	if	(document.getElementById("lomasvisto"))
		document.getElementById("lomasvisto").className="activo";
	if (document.getElementById("lomasescuchado"))
		document.getElementById("lomasescuchado").className="";
	if (document.getElementById("descarga"))
		document.getElementById("descarga").className="";
	//document.getElementById("mdescarga").className="";
	
	if (flagHijo==1){
		dato=nodoAct;
		carpetaComun(idInstalacion,dato,0,0);
	} else {
	 	parametro="&nodoPadre="+dato+"&anterior=0&subir=0&tipo_cont=2";
		FWK.loadApiInto("carpetas","browser|browser|browser|principal","carpetas","&cmd=setHijos"+parametro);
		estadoClass();
	}
	
}//end func


/*---------------------------------------------------*/
function browserLoMasEscuchado(dato){
	browserSetOrden('MASE');
	if (document.getElementById("lomasnuevo"))
		document.getElementById("lomasnuevo").className="";
	if	(document.getElementById("lomasvisto"))
		document.getElementById("lomasvisto").className="";
	if (document.getElementById("lomasescuchado"))
		document.getElementById("lomasescuchado").className="activo";
	if (document.getElementById("descarga"))
		document.getElementById("descarga").className="";
	//document.getElementById("mdescarga").className="";
	if (flagHijo==1){
		dato=nodoAct;
		carpetaComun(idInstalacion,dato,0,0);
	} else {
		parametro="&nodoPadre="+dato+"&anterior=0&subir=0&tipo_cont=1";
		FWK.loadApiInto("carpetas","browser|browser|browser|principal","carpetas","&cmd=setHijos"+parametro);
		estadoClass();
	}
	
}//end func



/*---------------------------------------------------*/
// setea para que el tipo de consulta sea por los mas nuevos
function browserDeLoUltimo(dato){
	browserSetOrden('ULT');
	if (document.getElementById("lomasnuevo"))
		document.getElementById("lomasnuevo").className="activo";
	if (document.getElementById("lomasescuchado"))
		document.getElementById("lomasescuchado").className="";
	if (document.getElementById("lomasvisto"))
		document.getElementById("lomasvisto").className="";
	if (document.getElementById("descarga"))
		document.getElementById("descarga").className="";
	//document.getElementById("mdescarga").className="";
	if (flagHijo==1){
		dato=nodoAct;
		carpetaComun(idInstalacion,dato,0,0);
	} else {
	 	parametro="&nodoPadre="+dato+"&anterior=0&subir=0";
		FWK.loadApiInto("carpetas","browser|browser|browser|principal","carpetas","&cmd=setHijos"+parametro);
	}
}//end func


/*setea para mostrar los mas vistos*/
function browserLoMasVistoB(dato,accion){
 	pathLinkPorArbol(accion);
	browserSetOrden('MASV');
	parametro="&nodoPadre="+dato+"&anterior=0&subir=0&tipo_cont=2";
	FWK.loadApiInto("carpetas","browser|browser|browser|principal","carpetas","&cmd=setHijos"+parametro);

}//end func

/*setea para mostrar los mas vistos*/
function browserLoMasEscuchadoB(dato,accion){
 	pathLinkPorArbol(accion);
	browserSetOrden('MASE');
	parametro="&nodoPadre="+dato+"&anterior=0&subir=0&tipo_cont=1";
	FWK.loadApiInto("carpetas","browser|browser|browser|principal","carpetas","&cmd=setHijos"+parametro);

}//end func


/*---------------------------------------------------*/
// setea para que el tipo de consulta sea por los mas nuevos
function browserDeLoUltimoB(dato,accion){
	pathLinkPorArbol(accion);
	browserSetOrden('ULT');
	parametro="&nodoPadre="+dato+"&anterior=0&subir=0";
	FWK.loadApiInto("carpetas","browser|browser|browser|principal","carpetas","&cmd=setHijos"+parametro);

}//end func

function pathLinkPorArbol(accion){
	switch(idInstalacion)
	{
		case 8120:
		case 3:
			tipo = tipoAudio;
			break;
		default:
			tipo = tipoVideo;
			break;
	
	}
	
	textoOut="<span ONCLICK='video();'  style='cursor:pointer;'>"+tipo+"</span>";
	catalogoPath.innerHTML = textoOut+" / "+"<SPAN class='link'> "+accion+"</SPAN>";
}


/*---------------------------------------------------*/
// setea para que el tipo de consulta sea por los mas vistos
function estadoClass(){
	
	if (browserOrden=="ULT"){
	 	if (document.getElementById("lomasnuevo"))
			document.getElementById("lomasnuevo").className="activo";
		if (document.getElementById("lomasvisto"))
			document.getElementById("lomasvisto").className="";
		if (document.getElementById("lomasescuchado"))
			document.getElementById("lomasescuchado").className="";
		if (document.getElementById("descarga"))
			document.getElementById("descarga").className="";
	}
	if (browserOrden=="MASV"){
	 	if (document.getElementById("lomasnuevo"))
			document.getElementById("lomasnuevo").className="";
		if (document.getElementById("descarga"))
			document.getElementById("descarga").className="";
		if (document.getElementById("lomasescuchado"))
			document.getElementById("lomasescuchado").className="";
		if (document.getElementById("lomasvisto"))
			document.getElementById("lomasvisto").className="activo";
	}
	if (browserOrden=="MASE"){
	 	if (document.getElementById("lomasnuevo"))
			document.getElementById("lomasnuevo").className="";
		if (document.getElementById("descarga"))
			document.getElementById("descarga").className="";
		if (document.getElementById("lomasescuchado"))
			document.getElementById("lomasescuchado").className="activo";
		if (document.getElementById("lomasvisto"))
			document.getElementById("lomasvisto").className="";
	}
}//end func

/*---------------------------------------------------*/
// setea CSS para descarga
function descarga(textomiin){
	if (document.getElementById("lomasnuevo"))
 		document.getElementById("lomasnuevo").className="";
 	if (document.getElementById("lomasvisto"))
		document.getElementById("lomasvisto").className="";
	if (document.getElementById("lomasescuchado"))
		document.getElementById("lomasescuchado").className="";
	if (document.getElementById("descarga"))
		document.getElementById("descarga").className="activo";
	if (document.getElementById("mdescarga"))
		document.getElementById("mdescarga").className="";
	if (getStatusUsuario() != "logueado"){
        mostrarLogin(false,descarga);
        return;
    }
	mostrarPlayer();
	downloads=1;
	switch(idInstalacion)
	{
		case 8120:
		case 3:
			tipo = tipoAudio;
			break;
		default:
			tipo = tipoVideo;
			break;
	
	}
	textoOut="<span ONCLICK='video();'  style='cursor:pointer;'>"+tipo+"</span>";
	catalogoPath.innerHTML = textoOut+" / "+"<SPAN class='link'> " + descargatxt + "</SPAN>";
	//alert("FN descarga");
	// Llama al JS de Pablo
	browseDownloader('downloader');

}//end func

function mdescarga(textomiin){
	if (document.getElementById("lomasnuevo"))
 		document.getElementById("lomasnuevo").className="";
 	if (document.getElementById("lomasvisto"))
		document.getElementById("lomasvisto").className="";
	if (document.getElementById("lomasescuchado"))
		document.getElementById("lomasescuchado").className="";
	if (document.getElementById("descarga"))
		document.getElementById("descarga").className="";
	if (document.getElementById("mdescarga"))
		document.getElementById("mdescarga").className="activo";
	if (getStatusUsuario() != "logueado"){
        mostrarLogin(false,mdescarga);
        return;
    }
    mostrarPlayer();
    downloads=2;
    textoOut = "";
	
	switch(idInstalacion)
	{
		case 8120:
		case 3:
			tipo = tipoAudio;
			break;
		default:
			tipo = tipoVideo;
			break;
	
	}
	textoOut="<span ONCLICK='video();'  style='cursor:pointer;'>"+tipo+"</span>";
	catalogoPath.innerHTML = textoOut+" / "+"<SPAN class='link'> " + mdescargatxt + "</SPAN>";
	//alert("FN mdescarga");

	// Llama al JS de Pablo
	browseDescargas();

}//end func




/*-------------------------------------------
Manejo de textos de PATH
Agrega un dato a la pila
----------------------------------------------*/

function nodoTextoAdd(texto,id_nodo){

 		nodoAct = id_nodo;
		agrega=0;
		if(window.debugBrowserAct) alert("nodoTextoAdd "+nodoTxt+";"+texto+";"+id_nodo);
		for (x=0;x<=nodoTxt.length-1; x++){
	 		if (nodoTxt[x]==texto){
				agrega=1;
			}
	 	}

	 	if (agrega==0){
			nodoTxt.push("<SPAN class='link' ONCLICK='pathLinkCarpeta("+id_nodo+");' style='cursor:pointer;'>/ "+texto+"</SPAN>");
		}

		switch(idInstalacion)
		{
		case 8120:
			case 3:
				tipo = tipoAudio;
				break;
			default:
				tipo = tipoVideo;
				break;
		
		}
		textoOut="<span ONCLICK='video();'  style='cursor:pointer;'>"+tipo+"</span>";
		
		for (i=2;i<=nodoTxt.length-1; i++){
			textoOut += "<SPAN class='link'> "+nodoTxt[i]+"</SPAN>";
		}
		if(window.debugBrowserAct) alert("nodoTextoAdd: "+textoOut);
		catalogoPath.innerHTML = textoOut;

}//end func


/*--------------------------------
BORRAR el texto de un PATH
quita un dato de la pila
---------------------------------*/

function nodoTextoDel(){
	if(window.debugBrowserAct) alert("nodoTextoDel 1");
 	nodoTxt.pop();
	switch(idInstalacion)
	{
		case 8120:
		case 3:
			tipo = tipoAudio;
			break;
		default:
			tipo = tipoVideo;
			break;
	
	}
	textoOut="<span ONCLICK='video();'  style='cursor:pointer;'>"+tipo+"</span>";
	
 	for (i=2;i<=nodoTxt.length-1; i++){
		textoOut += "<SPAN class='link'> "+nodoTxt[i]+"</SPAN>";
	}
	catalogoPath.innerHTML = textoOut;
}//end func

/*-----------------------------------
PATH LINK
Arma el path
-----------------------------------*/
function pathLinkCarpeta(id_nodo){

		while(nodo[nodo.length-1]!=id_nodo) {
			nodo.pop();
			nodoTxt.pop();
		}
		switch(idInstalacion)
		{
			case 8120:
			case 3:
				tipo = tipoAudio;
				break;
			default:
				tipo = tipoVideo;
				break;
		
		}
	
		textoOut="<span ONCLICK='video();'  style='cursor:pointer;'>"+tipo+"</span>";
		for (i=2;i<=nodo.length-1; i++){
			textoOut += "<SPAN class='link'> "+nodoTxt[i]+"</SPAN>";
		}

		catalogoPath.innerHTML = textoOut;

		parametro="&nodoPadre=0&anterior="+id_nodo+"&subir=1";
		FWK.loadApiInto("carpetas","browser|browser|browser|principal","carpetas","&cmd=setHijos"+parametro);
}//end func

/*---------------------------------------------------*/
// Arma el path para un dato del buscador
function pathLinkCarpetaBusqueda(texto){

 	textoBusqueda = texto;
 	id_nodo=0;
	while(nodo[nodo.length-1]!=id_nodo) {
		nodo.pop();
		nodoTxt.pop();
	}
		switch(idInstalacion)
		{
			case 8120:
			case 3:
				tipo = tipoAudio;
				break;
			default:
				tipo = tipoVideo;
				break;
		
		}
	textoOut="<span ONCLICK='video();'  style='cursor:pointer;'>"+tipo+"</span>";
	for (i=2;i<=nodo.length-1; i++){
		textoOut += "<SPAN class='link'> "+nodoTxt[i]+"</SPAN>";
	}
	catalogoPath.innerHTML = textoOut+" "+msg_idioma[0]+" "+texto;
	parametro="&nodoPadre=0&anterior="+id_nodo+"&subir=1&refreshCinta=1";
	FWK.loadApiInto("carpetas","browser|browser|browser|principal","carpetas","&cmd=setHijos"+parametro);
}//end func

/*---------------------------------------------------*/
// Imprime el cartel para un EOF de la busqueda
// Atencion !!!
// Para que salgan los carteles deben estar puestos en el XSL (cinta_dump.xsl)
//
//
function nodoTextoAddNoResult()
{
	browserCinta.setTotales(0);

	if(document.getElementById("browser_noseencontraron")){
		MENSAJE_NOENCONTRARON=document.getElementById("browser_noseencontraron").innerHTML;
		nodoTextoAddSimple(document.getElementById("browser_noseencontraron").innerHTML);
  	}else{
  		if(MENSAJE_NOENCONTRARON){
  			nodoTextoAddSimple(MENSAJE_NOENCONTRARON);
  		}else{
  			//alert ("DENTRO DEL IF");
  			//nodoTextoAddSimple('No se encontraron resultados');
  		}
	}

}//end func

/*---------------------------------------------------*/
// Arma el path para un dato del buscador
function nodoTextoAddSimple(texto)
{
	switch(idInstalacion)
		{
			case 8120:
			case 3:
				tipo = tipoAudio;
				break;
			default:
				tipo = tipoVideo;
				break;
		
		}
	textoOut="<span ONCLICK='video();'  style='cursor:pointer;'>"+tipo+"</span> ";

	if(document.getElementById('catalogoPath').innerText.length > 30)
	{
		document.getElementById('catalogoPath').innerHTML = textoOut +
			" <SPAN class='link'>/ " + texto.substring(0,30) + "...</SPAN>";
	}
	else
	{
		//alert("Texto: " + texto);
		if (downloads==1){
			//alert("downloads 1");
			textoOut += "<SPAN class='link'>/ " + descargatxt + "</SPAN>";
			downloads=0;
		}
		if (downloads==2){
			//alert("downloads 2");
			textoOut += "<SPAN class='link'>/ " + mdescargatxt + "</SPAN>";
			downloads=0;
		}
		//alert("textoOut: "+textoOut);
		document.getElementById('catalogoPath').innerHTML = textoOut + " <SPAN class='link'>/ "+texto+ "</SPAN>";

	}
}//end func

/*---------------------------------------------------*/
// setea el CSS para caso de ultimo nivel del arbol
function marcaSeleccion(id_nodo){
	try{
	 	document.getElementById("id_nodo_"+nodo_ant).className="";
	} catch(e){}
	try{
		document.getElementById("id_nodo_"+id_nodo).className="over";
	} catch(e){}
} // end func



function video(){
 	nodoAct=0;
 	flagHijo=0;
 	while(nodo[nodo.length-1]!=nodoAct) {
		nodo.pop();
		nodoTxt.pop();
	}
		switch(idInstalacion)
		{
			case 8120:
			case 3:
				tipo = tipoAudio;
				break;
			default:
				tipo = tipoVideo;
				break;
		
		}
	textoOut="<span ONCLICK='video();'  style='cursor:pointer;'>"+tipo+"</span>";
	//alert ("video - textoOut: "+ textoOut);
	for (i=2;i<=nodo.length-1; i++){
		textoOut += "<SPAN class='link'> "+nodoTxt[i]+"</SPAN>";
	}
	catalogoPath.innerHTML = textoOut;
	parametro="&nodoPadre=0&anterior=0&subir=0";
	FWK.loadApiInto("carpetas","browser|browser|browser|principal","carpetas","&cmd=setHijos"+parametro);
}




function msg()
{
 //alert("Hola.. soy un ALERT !!!");
}



function cartel(texto_ult,texto_mas, tipo_audio, tipo_video){
	textoUlt	= texto_ult;
	textoMas	= texto_mas;
	
	tipoAudio	= tipo_audio;
	tipoVideo	= tipo_video;

		switch(idInstalacion)
		{
			case 8120:
			case 3:
				tipo = tipoAudio;
				break;
			default:
				tipo = tipoVideo;
				break;
		
		}
	
	if (!textoBusqueda){
		if (nodo.length<=2){
			if(browserOrden=='MASV'){
				textoOut="<span ONCLICK='video();'  style='cursor:pointer;'>"+tipo+"</span>";
				catalogoPath.innerHTML = textoOut+" / "+"<SPAN class='link'> "+textoMas+"</SPAN>";
			}

			if(browserOrden=='ULT'){
				textoOut="<span ONCLICK='video();'  style='cursor:pointer;'>"+tipo+"</span>";
				catalogoPath.innerHTML = textoOut+" / "+"<SPAN class='link'> "+textoUlt+"</SPAN>";
			}
		}
	} else {
		textoBusqueda = null;
	}
}

function mensajeMiAdd(texto){
	msg_idioma.push(texto);
}







/*IMPORTS*/
/*VARIABLES*/
window.idInstalacion=idInstalacion;
window.browserOrden=browserOrden;
window.nodo_ant=nodo_ant;
window.nodo=nodo;
window.nodoTxt=nodoTxt;
window.flagHijo=flagHijo;
window.nodoAct=nodoAct;
window.textoUlt=textoUlt;
window.textoMas=textoMas;

window.tipoAudio=tipoAudio;
window.tipoVideo=tipoVideo;

window.textoBusqueda=textoBusqueda;
window.msg_idioma=msg_idioma;
window.MENSAJE_NOENCONTRARON=MENSAJE_NOENCONTRARON;
window.textomi=textomi;
/*FUNCIONES*/
window.verVariables=verVariables;
window.carpetaCero=carpetaCero;
window.carpetaComun=carpetaComun;
window.raiz=raiz;
window.hijo=hijo;
window.sinHijo=sinHijo;
window.anterior=anterior;
window.browserSetOrden=browserSetOrden;
window.browserLoMasVisto=browserLoMasVisto;
window.browserLoMasEscuchado=browserLoMasEscuchado;
window.browserDeLoUltimo=browserDeLoUltimo;
window.browserLoMasEscuchadoB=browserLoMasEscuchadoB;
window.browserLoMasVistoB=browserLoMasVistoB;
window.browserDeLoUltimoB=browserDeLoUltimoB;
window.pathLinkPorArbol=pathLinkPorArbol;
window.estadoClass=estadoClass;
window.descarga=descarga;
window.mdescarga=mdescarga;
window.nodoTextoAdd=nodoTextoAdd;
window.nodoTextoDel=nodoTextoDel;
window.pathLinkCarpeta=pathLinkCarpeta;
window.pathLinkCarpetaBusqueda=pathLinkCarpetaBusqueda;
window.nodoTextoAddNoResult=nodoTextoAddNoResult;
window.nodoTextoAddSimple=nodoTextoAddSimple;
window.marcaSeleccion=marcaSeleccion;
window.video=video;
window.msg=msg;
window.cartel=cartel;
window.mensajeMiAdd=mensajeMiAdd;
window.refreshBrowser=refreshBrowser;
window.execCarpetaComunHabilitada=execCarpetaComunHabilitada;
















/*--------------------------------
TODO : BORRAR
---------------------------------*/

/*--------------------------------
		REGRESA al nodo anterior
-----------------------------------*/
function anteriorfin(superior)
{
 	if (nodo.length > 2){
 		nodo.pop();
 		nodo.pop();
 	}
	ultimo = nodo.length-1;
	parametro="&nodoPadre=0&anterior="+nodo[ultimo]+"&subir=1";
	carpetaNodo(superior);
	FWK.loadApiInto("carpetas","browser|browser|browser|principal","carpetas","&cmd=setHijos"+parametro);
}