
function getXMLHTTPRequest() {
try {
req = new XMLHttpRequest();
} catch(err1) {
  try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (err2) {
    try {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (err3) {
      req = false;
    }
  }
}
return req;
}

var http = getXMLHTTPRequest();

function guardaNews() {
var a = document.getElementById('mail').value;


  myRand = parseInt(Math.random()*999999999999999);
  var myurl = 'envia_mail.php?&mail='+a+'&ram='+myRand;
  var modurl = myurl;
  http.open("GET", modurl, true);
  http.onreadystatechange = muestra_guardaNews;
  http.send(null);
}

function muestra_guardaNews() {
   if (http.readyState == 4) {

   	 if(http.status == 200) {

      var miTexto = http.responseText;
	  
      //document.getElementById('news').innerHTML= miTexto;
	 document.getElementById('news').innerHTML = "Su inscripcion fue enviado correctamente";
	 
	 timer = setTimeout("reset()", 10000);;
	  
	 
    }
  }
}

function reset(){
	 document.getElementById('news').innerHTML ='<table width="246" border="0" cellspacing="0" cellpadding="0"><tr><th width="70" align="left" valign="top" scope="col"><img src="images/icono_newsletter_1.gif" width="70" height="56" alt="icono" /></th><th width="176" align="left" valign="top" scope="col"><table width="176" border="0" cellspacing="0" cellpadding="0"><tr><th align="left" valign="top" scope="row"><img src="images/icono_newsletter_2.gif" width="176" height="33" alt="newsletter" /></th></tr><tr><th height="23" align="left" valign="top" scope="row"><table width="176" border="0" cellspacing="0" cellpadding="0"><tr><th width="103" height="23" align="left" valign="top" scope="col"><input name="mail" type="text" id="mail" size="10" /></th><th align="left" valign="top" scope="col"><a href="JavaScript:guardaNews()" ><img src="images/btn_suscribir_1.gif" name="suscribir" width="63" height="23" border="0" id="suscribir" /></a></th></tr></table></th></tr></table></th></tr></table>';
}
