// JavaScript Document
function solonumero(obj) {
    var temp;
  	temp=parseInt(obj.value);
	if (obj.value.length>0){
		if (temp!=obj.value) {
			alert ("EN ESTE CAMPO SOLO SE PERMITEN NÚMEROS.");
   			if (isNaN(temp))
   				obj.value="";
 			else
  				obj.value=temp;
		}
	}	
}
	
function validar_usuario(formulario,tipo){
	var fomulario = document.getElementById(formulario); 

	fomulario.txt_nombre.value = trim(fomulario.txt_nombre.value);	
	fomulario.txt_documento.value = trim(fomulario.txt_documento.value);	
	fomulario.txt_telefono.value = trim(fomulario.txt_telefono.value);	
	fomulario.txt_direccion.value = trim(fomulario.txt_direccion.value);
	if (tipo===0) fomulario.txt_clave.value = trim(fomulario.txt_clave.value);
	if (fomulario.txt_nombre.value.length==0) {alert('ES NECESARIO QUE INGRESE SUS NOMBRES Y APELLIDOS.');return false;}
	if (fomulario.txt_documento.value.length==0) {alert('ES NECESARIO QUE INGRESE EL NUMERO DE SU DOCUMENTO.');return false;}
	if (!es_correo(fomulario.txt_email.value)) {alert('EL CORREO ELECTRONICO QUE INGRESO NO ES VALIDO.');return false;}
	if (fomulario.lts_departamentos.value==0) {alert('ES NECESARIO QUE SELECCIONE UN DEPARTAMENTO.');return false;}
	if (tipo===0) if (fomulario.txt_clave.value.length < 4) {alert('LA CALVE DEBE TENER MAS DE 3 CARACTERES.');return false;}
	if (tipo===0) if (fomulario.txt_clave.value != fomulario.txt_clave2.value) {alert('LA CLAVE NO ES IGUAL A LA CONFIRMACION .');return false;}

	if (tipo===0) include_formulario('usuarios/usu_nuevo.php','POST',formulario,'div_contenido');
	if (tipo===1) include_formulario('usuarios/usu_actualizar.php','POST',formulario,'div_contenido');
	return true;
}

function validar_peticion(formulario){
	var fomulario = document.getElementById(formulario); 
	fomulario.txt_asunto.value = trim(fomulario.txt_asunto.value);
	fomulario.txt_descripcion.value = trim(fomulario.txt_descripcion.value);
	if (fomulario.txt_asunto.value.length==0) {alert('DEBE INGRESAR EL ASUNTO DE LA SOLICITUD.');return false;}
	if (fomulario.txt_descripcion.value.length==0) {alert('DEBE INGRESAR LA DESCRIPCION DETALLADA DE LA SOLICITUD.');return false;}

	include_formulario('usuarios/usu_sol_crear.php','POST',formulario,'div_contenido')
	return true;
}