function xmlhttpPost(str,Url,tipo) {
	var xmlHttpReq = false;
	var self = this;
	var strURL = Url;
	self.opt=tipo;
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		try
	    {
	        self.xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
	    }   
	    catch (err)
	    {
	        try
	        {
	            self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	        }
	        catch (err2)
	        {
	        }
	    }
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function(tipo) {
		if (self.xmlHttpReq.readyState == 4) {

			switch (self.opt){
				case 1:
				updatepage(self.xmlHttpReq.responseText);
				break;
				case 2:
				updateVotos(self.xmlHttpReq.responseText);
				break;
				case 3:
				updateSuscrito(self.xmlHttpReq.responseText);
				break;
			}

		}
	}
	self.xmlHttpReq.send(str);
}

function updatepage(str){
	document.getElementById("DIV-videoFavorito").innerHTML = str;
}

function updateSuscrito(str){
	document.getElementById("DIV-suscribirse").innerHTML = str;
}

function updateVotos(str){
	document.getElementById("DIV-NVOTOS").innerHTML = str;
	var noVotar='';
	noVotar+='<img src="/img/opciones_votar_no.gif" width="28" height="53" border="0" align="left" usemap="#Map" class="img" />';
	noVotar+='<map name="Map" id="Map">';
	noVotar+='<area shape="rect" coords="0,0,19,17" href="javascript:yaVotado(1);" alt="Sumar voto" />';
	noVotar+='<area shape="rect" coords="0,29,18,46" href="javascript:yaVotado(1);" alt="Restar voto" />';
	noVotar+='</map>';
	document.getElementById("DIV-VOTAR").innerHTML = noVotar;
}

function videoFavorito(codVideo){
	qstr = 'codVideo=' + codVideo + '&tipo=1';  
	xmlhttpPost(qstr,"/verVideo/videosFavorito.phtml",1);
}
function quitarVideoFavorito(codVideo){
	qstr = 'codVideo=' + codVideo + '&tipo=2';  
	xmlhttpPost(qstr,"/verVideo/videosFavorito.phtml",1);
}
function suscribirse(codUsuario){
	qstr = 'codUsuario=' + codUsuario + '&tipo=1';  
	xmlhttpPost(qstr,"/verVideo/suscribirse.phtml",3);
}
function quitarSuscrito(codUsuario){
	qstr = 'codUsuario=' + codUsuario + '&tipo=2';  
	xmlhttpPost(qstr,"/verVideo/suscribirse.phtml",3);
}
function votoPlus(codVideo){
	qstr = 'codVideo='+codVideo+'&voto=1';
	xmlhttpPost(qstr,"/verVideo/votoVideo.phtml",2);
}
function votoMinus(codVideo){
	qstr = 'codVideo='+codVideo+'&voto=0';
	xmlhttpPost(qstr,"/verVideo/votoVideo.phtml",2);
}


function estilos(num){
	switch (num) {
		case 1:
		document.getElementById("relacionados").className = 'kurrin';
		document.getElementById("masdelusuario").className = '';
		document.getElementById("otrosusuarios").className = '';

		document.getElementById('relacionados2').style.display='block';
		document.getElementById('masdelusuario2').style.display='none';
		document.getElementById('otrosusuarios2').style.display='none';
		
		break;
		case 2:
		document.getElementById("relacionados").className = '';
		document.getElementById("masdelusuario").className = 'kurrin';
		document.getElementById("otrosusuarios").className = '';

		document.getElementById('relacionados2').style.display='none';
		document.getElementById('masdelusuario2').style.display='block';
		document.getElementById('otrosusuarios2').style.display='none';
		
		break
		case 3:
		document.getElementById("relacionados").className = '';
		document.getElementById("masdelusuario").className = '';
		document.getElementById("otrosusuarios").className = 'kurrin';

		document.getElementById('relacionados2').style.display='none';
		document.getElementById('masdelusuario2').style.display='none';
		document.getElementById('otrosusuarios2').style.display='block';
		
		break
		default:
		document.getElementById("relacionados").className = 'kurrin';

		document.getElementById('relacionados2').style.display='block';
		document.getElementById('masdelusuario2').style.display='none';
		document.getElementById('otrosusuarios2').style.display='none';
	}
}

