// JavaScript Document
var comentarios, frmComentarios, idv, pag, fkVideo, stNick, stComentario;
var pag=0;

function copiarPortapapeles(texto)
{
	if (window.clipboardData){
		window.clipboardData.setData('Text', texto);
		alert('Copiado al portapapeles');
	}else{
		alert('Utilice Ctrl+C para copiar');
	}
	return false;
}

var div, contenedor;
function divPopup(div, ancho, alto)
{
	if(document.getElementById("dvCodigo")) div = document.getElementById("dvCodigo");
	if(document.getElementById("contenedor")) contenedor = document.getElementById("contenedor");
	
	div.style.width=ancho+"px";
	div.style.height=alto+"px";
	div.style.marginTop=-alto/2+"px";
	div.style.marginLeft=-ancho/2+"px";
	div.style.display="";
	
	if(document.getElementById("txtCod")) document.getElementById("txtCod").select();
	
	return false;
}
function cerrarPopup(pid)
{
	var div = document.getElementById(pid);
	var contenedor = document.getElementById("contenedor");
	
	contenedor.style.opacity=100; //Firefox
  contenedor.style.filter="alpha(opacity=100)"; //IE*/
	
	div.style.display="none";
}

function nuevoAjax()
{
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function cargarComentarios()
{
	if(document.getElementById('comentarios'))
	{
		comentarios = document.getElementById('comentarios');
		
		if(document.getElementById('hididVideo')) idv = document.getElementById('hididVideo').value;
		if(document.getElementById('hidPag')) pag = parseInt(document.getElementById('hidPag').value);
		
		ajax = nuevoAjax();
		ajax.open("GET", "includes/comentarios.php?pag="+pag+"&idv="+idv, true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				comentarios.innerHTML = ajax.responseText
			}
		}
		ajax.send(null)
	}
}
function siguiente()
{
	if(document.getElementById('hidnuComentarios')){
		nuComentarios = document.getElementById('hidnuComentarios').value
		if(pag+2<=nuComentarios && pag+3<=nuComentarios)pag += 2;
	}
	ajax = nuevoAjax();
	ajax.open("GET", "includes/comentarios.php?pag="+pag+"&idv="+idv, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			comentarios.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}
function anterior()
{
	if(pag>=2)pag -= 2;
	ajax = nuevoAjax();
	ajax.open("GET", "includes/comentarios.php?pag="+pag+"&idv="+idv, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			comentarios.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}

function cargarfrmComentarios()
{
	if(document.getElementById('frmComentarios'))
	{
		frmComentarios = document.getElementById('frmComentarios');
		
		if(document.getElementById('hididVideo')) idv = document.getElementById('hididVideo').value;
		
		ajax2 = nuevoAjax();
		ajax2.open("GET", "includes/frmComentarios.php?idv="+idv, true);
		ajax2.onreadystatechange=function() {
			if (ajax2.readyState==4) {
				frmComentarios.innerHTML = ajax2.responseText
			}
		}
		ajax2.send(null)
	}
}
function enviarComentario()
{
	if(document.getElementById('frmComentarios'))
	{
		frmComentarios = document.getElementById('frmComentarios');
		
		if(document.getElementById('fkVideo')) fkVideo = document.getElementById('fkVideo').value;
		if(document.getElementById('stNick')) stNick = document.getElementById('stNick').value;
		if(document.getElementById('stComentario')) stComentario = document.getElementById('stComentario').value;
		
		ajax2 = nuevoAjax();
		ajax2.open("POST", "includes/frmComentarios.php", true);
		ajax2.onreadystatechange=function() {
			if (ajax2.readyState==4) {
				frmComentarios.innerHTML = ajax2.responseText
			}
		}
		ajax2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax2.send("fkVideo="+fkVideo+"&stNick="+stNick+"&stComentario="+stComentario)
		
		cargarComentarios();
	}
}




<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

MM_preloadImages('img/SeccionMoviles_over.gif','img/SeccionMulti_over.gif','img/SeccionBlog_over.gif','img/SeccionOnline_over.gif','img/SeccionFlash_over.gif','img/SeccionConsolas_over.gif')

//-->


var activo='';

 function desp(sec)
{
    if (activo!=sec)
    {
		if (document.getElementById(sec)) MM_swapImage(sec,'','img/' + sec + '_over.gif',1);
				
		activo=sec;
		marca=sec;
	}
} 