dirpbl="http://pare.cl/";



var mystring=navigator.userAgent

var needle=/irefox/

var firefox=mystring.match(needle)





nn=(document.layers)?true:false; 

ie=(document.all)?true:false; 

function keyDown(e) { 

	var evt=(e)?e:(window.event)?window.event:null; 

	if(evt){ 

		var key=(evt.charCode)?evt.charCode: ((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0)); 

		if (key == 13) {parent.framevideo.listonumero();}

		if (key >95 && key <106) {parent.framevideo.numeropres(key);}

	} 

} 

document.onkeydown=keyDown; 

if(nn) document.captureEvents(Event.KEYDOWN);



var ya_reviso_fb="no";

var puede_cambiar_fb_status="no";

var puede_cambiar_fb_status_efectivamente=false;



var estalogeado="no";

document.getElementById("guia_contenido").style.height=document.getElementById("botones").offsetHeight;

var canales2 = new Object();

var pais_actual=false;

var cat_actual=false;

var idioma_actual=false;



var ultimo_marcado="documentales";

var canal_previo="";

var canal_actual="";

var minutos_canal_actual=0;

var minutos_canal_actual_total=0;

var cargo_publicidad_izq_arriba=0;

var mostrar_estatus=false;



Object.prototype.clone = function() {

  var newObj = (this instanceof Array) ? [] : {};

  for (i in this) {

    if (i == 'clone') continue;

    if (this[i] && typeof this[i] == "object") {

      newObj[i] = this[i].clone();

    } else newObj[i] = this[i]

  } return newObj;

};







function datos20(res,elcanal,sinpantas) {

	

}

function busqueda(quebuscar) {
	document.getElementById("paises").value="todos";

	document.getElementById("idioma").value="todos";

	document.getElementById("idioma").className = "notused";

	document.getElementById("paises").className = "notused";

	

//	cambio_submenu('idioma',document.getElementById("idioma"));

			

	var bus=((quebuscar=="") || (typeof(quebuscar)=="undefined")) ? document.getElementById("buscado").value : quebuscar;

	obtiene_lista_justin("buscar",bus,"busqueda2");
	
}
function mergeObjects (target, source) {
for (var prop in source) {
if (source.hasOwnProperty(prop)) {
target[prop] = source[prop];
}
}
}
function busqueda2(tipo,quebuscar,contelevidentes) {


	temp1=new Object();


	if (quebuscar=="manoollo") {
		temp3=new Object();		
		temp2=new Object();
		temp3=filter(canales2, "buscado","manoollo",1);
		temp1=filter(canales2, 6 ,"Chile",1);			
		jQuery.extend( temp1,temp3);	
			
	}
	else {

		temp1=filter(canales2, "buscado",quebuscar,1);
	
	}
	
	if (temp1.length){cambia_guia(temp1);}
	else {
		temp = "<table width=300><tr><td><b>"+idio("No hay resultados para tu busqueda")+"</b>";
		temp = temp +"</td></tr><table>";
		document.getElementById("guia_contenido").innerHTML += temp;		
	}

}

function cuadro_busqueda() {

	temp="<input name='buscado' id='buscado' > <input onClick='busqueda();' type='button' value='"+idio("Buscar")+"'>";

	temp = temp +"<table width=300><tr><td>"+idio("Puedes buscar por nombre del canal, descripción o tag. Por ejemplo: 'simpsons' o 'real madrid' o 'naruto'");

	temp = temp +"</td></tr><table>";

	document.getElementById("guia_contenido").innerHTML = temp;



}



function filter(objeto, campo,contenido,contelevidentes) {
	if (contenido==-1) {return objeto;}

	var newObj = new Object;
	var newArr = new Array;
	for (i in objeto) {
		if (i == 'clone') continue;
		if (objeto[i][campo]==contenido || contenido==0) {
			newObj = objeto[i].clone();
			if (objeto[i][0]!="") {
				newArr.push(newObj);
			}
		}

		//julio esto esta funcionando

		if ((campo=="buscado")) {
			var re = new RegExp(contenido, "i");
			var str = objeto[i][4]+" "+objeto[i][3]+" "+objeto[i][10]+" "+objeto[i][7]+" "+objeto[i][6]+" "+objeto[i][0]+" .";
//var str = "";

			if (str.match(re)) {
				newObj = objeto[i].clone();
				if (objeto[i][0]!="") {
					newArr.push(newObj);
				}
			}
		}
	}

	//ordenamiento sigue dos horas mas dela ultima renivacion del televidentes

	if ((estatuscanales_offset-2)<tiempo_offset || (contelevidentes==1))	{
		newArr.sort(sortfunction_extendido);
	}

	else {
		newArr.sort(sortfunction);

	}

	return newArr;

  

}

function filter_favs(objeto, favoritos) {

	

	var newObj = new Object;

	var newArr = new Array;

	for (i in objeto) {

		

		if (i == 'clone') continue;

		for (f in favoritos) {



			

			if (favoritos[f]==i) {

				newObj = objeto[i].clone();

				//no lo agrega 

				if (objeto[i][0]!="") {

					newArr.push(newObj);

				}				

			}

		}

	}

	//ordenamiento sigue dos horas mas dela ultima renivacion del televidentes

	if ((estatuscanales_offset-2)<tiempo_offset)	{

		newArr.sort(sortfunction_extendido);

	}

	else {

		newArr.sort(sortfunction);

	}

	return newArr;  

}



function filter_o (objeto, campo,contenido) {//com: si el contrenuido es 0, solo copia y sortea

	if (contenido==-1) {return objeto;}

	

	var newObj = (objeto instanceof Array) ? [] : {};

	

	for (i in objeto) {

		if (i == 'clone') continue;

		if (objeto[i][campo]==contenido || contenido==0) {

			newObj[i] = objeto[i].clone();

		}

	}

	return newObj;

  

}



var indiceimportanciacuartos=3;







function sortfunction_extendido(a, b){

	var peso_a=0;

	var peso_b=0;

	

	var signo_a;

	var signo_b;

	

	signo_a = (estatuscanales[a[1]]==-1) ? -1 : 1;

	signo_b = (estatuscanales[b[1]]==-1) ? -1 : 1;



	peso_por_videntes_a = (televidentes[a[1]]>1) ? televidentes[a[1]]/2 : 1;

	peso_por_videntes_b = (televidentes[b[1]]>1) ? televidentes[b[1]]/2 : 1;

	peso_por_videntes_a = (peso_por_videntes_a>1) ? (peso_por_videntes_a+90) : peso_por_videntes_a;

	peso_por_videntes_b = (peso_por_videntes_b>1) ? (peso_por_videntes_b+90) : peso_por_videntes_b;


	peso_a = (pesoscanales[a[1]]>0) ?  (pesoscanales[a[1]] * indiceimportanciacuartos) : 0;

//	peso_a = (peso_a + a[9] + peso_por_videntes_a) * signo_a ;
	peso_a = (peso_a + a[9] + (peso_por_videntes_a*4)) * signo_a ;

	

	peso_b = (pesoscanales[b[1]]>0) ?  (pesoscanales[b[1]] * indiceimportanciacuartos) : 0;

	peso_b = (peso_b + b[9]  + peso_por_videntes_b) * signo_b;
	peso_b = (peso_b + b[9]  + (peso_por_videntes_b*4)) * signo_b;



	var res=(peso_a>=peso_b) ? -1 : 1; 

	

	return res;



}

function sortfunction (a, b){

	var peso_a=0;

	var peso_b=0;	



	peso_a = (pesoscanales[a[1]]>0) ?  (pesoscanales[a[1]] * indiceimportanciacuartos) : 0;

	peso_a = peso_a + a[9];

	

	peso_b = (pesoscanales[b[1]]>0) ?  (pesoscanales[b[1]] * indiceimportanciacuartos) : 0;

	peso_b = peso_b + b[9];



	var res=(peso_a>=peso_b) ? -1 : 1; 

	

	return res;



}

function cambia_guia(objeto) {
	cambia_guia2(objeto);
	return;

	var html="";
	var aunenlinea=1;
	for (var i in objeto)
	{
		if (i == 'clone') continue;
		if (estatuscanales_offset<tiempo_offset) {	
			if ((aunenlinea==1) &&  (estatuscanales[objeto[i][1]]==-1)) {
				html = html + "<small>Posiblemente offline:</small>";
				aunenlinea=0;
			}
		}
		html = html + "<li class='licanal'><a title='"+objeto[i][10]+"' href=\"javascript:cambiar('"+objeto[i][1]+"')\">&nbsp;&nbsp;"+objeto[i][0]+"</a> </li>";
	}	
	document.getElementById("guia_contenido").innerHTML ="<ul id='lista'>"+html+"</ul>";
	return;	

}



/*----------------------------------sobre pantalla (deberia ir en otro lado modularmente-----------------*/





var timersobrepan =null;
var timerbuscavideos =null;

var funcion_para_chatoguia;



function doAtLoad() {

    flashObj = (navigator.appName.indexOf ("Microsoft") !=-1)?window["Movie1"]:window.document["Movie1"];

    

      

    //borrar

//   	flashObj.datos_canal("http://api.justin.tv/api/stream/list.json?channel=alcotv&azar=","datos20","alcotv");

}

function datos_res(res, funcion, elcanal) {

//borrar	

	eval(funcion+"(res,'"+elcanal+"');");

}

function get_at(o,at) {

	var sub=o.getElementsByTagName(at)[0];

	r = (sub.childNodes[0]==null)? "" : sub.childNodes[0].nodeValue;

	return r;

}



function datos_res_canal(res,elcanal) {

	var texto="";

	var xmlDoc=xml(res);

	texto += get_at(xmlDoc,"status");

	texto += " " + get_at(xmlDoc,"title");

	texto += " " + get_at(xmlDoc,"description");

	texto += " " + get_at(xmlDoc,"tags");

	sobrepan2(texto);

}

function datos_res_canal3(res,elcanal) {

	datos_res_canal2(res,elcanal,1);

}



function get_at2(o,at,i) {

	if (i>-1) {}

	else {i=0;}

	if (typeof(o.getElementsByTagName(at)[i]) != "object" ) return "";

	var sub=o.getElementsByTagName(at)[i];

	r = (sub.firstChild.nodeValue==null)? "" : sub.firstChild.nodeValue;

	return r;

}

function get_clipid(emb) {

return emb.replace("http://www.justin.tv/clip/","");

/*	

        result=emb.match(/id=.+"/g);

        res2=(result == null) ? "" : result[0].slice(3,-1);

        return res2;

 */

}

var objetoclis=new Array();

var objetoclis_nom_num=new Array();

function datos_res_ondemand(res,elcanal,sinpantas) {	

	objetoclis=new Array();

	objetoclis_nom_num=new Array();

	var texto="";

//alert(res);

	

	var xmlDoc=xml(res);

            var root = xmlDoc.getElementsByTagName('clips').item(0);  

//alert(root.childNodes.length);                   

            for (var iNode = 0; iNode < (root.childNodes.length/2)-1; iNode++) { 

     

				var elname=elcanal+"_"+String(iNode); 

				

                temp1=new Array("","","","","","","","","","","","","","","","");                               

                temp1[1]=elcanal+"_"+iNode;               

				temp1[0]= get_at2(xmlDoc,"title",iNode);

                temp1[14]="justinclip";

                temp1[15]=get_clipid(get_at2(xmlDoc,"page_url",iNode));

                temp1[16]=get_at2(xmlDoc,"image_url_small",iNode);                               

                temp1[10] = get_at2(xmlDoc,"description",iNode);

                

                

                objetoclis.push(temp1);

                objetoclis_nom_num[elname]=objetoclis.length-1;

            }	            

            lista_canales(objetoclis,"guia_contenido",idio("Videos guardados del canal ")+"<br><b><a href='javascript:cambiar(\""+canales2[elcanal][1]+"\")'>"+canales2[elcanal][0]+"</a></b>");

}
function datos_res_ondemand2_mogulus(res,elcanal,sinpantas) {	
clearInterval(timerbuscavideos);	
	objetoclis=new Array();	
	objetoclis_nom_num=new Array();
	var texto="";
	var myObject = eval('(' + res + ')');

	for ( var i in myObject["rss"]["channel"]["item"])
	{

if ((typeof(myObject["rss"]["channel"]["item"][i]["title"]) != "undefined")) {

		var elname=elcanal+"_"+String(i); 
                temp1=new Array("","","","","","","","","","","","","","","","");                               
                temp1[1]=elcanal+"_"+String(i);             
                temp1[100]=elcanal;             
//				temp1[0]=  myObject[i]['start_time'] ;//get_at2(xmlDoc,"title",i);
                temp1[14]="mogulusclip";
              temp1[15]=myObject["rss"]["channel"]["item"][i]["guid"];//get_clipid(get_at2(xmlDoc,"page_url",i));id

				temp1[16]= 	myObject["rss"]["channel"]["item"][i]["thumbnail"]["@url"];
//                temp1[16]= 	myObject["rss"]["channel"]["item"][i]["thumbnail"]["@url"];//get_at2(xmlDoc,"image_url_small",i);       image_url_medium                        
                temp1[10] = myObject["rss"]["channel"]["item"][i]["title"];;//get_at2(xmlDoc,"description",i);title
                temp1[0] = myObject["rss"]["channel"]["item"][i]["title"];;//get_at2(xmlDoc,"description",i);title
                objetoclis.push(temp1);
                objetoclis_nom_num[elname]=objetoclis.length-1;    	
}
}

//  	lista_canales(objetoclis,"guia_contenido",idio("Videos guardados del canal ")+"<br><b>"+canales2[elcanal][0]+"</b>");
    lista_canales(objetoclis,"guia_contenido",idio("Videos guardados del canal ")+"<br><b><a href='javascript:cambiar(\""+canales2[elcanal][1]+"\")'>"+canales2[elcanal][0]+"</a></b>");

  

	return;
}


function datos_res_ondemand2(res,elcanal,sinpantas) {	
		var myObject = eval('(' + res + ')');
		datos_res_ondemand2_directo(myObject,elcanal,sinpantas);
}

