function echeck(str,msg) 
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   if (msg) alert("Verifique su correo electrónico"); 
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   if (msg) alert("Verifique su correo electr&oacute;nico")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		if (msg) alert("Verifique su correo electr&oacute;nico")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		if (msg) alert("Verifique su correo electr&oacute;nico")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		if (msg) alert("Verifique su correo electr&oacute;nico")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		if (msg) alert("Verifique su correo electr&oacute;nico")
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		if (msg) alert("Verifique su correo electr&oacute;nico")
		return false
	 }

	 return true					
}

function ValidateMail(obj,msgs,first)
{
	var emailID=obj;
	var msg=msgs;
	if ((emailID.value==null)||(emailID.value=="")){
		if (msg) { alert("Ingrese un correo electr&oacute;nico."); }
		if (first) { emailID.focus(); }
		return false;
	}
	if (echeck(emailID.value,msg)==false){
		emailID.value="";
		if (first) { emailID.focus(); }
		return false;
	}
	return true
 }
	 
function clean()
{	
	var element=document.getElementById('mail');
	if (element.value=="sucorreo@mail.com")
	{
		element.value="";
	}
}

function check()
{
	var element=document.getElementById('mail');
	if (element.value=="")
	{
		element.value="sucorreo@mail.com";
	}
}

function send()
{
		var url="lib/registro.php?mail="+document.getElementById('mail').value;
		var cadena="width=440px,height=250px,scrollbars=no,resizable=no"; //,location=no";
		if (ValidateMail(document.getElementById('mail'),true,true))
		{	
			document.getElementById('mailform').style["display"]="none";
			document.getElementById('mailfoot').style["display"]="none";
			document.getElementById('mailform2').style["display"]="block";
			window.open(url,"registro",cadena);
		}

}
function send2()
{
	var mail=document.getElementById('mail');
	if (mail.value=="sucorreo@mail.com")
	{
			mail.value="";
			mail.focus();
	}else{
		var url="lib/registro.php?mail="+mail.value;
		var cadena="width=440px,height=250px,scrollbars=no,resizable=no"; //,location=no";
		if (ValidateMail(mail,true,true))
		{	
			document.getElementById('mailform').style["display"]="none";
			document.getElementById('mailfoot').style["display"]="none";
			document.getElementById('mailform2').style["display"]="block";
			window.open(url,"registro",cadena);
		}
	}
}
function validate(e)
{
	value = (document.all) ? e.keyCode : e.which;
	if (value==13)
	{ 
		send();
		return false; 
	}
}
