

////////////////////////////////////////////////////////////////////////////////////////////

//Funciones para validar las cadenas de texto que se ingresan

//Validar vacio
function valida_vacio(s){
	
	var i=0;
	var j=0;
	for (i=0;i<s.length;i++){
		if (s.substring(i,i+1)==" ")
			j++;
	}
		if (j==s.length)
			return false;
		else
			return true;
}



var lowercaseLetters = " abcdefghijklmnopqrstuvwxyzáéíóúńü";

var uppercaseLetters = " ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚŃ";

var whitespace = " \t\n\r";

var defaultEmptyOK = false;



// Quita todos los caracteres que que estan en "bag" del string "s" s.

function stripCharsInBag (s, bag)

{   var i;

    var returnString = "";



    // Buscar por el string, si el caracter no esta en "bag", 

    // agregarlo a returnString

    

    for (i = 0; i < s.length; i++)

    {   var c = s.charAt(i);

        if (bag.indexOf(c) == -1) returnString += c;

    }



    return returnString;

}



//Campo Vacio

function isEmpty(s)

{   return ((s == null) || (s.length == 0))

}



//Espacios en Blanco

function isWhitespace (s)

{   var i;

    if (isEmpty(s)) return true;

    for (i = 0; i < s.length; i++)

    {   

        var c = s.charAt(i);

        // si el caracter en que estoy no aparece en whitespace,

        // entonces retornar falso

        if (whitespace.indexOf(c) == -1) return false;

    }

    return true;

}



//Es letra

function isLetter (c)

{

    return( ( uppercaseLetters.indexOf( c ) != -1 ) ||

            ( lowercaseLetters.indexOf( c ) != -1 ) )

}



//Es numero

function isDigit (c)

{   return ((c >= "0") && (c <= "9"))

}



//Es del alfabeto

function isAlphabetic (s)

{   var i;



    if (isEmpty(s)) 

       if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;

       else return (isAlphabetic.arguments[1] == true);

    for (i = 0; i < s.length; i++)

    {   

        // Check that current character is letter.

        var c = s.charAt(i);



        if (!isLetter(c))

        return false;

    }

    return true;

}



//Nombres comunes

function isName (s)

{

    if (isEmpty(s)) 

       if (isName.arguments.length == 1) return defaultEmptyOK;

       else return (isAlphabetic.arguments[1] == true);

    

    return( isAlphabetic( stripCharsInBag( s, whitespace ) ) );

}





// s tiene solo letras y numeros

function isAlphanumeric (s)

{   var i;



    if (isEmpty(s)) 

       if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;

       else return (isAlphanumeric.arguments[1] == true);



    for (i = 0; i < s.length; i++)

    {   

        var c = s.charAt(i);

        if (! (isLetter(c) || isDigit(c) ) )

        return false;

    }



    return true;

}



// s tiene solo letras, numeros o espacios en blanco

function isName2 (s)

{

    if (isEmpty(s)) 

       if (isName.arguments.length == 1) return defaultEmptyOK;

       else return (isAlphanumeric.arguments[1] == true);

    

    return( isAlphanumeric( stripCharsInBag( s, whitespace ) ) );

}



//Es entero

function isInteger (s)

{   var i;

    if (isEmpty(s)) 

       if (isInteger.arguments.length == 1) return defaultEmptyOK;

       else return (isInteger.arguments[1] == true);

    

    for (i = 0; i < s.length; i++)

    {   

        var c = s.charAt(i);

        if (!isDigit(c)) return false;

    }

    return true;

}



///////////////////////////////////////////////////////////////////////////////////////////



//Función para contactenos



function validarcontacto(v){



if (v.nombre.value == ''){

		alert("Debe Ingresar su Nombre");

		v.nombre.focus();

		return false;

}

else if (!isName(v.nombre.value)){

		alert("El Nombre que Ingresó no es Válido");

		v.nombre.select();

		return false;

}

else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(v.email.value))){

		alert("Correo Inválido");

		v.email.focus();

		return false; 

}

else if (v.mensaje.value == ''){

			alert("Debe Ingresar el Mensaje del Correo");

			v.mensaje.focus();

			return false; 

}

else if (isWhitespace(v.mensaje.value)){

			alert("Debe Ingresar el Mensaje del Correo");

			v.mensaje.select();

			return false; 

}

else {

	return true;

} 

} 





///////////////////////////////////////////////////////////////////////////////////////////



//Función para Interesados en Proyectos