function datos_res_ondemand2_directo(res,elcanal,sinpantas) {	
clearInterval(timerbuscavideos);	
	objetoclis=new Array();	
	objetoclis_nom_num=new Array();
	var texto="";
//	var myObject = eval('(' + res + ')');
	var myObject = res;
	for ( var i in myObject )
	{
		var elname=elcanal+"_"+String(i); 
                temp1=new Array("","","","","","","","","","","","","","","","");                               
                temp1[1]=elcanal+"_"+String(i);             
                temp1[100]=elcanal;             
				temp1[0]=  myObject[i]['start_time'] ;//get_at2(xmlDoc,"title",i);
                temp1[14]="justinclip";
                temp1[15]=myObject[i]['id'] ;//get_clipid(get_at2(xmlDoc,"page_url",i));id
                temp1[16]=myObject[i]['image_url_medium'] ;//get_at2(xmlDoc,"image_url_small",i);       image_url_medium                        
                temp1[10] = myObject[i]['title'] ;;//get_at2(xmlDoc,"description",i);title
                objetoclis.push(temp1);
                objetoclis_nom_num[elname]=objetoclis.length-1;    	
	}
 // 	lista_canales(objetoclis,"guia_contenido",idio("Videos guardados del canal ")+"<br><b>"+canales2[elcanal][0]+"</b>");

    lista_canales(objetoclis,"guia_contenido",idio("Videos guardados del canal ")+"<br><b><a href='javascript:cambiar(\""+canales2[elcanal][1]+"\")'>"+canales2[elcanal][0]+"</a></b>");
 

	return;

	/*

	var xmlDoc=xml(res);

            var root = xmlDoc.getElementsByTagName('clips').item(0);  


            for (var iNode = 0; iNode < (root.childNodes.length/2)-1; iNode++) { 

     

				var elname=elcanal+"_"+String(iNode); 

				

                temp1=new Array("","","","","","","","","","","","","","","","");                               

                temp1[1]=elcanal+"_"+iNode;               

				temp1[0]= get_at2(xmlDoc,"title",iNode);

                temp1[14]="justinclip";

                temp1[15]=get_clipid(get_at2(xmlDoc,"page_url",iNode));

                temp1[16]=get_at2(xmlDoc,"image_url_small",iNode);                               

                temp1[10] = get_at2(xmlDoc,"description",iNode);

                

                

                objetoclis.push(temp1);

                objetoclis_nom_num[elname]=objetoclis.length-1;

            }	            

            lista_canales(objetoclis,"guia_contenido",idio("Videos guardados del canal ")+"<br><b>"+canales2[elcanal][0]+"</b>");

            

            

            

	var texto="";

	var myObject = eval('(' + res + ')');

	var tele=((typeof(myObject[0]) != "object")) ? "0" : myObject[0]["stream_count"];	

	var estatus=((typeof(myObject[0]) != "object")) ? "0" : myObject[0]["channel"]["status"];	

	if (sinpantas != 1) {

		if ((tele==0) && (res=="[]")) {

			document.getElementById("thumb_"+elcanal).src="img/aguste.jpg";

			document.getElementById("viewers_"+elcanal).innerHTML="";

		}

		else {

			document.getElementById("viewers_"+elcanal).innerHTML="<img  align='baseline' border=0 src='img/ojo4.jpg'> "+tele;

			canales2[elcanal][10]=estatus;


			if ((estatus != "") && (mostrar_estatus==true)) {

				document.getElementById("canal_"+elcanal).innerHTML="<MARQUEE direction='left' loop='2000' width='100%' scrollamount='1' scrolldelay='10'><b>"+canales2[elcanal][0]+"</b>: "+canales2[elcanal][10]+"</MARQUEE>";



				

			}

			

		}

	}

	

	televidentes[elcanal]=tele;

	

	var texto="";

	texto +=  ((typeof(myObject[0]) != "object")) ? "" : myObject[0]["channel"]["status"];	//get_at(xmlDoc,"title");

	texto += " " + ((typeof(myObject[0]) != "object")) ? "" : myObject[0]["channel"]["title"];	//get_at(xmlDoc,"title");

	texto += " " +((typeof(myObject[0]) != "object")) ? "" : myObject[0]["channel"]["description"];//get_at(xmlDoc,"description");

	texto += " " + ((typeof(myObject[0]) != "object")) ? "" : myObject[0]["channel"]["tags"];//get_at(xmlDoc,"tags");

	

	sobrepan2(texto);

	*/

	            

}

function sobre_mapa(canal) {
	sobrepan(canales2[canal][1],canales2[canal][14]);

	parent.framevideo.document.getElementById("megustapachileid").style.display="none";
	parent.framevideo.document.getElementById("explicamapachile").style.display="block";
	parent.framevideo.document.getElementById("explicamapachile").innerHTML=descrip4(canal);
	
	
	
}
function fuera_mapa(canal) {
	fuerapan(canales2[canal][1],canales2[canal][14]);
}


function sobre_mapa_radios(canal) {
	//sobrepan(radios[canal][1],radios[canal][14]);
	
	document.getElementById("bajo_guia2").innerHTML=""+descrip5(canal);
	document.getElementById("bajo_guia2").style.display="block";
	document.getElementById("bajo_guia").style.display="none";
	clearInterval(timersobrepan);
	timersobrepan = setTimeout("vuelve_de_sobrepan()",8000);	 
		
//	parent.framevideo.document.getElementById("megustapachileid").style.display="none";
//	parent.framevideo.document.getElementById("explicamapachile").style.display="block";
//	parent.framevideo.document.getElementById("explicamapachile").innerHTML=descrip4(canal);
	
}
function fuera_mapa_radios(canal) {
	fuerapan(radios[canal][1],radios[canal][14]);
}

/*

function datos_res_canal4(res,elcanal) {

	var xmlDoc=xml(res);

	alert(get_at(xmlDoc,"embed_enabled"));

	if (get_at(xmlDoc,"embed_enabled")=="false") {

			popjustin(elcanal);

			parent.framevideo.document.getElementById("video_bajo").innerHTML=html+'<br><center><span class="small">Si tienes problemas viendo este canal haz <a href="http://es.justin.tv/'+elcanal+'/popout" target="_new">clic acá</a></span></center>';			

	}

}

*/
function datos_res_canal4(res,elcanal) {

	var myObject = eval('(' + res + ')');
	datos_res_canal4_directo(myObject,elcanal);
}
function datos_res_canal4_directo(res,elcanal) {

	var sinpantas=1;

	var texto="";

//	var myObject = eval('(' + res + ')');
	var myObject = res;

	var tele=((typeof(myObject[0]) != "object")) ? "0" : myObject[0]["embed_enabled"];

	if (tele==false) {

			popjustin(elcanal);

			parent.framevideo.document.getElementById("video_bajo").innerHTML=html+'<br><center><span class="small">Si tienes problemas viendo este canal haz <a href="http://es.justin.tv/'+elcanal+'/popout" target="_new">clic acá</a></span></center>';			

	}

	return;	
/*
	var estatus=((typeof(myObject[0]) != "object")) ? "0" : myObject[0]["channel"]["status"];	

	if (sinpantas != 1) {

		if ((tele==0) && (res=="[]")) {

			document.getElementById("thumb_"+elcanal).src="img/aguste.jpg";

			document.getElementById("viewers_"+elcanal).innerHTML="";

		}

		else {

			document.getElementById("viewers_"+elcanal).innerHTML="<img  align='baseline' border=0 src='img/ojo4.jpg'> "+tele;

			canales2[elcanal][10]=estatus;



			if ((estatus != "") && (mostrar_estatus==true)) {

				document.getElementById("canal_"+elcanal).innerHTML="<MARQUEE direction='left' loop='2000' width='100%' scrollamount='1' scrolldelay='10'><b>"+canales2[elcanal][0]+"</b>: "+canales2[elcanal][10]+"</MARQUEE>";



				

			}

			

		}

	}

	

	televidentes[elcanal]=tele;

	

	*/

}





/*

function datos_res_canal(res,elcanal) {

	var texto="";

	var xmlDoc=xml(res);

	texto += get_at(xmlDoc,"status");

	texto += " " + get_at(xmlDoc,"title");

	texto += " " + get_at(xmlDoc,"description");

	texto += " " + get_at(xmlDoc,"tags");

	sobrepan2(texto);

}

*/

function datos_res_canal2(datos,elcanal,sinpantas) {
	var myObject = eval('(' + res + ')');
	datos_res_canal2_directo(myObject,elcanal,sinpantas);
}

function pone_televidentes_en_div(telev,canal) {
	if (telev == undefined || telev =="") {return;}
	if (telev==0) {
			document.getElementById("thumb_"+canal).src="img/aguste.jpg";
			document.getElementById("viewers_"+canal).innerHTML="";
	}
	else {
			document.getElementById("viewers_"+canal).innerHTML="<img  align='baseline' border=0 src='img/ojo4.png'> "+telev;

	}
}

function datos_res_canal2_directo(res,elcanal,sinpantas) {

	var texto="";
	var myObject = res;
	var tele=((typeof(myObject[0]) != "object")) ? "0" : myObject[0]["stream_count"];	
	var estatus=((typeof(myObject[0]) != "object")) ? "0" : myObject[0]["channel"]["status"];	
	if (sinpantas != 1) {
		if ((tele==0) && (res=="[]")) {
			pone_televidentes_en_div(0,elcanal);
//			document.getElementById("thumb_"+elcanal).src="img/aguste.jpg";
//			document.getElementById("viewers_"+elcanal).innerHTML="";
		}
		else {
			pone_televidentes_en_div(tele,elcanal);
			canales2[elcanal][10]=estatus;
			//esto deberia ser mas condicional
			if ((estatus != "") && (mostrar_estatus==true)) {
				document.getElementById("canal_"+elcanal).innerHTML="<MARQUEE direction='left' loop='2000' width='100%' scrollamount='1' scrolldelay='10'><b>"+canales2[elcanal][0]+"</b>: "+canales2[elcanal][10]+"</MARQUEE>";				
			}	
		}
	}
	televidentes[elcanal]=tele;
	var texto="";
	texto +=  ((typeof(myObject[0]) != "object")) ? "" : myObject[0]["channel"]["status"];	//get_at(xmlDoc,"title");
	texto += " " + ((typeof(myObject[0]) != "object")) ? "" : myObject[0]["channel"]["title"];	//get_at(xmlDoc,"title");
	texto += " " +((typeof(myObject[0]) != "object")) ? "" : myObject[0]["channel"]["description"];//get_at(xmlDoc,"description");
	texto += " " + ((typeof(myObject[0]) != "object")) ? "" : myObject[0]["channel"]["tags"];//get_at(xmlDoc,"tags");
	sobrepan2(texto);
}
function datos_res_canal2_ustream(res,elcanal,sinpantas) {
	
	alert(res);
	var texto="";
	var myObject = eval('(' + res + ')');	
	var tele=((typeof(myObject["channel"]) != "object")) ? "None" : myObject["channel"]["currentViewerCount"];	
	document.getElementById("viewers_"+elcanal).innerHTML="<img  align='baseline' border=0 src='img/ojo4.png'> "+tele;
	televidentes[elcanal]=tele;
	return;
}

function datos_res_canal2_mogulus(res,elcanal,sinpantas) {
//alert(res);
	var texto="";
	var myObject = eval('(' + res + ')');	
	var tele=((typeof(myObject["channel"]) != "object")) ? "None" : myObject["channel"]["currentViewerCount"];	
	document.getElementById("viewers_"+elcanal).innerHTML="<img  align='baseline' border=0 src='img/ojo4.png'> "+tele;
	televidentes[elcanal]=tele;
	return;
/*
	var estatus=((typeof(myObject[0]) != "object")) ? "0" : myObject[0]["channel"]["status"];	
	if (sinpantas != 1) {
		if ((tele==0) && (res=="[]")) {
			document.getElementById("thumb_"+elcanal).src="img/aguste.jpg";
			document.getElementById("viewers_"+elcanal).innerHTML="";
		}
		else {
			document.getElementById("viewers_"+elcanal).innerHTML="<img  align='baseline' border=0 src='img/ojo4.jpg'> "+tele;
			canales2[elcanal][10]=estatus;
			//esto deberia ser mas condicional
			if ((estatus != "") && (mostrar_estatus==true)) {
				document.getElementById("canal_"+elcanal).innerHTML="<MARQUEE direction='left' loop='2000' width='100%' scrollamount='1' scrolldelay='10'><b>"+canales2[elcanal][0]+"</b>: "+canales2[elcanal][10]+"</MARQUEE>";				
			}	
		}
	}
	televidentes[elcanal]=tele;
	var texto="";
	texto +=  ((typeof(myObject[0]) != "object")) ? "" : myObject[0]["channel"]["status"];	//get_at(xmlDoc,"title");
	texto += " " + ((typeof(myObject[0]) != "object")) ? "" : myObject[0]["channel"]["title"];	//get_at(xmlDoc,"title");
	texto += " " +((typeof(myObject[0]) != "object")) ? "" : myObject[0]["channel"]["description"];//get_at(xmlDoc,"description");
	texto += " " + ((typeof(myObject[0]) != "object")) ? "" : myObject[0]["channel"]["tags"];//get_at(xmlDoc,"tags");
	sobrepan2(texto);
*/
}

function xml(txt) {

	try //Internet Explorer

	  {

	  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");

	  xmlDoc.async="false";

	  xmlDoc.loadXML(txt);

	  return xmlDoc; 

	  }

	catch(e)

	  {

	  parser=new DOMParser();

	  xmlDoc=parser.parseFromString(txt,"text/xml");

	  return xmlDoc;

	  }

}



var timer233=null;

var ultimo_pan_esperando=null;



function fuerapan(canal,tipo) {	

	clearInterval(timer233);

}			

function sobrepan(canal,tipo) {	

	

	sobrepan1(canal,tipo);

	clearInterval(timer233);

	

/*	

	if (ultimo_pan_esperando != canal) {

		clearInterval(timer233);

		timer233 =setTimeout(function() {sobrepan1(canal,tipo)}, 1000);

		ultimo_pan_esperando=canal;

	}

*/	

}

