
function nuevoAjax(){  
  var xmlhttp=false; 
  var ids = ["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0",		             "Msxml2.XMLHTTP","Microsoft.XMLHTTP"];
  for(var i=0; !xmlhttp && i<ids.length; i++) {
      try{
		xmlhttp = new ActiveXObject(ids[i]);
	  }catch(ex){	
		//alert("i"+i);
    	xmlhttp = false;
	  }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') { 
  	 xmlhttp = new XMLHttpRequest(); 
  } 
  return xmlhttp; 
} 


 function altaBoletin_1(){
	var xml_doc="";
	ajax=nuevoAjax(); 
	xml_doc='type_element=boletin&action=insert';
	if (document.formulario_boletin.email.value==""){
		alert("Enter an e-mail");
		return false;
	}
	if (document.formulario_boletin.nombre.value==""){
		alert("Enter your name");
		return false;
	}
	xml_doc+='&email='+document.formulario_boletin.email.value;
	xml_doc+='&nombre='+document.formulario_boletin.nombre.value;
	for (i=0;i<document.formulario_boletin.idioma.length;i++){
       if (document.formulario_boletin.idioma[i].checked)
          break;
    }
	xml_doc+='&idioma='+document.formulario_boletin.idioma[i].value;
 	var format = "";
	div_alerta = document.getElementById('resultados_boletin');
	div_alerta.innerHTML = "<font color='#FF3333'>Processing registry<img src='Images/puntos.gif' width='14' height='6' align='absmiddle'></font>";
	ajax.open("POST", "../filtros/ajaxCorella.php",true); 
	ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	ajax.send(xml_doc);
	ajax.onreadystatechange=function() { 
		if (ajax.readyState==4) { 
		   format = ajax.responseText.split("&");
		    if (format.length>3){
		         if (format[2] == "0"){
					 div_alerta = document.getElementById('resultados_boletin');
			   		 div_alerta.innerHTML = "<font color='#FF3333'>Mail registered, please use a new one.</font>";
				 }else{
					 document.formulario_boletin.email.value = "";
					 document.formulario_boletin.nombre.value = "";
					 div_alerta = document.getElementById('resultados_boton');
					 div_alerta.innerHTML = "<img src='Images/at-cliente_63.gif' name='enviar' width='39' height='26' border='0' id='enviar'>";
					 div_alerta = document.getElementById('resultados_boletin');
					 div_alerta.innerHTML = "<font color='#FF3333'>Successfully register.</font>";
				 }
				 
			}else{
				 div_alerta = document.getElementById('resultados_boletin');
			   	 div_alerta.innerHTML = "<font color='#FF3333'>Error.</font>";
			}
		}
	} 
}

 function altaBoletin_1_sms(){
	var xml_doc="";
	ajax=nuevoAjax(); 
	xml_doc='type_element=boletin&action=insert';
	if (document.formulario_boletin.telefono.value==""){
		alert("Enter your phone number");
		return false;
	}
	if (document.formulario_boletin.nombre.value==""){
		alert("Enter your name");
		return false;
	}
	xml_doc+='&telefono='+document.formulario_boletin.telefono.value;
	xml_doc+='&nombre='+document.formulario_boletin.nombre.value;
	for (i=0;i<document.formulario_boletin.idioma.length;i++){
       if (document.formulario_boletin.idioma[i].checked)
          break;
    }
	xml_doc+='&idioma='+document.formulario_boletin.idioma[i].value;
 	var format = "";
	div_alerta = document.getElementById('resultados_boletin');
	div_alerta.innerHTML = "<font color='#FF3333'>Processing registry<img src='Images/puntos.gif' width='14' height='6' align='absmiddle'></font>";
	ajax.open("POST", "../filtros/ajaxCorella.php",true); 
	ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	ajax.send(xml_doc);
	ajax.onreadystatechange=function() { 
		if (ajax.readyState==4) { 
		   format = ajax.responseText.split("&");
		    if (format.length>3){
		         if (format[2] == "0"){
					 div_alerta = document.getElementById('resultados_boletin');
			   		 div_alerta.innerHTML = "<font color='#FF3333'>This phone number is already registered, please try a new one.</font>";
				 }else{
					 document.formulario_boletin.telefono.value = "";
					 document.formulario_boletin.nombre.value = "";
					 div_alerta = document.getElementById('resultados_boton');
					 div_alerta.innerHTML = "<img src='Images/at-cliente_63.gif' name='enviar' width='39' height='26' border='0' id='enviar'>";
					 div_alerta = document.getElementById('resultados_boletin');
					 div_alerta.innerHTML = "<font color='#FF3333'>Successfully register.</font>";
				 }
				 
			}else{
				 div_alerta = document.getElementById('resultados_boletin');
			   	 div_alerta.innerHTML = "<font color='#FF3333'>Error.</font>";
			}
		}
	} 
}



