function sendit()
{
	var F = document.datos;
	var motivo = document.getElementById("Asunto");
	if(motivo == "Consulta"){
		F.recipient.value = "m.ledezma@tecno-indusil.com";
		F.action = "local-cgi/formmail.pl";
	}else{
		F.recipient.value = "ventas@tecno-indusil.com";
		F.action = "local-cgi/formmail2.pl";
	}
	if (trim(motivo.value) == '')
	{
		alert('Seleccione el motivo de su mensaje.');
		motivo.focus();
		return false;
	}
	
	var correo = document.getElementById("txtMail");
	if (trim(correo.value) == '')
	{
		alert('Debe proporcionar una dirección de e-mail.');
		correo.focus();
		return false;	
	}
	else if (trim(correo.value) != '' && !esEmail(correo.value))
	{
		alert("El e-mail no es válido. Proporciónenos una dirección de mail válida.");
		correo.focus();
		correo.select();
		return false;
	}
	else
	{
		F.email.value = correo.value;
	}
		
		
	if (trim(F.Nombre.value) == '')
	{
		alert('Debe proporcionarnos su nombre.');
		F.Nombre.focus();
		return false;
	}

	
	var apenom = document.getElementById("Apellido");
		if (trim(apenom.value) == '')
	{
		alert('Debe proporcionar su apellido');
		apenom.focus();
		return false;
	}
	else
	{
		F.realname.value = apenom.value;
	}

	
	
	/*if (trim(F.Apellido.value) == '')
	{
		alert('Debe proporcionarnos su apellido.');
		F.Apellido.focus();
		return false;
	}*/

	if (trim(F.Cliente.value) == '')
	{
		alert('Debe proporcionarnos su razon social.');
		F.Cliente.focus();
		return false;
	}


	if (trim(F.Consulta.value) == '')
	{
		alert('Debe ingresar la descripción de su consulta.');
		F.Consulta.focus();
		F.Consulta.select();
		return false;
	}
	else if (F.Consulta.value.length > 2000)
	{
		alert('El texto del mensaje no puede sobrepasar los 2.000 caracteres.');
		F.Consulta.focus();
		F.Consulta.select();
		return false;
	}
	else{
		F.submit();
	}
}


function trim(s){return s.replace(/(^\s*)|(\s*$)/g, '');}
function isEmpty(s){return ((s == null) || (s.length == 0));}
function esNumero(dato){dato = '' + dato;return (!isEmpty(dato) && !isNaN(dato) && dato.indexOf('E') == -1 && dato.indexOf('e') == -1);}

function validTel(obj)
{
	var val = stripCharsInBag(obj.value, " .-\t");
	if (val != '' && (esNumero(val) && (val.length == 8 || val.length == 10) && (val.substr(0,1) == '1' || val.substr(0,1) == '4' || val.substr(0,1) == '5')))
		return true;
	return false;
}

function stripCharsInBag (s, bag)
{
	s += '';
	var i;
	var returnString = "";
	for (i = 0; i < s.length; i++)
	{   
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}

function esEmail(s)
{
	s = '' + s;
   var r, re;
   re = /^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\._-]+\.[a-zA-Z0-9_]+$/g;
   r = s.match(re);
   return (r != null);
}
/*function restrTextMax(max)
{
	var obj = event.srcElement;
	if (obj.value.length < max || event.keyCode == 13)
		return true;

	alert('Ha alcanzado la longitud máxima. No puede \nsobrepasar los ' + max + ' caracteres.\n');
	event.returnValue = false;
}*/