function sobrepan1(canal,tipo) {
	
	if (base_actual=="canales2") {
	}
	else if (base_actual=="radios") {
		eval("var canales2=radios");;
		sobre_mapa_radios(canal);
		return;
		
	}
//alert(base_actual+""+canales2+");	

	if (tipo=="justinclip") {
		document.getElementById("bajo_guia2").innerHTML="<span class='inverso1'>"+objetoclis[objetoclis_nom_num[canal]][0]+"</span> "+objetoclis[objetoclis_nom_num[canal]][10];
		//+descrip1(canal);
		document.getElementById("bajo_guia2").style.display="block";
		document.getElementById("bajo_guia").style.display="none";	
		clearInterval(timersobrepan);
		timersobrepan = setTimeout("vuelve_de_sobrepan()",8000);	
		return;
	}
	document.getElementById("bajo_guia2").innerHTML="<span class='inverso1'>"+canales2[canal][0]+"</span> "+descrip1(canal);
	document.getElementById("bajo_guia2").style.display="block";
	document.getElementById("bajo_guia").style.display="none";
	clearInterval(timersobrepan);
	timersobrepan = setTimeout("vuelve_de_sobrepan()",8000);	 
	if (tipo=="justin") {		
		var rand_no = Math.random();
		
//		flashObj.datos_canal("http://api.justin.tv/api/stream/list.json?channel="+canales2[canal][15]+"&azar="+rand_no,"datos_res_canal2",canal);


 	$.getJSON("http://api.justin.tv/api/stream/list.json?channel="+canales2[canal][15]+"&azar="+rand_no+"&jsonp=?", function(data){datos_res_canal2_directo(data,canales2[canal][15],0);});


	        
	        		document.getElementById("bajo_guia2").innerHTML +="<div id='bajo_guia2_justin'><img src='img/load_azul7.gif'>"+descrip2(canal)+"</div>";
	}
	else {
		document.getElementById("bajo_guia2").innerHTML +=descrip2(canal);
	}
}

function sobrepan2(mensaje) {
	document.getElementById("bajo_guia2_justin").innerHTML = mensaje;
}

function vuelve_de_sobrepan() {

	clearInterval(timersobrepan);

	document.getElementById("bajo_guia2").style.display="none";

	document.getElementById("bajo_guia").style.display="block";



}

/*----------------------------------FIN sobre pantalla (deberia ir en otro lado modularmente-----------------*/



var lugar_relativo_act=0;
var fila=0;
var table_faltan_parciales=0;
var mediapubli_rows=3;
var mediapubli_cols=2;

var faltan_filas_parciales=0;
var faltan_celdas_parciales_por_fila=0;

 





function addRowToTable(table,contenido,id)

{
	

	
	var tbl = document.getElementById(table);

	//--deja determinado que fila y columna(lugar_relativo_act)
	if (lugar_relativo_act>=numero_de_columnas) {
		//reinicia
		lugar_relativo_act=1;
	}
	else {
		lugar_relativo_act +=1;
	}
	if (lugar_relativo_act==1) {			
	  var lastRow = tbl.rows.length;
	  var row = tbl.insertRow(lastRow);	      
	  fila=fila+1;
	}
	else {
	  var lastRow = tbl.rows.length;
	  var row = tbl.rows[lastRow-1];	  
	}
	
//alert(fila + " - "+lugar_relativo_act);	
	
//contenido=lugar_relativo_act;

	//------------------
	  if ((fila==2) && (lugar_relativo_act==1))  {	//publicidad mas un canal  
		var cellRight = row.insertCell(lugar_relativo_act-1);
		cellRight.id="celdapublicidadmedia";
		cellRight.colSpan = mediapubli_cols;		  
		cellRight.rowSpan = mediapubli_rows;			  
	  	cellRight.innerHTML=cambia_publicidad_media("motote2");
//	  	lugar_relativo_act++;
//		var cellRight = row.insertCell(lugar_relativo_act-1);
//		var cellRight = row.insertCell(lugar_relativo_act);
//		cellRight.innerHTML=contenido; 
		
		
		faltan_filas_parciales=mediapubli_rows;
		faltan_celdas_parciales_por_fila=numero_de_columnas-mediapubli_cols;
//		faltan_filas_parciales=3;
//		faltan_celdas_parciales_por_fila=2;

		addRowToTable(table,contenido,id);


//		faltan_celdas_parciales_por_fila--; //porque aca ya se agrego un extra.
		
//	  	lugar_relativo_act =2;
//	  	table_faltan_parciales=mediapubli_rows-1;
	  }
	  else if (faltan_filas_parciales>0) {//celda junto a puiblicidad
	  
//	  	var cellRight = row.insertCell(0);
		  var cellRight = row.insertCell(lugar_relativo_act-1);	  
    	cellRight.innerHTML=contenido;  
    	cellRight.valign="top";  
		cellRight.id="celda"+id;
		

				
			 faltan_celdas_parciales_por_fila--;
			 if (faltan_celdas_parciales_por_fila==0) {//fila terminada
			 
				  lugar_relativo_act=numero_de_columnas;
				  faltan_filas_parciales--;
				  faltan_celdas_parciales_por_fila=numero_de_columnas-mediapubli_cols;
			 }
 	  }
	  else {//celda cualquiera
		  var cellRight = row.insertCell(lugar_relativo_act-1);	  
		cellRight.innerHTML=contenido;  	  
		cellRight.id="celda"+id;
    	cellRight.valign="top";  
		}
}

/* respaldo.. borrar despues
	//------------------
	  if ((fila==2) && (lugar_relativo_act==1))  {	//publicidad	  
		var cellRight = row.insertCell(lugar_relativo_act-1);
		cellRight.id="celdapublicidadmedia";
		cellRight.colSpan = mediapubli_cols;		  
		cellRight.rowSpan = mediapubli_rows;		  
	  	cellRight.innerHTML=cambia_publicidad_media("motote2");
	  	lugar_relativo_act++;
		var cellRight = row.insertCell(lugar_relativo_act-1);
		cellRight.innerHTML=contenido; 
	  	lugar_relativo_act =numero_de_columnas;
	  	table_faltan_parciales=mediapubli_rows-1;
	  }
	  else if (table_faltan_parciales>0) {//celda junto a puiblicidad
		table_faltan_parciales--;
	  	var cellRight = row.insertCell(0);
    	cellRight.innerHTML=contenido;  
    	cellRight.valign="top";  
		cellRight.id="celda"+id;
		lugar_relativo_act =numero_de_columnas;	  
	  }
	  else {//celda cualquiera
		  var cellRight = row.insertCell(lugar_relativo_act-1);	  
		cellRight.innerHTML=contenido;  	  
		cellRight.id="celda"+id;
    	cellRight.valign="top";  
		}
*/
var timer40=null;

var objeto_glob=new Object();

function lista_canales(objeto,receptorhtml,previo) {	
	fila=0;
	objeto_glob=objeto;		
	var tablaname="tablaguia"+receptorhtml;
	document.getElementById(receptorhtml).innerHTML =previo+"<table id ='"+tablaname+"'></table>";
	lugar_relativo_act=0;
	lista_canales_sub (0,12,tablaname);
	
	primer_retardo=1500;//unsgeundo extra
	
	
	
	for (var i=12;i<=objeto.length;i+=12)	
	{
		
		ii=((i*1)+(12*1));
		var t="lista_canales_sub ("+i+","+ii+",'"+tablaname+"')";

		
		setTimeout(t,((i/12)*500)+primer_retardo);	
	}

}

function lista_canales_sub (inicio,fin,receptorhtml) {
	

	objeto=objeto_glob.slice(inicio,fin);      	
	for (var i in objeto)
	{		

		var randomnumber=Math.floor(Math.random()*11)
		var aunenlinea=1;
		var tiempo=2000;
		if (i == 'clone') continue;
		tiempo= tiempo+200;
		if (estatuscanales_offset<tiempo_offset) {	
			if ((aunenlinea==1) &&  (estatuscanales[objeto[i][1]]==-1)) {
				aunenlinea=0;
			}
		}

		html1="";
		html1 = html1 + "<div onMouseOver=\"sobrepan('"+objeto[i][1]+"','"+objeto[i][14]+"')\"  onMouseOver=\"fuerapan('"+objeto[i][1]+"','"+objeto[i][14]+"')\" style:'margin:0px;padding:0px'><a   href=\"javascript:cambiar('"+objeto[i][1]+"','"+objeto[i][14]+"')\" class='panta' >";
		var img_id=" id='thumb_"+objeto[i][1]+"' ";
		
		var estethumb="thumb_"+objeto[i][1];
		var timerthumb=" timer_"+estethumb+" =null;clearInterval(timer_"+estethumb+");timer_"+estethumb+" = setTimeout(\"no_cargo_imagen('"+estethumb+"')\",3000);"
		eval(timerthumb);
		var encarga=" onload=\"secargoimagen('"+estethumb+"')\" ";
		
		var viewers_id=" id='viewers_"+objeto[i][1]+"' ";
		var marca_id=" id='marca_"+objeto[i][1]+"' ";
		var titulo_id=" id='canal_"+objeto[i][1]+"' ";
		if (aunenlinea==1) {
			if (televidentes[objeto[i][1]]==0) {
				html1 = html1 + "<img  border=0  "+img_id+" src='img/aguste.jpg' width='65' height='48'>";			
			}	
			else if (objeto[i][14]=="justin") {
				html1 = html1 + "<img border=0 "+img_id+encarga+" src='http://static-cdn.justin.tv/previews/live_user_"+objeto[i][15]+"-75x56.jpg?azar="+randomnumber+"' width='65' height='48'>";
			}	
			else if (objeto[i][14]=="mogulus") {
				html1 = html1 + "<img border=0  "+img_id+encarga+" src='http://thumbnail.api.livestream.com/thumbnail?name="+objeto[i][15]+"&azar="+randomnumber+"' width='65' height='48'>";
			}

			else if (objeto[i][16]!="") {

				html1 = html1 + "<img  border=0  "+img_id+encarga+" src='"+objeto[i][16]+"' width='65' height='48'>";

			}					

			else {

				if (dom=="todos") {html1 = html1 + "<img  border=0  "+img_id+encarga+" src='img/logo.gif' width='65' height='48'>";}

				else {html1 = html1 + "<img  border=0  "+img_id+encarga+" src='img/fav_cuadrado4.png' width='65' height='48'>";}

			}

		}

		else {

				html1 = html1 + "<img  border=0  "+img_id+encarga+" src='img/aguste.jpg' width='65' height='48'>";

		}

		//display:inline;
		html1 = html1 + "<br>";
		html1 = html1 + "<div "+titulo_id+" style='display:inline;' title='"+objeto[i][0]+"'>";
		html1 = html1 + objeto[i][0];
		html1 = html1 + "</div>";
		marca="";
		var marca2="";

		if (objeto[i][14]=="sopcast") {
			marca="<img  align='baseline' border=0 src='img/sopcast.png'>";
		}
		if (objeto[i][16]!="" && objeto[i][14]=="justin" ) {
			
			
			marca2="<img  align='baseline' height=12 border=0 src='"+objeto[i][16]+"'>";
		}


		if (marca=="" && marca2=="" )  {html1 = html1 + "<br><div class='conteviews'><div class='viewers' "+viewers_id+"></div></div>";}
		if (marca!="") {html1 = html1 + "<br><div class='conteviews'><div class='viewers2' "+viewers_id+"></div></div><div  class='marca' "+marca_id+">"+marca+"</div>";}
		if (marca2!="") {html1 = html1 + "<br><div class='conteviews'><div class='viewers2' "+viewers_id+"></div></div><div  class='marca2' "+marca_id+">"+marca2+"</div>";}
		
		html1 = html1 + "</a></div>";
/*
.viewers {
top:-60;position:relative;display:inline;background:black;color:white;font-size:9px;margin:0;padding:0;
}
.marca {
top:-60;left:-40;position:relative;display:inline;color:white;font-size:9px;margin:0;padding:0;
}
*/

	
		addRowToTable(receptorhtml,html1,objeto[i][1]);	
		if (typeof(objeto[i][1]) == "string") {
			if (objeto[i][14]=="justin" && televidentes[objeto[i][1]]!=0) {
				var t="pantas_guia_justin('"+ objeto[i][1] +"')";
				setTimeout(t,tiempo);		
			}
			else 	if (objeto[i][14]=="mogulus" ) {
				var t="pantas_guia_mogulus('"+ objeto[i][1] +"')";
				setTimeout(t,tiempo);		
			}
			else 	if (objeto[i][14]=="ustream" ) {
				var t="pantas_guia_ustream('"+ objeto[i][1] +"')";
				setTimeout(t,tiempo);		
			}
			
		}
	}	

}


		
function pantas_guia_justin(canal) {
	//return. por ahora no usamos esto porque estamos probando que lea de antes  por categoria
	//datos_res_canal2_directo(data,canal,0);}
	pone_televidentes_en_div(televidentes[canal],canal)
	return;
	
	var rand_no = Math.random();
	//flashObj.datos_canal("http://api.justin.tv/api/stream/list.json?channel="+canal+"&azar="+rand_no,"datos_res_canal2",canal);		
               	 $.getJSON("http://api.justin.tv/api/stream/list.json?channel="+canal+"&azar="+rand_no+"&jsonp=?", function(data){datos_res_canal2_directo(data,canal,0);});

}

function pantas_guia_mogulus(canal) {
	var rand_no = Math.random();
	flashObj.datos_canal("http://x"+canal+"x.api.channel.livestream.com/2.0/livestatus.json?azar="+rand_no,"datos_res_canal2_mogulus",canal);		
}
function pantas_guia_ustream(canal) {
	return; //esto no fundiona no se porque
	
	var rand_no = Math.random();
	var  url="http://api.ustream.tv/json/channel/all/search/channelID:eq:"+canales2[canal][15]+"?key=96453A619C36345115048FD52535AAF7&azar="+rand_no;
	url="http://api.ustream.tv/json/channel/all/search/channelID:eq:603541?key=96453A619C36345115048FD52535AAF7&azar=0.dfregregr";
//	url="http://x"+canal+"x.api.channel.livestream.com/2.0/livestatus.json?azar="+rand_no;
	
//	var  url="http://x"+canal+"x.api.channel.livestream.com/2.0/livestatus.json?azar="+rand_no;
	//alert(url);
	flashObj.datos_canal(url,"datos_res_canal2_ustream",canal);		
}


function cambia_guia2(objeto) {
	var html="";
	//document.getElementById("guia_contenido").innerHTML =lista_canales(objeto);
	lista_canales(objeto,"guia_contenido","");
	return;	
}



function sacafiltro(que) {

	if (que == "paises") {

		document.getElementById("paises").value="todos";

		cambio_submenu('pais',document.getElementById("paises"));

	}

	if (que == "idioma") {

		document.getElementById("idioma").value="todos";

		cambio_submenu('idioma',document.getElementById("idioma"));

	}	



}

var ultimo_buscado="";

var pedidosajustin = new Object();