function validarinteresado(v){



if (v.nombre.value == ''){

		alert("Debe Ingresar su Nombre");

		v.nombre.focus();

		return false;

}



else if (!isName(v.nombre.value)){

		alert("El Nombre que Ingresó no es Válido");

		v.nombre.select();

		return false;

}

else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(v.email.value))){

		alert("Correo Inválido");

		v.email.focus();

		return false; 

}

else if (v.mensaje.value == ''){

			alert("Debe Ingresar su Solicitud");

			v.mensaje.focus();

			return false; 

}

else if (isWhitespace(v.mensaje.value)){

			alert("Debe Ingresar su Solicitud");

			v.mensaje.select();

			return false; 

}

else {

	return true;

} 

} 





///////////////////////////////////////////////////////////////////////////////////////////



//Función para Proveedores

function valor_radio(objeto){
	valor=0;
	for (n=0;n<objeto.length;n++){
		if (objeto[n].checked==true)
			valor=objeto[n].value;
	}
		return valor;
}

function validarproveedor(v,doc,array_con_mails){
	if (v.nombre.value == ''){
		alert("Ingrese el nombre o la razon social del proveedor");
		v.nombre.focus();
		return false;
	}else if (isWhitespace(v.nombre.value)){
		alert("Ingrese un nombre o la razon social del proveedor");
		v.nombre.select();
		return false;
	}if (v.cedula.value == ''){
		alert("Ingrese el numero del documento del proveedor");
		v.cedula.focus();
		return false;
	}else if (isWhitespace(v.cedula.value)){
		alert("Ingrese el numero del documento del proveedor");
		v.cedula.select();
		return false;
	}else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(v.email.value))){
		alert("Email vacío o inválido para el proveedor");
		v.email.focus();
		return false; 
	}else if (valida_email(v.email.value,array_con_mails)==false){
		alert("El email ingresado ya se encuentrea en nuestra base de datos");
		v.email.focus();
		return false; 
	}else if (v.direccion.value == ''){
		alert("Ingrese la direccion del proveedor");
		v.direccion.focus();
		return false;
	}else if (isWhitespace(v.direccion.value)){
		alert("Ingrese una direccion válida para el proveedor");
		v.direccion.select();
		return false;
	}else if (v.telefono.value == ''){
		alert("Ingrese el telefono del proveedor");
		v.telefono.focus();
		return false;
	}else if (isWhitespace(v.telefono.value)){
		alert("Ingrese un telefono válido para el proveedor");
		v.telefono.select();
		return false;
	}else if (valor_radio(v.opt_pais)==0){
		alert("Debe seleccionar el pais");
		return false;
	}
	//Validacion de la ubicacion del proveedor
	if (valor_radio(v.opt_pais)==1){
		//Colombia
		if (v.cmb_departamento.value=="-"){
			alert("Debe seleccionar el departamento");
			v.cmb_departamento.focus();
			return false;
		}else if (v.cmb_municipio.value=="-"){
			alert("Debe seleccionar la ciudad");
			v.cmb_municipio.focus();
			return false;
		}
	}else{
		//Distintro a Colombia
		if (v.cmb_pais.value=="-"){
			alert("Debe seleccionar el pais");
			v.cmb_pais.focus();
			return false;
		}else if (v.txt_ciudad.value == ''){
			alert("Ingrese la ciudad");
			v.txt_ciudad.focus();
			return false;
		}else if (isWhitespace(v.txt_ciudad.value)){
			alert("Ingrese una ciudad válida");
			v.txt_ciudad.select();
			return false;
		}
	}
	
	//Siguiendo con la validacion
	if (v.contacto.value == ''){
		alert("Ingrese el contacto");
		v.contacto.focus();
		return false;
	}else if (isWhitespace(v.contacto.value)){
		alert("Ingrese el contacto");
		v.contacto.select();
		return false;
	}else if (valor_radio(v.rb_naturaleza)==0){
		alert("Seleccione una naturaleza");
		return false;
	}else if (v.cmb_regimen.value=="-"){
		alert("Debe seleccionar el regimen tributario");
		v.cmb_regimen.focus();
		return false;
	}
	
	//Datos de Iva, regimen y retencion
	/*
	if (valida_vacio(v.txt_res_gra_con_num.value)==false){
		alert("Debe digitar el No. de resolución de gran contribuyente.");
		v.txt_res_gra_con_num.focus();
		return false;
	}else if (valida_vacio(v.txt_res_aut_fte_num.value)==false){
		alert("Debe digitar el No. de retencion de auto-retenedor de rete-fuente.");
		v.txt_res_aut_fte_num.focus();
		return false;
	}else if (valida_vacio(v.txt_res_aut_iva.value)==false){
		alert("Debe digitar el No. de retencion de auto-retenedor de IVA.");
		v.txt_res_aut_iva.focus();
		return false;
	}else if (valida_vacio(v.txt_act_eco_ren.value)==false){
		alert("Debe digitar la actividad económica para la renta.");
		v.txt_act_eco_ren.focus();
		return false;
	}else if (valida_vacio(v.txt_act_eco_ica.value)==false){
		alert("Debe digitar la actividad económica para ICA.");
		v.txt_act_eco_ica.focus();
		return false;
	}else if (valida_vacio(v.txt_cod_ciiu.value)==false){
		alert("Debe digitar el código CIIU.");
		v.txt_cod_ciiu.focus();
		return false;
	}else if (valida_vacio(v.txt_tar_ciiu.value)==false){
		alert("Debe digitar la tarifa CIIU.");
		v.txt_tar_ciiu.focus();
		return false;
	}else if (valida_vacio(v.txt_mun_ica.value)==false){
		alert("Debe digitar el municipio donde tributa ICA.");
		v.txt_mun_ica.focus();
		return false;
	}else 
	*/
	if (valida_vacio(v.celular.value)==false){
		alert("Debe digitar el celular.");
		v.celular.focus();
		return false;
	}else if (v.cmb_nivel1.value=="-"){
		alert("Debe seleccionar el grupo al cual pertenece.");
		v.cmb_nivel1.focus();
		return false;
	}
	/*
	seleccionados=0;
	for (i=0; i<v.elements.length; i++){
		if (v.elements[i].type=="checkbox" && v.elements[i].id.substring(0,9)=="chk_grupo" && v.elements[i].checked==true)
			seleccionados++;
	}
	*/
	
	if (v.hd_grupos_prov.value==""){
		alert("Debe selecionar un grupo al cual pertenece.");
		return false;
	}
	
		return true;
}





