

function f_contactenos(){
	with (document.forms[0]){
		if(trim(txt_nombre.value)==''){
			window.alert("Por favor, ingrese su nombre.");	
			txt_nombre.focus();
			return;
		}
		if(txt_nombre.value.length>20){
			window.alert("Solo puede ingresar hasta 20 caracteres.");
			txt_nombre.focus();
			return;
		}
		
		if(trim(txt_apellido_paterno.value)==''){
			window.alert("Por favor, ingrese su apellido paterno.");	
			txt_apellido_paterno.focus();
			return;
		}
		if(txt_apellido_paterno.value.length>20){
			window.alert("Solo puede ingresar hasta 20 caracteres.");
			txt_apellido_paterno.focus();
			return;
		}
		/*
		if(trim(txt_apellido_materno.value)==''){
			window.alert("Por favor, ingrese su apellido materno.");	
			txt_apellido_materno.focus();
			return;
		}
		*/
		if(txt_apellido_materno.value.length>20){
			window.alert("Solo puede ingresar hasta 20 caracteres.");
			txt_apellido_materno.focus();
			return;
		}
		if(txt_tipo_documento.selectedIndex==0){
			window.alert("Por favor, seleccione un tipo de documento.");	
			txt_tipo_documento.focus();
			return;
		}
		if(trim(txt_numero_documento.value)==''){
			window.alert("Por favor, ingrese su n\u00famero de documento.");	
			txt_numero_documento.focus();
			return;
		}
		if(isNaN(txt_numero_documento.value)){
			window.alert("Solo puede ingresar numeros.");
			txt_numero_documento.focus();
			return;
		}
		if(txt_tipo_documento.value=='DNI' && txt_numero_documento.value.length!=8){
			window.alert("Debe ingresar 8 caracteres.");
			txt_numero_documento.focus();
			return;
		}
		if(txt_tipo_telefono.selectedIndex==0){
			window.alert("Por favor, seleccione un tipo de tel\u00e9fono.");
			txt_tipo_telefono.focus();
			return;
		}
		
		if(txt_telefono.value==''){
			window.alert("Por favor, ingrese su tel\u00e9fono de contacto.");
			txt_telf.focus();
			return;
		}
		if(txt_telefono.value.length>30){
			window.alert("Solo puede ingresar hasta 30 caracteres.");
			txt_telefono.focus();
			return;
		}
						
		if(trim(txt_email.value)==''){
			window.alert("Por favor, ingrese su e-mail de contacto.");
			txt_email.focus();
			return;
		} else {
			if(txt_email.value.length>50){
				window.alert("Solo puede ingresar hasta 50 caracteres.");
				txt_email.focus();
				return;
			}
			var filter=/^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/;
			if (!filter.test(txt_email.value)){
				window.alert("Por favor, ingrese un e-mail v\u00e1lido");
				txt_email.focus();
				return;
			}
		}

		if(trim(txt_direccion.value)==''){
			window.alert("Por favor, ingrese su direcci\u00f3n.");	
			txt_direccion.focus();
			return;
		}
		if(txt_direccion.value.length>50){
			window.alert("Solo puede ingresar hasta 50 caracteres.");
			txt_direccion.focus();
			return;
		}
		
		if(trim(txt_motivo.value)==''){
			window.alert("Por favor, ingrese su motivo.");
			txt_motivo.focus();
			return;
		}
		if(txt_motivo.value.length>120){
			window.alert("Solo puede ingresar hasta 120 caracteres.");
			txt_motivo.focus();
			return;
		}

		if(txt_cliente[0].checked==false && txt_cliente[1].checked==false){
			window.alert("Por favor, seleccione una respuesta.");
			return;
		}

		if(trim(captcha.value)==''){
			window.alert("Por favor, ingrese los caracteres que se muestran en la figura.");
			captcha.focus();
			return;
		}
		
		submit();
		
	}
}