function procesa_lista_justin(res,tipo,buscado,funcionretorno) {
	
	eval("pedidosajustin['"+idioma_actual+"_"+cat_actual+"']=1");	
	var myObject = res;


	for ( var i in myObject )
	{
		if (myObject[i]['channel'] != undefined){
			televidentes[myObject[i]['channel']['login']]=myObject[i]['stream_count'];
		}	
		              
	}	
//	cambio_submenu2(tipo,buscado,1);
	eval(funcionretorno+"('"+tipo+"','"+buscado+"',1);");
	

}
function obtiene_lista_justin(tipo,buscado,funcionretorno){

	if (pedidosajustin[idioma_actual+"_"+cat_actual]==1) {
		eval(funcionretorno+"('"+tipo+"','"+buscado+"',1);");
		
		//cambio_submenu2(tipo,buscado,1);
		return;
	}
	
	var idioma;
	if (idioma_actual !="todos" || idioma_actual !=false) {		
		switch (idioma_actual) {			
			case "english":idioma="en";break;		
			case "spanish":idioma="es";break;		
			case "spanish1":idioma="es";break;		
			case "spanish2":idioma="es";break;
			default: idioma=(idioma2=="")?"es":"en";		
		}
	}else {idioma=(idioma2=="")?"es":"en";}
	var categoria;
	if (cat_actual !="todos") {		
		switch (cat_actual) {
			case "musica":categoria="&category=entertainment&subcategory=music";break;		
			case "cine":categoria="&category=entertainment&subcategory=movies,sci_f,comedy,series";break;		
			case "variado":categoria="&category=entertainment";break;		
			case "documentales":categoria="&category=entertainment&subcategory=documentary";break;		
			case "noticias":categoria="&category=news";break;		
			case "anime":categoria="&category=entertainment";break;		
			case "infantil":categoria="&category=entertainment";break;		
			case "deportes":categoria="&category=sports";break;		
			case "religioso":categoria="";break;		
			default: categoria="";break;
		}
	}else {categoria="";}
	idioma="&language="+idioma;
	
	document.body.style.cursor = 'wait';
	$.jsonp({
	    url: "http://api.justin.tv/api/stream/list.json?limit=55&"+categoria+idioma+"&jsonp=?",
	    success: function(data){
		    document.body.style.cursor = 'default';
	    	procesa_lista_justin(data,tipo,buscado,funcionretorno);
	    },
	    error: function() {
		    document.body.style.cursor = 'default';
	       //cambio_submenu2(tipo,buscado,1);
	       eval(funcionretorno+"('"+tipo+"','"+buscado+"',1);");
	    }
	});


}
function cambio_submenu(tipo,buscado,contelevidentes) {	
	document.getElementById("guia_contenido").innerHTML = "<div id='loader'><img src='img/load_azul7.gif'><small></small></div>";


	switch (tipo) {
		case "pais":
		buscado=buscado.options[buscado.selectedIndex].value;	
		pais_actual=buscado;
		break;		
		case "idioma":
		buscado=buscado.options[buscado.selectedIndex].value;	
		idioma_actual=buscado;
		break;		
		case "cat":
		cat_actual=buscado;
		break;		
	}	
		
	obtiene_lista_justin(tipo,buscado,"cambio_submenu2");

}	
function cambio_submenu2(tipo,buscado,contelevidentes) {	
		
	cambio_etiqueta("guia"); 
	document.getElementById("guia_contenido").style.display ="block";
	document.getElementById("guia_contenido_recomendados").style.display ="none";
	temp1=new Object();
	temp2=new Object();
	temp3=new Object();
	var que_numero;
	var html="";
	//mostrar_estatus=(buscado=="deportes")? true : false;
	switch (tipo) {
		case "cat":
		que_numero=3;
		break;
		case "pais":
		que_numero=6;
		break;		
		case "idioma":
		que_numero=5;
		break;		
	}	
	if (tipo=="pais") {
		ultimo_buscado=limpia_pais2(buscado);
	}
	else if (tipo=="idioma") {
	}
	else {
		ultimo_buscado=buscado;		
	}

	

	if (buscado=="todas" || buscado=="todos" ) {		
		temp1=filter(canales2, que_numero ,0,contelevidentes);		
		buscado=-1;
	}
	else {	
		temp1=filter(canales2, que_numero ,buscado,contelevidentes);						
	}

	switch (tipo) {
		case "cat":
			if (pais_actual) { 
				temp2=filter(temp1, 6 ,pais_actual,contelevidentes);
			}
			else {
				temp2=temp1.clone();				
			}
			if (idioma_actual) { 
				temp3=filter(temp2, 5 ,idioma_actual,contelevidentes);
			}
			else {
				temp3=temp2.clone();				
			}			
			cat_actual=buscado;
			break;
			
		case "pais":			
			if (cat_actual) {				 			
				temp2=filter(temp1, 3 ,cat_actual,contelevidentes);
			}
			else {
				temp2=temp1.clone();				
			}
			if (idioma_actual) { 
				temp3=filter(temp2, 5 ,idioma_actual,contelevidentes);
			}
			else {
				temp3=temp2.clone();				
			}				
			pais_actual=buscado;
			break;	

		case "idioma":			
			if (cat_actual) {				 			
				temp2=filter(temp1, 3 ,cat_actual,contelevidentes);
			}
			else {
				temp2=temp1.clone();				
			}
			if (pais_actual) { 
				temp3=filter(temp2, 6 ,pais_actual,contelevidentes);
			}
			else {
				temp3=temp2.clone();				
			}			
			idioma_actual=buscado;
			break;							

	}		

		
	//aca falta aplicar el filtro de pais e idioma
	cambia_guia(temp3);
	var filtros="";
	if (((idioma_actual!=false) && (idioma_actual!=-1))) {
		filtros=filtros+" en <b>"+idiomas[document.getElementById("idioma").value]+" <a href='javascript:sacafiltro(\"idioma\");'><img src='img/borrar.gif' align='ABSMIDDLE' border=0 alt='Sacar este filtro'></a></b>";
		document.getElementById("idioma").className = "used";
	}
	else {
		document.getElementById("idioma").className = "notused";
	}
	if (((pais_actual!=false)  && (pais_actual!=-1))  ) {
		if  (filtros =="") {}
		else {filtros = filtros + " "+idio("y") ;}
		filtros = filtros + " "+idio("en")+" <b>"+document.getElementById("paises").value+" <a href='javascript:sacafiltro(\"paises\");'><img src='img/borrar.gif' align='ABSMIDDLE' border=0 alt='Sacar este filtro'></a></b>";
		document.getElementById("paises").className = "used";
	}
	else {
		document.getElementById("paises").className = "notused";

	}	
	if (filtros != "") {
		document.getElementById("guia_contenido").innerHTML = "<small>"+idio("Solo los canales")+" "+filtros +"</small>" +document.getElementById("guia_contenido").innerHTML ;
}
	return;//no cacho porqué esto llega esta aca no mas

}

function cambio_menu(cat) {

	



	

	if (cat=="porpais") {

		document.getElementById("botones_porcat").style.display ="none";

		document.getElementById("botones_porpaises").style.display ="block";

	}

	else if (cat=="porcat") {

		document.getElementById("botones_porcat").style.display ="block";

		document.getElementById("botones_porpaises").style.display ="none";

	}

	else if (cat=="favoritos") {				

		

		eval("document.getElementById('boton_"+ultimo_marcado+"').className = 'guia_menu_item_nomarcado';");

		eval("document.getElementById('boton_"+cat+"').className = 'guia_menu_marcado';");

		eval("document.getElementById('guia_"+cat+"').style.display = 'block';");

		eval("document.getElementById('guia_"+ultimo_marcado+"').style.display = 'none';");

		ultimo_marcado=cat;			

		

	}



}

    function show(muestra) {

       var m = document.getElementById(muestra);

          m.style.display = 'block';

    }   

    function hide(muestra) {

       var m = document.getElementById(muestra);

          m.style.display = 'none';

    }   





	var timer=null;

	var canal_chat_actual="";

	

function chatjustin(canal) {

	var ancho=470+ancho_extra;
//			document.getElementById("chat").innerHTML="<iframe src='http://www.justin.tv/chat/embed?default_chat=jtv&channel="+canal+"' scrolling='auto' style='width:"+ancho+"px; height:"+370+"px' frameborder='0' width='"+ancho+"' height='"+370+"' ></iframe>";
			document.getElementById("chat").innerHTML="<iframe src='http://www.justin.tv/chat/embed?default_chat=jtv&channel="+canal+"' scrolling='auto' width="+ancho+" height=430  frameborder='0'></iframe>";

}	

function cambia_chat(tiempo) {
	

	
	var canal=canal_actual;
	var quechat=canal;
	if (parent.framevideo.numero!="") {
		 quechat=parent.framevideo.numero+"enfavchannels";
	}
	if (canal_chat_actual == canal) {clearInterval(timer);return;}
	canal_chat_actual=canal;
	if (canal != 0) {
		if (canales2[canal][17]==0) {
			arriba_chat="";
			if (canales2[canal][14]=="justin") {
				arriba_chat="<a href='javascript:chatjustin(\""+canal+"\");'>"+idio("Entrar a chat de justin (Puede que necesites una cuenta justin)")+"</a>";	
			}
			document.getElementById("chat").innerHTML=arriba_chat+"<iframe src='swf_chat.html?canal="+quechat+"&ancho="+(470+ancho_extra)+"&alto="+380+"' scrolling='no' style='width:"+(475+ancho_extra)+"px; height:"+385+"' frameborder='0'></iframe>";
		}
		else {
			var temp1=canales2[canal][17];
			var arrtemp= temp1.split("-");
			if (arrtemp[0]=="meebo") {
				var id=arrtemp[1];			
				document.getElementById("chat").innerHTML="<iframe src='swf_chat_meebo.html?"+id+"' scrolling='no' style='width:"+(475+ancho_extra)+"px; height:460' frameborder='0'></iframe>";
			}
		}
		timer = setTimeout("cambio_etiqueta('chat')",tiempo);
	}	
	else {
		document.getElementById("chat").innerHTML="";
		clearInterval(timer);
	}

}	





function popup2(pagina) {

	alert(idio("Este canal será abierto en una ventana flotante."));	

	parent.framevideo.justinpopwin1=window.open(pagina,'justinpopwin','width=630,height=450,top=130,left=0,scrollbars=yes,resizable=no,toolbar=no,menu=no,location=no,status=yes,top=130,left=0');

	parent.framevideo.document.getElementById("video").innerHTML="<div style='width:350;height:450;'><br><br><span class='ennegreo'>Si solo escuchas el canal pero no lo ves haz <a href='javascript:parent.framevideo.justinpopwin1.focus();'>clic acá<a/></span></div>";

	void(0);

}



function popjustin(canal) {

	alert(idio("Este canal será abierto en una ventana flotante."));	

	parent.framevideo.justinpopwin1=window.open('http://es.justin.tv/'+canal+'/popout','justinpopwin','width=630,height=450,top=130,left=0,scrollbars=yes,resizable=no,toolbar=no,menu=no,location=no,status=yes,top=130,left=0');

	parent.framevideo.document.getElementById("video").innerHTML="<div style='width:350;height:450;'><br><br><span class='ennegreo'>Si solo escuchas el canal pero no lo ves haz <a href='javascript:parent.framevideo.justinpopwin1.focus();'>clic acá<a/></span></div>";

	void(0);

}

function popustream(canal) {

	alert("Este canal será abierto en una ventana flotante.");	

	parent.framevideo.justinpopwin1=window.open('http://www.ustream.tv/channel-popup/'+canales2[canal][15],'justinpopwin','width=500,height=400,top=130,left=0,scrollbars=no,resizable=no,toolbar=no,menu=no,location=no,status=yes,top=130,left=0');

	parent.framevideo.document.getElementById("video").innerHTML="<div style='width:350;height:450;'><br><br><span class='ennegreo'>Si solo escuchas el canal pero no lo ves haz <a href='javascript:parent.framevideo.justinpopwin1.focus();'>clic acá<a/></span></div>";

	void(0);

}





function rm_player(canal) {
	if (base_actual=="canales2") {
	}
	else if (base_actual=="radios") {
		eval("var canales2=radios");;
	}

	
	var url=canales2[canal][15];

	var html="";
	

	
	        html=html+"<div><object classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA height=330 id=RVOCX width=500 nojava='true'>";
           html=html+"    <param name='autostart' value='true'>";
           html=html+"    <param name='console' value='_master'>";
           html=html+"    <param name='controls' value='ImageWindow'>";
           html=html+"    <param name='src' value='"+url+"'>";
           html=html+"    <embed type='audio/x-pn-realaudio-plugin' pluginspage='http://www.real.com/player/index.html?src=001027realhome_1' width='500' height='330' controls='ImageWindow' autostart='true' console='_master' src='"+url+"' vspace='0' hspace='0'>";

           html=html+"    </embed>";
          html=html+"   </object></div>";
			html=html+"<div>";
			html=html+" <object classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA height=30 id=RVOCX width=500 nojava='true' align='top'>";
          html=html+"     <param name='controls' value='ControlPanel'>";
         html=html+"      <param name='src' value='"+url+"'>";
        html=html+"       <param name='console' value='_master'>";
        html=html+"       <embed type='audio/x-pn-realaudio-plugin' pluginspage='http://www.real.com/player/index.html?src=001027realhome_1' width='500' height='30' controls='ControlPanel' console='_master' src='"+url+"' vspace='0' hspace='0' align='top'>";
        html=html+"       </embed>";

       html=html+"      </object>";
       html=html+"      </div>";
              

     return html;

     	

}





function wm_player(canal) {

	if (base_actual=="canales2") {
	}
	else if (base_actual=="radios") {
		eval("var canales2=radios");;
	}

	
	var url=canales2[canal][15];

	var html="";

     html = html + '<OBJECT ID=MediaPlayer ';

     html = html + 'CLASSID=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 ';

     html = html + 'CODEBASE=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715 ';

     html = html + 'standby="Loading Microsoft Windows Media Player components..." ';

     html = html + 'TYPE="application/x-oleobject" width="500" height="400">';

     html = html + '<PARAM NAME="FileName" VALUE="' + url + '">';

     html = html + '<PARAM NAME="AutoStart" VALUE="true">';

     html = html + '<PARAM NAME="ShowStatusBar" VALUE="1">';

     html = html + '<PARAM NAME="ShowControls" VALUE="1">';



     //Netscape code

     html = html + '    <Embed type="application/x-mplayer2"';

     html = html + '        pluginspage="http://www.microsoft.com/windows/windowsmedia/"';

     html = html + '        filename="' + url + '"';

     html = html + '        src="' + url + '"';

     html = html + '        Name=MediaPlayer';

     html = html + '        ShowControls=1';

     html = html + '        ShowDisplay=0';

     html = html + '        ShowStatusBar=1';

     html = html + '        width="500"';

     html = html + '        height="400"';

     html = html + '        displaysize="4"';

     html = html + '        autosize=-1>';     

     html = html + '    </embed>';

     html = html + '</OBJECT>';

	

     return html;

     	

}



