function validar_campos_1()
{
	//	first_name
	var texto;
	var error='';
	texto = document.getElementById('first_name').value;
	resultado=longitud('Nombre', texto, '2', '50');
	if(resultado.length>0)
	{
		error+=resultado;		
	}
	
	//	last_name
	texto = document.getElementById('last_name').value;
	resultado=longitud('Apellido', texto, '2', '50');
	if(resultado.length>0)
	{
		error+=resultado;		
	}
	//	Email
	texto = document.idForm.elements['email'].value;
	if(!email(texto))
	{
		error+="Email: por favor introduzca un email v\u00e1lido\n";
	}


	//	Email_Alternativo__c
	texto = document.getElementById('Email_Alternativo__c').value;
	if(texto.length>0)
	{
		if(!email(texto))
		{
			error+="Email Alternativo: por favor introduzca un email v\u00e1lido\n";
		}
	}
	//	company
	texto = document.getElementById('company').value;
	resultado=longitud('Empresa', texto, '4', '50');
	if(resultado.length>0)
	{
		error+=resultado;		
	}

	//	industry
	texto = document.getElementById('industry').value;
	if(texto=='-')
	{
		error+="Tipo de empresa: Seleccione al menos una opci\u00f3n\n";		
	}

	//	Title_Aeronautico__c
/*	texto = document.getElementById('Title_Aeronautico__c').value;
	if(texto=='-')
	{
		error+="Cargo: Seleccione al menos una opcion\n";		
	}
*/
	
	//	country
	texto = document.getElementById('country').value;
	resultado=longitud('Pa\u00eds', texto, '2', '50');
	if(resultado.length>0)
	{
		error+=resultado;		
	}

	//	city
	texto = document.getElementById('city').value;
	if(texto.length>0)
	{
		resultado=longitud('Ciudad', texto, '2', '50');
		if(resultado.length>0)
		{
			error+=resultado;		
		}
	}
	
	//	phone
/*	texto = document.getElementById('phone').value;
	if(texto.length>0)
	{
		error+="Tel\u00e9fono: por favor introduzca un n\u00famero v\u00e1lido\n";
	}
*/	
	//	casos de uso
	check1 = document.getElementById('CS_Aerolinea_con_Taller_Propio__c').checked;
	check2 = document.getElementById('CS_MRO__c').checked;
	check3 = document.getElementById('CS_Taxi_Aereo__c').checked;
	check4 = document.getElementById('CS_Taxi_Aereo_con_Taller_Propio__c').checked;
	check5 = document.getElementById('CS_Escuelas__c').checked;

	if(check1==false & check2==false & check3==false & check4==false & check5==false & document.getElementById('Demo__c').checked==false)
	{
		error+="Solicitud: debe seleccionar una opci\u00f3n del contenido a enviar (casos de estudio, demo o c\u00e1psulas aeron\u00e1uticas)\n";
	}

	if(document.getElementById('Demo__c').checked)
	{
		//	Demo SOMA
		check1 = document.getElementById('DEMO_Lunes__c').checked;
		check2 = document.getElementById('DEMO_Martes__c').checked;
		check3 = document.getElementById('DEMO_Miercoles__c').checked;
		check4 = document.getElementById('DEMO_Jueves__c').checked;
		check5 = document.getElementById('DEMO_Viernes__c').checked;
		check6 = document.getElementById('Lead2CallNow__c').checked;
	
		if(check1==false & check2==false & check3==false & check4==false & check5==false & check6==false)
		{
			error+="Demo SOMA: debe seleccionar al menos una opci\u00f3n\n";
		}
		
/*		if(!copyLead2CallPhone())
		{
			error+="Tel\u00e9fono: por favor introduzca un n\u00famero v\u00e1lido\n";
		}
*/	}
		
	return error;
/*	if(error!='')
	{
		alert(error);
		return false;
	}else
	{	
		return true;
	}
*/
}

function validar_campos_representante()
{
	//	first_name
	var texto;
	var error='';
	texto = document.getElementById('first_name').value;
	resultado=longitud('Nombre', texto, '2', '50');
	if(resultado.length>0)
	{
		error+=resultado;		
	}
	
	//	last_name
	texto = document.getElementById('last_name').value;
	resultado=longitud('Apellido', texto, '2', '50');
	if(resultado.length>0)
	{
		error+=resultado;		
	}
	//	Email
	texto = document.idForm.elements['email'].value;
	if(!email(texto))
	{
		error+="Email: por favor introduzca un email v\u00e1lido\n";
	}


	//	company
	texto = document.getElementById('company').value;
	resultado=longitud('Empresa', texto, '4', '50');
	if(resultado.length>0)
	{
		error+=resultado;		
	}

	//	country
	texto = document.getElementById('Country_List_Latin_America__c').value;
	if(texto =='-')
	{
		error+="Pais: seleccione una opci\u00f3n\n";
	}

	//	Representante_Soma_Paises__c
	texto = document.getElementById('Representante_Soma_Paises__c').value;
	resultado=longitud('Paises representante', texto, '4', '10000');
	if(resultado.length>0)
	{
		error+=resultado;		
	}

	//	Representante_Soma_Razones__c
	texto = document.getElementById('Representante_Soma_Razones__c').value;
	resultado=longitud('Razones', texto, '4', '10000');
	if(resultado.length>0)
	{
		error+=resultado;		
	}

		
	return error;
}

function longitud(campo, texto, min, max)
{
	error='';
/*	if(texto.length == 0)
	{
		error="Campo requerido no puede ser vacio";
	}
	else */if(texto.length < min | texto.length > max)
	{
		error="por favor introduzca "+campo+" v\u00e1lido";
		//error="Minimo "+min+" caracteres de longitud";
	}
	if(error.length>0)
	{
		error=campo+": "+error+"\n";
	}	
	return error;
}

function email(texto){

    var mailres = true;            
    var cadena = "abcdefghijklmn�opqrstuvwxyzABCDEFGHIJKLMN�OPQRSTUVWXYZ1234567890@._-";
    
    var arroba = texto.indexOf("@",0);
    if ((texto.lastIndexOf("@")) != arroba) arroba = -1;
    
    var punto = texto.lastIndexOf(".");
                
     for (var contador = 0 ; contador < texto.length ; contador++){
        if (cadena.indexOf(texto.substr(contador, 1),0) == -1){
            mailres = false;
            break;
     }
    }

    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1))
     mailres = true;
    else
     mailres = false;
                
    return mailres;
} 

function isNumberKey(evt)
{
	 var charCode = (evt.which) ? evt.which : event.keyCode
	 if ((charCode > 31 && (charCode < 48 || charCode > 57)))
		 	return false;
	 return true;
} 
