var CajaHttp=null;

document.write('<link href="ajax/styleform.css" rel="stylesheet" type="text/css">');
document.write('<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />')
document.write('<div id="acuden"></div><div><g:plusone></g:plusone></div>');
document.write('<div id="mainForm"><div id="formHeader"><h2 class="formInfo">Comentarios</h2>');
document.write('</div>');
document.write('<div id="form"></div>');
document.write('<div id="uno"></div>');
document.write('<div id="dos"></div> </div>');
envioInfo('/cclosdolores/comentarios/acuden.php','','','acuden');
envioInfo('/cclosdolores/comentarios/form.php','','','form');
envioInfo('/cclosdolores/comentarios/muestralos.php','primero=0&saltos=25','','uno');
document.write("<script type='text/javascript' src='/cclosdolores/cssformularios/validarcampos.js'></script"+">");
function envioInfo(CajaRequest,pget,ppost,capas)
{
// ver http://www.cristalab.com/tutoriales/enviar-datos-por-post-y-get-en-ajax-en-una-funcion-c237l/	
    	

	CajaHttp = false;
	CajaHttp = CreateXmlHttp();
	if(ppost!=""){
	        CajaHttp.open("POST", CajaRequest+"?"+ppost+"&tiempo="+new Date().getTime(),true);
	        
   	 } else {
        	CajaHttp.open("GET", CajaRequest+"?"+pget+"&tiempo="+new Date().getTime(),true);
    	}

	CajaHttp.onreadystatechange = function(capa,ajax){ return  function() {
 	if (ajax.readyState==1){
           	 document.getElementById(capa).innerHTML = 
				"<div style='text-align:center;width:99%;'><img src='http://cclosdolores.es/cclosdolores/web_images/cargando.gif'> Aguarde por favor...<br><br></div>";
        }


    	
		    if(ajax.readyState == 4 && ajax.status == 200)
		    {
		        document.getElementById(capa).innerHTML=ajax.responseText;
       
    		    }
    	
    };
    }(capas,CajaHttp)
    if(ppost!=""){
        CajaHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        CajaHttp.send(ppost);
    } else {
        CajaHttp.send(null);
    }

    
    
   
   

}

function CreateXmlHttp()
{
    var xmlHttp;    
    // Probamos con IE
    try
    {
        // Funcionar&#225; para JavaScript 5.0
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(oc)
        {  
            xmlHttp = null;
        }
    }

    // Si no se trataba de un IE, probamos con esto
    if(!xmlHttp && typeof XMLHttpRequest != "undefined")
    {
        xmlHttp = new XMLHttpRequest();
    }
     
    return xmlHttp;
}
function limpiar(formId) {
	frm = document.getElementById(formId);
	if (!frm) return;
	for(i=0; i<frm.elements.length; i++){
		if (frm.elements[i].type == 'text')
			frm.elements[i].value = '';
		if (frm.elements[i].type == 'textarea')	
			frm.elements[i].value = '';
	}
}

function meteyrefresca()
{
formu = document.getElementById('interes');
mdestino = '/cclosdolores/comentarios/interes2.php';
mget = '';
mpost = 'nik='+ formu.nik.value +'&comentario=' + formu.comentario.value;
mcapa = 'uno';
envioInfo(mdestino,mget,mpost,mcapa);
limpiar('interes');
mdestino = '/cclosdolores/comentarios/muestralos.php';
mget = 'primero=0&saltos=15';
mpost = '';
mcapa = 'uno';
setTimeout("envioInfo(mdestino,mget,mpost,mcapa);",2000);
}