var idiomas = new Object(); 

idiomas['spanish'] = idio("Español");

idiomas['spanish1'] = idio("Español Americano");

idiomas['spanish2'] = idio("Español Ibérico");

idiomas['english'] = idio("Inglés");

idiomas['catalan'] = idio("Catalán");



var categorias = new Object(); 

categorias['musica'] = idio("Música");

categorias['cine'] = idio("Cine y series");

categorias['variado'] = idio("Variado");

categorias['documentales'] = idio("Documentales");

categorias['noticias'] = idio("Noticias");

categorias['anime'] = idio("Animé y animación");

categorias['infantil'] = idio("Infantil");

categorias['deportes'] = idio("Deportes");

categorias['religioso'] = idio("Religioso");



var subcategorias = new Object(); 

subcategorias ['futbol'] = idio("Fútbol");

subcategorias ['local'] = idio("TV local o regional");

subcategorias ['independiente'] = idio("TV independiente");







function cambiar_por_numero(canal) {

	cambiar(can_por_num[canal]);

	cambio_submenu('cat',canales2[can_por_num[canal]][3]);

	//cambiar_arbol(canales2[can_por_num[canal]][3]);	

	var myNode = findObj("node"+canales2[can_por_num[canal]][3]);

	highlightObjLink(myNode);

	//alert("uno");

}

function cambiar_arbol(cat) {

	var myNode = findObj("node"+cat);	

	highlightObjLink(myNode);	

	

}
function descrip4(canal) {//para mapachile
	if (base_actual=="canales2") {
	}
	else if (base_actual=="radios") {
		eval("var canales2=radios");;
	}
	
ret= "<span class='small'>"+canales2[canal][0]+"</span><br>";
ret= ret+"<table width='328'><tr><td valign=top align=left>";
ret= ret +saca_imagen(canal)
ret= ret + "</td><td valign=top><div class='detalles1'><span class='small'>"+descrip1(canal)+descrip2(canal)+"</small></span></td></tr></table>";
return ret;
			
}
function descrip5(canal) {//para mapachile
	if (base_actual=="canales2") {
	}
	else if (base_actual=="radios") {
		eval("var canales2=radios");;
	}
	
ret= "";
ret= ret+"<table width='450'><tr><td valign=top align=left>";
ret= ret +saca_imagen(canal,1)
ret= ret + "</td><td valign=top ><small><span class='inverso1'> Radio "+ canales2[canal][0]+"</span> "+descrip1(canal)+" "+descrip2(canal)+" "+descrip_ciudad(canal)+"</small></td></tr></table>";
return ret;
				
}

function descrip_ciudad(canal) {

	if (base_actual=="canales2") {
	}
	else if (base_actual=="radios") {
		eval("var canales2=radios");;
	}

	if (canales2[canal][7]!="") {
	return "("+canales2[canal][7]+")";	
	}
	else {
		return "";
	}
}
function descrip1_2(canal) {
	
	
	//eval("var canales2="+base_actual+";");
	
	

	if (base_actual=="canales2") {
	}
	else if (base_actual=="radios") {
		eval("var canales2=radios");;
	}

	
	var html_detalles="";
	var temp="";
	//temp  = (canales2[canal][6] != "") ? (idio("País")+": <b>"+canales2[canal][6])+" </b>" : ""; html_detalles = html_detalles + temp;
	//temp  = (canales2[canal][5] != "") ? (idio("Idioma")+": <b>"+idiomas[canales2[canal][5]])+" </b>" : ""; html_detalles = html_detalles + temp;
	//temp  = ((categorias[canales2[canal][3]] != "") && (categorias[canales2[canal][3]] != undefined)) ? (idio("Categoría")+": <b>"+categorias[canales2[canal][3]])+" </b>" : ""; html_detalles = html_detalles + temp;
	//temp  = ((subcategorias[canales2[canal][4]] != "") && (subcategorias[canales2[canal][4]] != undefined)) ? (" / <b>"+subcategorias[canales2[canal][4]])+" </b>" : ""; html_detalles = html_detalles + temp;	
	temp  = (canales2[canal][8] != "") ? (idio("Página Web")+": <b>"+canales2[canal][8])+" </b>" : ""; html_detalles = html_detalles + temp;
	return html_detalles;
}
function descrip1(canal) {
	
	
	//eval("var canales2="+base_actual+";");
	
	

	if (base_actual=="canales2") {
	}
	else if (base_actual=="radios") {
		eval("var canales2=radios");;
	}

	
	var html_detalles="";
	var temp="";
	temp  = (canales2[canal][6] != "") ? (idio("País")+": <b>"+canales2[canal][6])+" </b>" : ""; html_detalles = html_detalles + temp;
	temp  = (canales2[canal][5] != "") ? (idio("Idioma")+": <b>"+idiomas[canales2[canal][5]])+" </b>" : ""; html_detalles = html_detalles + temp;
	temp  = ((categorias[canales2[canal][3]] != "") && (categorias[canales2[canal][3]] != undefined)) ? (idio("Categoría")+": <b>"+categorias[canales2[canal][3]])+" </b>" : ""; html_detalles = html_detalles + temp;
	temp  = ((subcategorias[canales2[canal][4]] != "") && (subcategorias[canales2[canal][4]] != undefined)) ? (" / <b>"+subcategorias[canales2[canal][4]])+" </b>" : ""; html_detalles = html_detalles + temp;	
	temp  = (canales2[canal][8] != "") ? (idio("Página Web")+": <b>"+canales2[canal][8])+" </b>" : ""; html_detalles = html_detalles + temp;
	return html_detalles;
}

function descrip3(canal) {
	if (base_actual=="canales2") {
	}
	else if (base_actual=="radios") {
		eval("var canales2=radios");;
	}

		
	var html_detalles=canales2[canal][0]+" ";
	var temp="";
	temp  = (canales2[canal][6] != "") ? ("("+canales2[canal][6])+") " : " "; html_detalles = html_detalles + temp;
	temp  = ((categorias[canales2[canal][3]] != "") && (categorias[canales2[canal][3]] != undefined)) ? (" - "+categorias[canales2[canal][3]])+" - " : ""; html_detalles = html_detalles + temp;
	temp  = ((subcategorias[canales2[canal][4]] != "") && (subcategorias[canales2[canal][4]] != undefined)) ? (" / "+subcategorias[canales2[canal][4]])+" -" : ""; html_detalles = html_detalles + temp;	
	temp  = (canales2[canal][8] != "") ? (" "+canales2[canal][10])+" " : ""; html_detalles = html_detalles + temp;
	return html_detalles;
}

function descrip2(canal) {
	if (base_actual=="canales2") {
	}
	else if (base_actual=="radios") {
		eval("var canales2=radios");;
	}

	var html_detalles="";
	var temp="";
	temp  = (canales2[canal][10] != "") ? (idio("Descripción")+": <b>"+canales2[canal][10])+" </b>" : ""; html_detalles = html_detalles + temp;
	return html_detalles;
}



vecescambio=0;



function noencontrovideos() {
	document.getElementById("guia_contenido").innerHTML = "<div id='loader'><small>"+idio('Lo sentimos.<br>Tiempo de espera superado.<br>Quizás no existen o el servidor no responde.')+"</small></div>";
	
}

function ondemand(canal) {
//		flashObj.datos_canal("http://api.justin.tv/api/channel/show/"+canales2[canal][15]+".xml","datos_res_canal",canal);
//		flashObj.datos_canal("http://api.justin.tv/api/channel/clips/"+canales2[canal][15]+".xml?limit=100","datos_res_ondemand",canal);

	timerbuscavideos=setTimeout("noencontrovideos()",20000);

	document.getElementById("guia_contenido").innerHTML = "<div id='loader'><img src='img/load_azul7.gif'><small>"+idio('Loading videos...Please wait.')+"</small></div>";

	if (canales2[canal][14]=="justin") {
		//flashObj.datos_canal("http://api.justin.tv/api/channel/archives/"+canales2[canal][15]+".json?limit=80","datos_res_ondemand2",canal);
                     $.getJSON("http://api.justin.tv/api/channel/archives/"+canales2[canal][15]+".json?limit=80&jsonp=?", function(data){datos_res_ondemand2_directo(data,canal,0);});
	
	}
	else if (canales2[canal][14]=="mogulus")  {
		flashObj.datos_canal("http://x"+canales2[canal][15]+"x.api.channel.livestream.com/2.0/latestclips.json","datos_res_ondemand2_mogulus",canal);
	}

}

function cambiar_justinclip(clipcanal) {

	var id=objetoclis[objetoclis_nom_num[clipcanal]][15];

	var can=objetoclis[objetoclis_nom_num[clipcanal]][100];

	parent.framevideo.document.getElementById("video").innerHTML="<div id='video2'></div>";	

	parent.framevideo.document.getElementById("video_bajo").innerHTML="<div class='detalles1'>"+objetoclis[objetoclis_nom_num[clipcanal]][0]+"<br> <span class='small'>"+objetoclis[objetoclis_nom_num[clipcanal]][10]+"</span></div>";	

	parent.framevideo.abre_clip(id,can,"video2")

}

function cambiar_mogulusclip(clipcanal) {

	var id=objetoclis[objetoclis_nom_num[clipcanal]][15];//id

	var can=objetoclis[objetoclis_nom_num[clipcanal]][100];//nombre del canal

	parent.framevideo.document.getElementById("video").innerHTML="<div id='video2'></div>";	

	parent.framevideo.document.getElementById("video_bajo").innerHTML="<div class='detalles1'>"+objetoclis[objetoclis_nom_num[clipcanal]][0]+"<br> <span class='small'>"+objetoclis[objetoclis_nom_num[clipcanal]][10]+"</span></div>";	

	
	parent.framevideo.abre_clip_mogulus(id,can,"video2")

}