//Función para validar ingreso a correos



function validarcorreo(v){



if (v.nombre.value == ''){

		alert("Debe Ingresar el Usuario");

		v.nombre.focus();

		return false;

}

else if (isWhitespace(v.nombre.value)){

			alert("Debe Ingresar el Usuario");

			v.nombre.select();

			return false; 

}

else if (v.pwd.value == ''){

			alert("Debe Ingresar la Contraseńa");

			v.pwd.focus();

			return false; 

}

else if (isWhitespace(v.pwd.value)){

			alert("Debe Ingresar la Contraseńa");

			v.pwd.select();

			return false; 

}

else {

	return true;

} 

} 





///////////////////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////

//funcion para abrir las ventanas emergentes



function popUp_ayuda(URL) {

day = new Date();

id = day.getTime();

eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=320,height=400,left=0,top=0');");

}

//Funcion solo numeros
var nav4 = window.Event ? true : false;
function acceptNum(evt){	
    	var key = nav4 ? evt.which : evt.keyCode;	
    	return (key <= 13 || (key >= 48 && key <= 57));
}
//Funcion solo numeros decimales
var nav4 = window.Event ? true : false;
function acceptNum2(evt){	
    	var key = nav4 ? evt.which : evt.keyCode;	
    	return (key <= 13 || (key >= 48 && key <= 57) || key==46);
}

//Funcion solo numeros decimales sin dos puntos
var nav4 = window.Event ? true : false;
function acceptNumDec(evt,valor){	
		var pos_punto=0;
    	var key = nav4 ? evt.which : evt.keyCode;	
    	if (key <= 13 || (key >= 48 && key <= 57)){
			window.status='';
			return true;
		}else if (key==46){
			pos_punto=valor.indexOf(".");
			if (pos_punto==-1){
				window.status='';
				return true;
			}else{
				window.status='El valor ya tiene el separador decimal';
				return false;
			}
		}else{
			window.status='Tecla ingresada no válida';
			return false;
		}
}
//Funcion NIT
var nav4 = window.Event ? true : false;
function acceptNit(evt,valor){	
		var pos_punto=0;
    	var key = nav4 ? evt.which : evt.keyCode;	
    	if (key <= 13 || (key >= 48 && key <= 57)){
			window.status='';
			return true;
		}else if (key==45){
			pos_punto=valor.indexOf("-");
			if (pos_punto==-1){
				window.status='';
				return true;
			}else{
				window.status='El valor ya tiene el separador de NIT ó el separador de teléfonos';
				return false;
			}
		}else{
			window.status='Tecla ingresada no válida';
			return false;
		}
}