var commentsmax = 10;

var totalComentarios=0;
var totalElementos=0;
var totalPaginas=0;
var paginas=new Array(0);
var maxComentarios=10;
var entra=0;

var comentarios = new Array(0);
var comentario = new Array(0);
var sub_comentario = new Array(0);

var puedeBorrars = new Array(0);
var id_comentarios = new Array(0);
var nombreUsuarios = new Array(0);
var fechaComentarios = new Array(0);
var textos = new Array(0);
var enlaceResponders = new Array(0);

var hijos = new Array(0);

var id_comentario_hijos = new Array(0);
var nombreUsuario_hijos = new Array(0);
var fechaComentario_hijos = new Array(0);
var texto_hijos = new Array(0);
var puedeBorrar_hijos = new Array(0);

var codVideo;
var enlace;
var registrado;
var pagina=1;

function init(video, enlaceComentarios) {
	codVideo=video;
	enlace=enlaceComentarios;
	estilos();
	getXMLget("/verVideo/comentarios.phtml");
}

function getXMLget(url) {
	if (url=="undefined") exit();
	var querystring = crearQueryString();
	var myAjax = null;

	myAjax = new Ajax.Request(
	url,
	{
		method: 'get',
		asynchronous: true,
		parameters: querystring,
		onComplete: processXML
	});

}
function enviarRespuesta(url,padre,comentario) {
	var querystring = crearQueryStringPost(padre,comentario);
	var myAjax = null;

	myAjax = new Ajax.Request(
	url,
	{
		method: 'post',
		asynchronous: true,
		parameters: querystring,
		onComplete:processPOST
	});
}

function enviarRespuestaAnonima(url,padre,comentario,captcha,nombre) {

	var querystring = crearQueryStringPost(padre,comentario)+"&code="+captcha+"&nombre="+nombre;
	var myAjax = null;

	myAjax = new Ajax.Request(
	url,
	{
		method: 'post',
		asynchronous: true,
		parameters: querystring,
		onComplete:processPOST
	});
}

function enviarComentario(url,comentario) {
	var querystring = crearQueryStringPost(0,comentario);
	var myAjax = null;
	
	
	myAjax = new Ajax.Request(
	url,
	{
		method: 'post',
		asynchronous: true,
		parameters: querystring,
		onComplete:processPOST
	});
}

function enviarComentarioAnonimo(url,comentario, captcha,nombre) {
	var querystring = crearQueryStringPost(0,comentario)+"&code="+captcha+"&nombre="+nombre;
	var myAjax = null;

	myAjax = new Ajax.Request(
	url,
	{
		method: 'post',
		asynchronous: true,
		parameters: querystring,
		onComplete:processPOST
	});
}

function eliminarComentario(cod) {
	var querystring = crearQueryStringEliminar(cod);
	var url='/verVideo/eliminar.phtml';
	var myAjax = null;

	myAjax = new Ajax.Request(
	url,
	{
		method: 'post',
		asynchronous: true,
		parameters: querystring,
		onComplete:processDeleteRecord
	});
}

function crearQueryString(){
	var str;

	str="coments=1";
	str+="&codVideo="+codVideo;
	str+="&pag="+pagina;
	return str;
}
function crearQueryStringPost(padre,comentario){
	var str;
	//comentario=comentario.replace("ñ","HV_ENE"); 
	str="codPadre="+padre;
	str+="&comentario="+encodeURI(escape(comentario));
	str+="&codVideo="+codVideo;
	//str=str.replace("HV_ENE","ñ"); 
	return str;
}
function crearQueryStringEliminar(cod){
	var str;
	str="id="+cod;
	return str;
}

