
function grabaDatos(ruta)
{
	if(ruta)	
	{
	
	 	if(!Trim(document.forms[0].nombre.value))
	 	{
			alert("Ingrese su nombre");
			document.forms[0].nombre.focus();
			
		}
		else if(!Trim(document.forms[0].apellido.value))
		{
					alert("Debe ingresar su apellido");
				document.forms[0].apellido.focus();
			
		}
		else if(!Trim(document.forms[0].email.value))
		{
					alert("Debe ingresar su email");
				document.forms[0].email.focus();	
				
		}
		else if(!email_ok(document.forms[0].email.value))
		{
					alert("Su email no es valido");
				document.forms[0].email.focus();	
				
		}else{
					
			document.forms[0].action = ruta;
			document.forms[0].submit();
		}
	}	
}

function LTrim(str){	
	while(str.length > 0 && str.charAt(0) == " "){
		str = str.substr(1,str.length)
	}

	return str
}

function RTrim(str){
	while(str.length > 0 && str.charAt(str.length-1) == " "){
		str = str.substr(0,str.length-1);
	}
	
	return str
}

function Trim(theStr){
	theStr = RTrim(theStr);
	theStr = LTrim(theStr);
	
	return theStr 
}

