// JavaScript Document
function Oculta(id){///Effect.BlindUp(id);;return false;
	//document.getElementById(id).style.visibility = 'hidden';;return false;
	document.getElementById(id).style.display = 'none';
	
	//id[0] = 'o'; id[1] = 'w'; id[2] = 'n';
	var ImgId = "imgDown" + id;
	document.getElementById(ImgId).style.display = '';
	//id[0] = 'p'; id[1] = 'e'; id[2] = 'r';
	ImgId = "imgUpper" + id;
	document.getElementById(ImgId).style.display = 'none';
							
	return false;
	
	//document.getElementById(id).getElementById("lista_noticias").style.visibility = 'hidden';
	//document.getElementById(id).childnodes(1).style.visibility = 'hidden';
	
	//document.getElementById(id).children.item(0).style.visibility = 'hidden';
}
	
function Muestra(id){//Effect.BlindDown(id);;return false;
	//document.getElementById(id).style.visibility = 'visible';;return false;
	document.getElementById(id).style.display = '';	
	
	//id[0] = 'p'; id[1] = 'e'; id[2] = 'r';
	var ImgId = "imgUpper" + id;
	document.getElementById(ImgId).style.display = '';
	//id[0] = 'o'; id[1] = 'w'; id[2] = 'n';
	ImgId = "imgDown" + id;
	document.getElementById(ImgId).style.display = 'none';
							
	return false;
	
	//document.getElementById(id).getElementById("lista_noticias").style.visibility = 'visible';
	//document.getElementById(id).childnodes(1).style.visibility = 'visible';
	//document.getElementById(id).children.item(0).style.visibility = 'visible';
}




function comments(id){
    if(document.getElementById)
    {
        //conseguimos el contenedor para escribir los datos
        target= document.getElementById("divComment"+id);
        //si esta oculto entonces mostramos los comentarios
        if(target.style.display == "none")
        {
            target.style.display= "";
            //escribimos un mensaje de carga
            target.innerHTML = '<center>' + imgLoading + '</center>';
            //iniciamos la clase
            var myConn = new XHConn();
            //si el nagevador no soporta XMLHTTP entonces manda un aviso.
            if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
            //funcion que ejecuta la conexion una vez ejecutado el envio
            //en nuestro caso escribimos el html con los comentarios y el formulario
            var comments = function (oXML) {  target.innerHTML = oXML.responseText; Muestra('divComment'+id);viewPhoto('vernover'+id,'ver.gif');};
            //llamamos a la funcion y le pasamos la id del articulo
            myConn.connect(urlComments, "POST", "comment_post_ID="+id, comments);
        } else {
            Oculta('divComment'+id);
			viewPhoto('vernover'+id,'nover.gif');
			//target.style.display = "none";
			
        }
    }  
}

function TraduceNoticia(id,idioma,url)
{
	 //conseguimos el contenedor para escribir los datos
        target= document.getElementById(id);
        //si esta oculto entonces mostramos los comentarios
        target.innerHTML = '<center>' + imgLoading + '</center>' ;
        //iniciamos la clase
        var myConn = new XHConn();
        //si el nagevador no soporta XMLHTTP entonces manda un aviso.
        if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
        //funcion que ejecuta la conexion una vez ejecutado el envio
        //en nuestro caso escribimos el html con los comentarios y el formulario
        var comments = function (oXML) {  target.innerHTML = oXML.responseText; Muestra(id);};
        //llamamos a la funcion y le pasamos la id del articulo
        myConn.connect(urlTraduce, "GET", 'url='+ url + '&lang=' + idioma, comments);
}

function NuevoComment(id,action,MiFormu)
{
	
		//Datos del comentario
		autor = escape(MiFormu.elements["author"].value);
		email = escape(MiFormu.elements["email"].value);
		url = escape(MiFormu.elements["url"].value);
		comment = escape(MiFormu.elements["comment"].value);
		//conseguimos el contenedor para escribir los datos
        target= document.getElementById('divComment'+id);
        //si esta oculto entonces mostramos los comentarios
        target.innerHTML = '<center>' + imgLoading + '</center>' ;
        //iniciamos la clase
        var myConn = new XHConn();
        //si el nagevador no soporta XMLHTTP entonces manda un aviso.
        if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
        //funcion que ejecuta la conexion una vez ejecutado el envio
        //en nuestro caso escribimos el html con los comentarios y el formulario
        var inserta = function (oXML) {comments(id);};
        //llamamos a la funcion y le pasamos la id del articulo
        myConn.connect(action, "POST", "comment_post_ID="+ id +"&autor=" + autor + "&email=" + email + "&url=" + url + "&comment=" + comment, inserta);
	
}

	/*  Muestra en grande la foto seleccionada */
	function viewPhoto(id,image) {document.getElementById(id).src = urlImages  + image;	}		

function Show(id)
{
	  if(document.getElementById)
    {
        //conseguimos el contenedor para escribir los datos
        target= document.getElementById(id);
        //si esta oculto entonces mostramos los comentarios
		var num = id.split("-");
        if(target.style.display == "none")
        {
			Effect.Grow(id);
			viewPhoto('masmenos' + num[1],'menos.gif');
        } else {
			Effect.Shrink(id);
			viewPhoto('masmenos' + num[1],'mas.gif');
        }
    }  
}