function processXML(request) {


	var comentarios;
	try {
		comentarios = request.responseXML.getElementsByTagName("comentarios")[0];

	}
	catch (e) {
		setTimeout("getXMLget('/verVideo/comentarios.phtml')", 10000);
		registrado = request.responseXML.getElementsByTagName("registrado")[0].firstChild.nodeValue;
		if (registrado==1) comentarVideo();
		else comentarVideoAnonimo();
		return;
	}
	
	try{
		comentario = comentarios.getElementsByTagName("comentario");
		totalComentarios = comentario.length;

		totalPaginas = comentarios.getElementsByTagName("totalPaginas")[0].firstChild.nodeValue;
		registrado = comentarios.getElementsByTagName("registrado")[0].firstChild.nodeValue;
	}
	catch (e) {
		registrado = request.responseXML.getElementsByTagName("registrado")[0].firstChild.nodeValue;
		if (registrado==1) comentarVideo();
		else comentarVideoAnonimo();
		return;

	}

	for (i = 0; i < comentario.length; i++) {
	
		puedeBorrars[i] = comentario[i].getElementsByTagName("puedeBorrar")[0].firstChild.nodeValue;

		id_comentarios[i] = comentario[i].getElementsByTagName("id_comentario")[0].firstChild.nodeValue;

		nombreUsuarios[i] = comentario[i].getElementsByTagName("nombreUsuario")[0].firstChild.nodeValue;
		
		fechaComentarios[i] = comentario[i].getElementsByTagName("fechaComentario")[0].firstChild.nodeValue;

		textos[i] = comentario[i].getElementsByTagName("texto")[0].firstChild.nodeValue;

		enlaceResponders[i] = comentario[i].getElementsByTagName("enlaceResponder")[0].firstChild.nodeValue;

		try {
			hijos[i] = comentario[i].getElementsByTagName("hijos")[0];

			sub_comentario = hijos[i].getElementsByTagName("sub_comentario");
			
			puedeBorrar_hijos[i] =  new Array(0);
			id_comentario_hijos[i] = new Array(0);
			nombreUsuario_hijos[i] = new Array(0);
			fechaComentario_hijos[i] = new Array(0);
			texto_hijos[i] = new Array(0);
			for(j=0; j < sub_comentario.length; j++){
				totalElementos++;
				puedeBorrar_hijos[i][j] = sub_comentario[j].getElementsByTagName("sub_puedeBorrar")[0].firstChild.nodeValue;
				
				id_comentario_hijos[i][j] = sub_comentario[j].getElementsByTagName("sub_id_comentario")[0].firstChild.nodeValue;

				nombreUsuario_hijos[i][j] = sub_comentario[j].getElementsByTagName("sub_nombreUsuario")[0].firstChild.nodeValue;

				fechaComentario_hijos[i][j] = sub_comentario[j].getElementsByTagName("sub_fechaComentario")[0].firstChild.nodeValue;

				texto_hijos[i][j] = sub_comentario[j].getElementsByTagName("sub_texto")[0].firstChild.nodeValue;
			}
		}
		catch (e) {
			hijos[i]=0;
		}
	}
	push();
}
function push() {

	var text = '<div id="paginacionUp"></div>';

	document.getElementById("votar").style.visibility="visible";
	if (enlace!="NOPERMISO"){
		if((comentario.length ) >= 5){
			text +='<div id="votar1"><a href="'+ enlace +'" title="Comentar el video">Comentar</a></div>';
		}

		for(i=0; i<comentario.length; i++){
			text +='<div class="coment">';
			text +='<h3>'+nombreUsuarios[i]+' <span>'+fechaComentarios[i]+'</span>';

			if(puedeBorrars[i]==1){
				text +='<div style="float:right;margin-right:3px;margin-top:-15px;"><a href="javascript:borrarComentario('+id_comentarios[i]+');"><img src="/img/eliminar2.gif" border="0"></a></div>';
			}

			text += '&nbsp;';
			if(typeof(hijos[i]) == 'object'){
				text +='<div id="comentarioMas'+id_comentarios[i]+'" style="display:none;float:left;margin-left:-28px;margin-top:5px;"><a href="javascript:mostrarComentarios('+id_comentarios[i]+');"><img src="/img/mas.gif" border="0"></a></div>';
				text +='<div id="comentarioMenos'+id_comentarios[i]+'" style="float:left;margin-left:-28px;margin-top:5px;"><a href="javascript:ocultarComentarios('+id_comentarios[i]+');"><img src="/img/menos.gif" border="0"></a></div>';
			}

			text +='</h3>';
			text +='<font color="#FFFFFF">'+tratarCadenaDeTexto(unescape(textos[i]))+'</font>';
			text +='<div style="text-align:right;"><a href="'+enlaceResponders[i]+'">Responder comentario</a></div>';
			text +='</div>';
			
			if(typeof(hijos[i]) == 'object'){
				text += '<div id="respuesta'+id_comentarios[i]+'" style="display:block;">';
				sub_comentario=hijos[i].getElementsByTagName("sub_comentario");
				for(j=0; j<sub_comentario.length; j++){
					text += '<div class="subcoment">';
					text += '<h3>'+nombreUsuario_hijos[i][j]+' <span>'+fechaComentario_hijos[i][j]+'</span>';
					if(puedeBorrar_hijos[i][j]==1){
						text +='<div style="float:right;margin-right:3px;margin-top:-15px;"><a href="javascript:borrarRespuesta('+id_comentario_hijos[i][j]+');"><img src="/img/eliminar2.gif" border="0"></a></div>';
					}
					text +='</h3>';
					text += '<font color="#FFFFFF">'+tratarCadenaDeTexto(unescape(texto_hijos[i][j]))+'</font>';
					text += '</div>';
				}
				text +='</div>';
	
			}
		}
		if((comentario.length ) >= 5){
			text +='<div id="votar1"><a href="'+ enlace +'" title="Comentar el video">Comentar</a></div>';
		}
		text +='<div id="paginacionDown"></div>';
			
		if (comentario.length<5){
			if (registrado==1) comentarVideo();
			else comentarVideoAnonimo();
			document.getElementById("DIV-comentarios").innerHTML = text+document.getElementById("DIV-comentarios").innerHTML;
		}
		else document.getElementById("DIV-comentarios").innerHTML = text;

	pintarPaginacion();
	
	}
	else{
		text='<div id="permitComent">La opcion de añadir comentarios ha sido deshabilidata para este video por el usuario</div>';
		document.getElementById("DIV-comentarios").innerHTML = text;
	}
}