function entrega_compartir(canal) {
	//canales2[canal][0]

	var compartir;
	var channel=(idioma=="en") ? "channel" : "canal";
	var patwitter=(idioma=="en") ? "Channel "+canales2[canal][0]+" online" : "Canal "+canales2[canal][0]+" online" ;
	patwitter=encodeURIComponent(patwitter);
	var dominio=(idioma=="en") ? "" : "es.";
	
//	var url="http%3A%2F%2F"+dominio+"favchannels.com%2Fwatch-tv-live-online%2Fcanales%2F"+channel+"_"+canales2[canal][1]+".html";
	var url="http://"+dominio+"favchannels.com/watch-tv-live-online/canales/"+channel+"_"+canales2[canal][1]+".html";
	url=encodeURIComponent(url);
	
	//facebook	
	compartir='<iframe id="fb_frame"';
	compartir=compartir + 'src="http://www.facebook.com/plugins/like.php?app_id=182791999016&amp;href='+url+'&amp;send=false&amp;layout=button_count&amp;width=130&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=lucida+grande&amp;height=21"';
	compartir=compartir + 'scrolling="no" frameborder="0" ';
	compartir=compartir + 'style="border:none; display: inline;overflow:hidden; width:102px; height:21px;" allowtransparency="true">';
	compartir=compartir + '</iframe>';
	//+1
	compartir=compartir + '<div id="g-plusone" ';
	compartir=compartir + 'style="height: 20px; width: 62px; display: inline; text-indent: 0px; margin-top: 0px; margin-right: ';
	compartir=compartir + '0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: ';
	compartir=compartir + '0px; padding-left: 0px; background-image: initial; background-attachment: initial; ';
	compartir=compartir + 'background-origin: initial; background-clip: initial; background-color: transparent;';
	compartir=compartir + 'border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; ';
	compartir=compartir + 'float: none; line-height: normal; font-size: 1px; vertical-align: baseline; ';
	compartir=compartir + 'background-position: initial initial; background-repeat: initial initial; ">';
	compartir=compartir + '<iframe allowtransparency="true" frameborder="0" hspace="0" id="I1_1323492304028" ';
	compartir=compartir + 'marginheight="0" marginwidth="0" name="I1_1323492304028" scrolling="no" ';
	compartir=compartir + 'src="https://plusone.google.com/_/+1/fastbutton?name=description&amp;url='+url+'&amp;size=medium&amp;count=true&amp;annotation=&amp;hl=en-US&amp;jsh=m%3B%2F_%2Fapps-static%2F_%2Fjs%2Fwidget%2F__features__%2Frt%3Dj%2Fver%3DqEPIOJrDcwM.es.%2Fsv%3D1%2Fam%3D!74w1rtNiplGIAAr7Ig%2Fd%3D1%2F#id=I1_1323492304028&amp;parent=http%3A%2F%2F'+dominio+'favchannels.com&amp;rpctoken=200871488&amp;_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe" style="width: 62px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; height: 20px; position: static; left: 0px; top: 0px; visibility: visible; " ';
	compartir=compartir + 'tabindex="-1" vspace="0"  title="+1"></iframe></div>';
	//twitter
	compartir=compartir + '<iframe allowtransparency="true" frameborder="0" scrolling="no" ';
	compartir=compartir + 'src="http://platform.twitter.com/widgets/tweet_button.html#_=1323492310458&amp;_version=2&amp;count=horizontal&amp;enableNewSizing=false&amp;id=twitter-widget-0&amp;lang=en&amp;original_referer=http%3A%2F%2F'+dominio+'favchannels.com%2F%3F'+num_por_can[canal]+'&amp;size=m&amp;text='+patwitter+'&amp;url=http%3A%2F%2F'+dominio+'favchannels.com%2F%3F'+num_por_can[canal]+'&amp;via=favchannels" ';
	compartir=compartir + 'class="twitter-share-button twitter-count-horizontal" ';
	compartir=compartir + 'style="height: 20px; width: 80px; display: inline;" title="Twitter Tweet Button">';
	compartir=compartir + '</iframe>';
		
	return compartir;
}
function cambiar(canal,tipo) {

//	var canales2=radios;

	if (base_actual=="canales2") {
	}
	else if (base_actual=="radios") {
		eval("var canales2=radios");;
	}

	if (tipo=="justinclip") {

		cambiar_justinclip(canal);

		return;

	}
	if (tipo=="mogulusclip") {

		cambiar_mogulusclip(canal);

		return;

	}	

	vecescambio=vecescambio+1;

	

//	var reddit=" <a target='_new' href='http://reddit.com/submit?url=Http%3A%2F%2F"+dominio+"%3F"+num_por_can[canal]+"&title=Canal+"+num_por_can[canal]+"+"+canales2[canal][0]+"'> <img src='img/reddit.ico' width=16 border=0 align='ABSMIDDLE' border=0></a> ";		
//	var del=" <a target='_new' href='http://del.icio.us/post?url=Http%3A%2F%2F"+dominio+"%3F"+num_por_can[canal]+"&title=Canal+"+num_por_can[canal]+"+"+canales2[canal][0]+"'> <img src='img/del.ico' width=16 border=0 align='ABSMIDDLE' border=0></a> ";		
//	var digg=" <a target='_new' href='http://digg.com/submit?url=Http%3A%2F%2F"+dominio+"%3F"+num_por_can[canal]+"&title=Canal+"+num_por_can[canal]+"+"+canales2[canal][0]+"'> <img src='img/digg.png' width=16 border=0 align='ABSMIDDLE' border=0></a> ";	
//	var facebook= "<a target='_new' href='http://www.facebook.com/sharer.php?u=Http%3A%2F%2F"+dominio+"%3F"+num_por_can[canal]+"&t=Canal+"+num_por_can[canal]+"+"+canales2[canal][0]+"'>"+idio('Compartir')+"<img src='img/fb2.png' border=0 align='ABSMIDDLE'></a> ";

	if (parent.framevideo.justinpopwin1 != null) {parent.framevideo.justinpopwin1.close();}

	clearInterval(timer);	

	var html="";

	var html_detalles=descrip1_2(canal)+descrip2(canal);

	

	if (html_detalles.length <70 ) {html_detalles = "<center>"+html_detalles +"</center>";}

	

	html_detalles = "<div class='detalles1'><span class='small'>"+html_detalles+"</span></div>";

	if (idioma=="en") {enlace="http://"+dominio+"/watch-tv-live-online/channel_"+canal+".html";}

	else {enlace="http://"+dominio+"?"+num_por_can[canal];}

		
	html = html +'<center><span class="small">';
	
	//canal y numero
	var html_arriba ='<center><span class="small">';

	var canal_numero="";
	if (base_actual=="canales2") {
		 canal_numero = canal_numero + '<b>'+canales2[canal][0]+'</b>';
		 canal_numero = canal_numero + '('+idio("canal")+' '+num_por_can[canal]+') ';	
	}
	else if (base_actual=="radios") {
		 canal_numero = canal_numero + '<b>Radio '+canales2[canal][0]+'</b>';
	} 

	html_arriba=html_arriba+"<table  width=500 CELLSPACING='0' border='0' CELLPADDING='0'>";
	html_arriba=html_arriba+"<tr><td style='align:left;' align='left'><div  style='width:220;overflow:hidden;height:21px;align:left;'>";
	html_arriba=html_arriba+"<span class='ennegreo'>"+canal_numero+"</span>";
	html_arriba=html_arriba+"</div>";
	html_arriba=html_arriba+"</td><td  style='align:right;' align='right'>";
	if (base_actual=="canales2") {html_arriba=html_arriba+entrega_compartir(canal);}
	html_arriba=html_arriba+"</td></tr><table>";	
	html_arriba=html_arriba+"</span></center>";
	
//	html = html + "<br>";

//	html = html +""+facebook+reddit+del+digg+ " ";

	html = html + "<img align='ABSMIDDLE' src='img/link.png'><input class='form1' style='font-size:11;'  onClick='javascript:this.select();' size=15 value='"+enlace+"'>"

	if (ya_es_fav(canal)) {

		html = html +'<div id="opcionfav" style="display:inline;"> <a href="javascript:sacar_fav(\''+canal+'\');"> '+idio('Sacar de favoritos')+'</a></div>';

	}

	else {

		html = html +'<div id="opcionfav" style="display:inline;"> <img src="img/41.png" border=0 align="ABSMIDDLE" vspace=1> <a href="javascript:sumar_fav(\''+canal+'\');">'+idio('Sumar a favoritos')+'</a></div>';

	}

	if (canales2[canal][14]=="justin" || canales2[canal][14]=="mogulus" ) {

		html = html +' <img src="img/39.png" border=0 align="ABSMIDDLE" vspace=1> <a href="javascript:parent.framechatoguia.ondemand(\''+canal+'\');">'+idio('Videos archivados')+'</a>';

	} 

	html = html + ' </span></center>';

	
	parent.framevideo.document.getElementById("video_bajo1").innerHTML=html_arriba;
	
	if (canales2[canal][16]=="" || canales2[canal][16]=="tvchilena3") {//p: todo esto de tvchielna3 deberia ser mas limpio.
		parent.framevideo.document.getElementById("video_bajo").innerHTML=html+html_detalles;

	}

	else  {

		parent.framevideo.document.getElementById("video_bajo").innerHTML="<table width='100%'><tr><td valign=top align=left>"+"<img  border=0  src='"+canales2[canal][16]+"' width='65' height='48'>"+"</td><td valign=top>"+html+html_detalles+"</td></tr></table>";

	}

	if (parent.framevideo.document.getElementById("MediaPlayer") != null) {

		if (document.all) {parent.framevideo.document.getElementById("MediaPlayer").stop();}

	}

	


	if (canales2[canal][11]==0) { 

	

		var temphtml="";

		

		switch(canales2[canal][14]) {

			case "wm":

			temphtml=wm_player(canal);

			parent.framevideo.rotar_publi=false;

			break;

			

			case "rm":

			temphtml=rm_player(canal);

			parent.framevideo.rotar_publi=false;

			break;

			

			case "justin":			

			
//			temphtml='<iframe target="contents" href="pa_justin_custom.html?'+canales2[canal][15]+'"   name="iframevideo" id="iframevideo"  src="pa_justin_custom.html?'+canales2[canal][15]+'" scrolling="no" style="width:500px; height:395px; margin:0px; padding:0px;" frameborder="0"></iframe>'; 			
			temphtml='<iframe target="contents" href="pa_justin.html?'+canales2[canal][15]+'"   name="iframevideo" id="iframevideo"  src="pa_justin.html?'+canales2[canal][15]+'" scrolling="no" style="width:500px; height:395px; margin:0px; padding:0px;" frameborder="0"></iframe>'; 			

			parent.framevideo.rotar_publi=true;		

			break;


			case "rtmp":			

			
//			temphtml='<iframe target="contents" href="pa_justin_custom.html?'+canales2[canal][15]+'"   name="iframevideo" id="iframevideo"  src="pa_justin_custom.html?'+canales2[canal][15]+'" scrolling="no" style="width:500px; height:395px; margin:0px; padding:0px;" frameborder="0"></iframe>'; 			
			temphtml='<iframe target="contents" href="pa_rtmp.html?'+canales2[canal][15]+'"   name="iframevideo" id="iframevideo"  src="pa_rtmp.html?'+canales2[canal][15]+'" scrolling="no" style="width:500px; height:395px; margin:0px; padding:0px;" frameborder="0"></iframe>'; 			

			parent.framevideo.rotar_publi=true;		

			break;
			case "sopcast":			

			temphtml='<iframe target="contents" href="http://www.sopcast.cn/channel/player.html?sopURL='+canales2[canal][15]+'&chName='+canales2[canal][0]+'"   name="iframevideo" id="iframevideo"   src="http://www.sopcast.cn/channel/player.html?sopURL='+canales2[canal][15]+canales2[canal][0]+'"    scrolling="no" style="width:396px; height:395px; margin:0px; padding:0px;" frameborder="0"></iframe>'; 			

			parent.framevideo.rotar_publi=true;			

			break;

									

			case "tikilive":			

			temphtml='<iframe target="contents" href="pa_tikilive.html?'+canales2[canal][15]+'"   name="iframevideo" id="iframevideo"  src="pa_tikilive.html?'+canales2[canal][15]+'" scrolling="no" style="width:500px; height:395px; margin:0px; padding:0px;" frameborder="0"></iframe>'; 			

			parent.framevideo.rotar_publi=true;			

			break;			



			case "freedocast":			

			temphtml='<iframe target="contents" href="pa_freedocast.html?'+canales2[canal][15]+'"   name="iframevideo" id="iframevideo"  src="pa_freedocast.html?'+canales2[canal][15]+'" scrolling="no" style="width:500px; height:395px; margin:0px; padding:0px;" frameborder="0"></iframe>'; 			

			parent.framevideo.rotar_publi=true;			

			break;

			

			case "freedocast2":			

			temphtml='<iframe target="contents" href="pa_freedocast2.html?'+canales2[canal][15]+'"   name="iframevideo" id="iframevideo"  src="pa_freedocast2.html?'+canales2[canal][15]+'" scrolling="no" style="width:500px; height:395px; margin:0px; padding:0px;" frameborder="0"></iframe>'; 			

			parent.framevideo.rotar_publi=true;			

			break;			

												

			case "mogulus":

			temphtml='<iframe target="contents" href="pa_mogulus.html?'+canales2[canal][15]+'"   name="iframevideo" id="iframevideo"  src="pa_mogulus.html?'+canales2[canal][15]+'" scrolling="no" style="width:500px; height:395px; margin:0px; padding:0px;" frameborder="0"></iframe>'; 			

			parent.framevideo.rotar_publi=true;

			break;

			

			case "ustream":

			temphtml='<iframe target="contents" href="pa_ustream.html?'+canales2[canal][15]+'"   name="iframevideo" id="iframevideo"  src="pa_ustream.html?'+canales2[canal][15]+'" scrolling="no" style="width:500px; height:395px; margin:0px; padding:0px;" frameborder="0"></iframe>'; 			

			parent.framevideo.rotar_publi=true;

			break;			

						

			default:

			temphtml='<iframe target="contents" href="'+canales2[canal][2]+'"   name="iframevideo" id="iframevideo" src="'+canales2[canal][2]+'"  scrolling="no" style="width:500px; height:395px; margin:0px; padding:0px;" frameborder="0"></iframe>'; 

			parent.framevideo.rotar_publi=true;

			break;

		}

		

		parent.framevideo.document.getElementById("video").innerHTML="<center>"+temphtml+"</center>";



	}

	else if (canales2[canal][11]<0) {

		switch(canales2[canal][14]) {

			case "justin":		

			/*

			popjustin(canal);

			parent.framevideo.document.getElementById("video_bajo").innerHTML=html+'<br><center><span class="small">Si tienes problemas viendo este canal haz <a href="http://es.justin.tv/'+canal+'/popout" target="_new">clic acá</a></span></center>';		

			*/

			temphtml='<iframe target="contents" href="pa_justin_custom.html?'+canales2[canal][15]+'"   name="iframevideo" id="iframevideo"  src="pa_justin_custom.html?'+canales2[canal][15]+'" scrolling="no" style="width:500px; height:395px; margin:0px; padding:0px;" frameborder="0"></iframe>'; 			

			parent.framevideo.rotar_publi=true;		

			parent.framevideo.document.getElementById("video").innerHTML="<center>"+temphtml+"</center>";

//			flashObj.datos_canal("http://api.justin.tv/api/stream/list.json?channel="+canales2[canal][15]+"&azar="+rand_no,"datos_res_canal4",canal);	
                          $.getJSON("http://api.justin.tv/api/stream/list.json?channel="+canales2[canal][15]+"&azar="+rand_no+"&jsonp=?", function(data){datos_res_canal4_directo(data,canal,0);});



			break;

			

			case "ustream":		

			popustream(canal);

			parent.framevideo.document.getElementById("video_bajo").innerHTML=html+'<br><center><span class="small">Si tienes problemas viendo este canal haz <a href="http://www.ustream.tv/channel-popup/'+canales2[canal][15]+'" target="_new">clic acá</a></span></center>';		

			break;

			

			case "":		

			popup2(canales2[canal][2]);

			//parent.framevideo.document.getElementById("video_bajo").innerHTML=html+'<br><center><span class="small">Si tienes problemas viendo este canal haz <a href="http://www.ustream.tv/channel-popup/'+canales2[canal][15]+'" target="_new">clic acá</a></span></center>';		

			break;			

			

		}

	}

	else if (canales2[canal][11]>0) {

		alert(idio("Si la imagen no aparece búsquela con el scroll."));		

//		parent.framevideo.document.getElementById("video").innerHTML='<iframe target="contents" href="'+canales2[canal][2]+'"   name="iframevideo" id="iframevideo" src="'+canales2[canal][2]+'"  scrolling="auto" style="width:490px; height:400px" frameborder="0"></iframe>';
		var rand_no2 = parseInt(Math.random()*100);

		parent.framevideo.document.getElementById("video").innerHTML='<iframe target="contents" name="iframevideo'+rand_no2+'" id="iframevideo'+rand_no2+'" src="pa_iframe.html?'+canales2[canal][2]+'"  scrolling="auto" style="width:490px; height:400px" frameborder="0"></iframe>';

		setTimeout("scroll("+canales2[canal][11]+","+canales2[canal][12]+","+rand_no2+")",4000);

		setTimeout("scroll("+canales2[canal][11]+","+canales2[canal][12]+","+rand_no2+")",8000);

		setTimeout("scroll("+canales2[canal][11]+","+canales2[canal][12]+","+rand_no2+")",12000);	

		

		

	}

	

		

	parent.framevideo.document.getElementById("formcanal").value=num_por_can[canal];

	

	if (canal_actual != canal) {

		canal_previo = canal_actual;

		canal_actual = canal;

	}

	minutos_canal_actual=0;	

	minutos_canal_actual_total=0;

	



	

	if ((canales2[canal][3]=="deportes") && (mostrar_estatus==true)) {

		mostrar_estatus=false;	

		cambio_submenu('cat',"deportes");	

	}	

	if ((canales2[canal][3]=="anime") && (mostrar_estatus==true)) {

		mostrar_estatus=false;	

		cambio_submenu('cat',"anime");	

	}	

	if ((canales2[canal][3]=="cine") && (mostrar_estatus==true)) {

		mostrar_estatus=false;	

		cambio_submenu('cat',"cine");	

	}	

	if ((canales2[canal][3]=="noticias") && (mostrar_estatus==true)) {

		mostrar_estatus=false;	

		cambio_submenu('cat',"noticias");	

	}				

	if (typeof(parent.framevideo.iframevideo)  != "undefined") {

		parent.framevideo.document.getElementById('iframevideo').contentWindow.document.bgColor=document.bgColor;

	}



/*	

	if (cargo_publicidad_izq_arriba==0) {

		publicidad_izq_arriba();

		cargo_publicidad_izq_arriba=1;

	}

*/

	top.document.title=canales2[canal][1];

	var rand_no = Math.random();

	parent.framevideo.document.getElementById("imagencanal").innerHTML="<img border=0  src='http://static-cdn.justin.tv/previews/live_user_"+canales2[canal][15]+"-75x56.jpg?azar="+rand_no+"' width='65' height='48'>";

			

	parent.framevideo.document.getElementById("programacion").style.display="none";

//	if (typeof(top.framechatoguia.framerecomendados)!="undefined") {
	if (typeof(top.framechatoguia)!="undefined") {

//		if (typeof(top.framechatoguia.framerecomendados.programas2[canal])!="undefined") {
		if (typeof(top.framechatoguia.programas2[canal])!="undefined") {


			hayprogramacion=1;

//			procesa_programacion(top.framechatoguia.framerecomendados.programas2[canal],canal);
			procesa_programacion(top.framechatoguia.programas2[canal],canal);

		}

		else {hayprogramacion=0;}

	} else {

		hayprogramacion=0;

	}

	
	

	if (firefox) {//asi hay programacion y esta en firefox no mostrara nunca publicidad abajo.

		return;

	}

	else {

		timer = setTimeout(function (){cambia_chat(2000)},200000);
//		timer = setTimeout(function (){cambia_chat(2000)},10000);

		if (hayprogramacion==0) {setTimeout("cambiar_publicidad1('"+canal+"')",6000);}

	}

				

		

	if (vecescambio==1) {
;
		azar=Math.floor(Math.random()*2)+1;

		if (azar==1) {

			//abre_telecito("telecito_teclado.swf");

			//abre_telecito("telecito_teclado_navidad.swf");

			abre_telecito("donate.swf");

		}

		else if (azar==2) {

			abre_telecito("telecito_tuweb.swf");

		}

	}

}