function seleccionar_subcapitulo(documento){
	var valor="";
	for (i=0; i<documento.form.rb_capitulos_mo.length; i++){
		if (documento.form.rb_capitulos_mo[i].checked==true)
			valor=documento.form.rb_capitulos_mo[i].value;
	}
	
	documento.form.hd_grupos_prov.value="";
	documento.form.hd_grupos_prov.value=valor+",";
	//Inhabilitar las familias que no pertenezcan al subcapitulo
	for (i=0; i<documento.form.elements.length; i++){
		if (documento.form.elements[i].type=="radio" && documento.form.elements[i].alt!=valor && documento.form.elements[i].alt!=""){
			documento.form.elements[i].disabled="disabled";
			documento.form.elements[i].checked=false;
			n=0;
			while (n<documento.form.hd_num_grupos.value){
				if (typeof eval("documento.form.chk_grupo_"+n)!="undefined"){
					mi_check=eval("documento.form.chk_grupo_"+n);
					if (mi_check.alt==documento.form.elements[i].value){	
						mi_check.disabled="disabled";
						mi_check.checked=false;
					}
				}
				n++;	
			}
		}else if (documento.form.elements[i].type=="radio" && documento.form.elements[i].alt==valor){
			documento.form.elements[i].disabled="";
			documento.form.elements[i].checked=false;
			n=0;
			while (n<documento.form.hd_num_grupos.value){
				if (typeof eval("documento.form.chk_grupo_"+n)!="undefined"){
					mi_check=eval("documento.form.chk_grupo_"+n);
					if (mi_check.alt==documento.form.elements[i].value){
						mi_check.disabled="disabled";
						mi_check.checked=false;
					}
				}
				n++;	
			}
		}
	}	
	//alert(documento.form.hd_grupos_prov.value);
		return false;
}

function seleccionar_familia(documento, obj_familia){
	var valor=obj_familia.value;
	var y=0;
	documento.form.hd_grupos_prov.value=obj_familia.alt+","+valor+",";
	//Inhabilitar los grupos que no pertenezcan a la familia
	for (y=0; y<documento.form.elements.length; y++){
		if (documento.form.elements[y].type=="checkbox" && documento.form.elements[y].alt!=valor && documento.form.elements[y].alt!="" && documento.form.elements[y].name.substring(0,9)=="chk_grupo"){
			documento.form.elements[y].disabled="disabled";
			documento.form.elements[y].checked=false;
		}else if (documento.form.elements[y].type=="checkbox" && documento.form.elements[y].alt==valor && documento.form.elements[y].alt!="" && documento.form.elements[y].name.substring(0,9)=="chk_grupo"){
			documento.form.elements[y].disabled="";
			documento.form.elements[y].checked=false;
		}
	}
	//alert(documento.form.hd_grupos_prov.value);
		return false;
}









//Funciones nueva_oferta
function seleccionar_subcapitulo_oferta(documento){
	var valor="";
	for (i=0; i<documento.form1.rb_capitulos_mo.length; i++){
		if (documento.form1.rb_capitulos_mo[i].checked==true)
			valor=documento.form1.rb_capitulos_mo[i].value;
	}
	
	documento.form1.hd_grupos_prov.value="";
	documento.form1.hd_grupos_prov.value=valor+",";
	//Inhabilitar las familias que no pertenezcan al subcapitulo
	for (i=0; i<documento.form1.elements.length; i++){
		if (documento.form1.elements[i].type=="radio" && documento.form1.elements[i].alt!=valor && documento.form1.elements[i].alt!=""){
			documento.form1.elements[i].disabled="disabled";
			documento.form1.elements[i].checked=false;
			n=0;
			while (n<documento.form1.hd_num_grupos.value){
				if (typeof eval("documento.form1.chk_grupo_"+n)!="undefined"){
					mi_check=eval("documento.form1.chk_grupo_"+n);
					if (mi_check.alt==documento.form1.elements[i].value){	
						mi_check.disabled="disabled";
						mi_check.checked=false;
					}
				}
				n++;	
			}
		}else if (documento.form1.elements[i].type=="radio" && documento.form1.elements[i].alt==valor){
			documento.form1.elements[i].disabled="";
			documento.form1.elements[i].checked=false;
			n=0;
			while (n<documento.form1.hd_num_grupos.value){
				if (typeof eval("documento.form1.chk_grupo_"+n)!="undefined"){
					mi_check=eval("documento.form1.chk_grupo_"+n);
					if (mi_check.alt==documento.form1.elements[i].value){
						mi_check.disabled="disabled";
						mi_check.checked=false;
					}
				}
				n++;	
			}
		}
	}	
	//alert(documento.form1.hd_grupos_prov.value);
		return false;
}