function mostrarComentarios(id){
	document.getElementById("respuesta"+id).style.display = "block";
	document.getElementById("comentarioMas"+id).style.display = "none";
	document.getElementById("comentarioMenos"+id).style.display = "block";
}
function ocultarComentarios(id){
	document.getElementById("respuesta"+id).style.display = "none";
	document.getElementById("comentarioMas"+id).style.display = "block";
	document.getElementById("comentarioMenos"+id).style.display = "none";
}

function responder(padre){

	text ='';
	
	text +='<span id="error_comentario" class="error"></span>';
	text += '<form name="comentar">';
	text += '<div class="coment">';
	text += '<div align="right">';
	text += '<input type="hidden" name="padre" id="padre" value="'+padre+'"/>'
	text += '<textarea style="background-color:#999; color:#000" name="respuesta" id="respuesta" cols="" rows=""></textarea>';
	text += '<input type="button" id="btnInsertarComentario" value="Responder" onClick="javascript:respondiendo();this.disabled=true;"/>';
	text += '</div>';
	text += '</div>';
	text += '</form>';
	document.getElementById("DIV-comentarios").innerHTML = text;

}
function borrarComentario(id_comentario){
	if(confirm('¡¡ATENCIÓN!!\n\n\nSI TU COMENTARIO TIENE RESPUESTAS TAMBIÉN SERÁN ELIMINADAS \n\n\¿Estás seguro que deseas eliminar tu comentario? \n\n '))
		eliminarComentario(id_comentario);
}
function borrarRespuesta(id_respuesta){
	if(confirm('¿Estás seguro de que deseas eliminar tu respuesta?'))
		eliminarComentario(id_respuesta);
}