function f_per_solicitud_producto_activo(){
	with (document.forms[0]){
		if(trim(txt_nombre.value)==''){
			window.alert("Por favor, ingrese su nombre.");	
			txt_nombre.focus();
			return;
		}
		if(txt_nombre.value.length>20){
			window.alert("Solo puede ingresar hasta 20 caracteres.");
			txt_nombre.focus();
			return;
		}
		
		if(trim(txt_apellido_paterno.value)==''){
			window.alert("Por favor, ingrese su apellido paterno.");	
			txt_apellido_paterno.focus();
			return;
		}
		if(txt_apellido_paterno.value.length>20){
			window.alert("Solo puede ingresar hasta 20 caracteres.");
			txt_apellido_paterno.focus();
			return;
		}
		/*
		if(trim(txt_apellido_materno.value)==''){
			window.alert("Por favor, ingrese su apellido materno.");	
			txt_apellido_materno.focus();
			return;
		}
		*/
		if(txt_apellido_materno.value.length>20){
			window.alert("Solo puede ingresar hasta 20 caracteres.");
			txt_apellido_materno.focus();
			return;
		}
		
		if(txt_tipo_documento.selectedIndex==0){
			window.alert("Por favor, seleccione un tipo de documento.");
			txt_tipo_documento.focus();
			return;
		}
		
		if(trim(txt_numero_documento.value)==''){
			window.alert("Por favor, ingrese su n\u00famero de documento.");
			txt_numero_documento.focus();
			return;
		}
		if(isNaN(txt_numero_documento.value)){
			window.alert("Por favor, ingrese un n\u00famero de documento v\u00e1lido.");
			txt_numero_documento.focus();
			return;
		}
		if(txt_tipo_documento.value=='DNI' && txt_numero_documento.value.length!=8){
			window.alert("Debe ingresar 8 caracteres.");
			txt_numero_documento.focus();
			return;
		}
		
		if(txt_sexo.selectedIndex==0){
			window.alert("Por favor, seleccione su sexo.");	
			txt_sexo.focus();
			return;
		}
		/*
		if(trim(txt_centro_labores.value)==''){
			window.alert("Por favor, ingrese su centro de labores.");
			txt_centro_labores.focus();
			return;
		}
		*/
		if(txt_centro_labores.value.length>40){
			window.alert("Solo puede ingresar hasta 40 caracteres.");
			txt_numero_documento.focus();
			return;
		}
		/*
		if(txt_modalidad.selectedIndex==0){
			window.alert("Por favor, seleccione una modalidad.");	
			txt_modalidad.focus();
			return;
		}
		*/
		if(trim(txt_ingresos.value)=='' && !isNaN(txt_ingresos.value)){
			window.alert("Por favor, ingrese una cantidad en ingresos netos.");	
			txt_ingresos.focus();
			return;
		}
		
		if(!isValidNumber(txt_ingresos.value)){
			window.alert("Por favor, ingrese un monto v\u00e1lido.");
			txt_ingresos.focus();
			return;
		}
				
		if(txt_productos.selectedIndex==0){
			window.alert("Por favor, seleccione un producto.");	
			txt_productos.focus();
			return;
		}
		
		if(txt_tipo_telefono.selectedIndex==0){
			window.alert("Por favor, seleccione un tipo de tel\u00e9fono.");
			txt_tipo_telefono.focus();
			return;
		}
		
		if(txt_telefono.value==''){
			window.alert("Por favor, ingrese su tel\u00e9fono de contacto.");
			txt_telefono.focus();
			return;
		}
		
		if(!isValidNumber(txt_telefono.value)){
			window.alert("Por favor, ingrese un tel\u00e9fono v\u00e1lido.");
			txt_telf.focus();
			return;
		}
		
		if(txt_telefono.value.length>10){
			window.alert("Solo puede ingresar hasta 10 caracteres.");
			txt_telf.focus();
			return;
		}

		if(trim(txt_email.value)==''){
			window.alert("Por favor, ingrese su e-mail de contacto.");
			txt_telf.focus();
			return;
		} else {
			if(txt_email.value.length>50){
				window.alert("Solo puede ingresar hasta 50 caracteres.");
				txt_email.focus();
				return;
			}
			var filter=/^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/;
			if (!filter.test(txt_email.value)){
				window.alert("Por Favor, Ingrese un e-mail valido");
				txt_email.focus();
				return;
			}
		}
		
		if(trim(txt_direccion.value)==''){
			window.alert("Por favor, ingrese su direcci\u00f3n.");
			txt_direccion.focus();
			return;
		}
		if(txt_direccion.value.length>50){
			window.alert("Solo puede ingresar hasta 50 caracteres.");
			txt_direccion.focus();
			return;
		}
		
		if(txt_departamento.value==0 && !isNaN(txt_departamento.value)){
			window.alert("Por favor, seleccione un departamento.");
			txt_departamento.focus();
			return;
		}

		if(txt_provincia.value==0 && !isNaN(txt_provincia.value)){
			window.alert("Por favor, seleccione una provincia.");
			txt_provincia.focus();
			return;
		}

		if(txt_distrito.value==0 && !isNaN(txt_distrito.value)){
			window.alert("Por favor, seleccione una distrito.");
			txt_distrito.focus();
			return;
		}
		/*
		if( txt_domingo.checked==false && 
			txt_lunes.checked==false && 
			txt_martes.checked==false && 
			txt_miercoles.checked==false && 
			txt_jueves.checked==false && 
			txt_viernes.checked==false && 
			txt_sabado.checked==false ) {
			window.alert("Por favor, seleccione sus d\u00edas de contacto.");
			txt_lunes.focus();
			return;
		}
		
		if(trim(txt_time1.value)==''){
			window.alert("Por favor, seleccione su hora inicial.");
			txt_horas.focus();
			return;
		}

		if(trim(txt_time2.value)==''){
			window.alert("Por favor, seleccione su hora final.");
			txt_horas.focus();
			return;
		}
		*/
		if(trim(captcha.value)==''){
			window.alert("Por favor, ingrese los caracteres que se muestran en la figura.");
			captcha.focus();
			return;
		}
		submit();
		
	}
}