function seleccionar_familia_oferta(documento, obj_familia){
	var valor=obj_familia.value;
	var y=0;
	documento.form1.hd_grupos_prov.value=obj_familia.alt+","+valor+",";
	//Inhabilitar los grupos que no pertenezcan a la familia
	for (y=0; y<documento.form1.elements.length; y++){
		if (documento.form1.elements[y].type=="checkbox" && documento.form1.elements[y].alt!=valor && documento.form1.elements[y].alt!="" && documento.form1.elements[y].name.substring(0,9)=="chk_grupo"){
			documento.form1.elements[y].disabled="disabled";
			documento.form1.elements[y].checked=false;
		}else if (documento.form1.elements[y].type=="checkbox" && documento.form1.elements[y].alt==valor && documento.form1.elements[y].alt!="" && documento.form1.elements[y].name.substring(0,9)=="chk_grupo"){
			documento.form1.elements[y].disabled="";
			documento.form1.elements[y].checked=false;
		}
	}
	//alert(documento.form.hd_grupos_prov.value);
		return false;
}

//Fin nueva_oferta.php


function seleccionar_familia(documento, obj_familia){
	var valor=obj_familia.value;
	var y=0;
	documento.form.hd_grupos_prov.value=obj_familia.alt+","+valor+",";
	//Inhabilitar los grupos que no pertenezcan a la familia
	for (y=0; y<documento.form.elements.length; y++){
		if (documento.form.elements[y].type=="checkbox" && documento.form.elements[y].alt!=valor && documento.form.elements[y].alt!="" && documento.form.elements[y].name.substring(0,9)=="chk_grupo"){
			documento.form.elements[y].disabled="disabled";
			documento.form.elements[y].checked=false;
		}else if (documento.form.elements[y].type=="checkbox" && documento.form.elements[y].alt==valor && documento.form.elements[y].alt!="" && documento.form.elements[y].name.substring(0,9)=="chk_grupo"){
			documento.form.elements[y].disabled="";
			documento.form.elements[y].checked=false;
		}
	}
	//alert(documento.form.hd_grupos_prov.value);
		return false;
}


//Esta funcion es para seleccionar el subcapitulo cuando estoy editando los grupos de un proveedor
function seleccionar_subcapitulo2(documento){
	var valor="";
	for (i=0; i<documento.form.rb_capitulos_mo.length; i++){
		if (documento.form.rb_capitulos_mo[i].checked==true)
			valor=documento.form.rb_capitulos_mo[i].value;
	}
	
	//Inhabilitar las familias que no pertenezcan al subcapitulo
	for (i=0; i<documento.form.elements.length; i++){
		if (documento.form.elements[i].type=="radio" && documento.form.elements[i].alt!=valor && documento.form.elements[i].alt!=""){
			documento.form.elements[i].disabled="disabled";
			n=0;
			while (n<documento.form.hd_num_grupos.value){
				if (typeof eval("documento.form.chk_grupo_"+n)!="undefined"){
					mi_check=eval("documento.form.chk_grupo_"+n);
					if (mi_check.alt==documento.form.elements[i].value){	
						mi_check.disabled="disabled";
					}
				}
				n++;	
			}
		}else if (documento.form.elements[i].type=="radio" && documento.form.elements[i].alt==valor){
			documento.form.elements[i].disabled="";
			n=0;
			while (n<documento.form.hd_num_grupos.value){
				if (typeof eval("documento.form.chk_grupo_"+n)!="undefined"){
					mi_check=eval("documento.form.chk_grupo_"+n);
					if (mi_check.alt==documento.form.elements[i].value){
						mi_check.disabled="disabled";
					}
				}
				n++;	
			}
		}
	}
		return false;
}

//Esta funcion es para seleccionar la familia cuando estoy editando los grupos de un proveedor
function seleccionar_familia2(documento, obj_familia){
	var valor=obj_familia;
	var y=0;
	//alert(valor);
	//Inhabilitar los grupos que no pertenezcan a la familia
	for (y=0; y<documento.form.elements.length; y++){
		if (documento.form.elements[y].type=="checkbox" && documento.form.elements[y].alt!=valor && documento.form.elements[y].alt!="" && documento.form.elements[y].name.substring(0,9)=="chk_grupo"){
			documento.form.elements[y].disabled="disabled";
		}else if (documento.form.elements[y].type=="checkbox" && documento.form.elements[y].alt==valor && documento.form.elements[y].alt!="" && documento.form.elements[y].name.substring(0,9)=="chk_grupo"){
			documento.form.elements[y].disabled="";
		}
	}
		return false;
}