function responderAnonimo(padre){

	text ='';
	
	
	text +='<span id="error_comentario" class="error"></span>';
	text += '<form name="comentar">';
	text += '<div class="coment"><font color="#FFFFFF">';
	text +='Nombre (opcional) </font>';
	text +='<input type="text" style="background-color:#999" size ="10" maxlength="10" id="nombre" name="nombre" /><br /><br />';
	text += '<div align="right">';
	text += '<input type="hidden" name="padre" id="padre" value="'+padre+'"/>'
	text += '<textarea style="background-color:#999; color:#000" name="respuesta" id="respuesta" cols="" rows=""></textarea>';

	text +='<span style="color:#FFFFFF">Inserta aquí el código de verificación que ves en la imagen</span>';
	text +='<input size="3" maxlength="3" type="text" id="code" name="code" />';
	text +='<img border="1" id="imgCaptcha" src="/verVideo/securimage_show.php?'+Math.random()+'"><br /><br />';
	text += '<input type="button" id="btnInsertarComentario" value="Responder" onClick="javascript:respondiendoAnonimo();this.disabled=true;"/>';
	text += '</div>';
	text += '</div>';
	text += '</form>';
	document.getElementById("DIV-comentarios").innerHTML = text;

}

function respondiendoAnonimo(){
	enviarRespuestaAnonima("/verVideo/respuesta.phtml",document.getElementById("padre").value,document.getElementById("respuesta").value,document.getElementById("code").value,document.getElementById("nombre").value);

}

function respondiendo(){
	enviarRespuesta("/verVideo/respuesta.phtml",document.getElementById("padre").value,document.getElementById("respuesta").value);

}

function comentarVideo(){
	if (enlace!="NOPERMISO"){
  	text ='';

  	text +='<span id="error_comentario" class="error"></span>';
  	text += '<form name="comentar">';
  	text += '<div class="coment">';
  	text += '<div align="right">';
  	text += '<textarea style="background-color:#999;color:#000;" name="comentario" id="comentario" cols="" rows=""></textarea>';
  	text += '<input type="button" id="btnInsertarComentario" value="Insertar Comentario" onClick="javascript:insertarComentario();this.disabled=true;"/>';
  	text += '</div>';
  	text += '</div>';
  	text += '</form>';
  	}
	else text='<div id="permitComent">No se permiten los comentarios en este video</div>';
	document.getElementById("DIV-comentarios").innerHTML = text;
}

function comentarVideoAnonimo(){
	if (enlace!="NOPERMISO"){
  	text ='';
  	text +='<span id="error_comentario" class="error"></span>';
  	
  	text += '<form name="comentar">';
  	text += '<div class="coment"><font color="#FFFFFF">';
  	text +='Nombre (opcional) </font>';
  	text +='<input type="text" style="background-color:#999" size ="10" maxlength="10" id="nombre" name="nombre" /><br /><br />';
  
  	text += '<div align="right">';
  	text += '<textarea style="background-color:#999; color:#000" name="comentario" id="comentario" cols="" rows=""></textarea>';
  	text +='<span style="color:#FFFFFF" >Inserta aquí el código de verificación que ves en la imagen</span>';
  	text +='<input size="3" maxlength="3" type="text" id="code" name="code" />';
  	text +='<img border="1" id="imgCaptcha" src="/verVideo/securimage_show.php?'+Math.random()+'"><br /><br />';
  		
  	text += '<input type="button" id="btnInsertarComentario" value="Insertar Comentario" onClick="javascript:insertarComentarioAnonimo();this.disabled=true;"/>';
  	text += '</div>';
  	text += '</div>';
  	text += '</form>';
  }	
	else text='<div id="permitComent">No se permiten los comentarios en este video</div>';
		
	document.getElementById("DIV-comentarios").innerHTML = text;
}