function f_per_solicitud_producto_pasivo(){
	with (document.forms[0]){
		if(trim(txt_nombre.value)==''){
			window.alert("Por favor, ingrese su nombre.");	
			txt_nombre.focus();
			return;
		}
		if(txt_nombre.value.length>20){
			window.alert("Solo puede ingresar hasta 20 caracteres.");
			txt_nombre.focus();
			return;
		}
		
		if(trim(txt_apellido_paterno.value)==''){
			window.alert("Por favor, ingrese su apellido paterno.");	
			txt_apellido_paterno.focus();
			return;
		}
		if(txt_apellido_paterno.value.length>20){
			window.alert("Solo puede ingresar hasta 20 caracteres.");
			txt_apellido_paterno.focus();
			return;
		}
		/*
		if(trim(txt_apellido_materno.value)==''){
			window.alert("Por favor, ingrese su apellido materno.");	
			txt_apellido_materno.focus();
			return;
		}
		*/
		if(txt_apellido_materno.value.length>20){
			window.alert("Solo puede ingresar hasta 20 caracteres.");
			txt_apellido_materno.focus();
			return;
		}
		if(txt_tipo_documento.selectedIndex==0){
			window.alert("Por favor, seleccione un tipo de documento.");
			txt_tipo_documento.focus();
			return;
		}
		
		if(trim(txt_numero_documento.value)==''){
			window.alert("Por favor, ingrese su n\u00famero de documento.");
			txt_numero_documento.focus();
			return;
		}
		if(isNaN(txt_numero_documento.value)){
			window.alert("Por favor, ingrese un n\u00famero de documento v\u00e1lido.");
			txt_numero_documento.focus();
			return;
		}
		if(txt_tipo_documento.value=='DNI' && txt_numero_documento.value.length!=8){
			window.alert("Debe ingresar 8 caracteres.");
			txt_numero_documento.focus();
			return;
		}
		
		if(txt_sexo.selectedIndex==0){
			window.alert("Por favor, seleccione su sexo.");	
			txt_sexo.focus();
			return;
		}
		/*
		if(trim(txt_centro_labores.value)==''){
			window.alert("Por favor, ingrese su centro de labores.");
			txt_centro_labores.focus();
			return;
		}
		*/
		if(txt_centro_labores.value.length>40){
			window.alert("Solo puede ingresar hasta 40 caracteres.");
			txt_centro_labores.focus();
			return;
		}
		/*
		if(txt_modalidad.selectedIndex==0){
			window.alert("Por favor, seleccione una modalidad.");	
			txt_modalidad.focus();
			return;
		}
		*/
		if(trim(txt_ingresos.value)=='' && !isNaN(txt_ingresos.value)){
			window.alert("Por favor, ingrese una cantidad en ingresos netos.");	
			txt_ingresos.focus();
			return;
		}
		
		if(!isValidNumber(txt_ingresos.value)){
			window.alert("Por favor, ingrese un monto v\u00e1lido.");
			txt_ingresos.focus();
			return;
		}
				
		if(txt_productos.selectedIndex==0){
			window.alert("Por favor, seleccione un producto.");	
			txt_productos.focus();
			return;
		}
		
		if(txt_tipo_telefono.selectedIndex==0){
			window.alert("Por favor, seleccione un tipo de tel\u00e9fono.");
			txt_tipo_telefono.focus();
			return;
		}
		
		if(txt_telefono.value==''){
			window.alert("Por favor, ingrese su tel\u00e9fono de contacto.");
			txt_telf.focus();
			return;
		}
		if(!isValidNumber(txt_telefono.value)){
			window.alert("Por favor, ingrese un tel\u00e9fono v\u00e1lido");
			txt_telf.focus();
			return;
		}
		if(txt_telefono.value.length>10){
			window.alert("Solo puede ingresar hasta 10 caracteres.");
			txt_telf.focus();
			return;
		}
		
		if(trim(txt_email.value)==''){
			window.alert("Por favor, ingrese su e-mail de contacto.");
			txt_telf.focus();
			return;
		} else {
			if(txt_email.value.length>50){
				window.alert("Solo puede ingresar hasta 50 caracteres.");
				txt_email.focus();
				return;
			}
			var filter=/^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/;
			if (!filter.test(txt_email.value)){
				window.alert("Por favor, ingrese un e-mail v\u00e1lido.");
				txt_email.focus();
				return;
			}
		}
		if(trim(txt_direccion.value)==''){
			window.alert("Por favor, ingrese su direcci\u00f3n.");
			txt_direccion.focus();
			return;
		}
		if(txt_direccion.value.length>50){
			window.alert("Solo puede ingresar hasta 50 caracteres.");
			txt_direccion.focus();
			return;
		}
		
		if(txt_departamento.value==0 && !isNaN(txt_departamento.value)){
			window.alert("Por favor, seleccione un departamento.");
			txt_departamento.focus();
			return;
		}

		if(txt_provincia.value==0 && !isNaN(txt_provincia.value)){
			window.alert("Por favor, seleccione una provincia.");
			txt_provincia.focus();
			return;
		}

		if(txt_distrito.value==0 && !isNaN(txt_distrito.value)){
			window.alert("Por favor, seleccione una distrito.");
			txt_distrito.focus();
			return;
		}
		/*
		if( txt_domingo.checked==false && 
			txt_lunes.checked==false && 
			txt_martes.checked==false && 
			txt_miercoles.checked==false && 
			txt_jueves.checked==false && 
			txt_viernes.checked==false && 
			txt_sabado.checked==false ) {
			window.alert("Por favor, seleccione sus d\u00edas de contacto.");
			txt_lunes.focus();
			return;
		}

		if(trim(txt_time1.value)==''){
			window.alert("Por favor, seleccione su hora inicial.");
			txt_horas.focus();
			return;
		}

		if(trim(txt_time2.value)==''){
			window.alert("Por favor, seleccione su hora final.");
			txt_horas.focus();
			return;
		}
		*/
		if(trim(captcha.value)==''){
			window.alert("Por favor, ingrese los caracteres que se muestran en la figura.");
			captcha.focus();
			return;
		}
		
		submit();
		
	}
}

