// JavaScript Document
//funcion de rollover para navegacion admin
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


function popup(url, nombre, ancho, alto, propiedades) {
	   var izq = (screen.width - ancho) / 2;
	   var arr = (screen.height - alto) / 2;
	   window.open(url, nombre, 'width=' + ancho + ',height=' + alto + ',left=' + izq + ',top=' + arr + ',' + propiedades);
}
//funcion para cambiar los videos
 function proyectar(v,t,p){
  	document.getElementById('miVideo').innerHTML=v; 
   document.getElementById('titulovideo').innerHTML=t;
   document.getElementById('pieVideo').innerHTML=p;  
  }
  
  function mostrar(nombreCapa){ 
document.getElementById(nombreCapa).style.height=170;  
document.getElementById(nombreCapa).style.display="block"; 
} 
function ocultar(nombreCapa){ 
document.getElementById(nombreCapa).style.height=0; 
document.getElementById(nombreCapa).style.display="none";
} 


function tablecollapse()
{
define('nombre', 'string', 'Nombre');
define('email', 'email', 'e-mail');
define('texto_ingresado', 'string', 'Confirmación Visual');
define('descripcion', 'string', 'Mensaje');

	/* Variables */
	var collapseClass='footcollapse';
	var collapsePic='imagenes/down.gif'; //Nombre de la imagen de la flecha hacia arriba
	var expandPic='imagenes/up.gif'; //Nombre de la imagen de la flecha hacia abajo
	var initialCollapse=false;

	// Verfica la clase que tiene la tabla
	var t=document.getElementsByTagName('table');
	var checktest= new RegExp("(^|\\s)" + collapseClass + "(\\s|$)");
	for (var i=0;i<t.length;i++)
	{
		// Sí la tabla no tiene la propiedad adecuada la salta.
		if(!checktest.test(t[i].className)){continue;}		

		// Crea un pie de página clickable
		t[i].getElementsByTagName('tfoot')[0].onclick=function()
		{
			// Verifica todo el cuerpo de la tabla y la muestra u oculta
			var tb=this.parentNode.getElementsByTagName('tbody');
			for(var i=0;i<tb.length;i++)
			{
				tb[i].style.display=tb[i].style.display=='none'?'':'none';
			}			
			// Cambia la imagen de acuerdo a si esta expandida o contraida
			var li=this.getElementsByTagName('img')[0];
			li.src=li.src.indexOf(collapsePic)==-1?collapsePic:expandPic;	
		}
		// Sí el cuerpo puede ser contraido lo hace
		if(initialCollapse)
		{
			var tb=t[i].getElementsByTagName('tbody');
			for(var j=0;j<tb.length;j++)
			{
				tb[j].style.display='none';
			}			
		}
		// Agrega un link a la imagen 
		// Acesa a la última celda en el pie de tabla
		var newa=document.createElement('a');
		newa.href='#';
		newa.onclick=function(){return false;}
		var newimg=document.createElement('img');
		newimg.src=initialCollapse?expandPic:collapsePic;
		var tf=t[i].getElementsByTagName('tfoot')[0];
		var lt=tf.getElementsByTagName('td')[tf.getElementsByTagName('td').length-1];
		newa.appendChild(newimg);
		lt.insertBefore(newa,lt.firstChild);
	}		
}
// Corre el script al cargar la página.



window.onload=tablecollapse;


//funcionjquery para formulario envio
function enviar_comentario(){
$(document).ready(function(){
var dataNombre = document.sampleform.nombre.value;
var dataEmail = document.sampleform.email.value;
var dataDescripcion = document.sampleform.descripcion.value;
var dataCaptcha = document.sampleform.texto_ingresado.value;
var dataCaptchaSesion = document.sampleform.cps.value;
var dataNoticia = document.sampleform.idnot.value;
      $("#elform").load("funciones/procesar-comentarios.php", {nombre:dataNombre, email:dataEmail, descripcion:dataDescripcion, texto_ingresado:dataCaptcha, idnot:dataNoticia}, function(){
      });

})
}

function mostarForm(){
$(document).ready(function(){
      $("#elform").load("includes/formulario-comentar.php", function(){
      });
})
}

function vota(noticia,puntos){
$(document).ready(function(){
      $("#votoNuevo").load("funciones/procesar-votos.php", {noticia:noticia, puntos:puntos}, function(){
      });

})
}

//funcionjquery para formulario envio
function enviar_noticia(){
$(document).ready(function(){
var dataNombre = document.envio_noticia.usuario.value;
var dataEmailRemitente = document.envio_noticia.email_remitente.value;
var dataPara = document.envio_noticia.para.value;
var dataEmailDestinatario = document.envio_noticia.email_destinatario.value;
var dataDescripcion = document.envio_noticia.comentario.value;
var dataUrl = document.envio_noticia.url.value;
var dataNoticia = document.envio_noticia.titulo.value;
      $("#mensaje").load("funciones/procesar-envio-noticia.php", {nombre:dataNombre,para:dataPara, email1:dataEmailRemitente,email2:dataEmailDestinatario, descripcion:dataDescripcion, url:dataUrl, noticia:dataNoticia}, function(){
      });

})
}