function insertarComentario(){

	enviarComentario("/verVideo/comentar.phtml",document.getElementById("comentario").value);

}

function insertarComentarioAnonimo(){

	enviarComentarioAnonimo("/verVideo/comentar.phtml",document.getElementById("comentario").value,document.getElementById("code").value,document.getElementById("nombre").value);

}
function lTrim(sStr){
 while (sStr.charAt(0) == " ") 
  sStr = sStr.substr(1, sStr.length - 1);
 return sStr;
}

function rTrim(sStr){
 while (sStr.charAt(sStr.length - 1) == " ") 
  sStr = sStr.substr(0, sStr.length - 1);
 return sStr;
}

function Trim(sStr){
 return rTrim(lTrim(sStr));
} 

function processPOST(request){

        if(request.responseText){

                var texto = Trim(request.responseText)
                if(texto.length>0){

                        try {
                                img = document.getElementById('imgCaptcha');
                                img.src = '/verVideo/securimage_show.php?' + Math.random();
                        }
                        catch(e){}
                        try {
                                btn = document.getElementById('btnInsertarComentario');
                                btn.disabled = false;
                        }
                        catch(e){}
                        try{
                                spanError=document.getElementById("error_comentario");
                                spanError.innerHTML="<center>"+request.responseText+"</center>";
                        }
                        catch(e){}
                }else{
                        getXMLget("/verVideo/comentarios.phtml");
                }
        }else{
                getXMLget("/verVideo/comentarios.phtml");
        }

}
function avisoDenuncia(){
	alert('Gracias, pero ya has denunciado el contenido de este video');
}

var denuncia = new Array(0);
var codTipoDenuncias = new Array(0);
var nombreDenuncias = new Array(0);
var videoDenuncia;

function denunciar(video){
	videoDenuncia=video;
	enviarDenuncia(video);
}

function enviarDenuncia(video){
	var url = "/verVideo/denunciar.phtml";

	var querystring = "codVideo="+video+"&tipoDenuncia=1";
	var myAjax = null;

	myAjax = new Ajax.Request(
	url,
	{
		method: 'post',
		asynchronous: true,
		parameters: querystring,
		onComplete: limpiarDenuncia
	});
}

function limpiarDenuncia(request){
	document.getElementById("DIV-denunciar").innerHTML=request.responseText;
}

function yaVotado(registrado){
	if (registrado) alert('Ya has votado este video');
	else alert("Registrate o logueate si deseas volver a votar.");
}

function copyit(theField) {
	alert(theField);
	theField.focus();
	theField.select();
	therange=theField.createTextRange();
	therange.execCommand("Copy");
}

function noActivadoVotar(){
	if(confirm("Para poder votar un video tienes que activar el usuario.\n¿Quieres activarlo ahora?")){
		location.href="/usuario/subirVideo/";
	}
}

function noActivadoComentar(){
	if(confirm("Para poder comentar un video tienes que activar el usuario.\n¿Quieres activarlo ahora?")){
		location.href="/usuario/subirVideo/";
	}
}