function f_emp_solicitud_producto(){
	with (document.forms[0]){
		if(trim(txt_ruc.value)==''){
			window.alert("Por favor, ingrese un n\u00famero de RUC.");
			txt_ruc.focus();
			return;
		}
		if(isNaN(txt_ruc.value)){
			window.alert("Por favor, ingrese solo n\u00fameros.");
			txt_ruc.focus();
			return;
		}
		if(txt_ruc.value.length!=11){
			window.alert("Debe ingresar un n\u00famero de 11 digitos.");
			txt_ruc.focus();
			return;
		}
		
		if(trim(txt_razonsocial.value)==''){
			window.alert("Debe ingresar una raz\u00f3n social.");
			txt_razonsocial.focus();
			return;
		}
		
		if(trim(txt_direccion.value)==''){
			window.alert("Por favor, ingrese la direcci\u00f3n de la empresa.");
			txt_direccionempresa.focus();
			return;
		}
		if(txt_direccion.value.length>30){
			window.alert("Solo puede ingresar hasta 30 caracteres.");
			txt_direccionempresa.focus();
			return;
		}
		
		if(txt_departamento.value==0 && !isNaN(txt_departamento.value)){
			window.alert("Por favor, seleccione un departamento.");
			txt_departamento.focus();
			return;
		}

		if(txt_provincia.value==0 && !isNaN(txt_provincia.value)){
			window.alert("Por favor, seleccione una provincia.");
			txt_provincia.focus();
			return;
		}

		if(txt_distrito.value==0 && !isNaN(txt_distrito.value)){
			window.alert("Por favor, seleccione una distrito.");
			txt_distrito.focus();
			return;
		}

		if(txt_rangoventas.selectedIndex==0){
			window.alert("Por Favor, seleccione un rango de ventas anuales.");
			txt_rangoventas.focus();
			return;
		}
		
		if(txt_productos.selectedIndex==0){
			window.alert("Por favor, seleccione un producto.");	
			txt_productos.focus();
			return;
		}
		
		if(trim(txt_nombre.value)==''){
			window.alert("Por favor, ingrese el nombre del contacto.");
			txt_nombre.focus();
			return;
		}
		if(txt_nombre.value.length>20){
			window.alert("Solo puede ingresar hasta 20 caracteres.");
			txt_nombre.focus();
			return;
		}
		
		if(trim(txt_cargo.value)==''){
			window.alert("Por favor, ingrese el cargo del contacto.");
			txt_cargo.focus();
			return;
		}
		if(txt_cargo.value.length>20){
			window.alert("Solo puede ingresar hasta 20 caracteres.");
			txt_cargo.focus();
			return;
		}

		if(txt_tipo_telefono.selectedIndex==0){
			window.alert("Por favor, seleccione un tipo de tel\u00e9fono.");
			txt_tipo_telefono.focus();
			return;
		}
		
		if(trim(txt_telefono.value)==''){
			window.alert("Por favor, ingrese un n\u00famero telef\u00f3nico.");
			txt_telefono.focus();
			return;
		}
		if(!isValidNumber(txt_telefono.value)){
			window.alert("Por favor, ingrese un tel\u00e9fono v\u00e1lido");
			txt_telefono.focus();
			return;
		}
		
		if(trim(txt_email.value)==''){
			window.alert("Por favor, ingrese su e-mail de contacto.");
			txt_telf.focus();
			return;
		} else {
			if(txt_email.value.length>50){
				window.alert("Solo puede ingresar hasta 50 caracteres.");
				txt_email.focus();
				return;
			}
			var filter=/^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/;
			if (!filter.test(txt_email.value)){
				window.alert("Por favor, ingrese un correo electr\u00f3nico v\u00e1lido.");
				txt_email.focus();
				return;
			}
		}
		/*
		if( txt_domingo.checked==false && 
			txt_lunes.checked==false && 
			txt_martes.checked==false && 
			txt_miercoles.checked==false && 
			txt_jueves.checked==false && 
			txt_viernes.checked==false && 
			txt_sabado.checked==false ) {
			window.alert("Por favor, seleccione sus d\u00edas de contacto.");
			txt_lunes.focus();
			return;
		}

		if(trim(txt_time1.value)==''){
			window.alert("Por favor, seleccione su hora inicial.");
			txt_horas.focus();
			return;
		}

		if(trim(txt_time2.value)==''){
			window.alert("Por favor, seleccione su hora final.");
			txt_horas.focus();
			return;
		}
		*/
		if(trim(captcha.value)==''){
			window.alert("Por favor, ingrese los caracteres que se muestran en la figura.");
			captcha.focus();
			return;
		}
		submit();
		
	}
}