//Seleccionar capitulo en editar ofera
function seleccionar_subcapitulo_edioferta(documento, formulario){
	var valor="";
	for (i=0; i<formulario.rb_capitulos_mo.length; i++){
		if (formulario.rb_capitulos_mo[i].checked==true)
			valor=formulario.rb_capitulos_mo[i].value;
	}
	
	formulario.hd_grupos_prov.value="";
	formulario.hd_grupos_prov.value=valor+",";
	//Inhabilitar las familias que no pertenezcan al subcapitulo
	for (i=0; i<formulario.elements.length; i++){
		if (formulario.elements[i].type=="radio" && formulario.elements[i].alt!=valor && formulario.elements[i].alt!=""){
			formulario.elements[i].disabled="disabled";
			formulario.elements[i].checked=false;
			n=0;
			while (n<formulario.hd_num_grupos.value){
				if (typeof eval("formulario.chk_grupo_"+n)!="undefined"){
					mi_check=eval("formulario.chk_grupo_"+n);
					if (mi_check.alt==formulario.elements[i].value){	
						mi_check.disabled="disabled";
						mi_check.checked=false;
					}
				}
				n++;	
			}
		}else if (formulario.elements[i].type=="radio" && formulario.elements[i].alt==valor){
			formulario.elements[i].disabled="";
			formulario.elements[i].checked=false;
			n=0;
			while (n<formulario.hd_num_grupos.value){
				if (typeof eval("formulario.chk_grupo_"+n)!="undefined"){
					mi_check=eval("formulario.chk_grupo_"+n);
					if (mi_check.alt==formulario.elements[i].value){
						mi_check.disabled="disabled";
						mi_check.checked=false;
					}
				}
				n++;	
			}
		}
	}	
	//alert(formulario.hd_grupos_prov.value);
		return false;
}

//Esta funcion es para seleccionar el subcapitulo cuando estoy editando los grupos de un proveedor
function seleccionar_subcapitulo_edioferta2(documento, formulario){
	var valor="";
	for (i=0; i<formulario.rb_capitulos_mo.length; i++){
		if (formulario.rb_capitulos_mo[i].checked==true)
			valor=formulario.rb_capitulos_mo[i].value;
	}
	
	//Inhabilitar las familias que no pertenezcan al subcapitulo
	for (i=0; i<formulario.elements.length; i++){
		if (formulario.elements[i].type=="radio" && formulario.elements[i].alt!=valor && formulario.elements[i].alt!=""){
			formulario.elements[i].disabled="disabled";
			n=0;
			while (n<formulario.hd_num_grupos.value){
				if (typeof eval("formulario.chk_grupo_"+n)!="undefined"){
					mi_check=eval("formulario.chk_grupo_"+n);
					if (mi_check.alt==formulario.elements[i].value){	
						mi_check.disabled="disabled";
					}
				}
				n++;	
			}
		}else if (formulario.elements[i].type=="radio" && formulario.elements[i].alt==valor){
			formulario.elements[i].disabled="";
			n=0;
			while (n<formulario.hd_num_grupos.value){
				if (typeof eval("formulario.chk_grupo_"+n)!="undefined"){
					mi_check=eval("formulario.chk_grupo_"+n);
					if (mi_check.alt==formulario.elements[i].value){
						mi_check.disabled="disabled";
					}
				}
				n++;	
			}
		}
	}
		return false;
}


//Selecicoanr familia a la hora de editar ofertas
function seleccionar_familia_edioferta(documento, obj_familia, formulario){
	var valor=obj_familia.value;
	var y=0;
	formulario.hd_grupos_prov.value=obj_familia.alt+","+valor+",";
	//Inhabilitar los grupos que no pertenezcan a la familia
	for (y=0; y<formulario.elements.length; y++){
		if (formulario.elements[y].type=="checkbox" && formulario.elements[y].alt!=valor && formulario.elements[y].alt!="" && formulario.elements[y].name.substring(0,9)=="chk_grupo"){
			formulario.elements[y].disabled="disabled";
			formulario.elements[y].checked=false;
		}else if (formulario.elements[y].type=="checkbox" && formulario.elements[y].alt==valor && formulario.elements[y].alt!="" && formulario.elements[y].name.substring(0,9)=="chk_grupo"){
			formulario.elements[y].disabled="";
			formulario.elements[y].checked=false;
		}
	}
	//alert(formulario.hd_grupos_prov.value);
		return false;
}

function seleccionar_familia_edioferta2(documento, obj_familia, formulario){
	var valor=obj_familia;
	var y=0;
	//alert(valor);
	//Inhabilitar los grupos que no pertenezcan a la familia
	for (y=0; y<formulario.elements.length; y++){
		if (formulario.elements[y].type=="checkbox" && formulario.elements[y].alt!=valor && formulario.elements[y].alt!="" && formulario.elements[y].name.substring(0,9)=="chk_grupo"){
			formulario.elements[y].disabled="disabled";
		}else if (formulario.elements[y].type=="checkbox" && formulario.elements[y].alt==valor && formulario.elements[y].alt!="" && formulario.elements[y].name.substring(0,9)=="chk_grupo"){
			formulario.elements[y].disabled="";
		}
	}
		return false;
}