function pintarPaginacion(){
	//pagina=pag;
	total = totalPaginas;
	pag = pagina;
	if (totalPaginas<total)totalPaginas=totalPaginas+1;
	if(totalPaginas > 1){

	
		var text='<table border="0" align="center" width="100%">';
			text+='<tr><td align="center" width="130">Mostrando: '+pagina+' de '+totalPaginas+' páginas</td></tr>';
			text+='<tr align="center"><td><table border=0>';
		var enlacePrimero="";
		var enlaceAnterior="";	
		if (pag!=1){
			enlacePrimero= '<a href="javascript:paginar(' +     1 +');" class=enlace_ant>Primera</a>';
			enlaceAnterior='<a href="javascript:paginar('+(pag-1)+');" class=enlace_an>Anterior</a>';
		}
		text+='<td class=paginacion align="left" width="55">'+enlacePrimero+'</td>';
		text+='<td class=paginacion align="left" width="80">'+enlaceAnterior+'</td>';
			
		if (pag<4) {
			inicio=0;
			fin=5;
		}
		else if (pag>(totalPaginas-2)){
			fin=totalPaginas;
			inicio=totalPaginas-5;
		}
		else{
			inicio=(pag-3);
			fin=(pag+2);
		}
		if (fin>totalPaginas) fin=totalPaginas;
		text+='<td class=paginacion><ul id="paglist">';
		for(i=inicio;i<fin;i++){
			numero=i+1;
		
			if(numero == pag){
				text+='<li id="actual"><b>'+numero+'</b></li>';
			}else{
				text+='<li><a href="javascript:paginar('+numero+');" class=link69>'+numero+'</a></li>';
			}
		}
		text+="</ul></td>";
		
		var enlaceUltimo="";
		var enlaceSiguiente="";	
		
		if (pag!=totalPaginas){
			enlaceSiguiente='<a href="javascript:paginar('+ (pag+1)  +');" class=enlace_si>Siguiente</a>';
			enlaceUltimo='<a href="javascript:paginar('+totalPaginas+');" class=enlace_sig>Ultima</a>';
		}
		text+='<td class=paginacion align="right" width="80">'+enlaceSiguiente+'</td>';
		text+='<td class=paginacion align="right" width="55">'+enlaceUltimo+'</td>';
		
		text+='</table></td></tr></table>';
		}else{
		text='';
	}
	
	document.getElementById('paginacionUp').innerHTML = text;
	document.getElementById('paginacionDown').innerHTML = text;
}
function paginar(num){
	pagina = num;
	getXMLget("/verVideo/comentarios.phtml");
}
function processDeleteRecord(){
	getXMLget("/verVideo/comentarios.phtml");
}

var Utf8 = {

	// public method for url encoding
	encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// public method for url decoding
	decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}

function popUp(URL) {
	id = "popUpVideo";
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=820,height=640');");
}
function tratarCadenaDeTexto(txt){
	txtFinal="";
	//i=0;
	arrayPalabras=false;

	palabra="";
	lon=0;
		arrayPalabras=txt.split(" ");
		if (isArray(arrayPalabras)) {
			lon=arrayPalabras.length;
			//if (!IsNumeric(lon)) lon=100;
			
		}
		for (ind=0; ind<lon; ind++){
			palabra=arrayPalabras[ind];
			while (palabra.length>75){
				txtFinal+=palabra.substring(0,74);
				txtFinal+=" ";
				palabra=palabra.substring(75,palabra.length);
			}
			txtFinal+=palabra+" ";
		}
		//txtFinal+=txt;
		return txtFinal;
	return txt;
}

function IsNumeric(sText){
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) IsNumber = false;
   }
   return IsNumber;
}

function isArray(testObject) {
    return testObject && !(testObject.propertyIsEnumerable('length')) && typeof testObject === 'object' && typeof testObject.length === 'number';
}

function irYMostrar(id){
	window.location.href='#'+id;
	mostrarSms(id);
}

function mostrarSms(id){
	document.getElementById('lista'+id).style.display='block';
	document.getElementById('contraer'+id).style.display='block';
	document.getElementById('verTodos'+id).style.display='none';
}

function ocultarSms(id){
	document.getElementById('lista'+id).style.display='none';
	document.getElementById('contraer'+id).style.display='none';
	document.getElementById('verTodos'+id).style.display='block';
}