function f_validar_agencias_cajeros(){
	with (document.forms[0]){
		if(canal.selectedIndex==0){
			window.alert("Por favor, elige una opcion a buscar.");
			canal.focus();
			return;
		}else if(canal.selectedIndex==1) {
			document.form1.action = "buscar_agencia.asp";
			/*document.form1.submit();*/ 
			submit();
		}else if(canal.selectedIndex==2) {
			document.form1.action = "buscar_cajero.asp";
			/*document.form1.submit();*/ 
			submit();
		}
	}
}

function ltrim(str)
{	while(""+str.charAt(0)==" ")
		{ 	str=str.substring(1,str.length); }
	return str; 
}

function reverse(str)
{	var reversedstr = "";
	var strArray;
	strArray = str.split("");
	for(var i = str.length -1 ; i >= 0 ; i--)
		{ 	reversedstr += strArray[i]; 	}
	return reversedstr;
}
	
function trim(str)
{ str = ltrim(str);
  str = reverse(str);
  str = ltrim(str);
  str = reverse(str);
  return str; 
}

function isValidNumber(e) {
	ok = "1234567890";
    for(i=0; i < e.length ;i++){
        if(ok.indexOf(e.charAt(i))<0){ 
            return (false);
        }
		else return (true);
    } 
}

function refreshImage() {
	document.getElementById('imgcaptcha').src = "imgcaptcha?rand=" + rand();
}

function rand() {
	var random = "" + Math.random();
	return random.replace(/\./, "")
}
