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 cargarContenido(datasource,divID,ide2){ 
var contenedor; 
var otro; 
contenedor = document.getElementById(divID); 
                        
ajax=nuevoAjax(); 

var tipo =document.getElementById("writed").value //Esta variable obtiene el valor de lo q puso el usuario en el textbox nombre
var idpro =document.getElementById("userd").value //Esta variable obtiene el valor de la ide 
var tmiem =document.getElementById("tipou").value //Esta variable obtiene el valor de la ide

ajax.open("GET", "upchat.php?uchat="+idpro+"&tipou="+tmiem+"&tchat="+tipo,true); 

var tipo =document.getElementById("writed").value=''; //vaciar
var tipo =document.getElementById("writed").focus();
startrefresh();

ajax.onreadystatechange=function() { 
if (ajax.readyState==4) { 
contenedor.innerHTML = ajax.responseText 
} 
} 
ajax.send(null) 
}

/////////////////refrescar chat


var tiempo2;
var capa2;
var urls2;
var numerar =0;
////////////////////////////////
//
// Refreshing the DIV
//
////////////////////////////////

function refrescar(tiempo2,capa2,urls2){

ajax=nuevoAjax();

// Timestamp for preventing IE caching the GET request
var fetch_unix_timestamp ="";// lets declare the variable

fetch_unix_timestamp = function()
{
return parseInt(new Date().getTime().toString().substring(0, 10))
}

numerar = numerar +1;

my_r = parseInt(Math.random()*999999999999999);

var timestamp = fetch_unix_timestamp();
var nocacheurl = "http://www.yahtools.com/"+urls2+"?count="+numerar+"&t="+timestamp;

// The code...

ajax.onreadystatechange=function(){
if(ajax.readyState==4){
document.getElementById(capa2).innerHTML=ajax.responseText;

setTimeout('refrescar(1,"chat","upchat.php")',tiempo2*1000);
}
}
ajax.open("GET",nocacheurl+'&my_r='+my_r,true);
ajax.send(null);
}

// Empieza la función de refrescar

window.onload = function startrefresh(){
//setTimeout('refrescar(15,"vips","vips.php")',15*1000);
setTimeout('refrescar(1,"chat","upchat.php")',3*1000);
}