var hayprogramacion=0;



function procesa_programacion(programas,canal) {//programas es array


		
		var factorpixel=0.06;

		var inicio_px=69;

		var alto=52;

		var xxxx=0;

		var iniciopag=22;

		var clic="top.framechatoguia.cambiar(\""+top.framechatoguia.canales2[canal][1]+"\",\""+top.framechatoguia.canales2[canal][14]+"\")";

		var overclic=top.framechatoguia.descrip3(canal);

		

		var ahora=new Array();

		var op=0;	

		for (pro in programas) {

			if (op>5) {break;} 

//	function procesa_canal2(canal,pro,randomnumber,clic,overclic,i) {

			xxxx=xxxx+1+"."+randomnumber;

//			ancho_px=top.framechatoguia.framerecomendados.stampTopixeles(programas[pro][1]-programas[pro][0]);
			ancho_px=stampTopixeles(programas[pro][1]-programas[pro][0]);

			if (ancho_px<0) continue;

//			if (ancho_px<0) return;

//			ubicacion_px=top.framechatoguia.framerecomendados.sacaubicacion(programas[pro][0]);				
			ubicacion_px=sacaubicacion(programas[pro][0]);				

			if (ubicacion_px<0 && ((ancho_px+ubicacion_px)>0)) {

				ancho_px=ancho_px+ubicacion_px;

				ubicacion_px=0;

			} 

			else if ((ubicacion_px<0 && ((ancho_px+ubicacion_px)<0))) {

				continue;

//				return;

			}

			ahora.push(programas[pro]);

			op++;

			

			var randomnumber=Math.floor(Math.random()*11)

			

			imagen=saca_imagen(canal);//"";


			

//			html="<span alt='"+programas[pro][2]+"' title='"+programas[pro][2]+" - "+programas[pro][3]+"'>"+top.framechatoguia.framerecomendados.stampTohora(programas[pro][0])+" - "+top.framechatoguia.framerecomendados.stampTohora(programas[pro][1])+"<br>";
			html="<span alt='"+programas[pro][2]+"' title='"+programas[pro][2]+" - "+programas[pro][3]+"'>"+stampTohora(programas[pro][0])+" - "+stampTohora(programas[pro][1])+"<br>";

			html=html+programas[pro][2]+"</span>";	

			

					/*

			createDiv(document.body,"logo"+xxxx,-1,((alto*i)-alto)+iniciopag,0,alto,inicio_px,-1,"absolute","inline","<a title='"+overclic+"' href='javascript:"+clic+"'>"+imagen+"</a>");

	

			createDiv(document.body,"uno"+xxxx,-1,((alto*i)-alto)+iniciopag,ubicacion_px+inicio_px,alto,ancho_px,"10px","absolute","inline","");

			createDiv(document.getElementById("uno"+xxxx),"dos"+xxxx,"dentroprog2",-1,-1,-1,-1,-1,-1,-1,"");

			createDiv(document.getElementById("dos"+xxxx),"tres"+xxxx,"dentroprog3",-1,-1,-1,-1,-1,-1,-1,"");

			createDiv(document.getElementById("tres"+xxxx),"cuatro"+xxxx,"dentroprog4",-1,-1,-1,-1,-1,-1,-1,html);	

			*/

	}

	

	parent.framevideo.document.getElementById("bloque_publi1").style.display="none";

	parent.framevideo.document.getElementById("bloque_publi_canal").style.display="none";

	parent.framevideo.document.getElementById("programacion").style.display="block";

//	parent.framevideo.document.getElementById("programacion").innerHTML="<span class='small'>"+idio("Ahora:")+" <b><i>"+ahora[0][2]+"</i></b><br>"+idio("Luego a las ")+" "+top.framechatoguia.framerecomendados.stampTohora(ahora[1][0])+":<b><i>"+ahora[1][2]+"</i></b> (<a href=\"javascript:top.framechatoguia.cambio_etiqueta('recomendados');\">...más</a>)</small>";
	parent.framevideo.document.getElementById("programacion").innerHTML="<span class='small'>"+idio("Ahora:")+" <b><i>"+ahora[0][2]+"</i></b><br>"+idio("Luego a las ")+" "+stampTohora(ahora[1][0])+":<b><i>"+ahora[1][2]+"</i></b> (<a href=\"javascript:top.framechatoguia.cambio_etiqueta('recomendados');\">...más</a>)</small>";

	setTimeout("saca_programacion('"+canal+"')",50000);	

}

//julio: por aca voy.. me falta un cafe
function secargoimagen(thumb) {
	eval("clearInterval(timer_"+thumb+");");
	//var timersobrepan =null;
	//timersobrepan = setTimeout("vuelve_de_sobrepan()",8000);

}
function no_cargo_imagen(thumb) {

	document.getElementById(thumb).src='img/fav_cuadrado4.png';//http://localhost/img/fav_cuadrado4.png
	
}
//borrar
function saca_imagen2(canal) {
		if (base_actual=="canales2") {
	}
	else if (base_actual=="radios") {
		eval("var canales2=radios");;
	}
	
	var estethumb="thumb_"+canales2[canal][1];
	setTimeout(function() {sobrepan1(canal,tipo)}, 1000);
	setTimeout("cambio_etiqueta('chat')",tiempo);

	
	var timerthumb=" timer_"+estethumb+" =null;clearInterval(timer_"+estethumb+");timer_"+estethumb+" = setTimeout(\"no_cargo_imagen('"+estethumb+"')\",3000);"
	eval(timerthumb);
	var encarga=" onload='secargoimagen(\"thumb_"+canales2[canal][1]+"\");' ";
	var img_id=" id='thumb_"+canales2[canal][1]+"' ";
	var imagen="";
	var randomnumber=Math.floor(Math.random()*11);
	
//		 if (top.framechatoguia.canales2[canal][16]!="" && top.framechatoguia.canales2[canal][16]!="tvchilena3") {
		 if (canales2[canal][16]!="" && canales2[canal][16]!="tvchilena3") {

//				imagen= "<img  border=0  "+img_id+" src='"+top.framechatoguia.canales2[canal][16]+"' width='65' height='48'>";
				imagen= "<img  border=0  "+img_id+encarga+" src='"+canales2[canal][16]+"' width='65' height='48'>";

			}	

//			else if (top.framechatoguia.canales2[canal][14]=="justin") {
			else if (canales2[canal][14]=="justin") {

//				imagen= "<img border=0 "+img_id+" src='http://static-cdn.justin.tv/previews/live_user_"+top.framechatoguia.canales2[canal][15]+"-75x56.jpg?azar="+randomnumber+"' width='65' height='48'>";
				imagen= "<img border=0 "+img_id+encarga+" src='http://static-cdn.justin.tv/previews/live_user_"+canales2[canal][15]+"-75x56.jpg?azar="+randomnumber+"' width='65' height='48'>";

			}	

//			else if (top.framechatoguia.canales2[canal][14]=="mogulus") {
			else if (canales2[canal][14]=="mogulus") {

//				imagen= "<img border=0  "+img_id+" src='http://thumbnail.api.livestream.com/thumbnail?name="+top.framechatoguia.canales2[canal][15]+"&azar="+randomnumber+"' width='65' height='48'>";
				imagen= "<img border=0  "+img_id+encarga+" src='http://thumbnail.api.livestream.com/thumbnail?name="+canales2[canal][15]+"&azar="+randomnumber+"' width='65' height='48'>";

			}							

			else {

				imagen= "<img  border=0  "+img_id+encarga+" src='img/fav_cuadrado4.png' width='65' height='48'>";
				imagen= "";

			}
			return new Array(imagen,img_id) ;

}
function saca_imagen(canal,solosihay) {
	//var arr=new Array;	
	var arr=saca_imagen2(canal);
	
	if (arr[0] != "") {
		return arr[0];
	}
	else {
		if (solosihay==1) {
			return "";
		}
		else {
			return "<img  border=0  "+arr[1]+" src='img/fav_cuadrado4.png' width='65' height='48'>";
		}
	}
	
}
function saca_programacion(canal) {

	parent.framevideo.document.getElementById("programacion").style.display="none";	

	cambiar_publicidad1(canal);	

	hayprogramacion=0;

}

function cierratelecito() {

	document.getElementById("contendor_telecito").innerHTML="<div id='telecito_content'></div>";

}

function abre_telecito(swf) {

	document.getElementById("contendor_telecito").innerHTML="<div id='telecito_content'></div>";

	var flashvars = {



	};

	var params = {

	  wmode: "transparent",

	  allowScriptAccess: "always"	  

	};

	var attributes = {

	  id: "telecito",

	  name: "telecito"

	};		

	src="telecito/"+idioma3+swf;	

	



	swfobject.embedSWF(src, "telecito_content", "130", "100", "9.0.0", "expressInstall.swf", flashvars, params, attributes);	

	

}



function cambia_estatus2() {

	canal=canal_actual;

	document.getElementById('frameuser').contentWindow.cambia_estatus(num_por_can[canal],canales2[canal][0]);

}

function borrar1() {

}

function cambio_chkb_compartir(esto) {

	nuevo_estado=esto.checked;

	if (nuevo_estado == true) cambio_etiqueta("user");

	if (typeof(document.getElementById('frameuser'))  != "undefined")

	{

		resultado=document.getElementById('frameuser').contentWindow.user_cambia_mandar_status(nuevo_estado,esto);

		

		esto.checked=resultado;

		puede_cambiar_fb_status_efectivamente=resultado;



	}



}

function pone_fb_user(foto,nombre) {

	if (foto =="" &&  nombre=="") {document.getElementById("fb_user").innerHTML="";return;}

	

	foto = (foto !="") ? "<img border='0' src='"+foto+"'>" :"";

	check ="";

	

	if (puede_cambiar_fb_status=="si") {check="checked"}

	compartir ="<br><table border='0'><tr><td valign='top'><input type='checkbox' "+check+" onClick='cambio_chkb_compartir(this);' id='compartir'></td><td><label for='compartir'><span class='ennegreo'><font size='1'>"+idio("Compartir con mis amigos Facebook cuando veo un canal por más de 18 minutos")+"</label></font></span></td></tr></table>";

	contenido = "<table border='0' width=450><tr><td>"+foto+"</td><td><span class='ennegreo'> "+idio("Bienvenide")+" <b>"+nombre+"</b></span>";

	contenido = contenido + compartir + "</td></table>";

	document.getElementById("fb_user").innerHTML=contenido;

}





function cambiar_publicidad1(canal) {

	if (parent.framevideo.rotar_publi==true) {

		azar=Math.floor(Math.random()*5)+1;

		parent.framevideo.document.getElementById("programacion").style.display="none";

		if (canales2[canal][13] > 0) {

			var temp1=(pbl[canal] != "") ? pbl[canal] : canal; 		

			parent.framevideo.document.getElementById("bloque_publi1").style.display="none";

			parent.framevideo.document.getElementById("bloque_publi_canal").style.display="block";

			parent.framevideo.document.getElementById("bloque_publi_canal").innerHTML='<iframe   name="publi_esp" id="publi_esp" src="'+dirpbl+'pbl/'+temp1+'_publicidad_izq'+azar+'.html"  scrolling="no" style="width:467px; height:59px" frameborder="0"></iframe>';

			

			

		}	

		else {

			parent.framevideo.document.getElementById("bloque_publi_canal").style.display="none";

			if (canal_previo != "") {

				if ((canales2[canal_previo][3] != canales2[canal][3])) {

					
					
				var src=dirpbl+'pbl/pa_googleads.html?'+canales2[canal][3]+'_publicidad_izq'+azar+'.html';
				var temp1='<iframe   name="publi_esp4" id="publi_esp4" src="'+src+'"  scrolling="no" width="467px" height="60px" frameborder="0"></iframe>';
				parent.framevideo.document.getElementById("bloque_publi1").innerHTML=temp1;	
				//parent.framevideo.document.getElementById("bloque_publi1").innerHTML='<iframe   onload="acorta(\'bloque_publi1\',\'publi_esp4\',59);" name="publi_esp4" id="publi_esp4" src="'+dirpbl+'pbl/'+canales2[canal][3]+'_publicidad_izq'+azar+'.html"  scrolling="no" width="467px" height="130px" frameborder="0"></iframe>';					

					parent.framevideo.document.getElementById("bloque_publi1").style.display="block";					

				}		

			}

			else {

				var src=dirpbl+'pbl/pa_googleads.html?'+canales2[canal][3]+'_publicidad_izq'+azar+'.html';
				var temp1='<iframe   name="publi_esp4" id="publi_esp4" src="'+src+'"  scrolling="no" width="467px" height="60px" frameborder="0"></iframe>';
				parent.framevideo.document.getElementById("bloque_publi1").innerHTML=temp1;
				//parent.framevideo.document.getElementById("bloque_publi1").innerHTML='<iframe  onload="acorta(\'bloque_publi1\',\'publi_esp4\',59);"  name="publi_esp4" id="publi_esp4" src="'+dirpbl+'pbl/'+canales2[canal][3]+'_publicidad_izq'+azar+'.html"  scrolling="no" width="467px" height="130px"  frameborder="0"></iframe>';


				parent.framevideo.document.getElementById("bloque_publi1").style.display="block";

				

			}	

		}

	}

	setTimeout("cambiar_publicidad2('"+canal+"')",3000);	

}

