function menu_desplegable_mostrar(nombre_id){
document.getElementById(nombre_id).style.display="block";
}

function menu_desplegable_ocultar(nombre_id){
document.getElementById(nombre_id).style.display="none";
}

 

function getHTTPObject() {
  var xmlhttp;
 
  if(window.XMLHttpRequest){
    xmlhttp = new XMLHttpRequest();
  }
  else if (window.ActiveXObject){
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    if (!xmlhttp){
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
}
  return xmlhttp;
}

function esMail(mail)
{
	var Template = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; //Formato de direccion de correo electronico
	
		if (!Template.test(mail)) 
		{	
			return true;
		}		else
		{return false;}
	
}

function trim(cadena)
{
	for(i=0; i<cadena.length; )
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(i+1, cadena.length);
		else
			break;
	}

	for(i=cadena.length-1; i>=0; i=cadena.length-1)
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(0,i);
		else
			break;
	}
	
	return cadena;
}

var httpRegistrarme = getHTTPObject(); 
function registrarme()
{
	if(trim(document.form1.nom.value)=="") { alert("Introduzca su nombre"); return; }
 	if(esMail(document.form1.email.value)) { alert("Introduzca email valido"); return; }
  
	var nom = document.form1.nom.value;
 	var email = document.form1.email.value;
 	var telefono = document.form1.telefono.value;
  
 	var myrand=parseInt(Math.random()*99999999);
	var modurl= "send_registrarme.php?e=1&myrand="+myrand+"&nom="+nom+"&email="+email+"&telefono="+telefono;
	pageTracker._trackEvent('Registro', 'Alta', 'buttonForm'); 
  	httpRegistrarme.open("GET", modurl, true);
	httpRegistrarme.onreadystatechange = rsp_registrarme;
	httpRegistrarme.send(null);
}

function rsp_registrarme() 
{
	if (httpRegistrarme.readyState == 4) 
	{
		if(httpRegistrarme.status == 200) 
		{
			estado = httpRegistrarme.responseText;
  			if(estado=="1")
			{ alert("Gracias por registrarte. Pronto te avisaremos ;-)"); document.form1.reset();document.getElementById('ID_MSGE_REGIS').innerHTML=""; }
 			else if(estado=="2")
			{ document.getElementById('ID_MSGE_REGIS').innerHTML="El eMail ya se encuentra registrado"; }
			else
			{ alert("Gracias por registrarte. Pronto te avisaremos ;-)"); document.getElementById('ID_MSGE_REGIS').innerHTML="";}
		}	
	} 
	else
	{
		document.getElementById('nom').value="";
		document.getElementById('telefono').value="";
		document.getElementById('email').value="";
		document.getElementById('ID_MSGE_REGIS').innerHTML="enviando...";
	}
}

var httpRecomendar = getHTTPObject(); 
function recomendar()
{
	if(trim(document.form2.tunom.value)=="") { alert("Introduzca su nombre"); return; }
 	if(esMail(document.form2.tuemail.value)) { alert("Introduzca su email valido"); return; }
	if(trim(document.form2.nombreamigo.value)=="") { alert("Introduzca el nombre de su amig@"); return; }
 	if(esMail(document.form2.emailamigo.value)) { alert("Introduzca email valido de su amig@"); return; }
  
	var tunom = document.form2.tunom.value;
 	var tuemail = document.form2.tuemail.value;
 	var nombreamigo = document.form2.nombreamigo.value;
 	var emailamigo = document.form2.emailamigo.value;

	var myrand=parseInt(Math.random()*99999999);
	var modurl= "send_recomendar.php?e=1&myrand="+myrand+"&tunom="+tunom+"&tuemail="+tuemail+"&nombreamigo="+nombreamigo+"&emailamigo="+emailamigo;
  	httpRecomendar.open("GET", modurl, true);
	httpRecomendar.onreadystatechange = rsp_recomendar;
	httpRecomendar.send(null);
}

function rsp_recomendar() 
{
	if (httpRecomendar.readyState == 4) 
	{
		if(httpRecomendar.status == 200) 
		{
			estado = httpRecomendar.responseText;
  			if(estado=="1")
			{ alert("Gracias por recomendar redsocialdiscapacitados.com"); document.form2.reset();document.getElementById('ID_MSGE_RECOM').innerHTML=""; }
			else
			{ alert("Ha ocurrido un error al enviar."); document.getElementById('ID_MSGE_RECOM').innerHTML="";}
		}	
	} 
	else
	{
		document.getElementById('ID_MSGE_RECOM').innerHTML="enviando...";
	}
}