/*************************************************** CHECKS: */

function checkSpell(to)
{
	// expresion regular de email:
	function echeck(str)
	{
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if(str.indexOf(at)==-1)
		{
			return false;
		}
		if(str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
			return false;
		}
		if(str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
			return false;
		}
		if(str.indexOf(at,(lat+1))!=-1)
		{
			return false;
		}
		if(str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		{
			return false;
		}
		if(str.indexOf(dot,(lat+2))==-1)
		{
			return false;
		}
		if(str.indexOf(" ")!=-1)
		{
			return false;
		}
		return true;
	}

	if(to=='olvido')
	{
		// valida email:
		if($('o_mail').value=="" || $('o_mail').value.length<3 || echeck($('o_mail').value)==false)
		{
			$('f_o_e_mail').style.display='block';
			$('o_mail').focus();
			return false;
		}
		else
		{
			$('f_o_e_mail').style.display='none';
		}
	}
	
	if(to=='registro')
	{
		// valida email:
		if($('r_mail').value=="" || $('r_mail').value.length<3 || echeck($('r_mail').value)==false)
		{
			$('r_e_mail').style.display='block';
			$('r_mail').focus();
			return false;
		}
		else
		{
			$('r_e_mail').style.display='none';
		}
		// valida contraseņas:
		if($('r_pass').value=="" || $('r_pass').value.length<6)
		{
			$('r_e_pass').style.display='block';
			$('r_pass').focus();
			return false;
		}
		else
		{
			$('r_e_pass').style.display='none';
		}
		if($('r_pass').value!=$('r_pass2').value)
		{
			$('r_e_pass2').style.display='block';
			$('r_pass2').focus();
			return false;
		}
		else
		{
			$('r_e_pass2').style.display='none';
		}
		// valida nombre:
		if($('r_user').value=='' || $('r_user').value.length<3)
		{
			$('r_e_user').style.display='block';
			$('r_user').focus();
			return false;
		}
		else
		{
			$('r_e_user').style.display='none';
		}
		// valida check de politicas:
		if($('r_politicas').checked==false)
		{
			$('r_e_politicas').style.display='block';
			return false;
		}
		else
		{
			$('r_e_politicas').style.display='none';
		}
	}
	
	if(to=='contacto')
	{
		// valida nombre:
		if($('f_c_nombre').value=='' || $('f_c_nombre').value.length<3)
		{
			$('f_c_e_nombre').style.display='block';
			$('f_c_nombre').focus();
			return false;
		}
		else
		{
			$('f_c_e_nombre').style.display='none';
		}
		// valida telefono:
		if($('f_c_telefono').value=='' || $('f_c_telefono').value.length<3)
		{
			$('f_c_e_telefono').style.display='block';
			$('f_c_telefono').focus();
			return false;
		}
		else
		{
			$('f_c_e_telefono').style.display='none';
		}
		// valida email:
		if($('f_c_email').value=="" || $('f_c_email').value.length<3 || echeck($('f_c_email').value)==false)
		{
			$('f_c_e_email').style.display='block';
			$('f_c_email').focus();
			return false;
		}
		else
		{
			$('f_c_e_email').style.display='none';
		}
		// valida consulta:
		if($('f_c_consulta').value=='' || $('f_c_consulta').value.length<3)
		{
			$('f_c_e_consulta').style.display='block';
			$('f_c_consulta').focus();
			return false;
		}
		else
		{
			$('f_c_e_consulta').style.display='none';
		}
	}
	
	// devuelvo true:
	return true;
}

/************************************************** CHECKS. */