function cargar_regimen(naturaleza, documento){
	 documento.	form.cmb_regimen.options.length=0;
		documento.	form.cmb_regimen.options[0]=new Option ("SELECCIONAR","-",false);
  if (naturaleza=="N")	{  
				documento.	form.cmb_regimen.options[1]=new Option ("PERSONA NATURAL","PERSONA NATURAL",false);
		}else if (naturaleza=="J")	{  
				documento.	form.cmb_regimen.options[1]=new Option ("REGIMEN SIMPLIFICADO","REGIMEN SIMPLIFICADO",false);
				documento.	form.cmb_regimen.options[2]=new Option ("REGIMEN COMUN NO AUTORRETENEDOR","REGIMEN COMUN NO AUTORRETENEDOR",false);
				documento.	form.cmb_regimen.options[3]=new Option ("REGIMEN COMUN AUTORRETENEDOR","REGIMEN COMUN AUTORRETENEDOR",false);
				documento.	form.cmb_regimen.options[4]=new Option ("GRAN CONTRIBUYENTE NO AUTORRETENEDOR NO RESPONSABLE DE IVA","GRAN CONTRIBUYENTE NO AUTORRETENEDOR NO RESPONSABLE DE IVA",false);
				documento.	form.cmb_regimen.options[5]=new Option ("GRAN CONTRIBUYENTE AUTORRETENEDOR NO RESPONSABLE DE IVA","GRAN CONTRIBUYENTE AUTORRETENEDOR NO RESPONSABLE DE IVA",false);
				documento.	form.cmb_regimen.options[6]=new Option ("GRAN CONTRIBUYENTE NO AUTORRETENEDOR REGIMEN COMUN","GRAN CONTRIBUYENTE NO AUTORRETENEDOR REGIMEN COMUN",false);
				documento.	form.cmb_regimen.options[7]=new Option ("GRAN CONTRIBUYENTE AUTORRETENEDOR REGIMEN COMUN","GRAN CONTRIBUYENTE AUTORRETENEDOR REGIMEN COMUN",false);
				documento.	form.cmb_regimen.options[8]=new Option ("CONSORCIO REGIMEN COMUN","CONSORCIO REGIMEN COMUN",false);
				documento.	form.cmb_regimen.options[9]=new Option ("CONSORCIO NO RESPONSABLE DE IVA","CONSORCIO NO RESPONSABLE DE IVA",false);
				documento.	form.cmb_regimen.options[10]=new Option ("ENTIDAD GUBERNAMENTAL","ENTIDAD GUBERNAMENTAL",false);
				documento.	form.cmb_regimen.options[11]=new Option ("REGIMEN ESPECIAL NO RESPONSABLE DE IVA","REGIMEN ESPECIAL NO RESPONSABLE DE IVA",false);
				documento.	form.cmb_regimen.options[12]=new Option ("REGIMEN ESPECIAL REGIMEN COMUN","REGIMEN ESPECIAL REGIMEN COMUN",false);
				documento.	form.cmb_regimen.options[13]=new Option ("NO RESPONSABLE DE IVA","NO RESPONSABLE DE IVA",false);
		}else if (naturaleza=="ME")	{  
				documento.	form.cmb_regimen.options[1]=new Option ("PERSONA NATURAL","PERSONA NATURAL",false);
		}else if (naturaleza=="NCN")	{  
				documento.	form.cmb_regimen.options[1]=new Option ("REGIMEN SIMPLIFICADO","REGIMEN SIMPLIFICADO",false);
				documento.	form.cmb_regimen.options[2]=new Option ("REGIMEN COMUN NO AUTORRETENEDOR","REGIMEN COMUN NO AUTORRETENEDOR",false);
		}else if (naturaleza=="CE")	{  
				documento.	form.cmb_regimen.options[1]=new Option ("PERSONA NATURAL","PERSONA NATURAL",false);
		}
		seleccionar_obligatorios('-',documento); //Limpiar los datos obligatorios
}