function cambia_publicidad_media(canal) {

	

	//ultimo_buscado

	azar=Math.floor(Math.random()*5)+1;

	buscado=((ultimo_buscado=="todas") || (ultimo_buscado=="todos") ) ? "" : ultimo_buscado;

	var src=dirpbl+'pbl/pa_googleads.html?'+buscado+idioma2+'_publicidadmedia'+azar+'.html';

//	var src='pbl/'+buscado+idioma2+'_publicidadmedia'+azar+'.html';

//	temp1='<iframe   onload="acorta(\'cellRight1\',\'publi_esp4\',200);" name="publi_esp4" id="publi_esp4" src="'+src+'"  scrolling="no" width="200px" height="410px" frameborder="0"></iframe>';

	temp1='<iframe   name="publi_esp4" id="publi_esp4" src="'+src+'"  scrolling="no" width="200px" height="200px" frameborder="0"></iframe>';

	return temp1;

}

function cambiar_publicidad2(canal) {	//arriba derecha



	setTimeout("cambiar_publicidad3('"+canal+"')",3000);

	return;



	azar=Math.floor(Math.random()*5)+1;

	var src="";

	if (canales2[canal][13] == 2) {

		var temp1=(pbl[canal] != "") ? pbl[canal] : canal; 

		src=dirpbl+"pbl/"+temp1+'_publicidad'+azar+'.html?2';

	}	

	else if ((canales2[canal][3]!="variado")) {//pone de la seccion

		src=dirpbl+"pbl/"+canales2[canal][3]+idioma2+'_publicidad'+azar+'.html?1';	

	}

	else if(canales2[canal][6]!="") {//pone del pais

	

		var pais=limpia_pais(canal);

		

		src=dirpbl+"pbl/"+pais+'_pbl_arr'+azar+'.html?2';		

	}

	else {//pone variado

		src=dirpbl+"pbl/"+'variado'+idioma2+'_publicidad'+azar+'.html?1';

	}

	

	

		if (canal_previo != "") {

			//si la categoria es distinta o .... la la cat es variado y el paise es distintro

		if ((canales2[canal][13] == 2) || (canales2[canal_previo][3] != canales2[canal][3]) || ((canales2[canal][3]=="variado") && (canales2[canal_previo][6] != canales2[canal][6])  )) {

			document.getElementById("publicidad_arriba1").innerHTML='<iframe   onload="acorta(\'publicidad_arriba1\',\'publi_esp2\',59);" name="publi_esp2" id="publi_esp2"  src="'+src+'"   scrolling="no" width="467px" height="130px" frameborder="0"></iframe>';

			document.getElementById("publicidad_arriba1").style.display="block";			

		}		

	}

	else {

			document.getElementById("publicidad_arriba1").innerHTML='<iframe  onload="acorta(\'publicidad_arriba1\',\'publi_esp2\',59);"  name="publi_esp2" id="publi_esp2"  src="'+src+'"  scrolling="no" width="467px" height="130px"  frameborder="0"></iframe>';

			document.getElementById("publicidad_arriba1").style.display="block";

	}

	setTimeout("cambiar_publicidad3('"+canal+"')",3000);	

}

function acorta(ubicacion,nombre,h) {

	

	if (document.getElementById(ubicacion).style.display=="none") document.getElementById(ubicacion).style.display="block";	

	document.getElementById(nombre).height=h+'px';

}



function cambiar_publicidad3(canal) {	

	

	//almedio-pais

	temp_pais=canales2[canal][6];

	temp_pais = (temp_pais == "República Dominicana") ? "Dominicana" : temp_pais;

	temp_pais = (temp_pais == "España") ? "Espana" : temp_pais;

	temp_pais = (temp_pais == "México") ? "Mexico" : temp_pais;

	temp_pais = (temp_pais == "Perú") ? "Peru" : temp_pais;

	if (canal_previo != "") {

		if ((canales2[canal_previo][6] != canales2[canal][6])) {

//por ahora no hay publicidad de pais			

		}		

	}

	else {

//por ahora no hay publicidad de pais				

	}

	setTimeout("cambiar_publicidad4('"+canal+"')",3000);	

}

function limpia_pais(canal) {

	return limpia_pais2(canales2[canal][6]);

}

function limpia_pais2(pais) {

	temp_pais=pais;

	temp_pais = (temp_pais == "República Dominicana") ? "Dominicana" : temp_pais;

	temp_pais = (temp_pais == "España") ? "Espana" : temp_pais;

	temp_pais = (temp_pais == "México") ? "Mexico" : temp_pais;

	temp_pais = (temp_pais == "Perú") ? "Peru" : temp_pais;	

	return temp_pais;

}

function cambiar_publicidad4(canal) {		

	azar=Math.floor(Math.random()*5)+1;	

	

	var src="";

	if (canales2[canal][13] == 2) {

		var temp1=(pbl[canal] != "") ? pbl[canal] : canal; 

		src=dirpbl+"pbl/pa_googleads.html?"+temp1+'_publicidad_abajo'+azar+'.html?1';
		//src=dirpbl+"pbl/"+temp1+'_publicidad_abajo'+azar+'.html?1';

	}		

	else if ((canales2[canal][3]!="variado")) {

		src=dirpbl+"pbl/pa_googleads.html?"+canales2[canal][3]+idioma2+'_publicidad_abajo'+azar+'.html?2';	
		//src=dirpbl+"pbl/"+canales2[canal][3]+idioma2+'_publicidad_abajo'+azar+'.html?2';	

	}

	else if(canales2[canal][6]!="") {

		var pais=limpia_pais(canal);

		src=dirpbl+"pbl/pa_googleads.html?"+pais+'_pbl_aba'+azar+'.html?2';		
		//src=dirpbl+"pbl/"+pais+'_pbl_aba'+azar+'.html?2';		

	}

	else {

		src=dirpbl+"pbl/pa_googleads.html?"+'variado'+idioma2+'_publicidad_abajo'+azar+'.html?2';
		//src=dirpbl+"pbl/"+'variado'+idioma2+'_publicidad_abajo'+azar+'.html?2';

	}

	 

					

//top.document.title=src;

	

	//abajo-categoria

	if (canal_previo != "") {

		//si la categoria es distinta o .... la la cat es variado y el paise es distintro

		if ((canales2[canal][13] == 2) || (canales2[canal_previo][3] != canales2[canal][3]) || ((canales2[canal][3]=="variado") && (canales2[canal_previo][6] != canales2[canal][6])  )) {

			var temp1='<iframe   name="publi_esp6" id="publi_esp6" src="'+src+'"  scrolling="no" width="467px" height="60px" frameborder="0"></iframe>';
			document.getElementById("publicidad_abajo").innerHTML=temp1;
			//document.getElementById("publicidad_abajo").innerHTML='<iframe    onload="acorta(\'publicidad_abajo\',\'publi_esp6\',59);"  name="publi_esp6" id="publi_esp6" src="'+src+'"  scrolling="no" width="467px" height="130px"  frameborder="0"></iframe>';
				
			//document.getElementById("publicidad_abajo").innerHTML='<iframe    onload="acorta(\'publicidad_abajo\',\'publi_esp6\',59);"  name="publi_esp6" id="publi_esp6" src="'+src+'"  scrolling="no" width="467px" height="130px"  frameborder="0"></iframe>';

				
			document.getElementById("publicidad_abajo").style.display="block";

		}

		else {

			

			}		

	}

	else {

		
			var temp1='<iframe   name="publi_esp6" id="publi_esp6" src="'+src+'"  scrolling="no" width="467px" height="60px" frameborder="0"></iframe>';
			document.getElementById("publicidad_abajo").innerHTML=temp1;
					
			//document.getElementById("publicidad_abajo").innerHTML='<iframe   onload="acorta(\'publicidad_abajo\',\'publi_esp6\',59);"   name="publi_esp6" id="publi_esp6" src="'+src+'"  scrolling="no" width="467px" height="130px" frameborder="0"></iframe>';

			document.getElementById("publicidad_abajo").style.display="block";

	}



}



function previo() {

	if (canal_previo != "") {

	

		cambiar(canal_previo);

	}

}

function alcualiza_li_favs () {

	var arrtemp1=new Array();

	var favs=getCookie('favs');

	var html="";

	var html0="";

	

	//revisar esto:

	

		//FALTA ARREGLAR!!!!!!!!!!!!!!!!

		//esto deebería estar afuera de este else!!!!!!!!!!!!1

		if (parent.framevideo.faltasincronizarfavs == 1) {

			html0="<div id= 'adfav' style='display:inline;'><table width=250><tr><td><span class='dentrocuadroppal'><font size='1'>"+idio("Los favoritos aun no están sicronizados con tu cuenta en todosloscanales.com.")+" <a href='javascript:sincro_favs0();'>"+idio("Haz clic acá")+"</a> "+idio("para sincronizarlos ahora. (O deja que lo haga solo en unos minutos")+"</font></span></td></tr></table></div>"

		}		



			

		if (favs!=null && favs!="")

	  {

		//ya existen favs

		arrtemp1 = favs.split(";");

		

		var temp=new Object();

		temp=filter_favs(canales2,arrtemp1);

		//html=lista_canales(temp);

		lista_canales(temp,"guia_contenido",html0);



	

	

  	}

	else {

	

		var htmlnofavs=idio("No tienes favoritos")+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

		if (estalogeado!="si") {

			htmlnofavs = htmlnofavs + "<table width='300' border=0><tr><td><span class='dentrocuadroppal'><br>"+idio("Para agregar favoritos")+", <a href='javascript:cambio_etiqueta(\"user\");'>"+idio("registrate o accede con tu cuenta facebook")+"</a> <img src='img/fb2.png' border=0 align='ABSBOTTOM'></span></td></tr></table>";

		}		

		document.getElementById("guia_contenido").innerHTML =html;

	

	}

	return;	

}





function sincro_favs0() {

	sincro_favs();

	document.getElementById("adfav").innerHTML ="";

}

function sincro_favs() {



	var randomnumber=Math.floor(Math.random()*11)

	if (estalogeado=="si") {

		favs=getCookie('favs');

		document.getElementById("user").innerHTML="<iframe id='frameuser' src='/canales?node/1&favs="+favs+"&azar="+randomnumber+"' scrolling='auto'  style='width:450px; height:375px'  frameborder='0'></iframe>";

		parent.framevideo.faltasincronizarfavs == 0;

	}

	else {

		alert("Para sincronizar favoritos ingresa en 'Tu Cuenta'");

		cambio_etiqueta("user");

	}

	

	

}

function sacar_fav(canal) {

	if (estalogeado == "no") {

		alert("Para sacar favoritos ingresa en 'Tu Cuenta'");

		cambio_etiqueta("user");

		return;		

	}

	var favs;

	var arrtemp1=new Array();

	var arrtemp2=new Array();

	favs=getCookie('favs');

	if (favs!=null && favs!="") {

		arrtemp1 = favs.split(";");

		for (i in arrtemp1) {

		 	if (i == 'clone') continue;

			if (arrtemp1[i] != canal) {arrtemp2.push(arrtemp1[i]);}

		}

		setCookie('favs', arrtemp2.join(";"),365);

		alcualiza_li_favs ();		



	}

	parent.framevideo.faltasincronizarfavs=1;



}

function ya_es_fav(canal) {

	var favs;

	favs=getCookie('favs');

	eval("var pat= /\;?"+canal+"\;?/;");

	var res=favs.match(pat);

	if ( favs == canal) {//no está 

		return true;

  	}

  	else if (res == null) {

	  	return false;

  	}

  	else {return true;}

}

function scroll(x,y,az) {

	if (eval("parent.framevideo.iframevideo"+az+".window")) {eval("parent.framevideo.iframevideo"+az+".window.scrollTo("+x+","+y+");");}

}

function testeo2() {

	parent.framevideo.iframevideo.iframevideo2.window.onLoad=function() {alert(2);};

}











function agregar(){





   if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) {





      var url="http://"+dominio+"/";

/*      

		if (idioma=="en") {

			url="http://en.Todosloscanales.com/";

		}

		else {			

		}

*/

      var titulo="favChannels.com";





      window.external.AddFavorite(url,titulo);





   }





   else {





      if(navigator.appName == "Netscape")





         alert ("Presione Crtl+D para agregar este sitio en sus Bookmarks");





   }





}



var last_publi=1;

function recarga_publib() {

	return;

	switch (last_publi) {

		case 1:

		document.getElementById("publicidadb1").style.display="none";

		document.getElementById("publicidadb2").style.display="block";

		last_publi=2;

		break;

		

		case 2:

		document.getElementById("publicidadb1").style.display="block";

		document.getElementById("publicidadb2").style.display="none";

		last_publi=1;

		break;



	} 	



}


//fuciones y variables necesarias para recomendados!!!!!!!!!!!!!!!!!!!!!!!
fecha_stamp=new Date().getTime(); 
fecha_stamp=parseInt(fecha_stamp/1000); 

var programas3=[];

factorpixel=0.06;
inicio_px=40;//69
alto=33;//52

function stampTohora(stamp) {
	d=new Date(); 
	d.setTime(stamp*1000);
	var fecha=agregacero(d.getHours())+":"+agregacero(d.getMinutes());
	return fecha;
}	


function stampTopixeles(stamp) {
	return stamp*factorpixel;
}	
function sacaubicacion(stamp) {	
//	if (((stamp-(fecha_stamp/1000))*factorpixel)<0) {alert(stamp+"-"+fecha_stamp);}
	return (stamp-(fecha_stamp))*factorpixel;	
	
}	
function agregacero(numero) {
	return (numero>=10) ? numero : "0"+numero;
}

setInterval("recarga_publib()",100000);







	