function seleccionar_obligatorios(regimen, documento){
			var asterisco="<b><font color='red'>*</font></b>";
			documento.getElementById("span_codigociiu").innerHTML="";
			documento.getElementById("span_resolucion_gran").innerHTML="";
			documento.getElementById("span_resolucion_rtfe").innerHTML="";
			documento.getElementById("span_resolucion_iva").innerHTML="";
			documento.getElementById("span_actividad").innerHTML="";
			documento.getElementById("span_actividad2").innerHTML="";
			documento.getElementById("span_tarifaciiu").innerHTML="";
			documento.getElementById("span_municipioica").innerHTML="";
			documento.getElementById("span_hojavida").innerHTML="";
  	if (regimen=="PERSONA NATURAL"){
				  documento.getElementById("span_hojavida").innerHTML=asterisco;
						documento.getElementById("span_actividad").innerHTML=asterisco;
						documento.getElementById("span_actividad2").innerHTML=asterisco;
				  documento.getElementById("span_codigociiu").innerHTML=asterisco;
						documento.getElementById("span_tarifaciiu").innerHTML=asterisco;
						documento.getElementById("span_municipioica").innerHTML=asterisco;
			}else if (regimen=="REGIMEN SIMPLIFICADO" || regimen=="REGIMEN COMUN NO AUTORRETENEDOR" || regimen=="CONSORCIO REGIMEN COMUN" || regimen=="CONSORCIO NO RESPONSABLE DE IVA" || regimen=="ENTIDAD GUBERNAMENTAL" || regimen=="REGIMEN ESPECIAL NO RESPONSABLE DE IVA" || regimen=="REGIMEN ESPECIAL REGIMEN COMUN" || regimen=="NO RESPONSABLE DE IVA"){
				  documento.getElementById("span_actividad").innerHTML=asterisco;
						documento.getElementById("span_actividad2").innerHTML=asterisco;
				  documento.getElementById("span_codigociiu").innerHTML=asterisco;
						documento.getElementById("span_tarifaciiu").innerHTML=asterisco;
						documento.getElementById("span_municipioica").innerHTML=asterisco;
			}else if (regimen=="REGIMEN COMUN AUTORRETENEDOR"){
				  documento.getElementById("span_resolucion_rtfe").innerHTML=asterisco;
						documento.getElementById("span_resolucion_iva").innerHTML=asterisco;
			}else if (regimen=="GRAN CONTRIBUYENTE NO AUTORRETENEDOR NO RESPONSABLE DE IVA"){
				  documento.getElementById("span_resolucion_gran").innerHTML=asterisco;
						documento.getElementById("span_actividad").innerHTML=asterisco;
						documento.getElementById("span_actividad2").innerHTML=asterisco;
						documento.getElementById("span_codigociiu").innerHTML=asterisco;
						documento.getElementById("span_tarifaciiu").innerHTML=asterisco;
						documento.getElementById("span_municipioica").innerHTML=asterisco;
			}else if (regimen=="GRAN CONTRIBUYENTE AUTORRETENEDOR NO RESPONSABLE DE IVA"){
				  documento.getElementById("span_resolucion_gran").innerHTML=asterisco;
						documento.getElementById("span_resolucion_rtfe").innerHTML=asterisco;
						documento.getElementById("span_resolucion_iva").innerHTML=asterisco;
						documento.getElementById("span_actividad").innerHTML=asterisco;
						documento.getElementById("span_actividad2").innerHTML=asterisco;
						documento.getElementById("span_codigociiu").innerHTML=asterisco;
						documento.getElementById("span_tarifaciiu").innerHTML=asterisco;
						documento.getElementById("span_municipioica").innerHTML=asterisco;
			}else if (regimen=="GRAN CONTRIBUYENTE NO AUTORRETENEDOR REGIMEN COMUN"){
				  documento.getElementById("span_resolucion_gran").innerHTML=asterisco;
						documento.getElementById("span_actividad").innerHTML=asterisco;
						documento.getElementById("span_actividad2").innerHTML=asterisco;
						documento.getElementById("span_codigociiu").innerHTML=asterisco;
						documento.getElementById("span_tarifaciiu").innerHTML=asterisco;
						documento.getElementById("span_municipioica").innerHTML=asterisco;
			}else if (regimen=="GRAN CONTRIBUYENTE AUTORRETENEDOR REGIMEN COMUN"){
				  documento.getElementById("span_resolucion_gran").innerHTML=asterisco;
						documento.getElementById("span_resolucion_rtfe").innerHTML=asterisco;
						documento.getElementById("span_actividad").innerHTML=asterisco;
						documento.getElementById("span_actividad2").innerHTML=asterisco;
						documento.getElementById("span_codigociiu").innerHTML=asterisco;
						documento.getElementById("span_tarifaciiu").innerHTML=asterisco;
						documento.getElementById("span_municipioica").innerHTML=asterisco;
			}
}