function fValidarCliente (){
	if (document.frmNuevo.txtNombre.value == ""){alert(fM("IntroduzcaNombreEmpresa"));return;}
	if (document.frmNuevo.txtCIF.value == ""){alert(fM("IntroduzcaCIF"));return;}
	else{if(document.frmNuevo.txtCIF.value.length<8){alert(fM("CIF8Digitos"));return;}}
	if (document.frmNuevo.txtDireccion.value == ""){alert(fM("IntroduzcaDireccion"));return;}
	if (document.frmNuevo.txtLocalidad.value == ""){alert(fM("IntroduzcaLocalidad"));return;}
	if (document.frmNuevo.cboProvincia.value == "0"){alert(fM("SeleccioneProvincia"));return;}
	if (document.frmNuevo.txtCP.value == ""){alert(fM("IntroduzcaCodigoPostal"));return;}
	else{if(document.frmNuevo.txtCP.value.length<5){alert(fM("CodigoPostal5Digitos"));return;}}
	if (document.frmNuevo.txtTelefono.value == ""){alert(fM("IntroduzcaTelefono"));return;}
	else{if(document.frmNuevo.txtTelefono.value.length<9){alert(fM("Telefono9Digitos"));return;}}
	if (document.frmNuevo.txtFax.value != ""){
		if(document.frmNuevo.txtFax.value.length<9){alert(fM("Fax9Digitos"));return;}
	}
	if (document.frmNuevo.txtCorreo.value == ""){alert(fM("IntroduzcaCorreo"));return;}
	else{if(!fValidarCorreo(document.frmNuevo.txtCorreo.value)){return;}}
	document.frmNuevo.submit();
}
//****************************************
function fValidarUsuario (intNuevo){
	if (intNuevo == 1){
		if (document.frmCajitas.txtLogin.value == ""){alert(fM("IntroduzcaLogin"));return;}
		if (document.frmCajitas.txtClave.value == ""){alert(fM("IntroduzcaClave"));return;}
	}
	if (intNuevo == 0){if (document.frmCajitas.txtClave2.value != document.frmCajitas.txtClave.value){alert("Las claves no son iguales");return;}}
	if (document.frmCajitas.txtNombre.value == ""){alert(fM("IntroduzcaNombre"));return;}
	if (document.frmCajitas.txtApellido1.value == ""){alert(fM("IntroduzcaApellido1"));return;}
	if (document.frmCajitas.txtTelefono.value != ""){
		if(document.frmCajitas.txtTelefono.value.length<9){alert(fM("Telefono9Digitos"));return;}
	}
	if (document.frmCajitas.txtCorreo.value==""){
		alert("Introduzca el correo electrónico");return;
	}else{
		if(!fValidarCorreo(document.frmCajitas.txtCorreo.value)){return;}
	}
	if (document.frmCajitas.cboDepartamento.value == "0"){alert(fM("SeleccioneDepartamento"));return;}
	if (document.frmCajitas.cboDentro.value != "N"){
		document.frmCajitas.hdnGrupos.value="";
		for (var i=0;i<document.frmCajitas.cboDentro.options.length;i++)
		{	if (i>0){strAgregar=","+document.frmCajitas.cboDentro.options[i].value;}
			else{strAgregar=document.frmCajitas.cboDentro.options[i].value;}
			document.frmCajitas.hdnGrupos.value=document.frmCajitas.hdnGrupos.value+strAgregar;
		}
		document.frmCajitas.submit();
	}else{
		if (document.frmCajitas.cboNivel.value == "3"){
			alert(fM("NoPuedeCrearUnAdminDeProyectosSinProyectos"));return;
		}else{
			document.frmCajitas.submit();
		}
	}
	
}
//****************************************
function fCambiaModulos (){
	if (document.frmCajitas.cboNivel.value=="1"){
		MM_showHideLayers ('divWeb','','show');
		MM_showHideLayers ('divAdmin','','hidden');
		MM_showHideLayers ('divAdmin2','','hidden');
		MM_showHideLayers ('divAdminP','','hidden');
		MM_showHideLayers ('divSocio','','hidden');
	}else{
		if (document.frmCajitas.cboNivel.value=="2"){
			MM_showHideLayers ('divWeb','','hidden');
			MM_showHideLayers ('divAdmin2','','hidden');
			MM_showHideLayers ('divAdmin','','show');
			if (document.frmCajitas.chkPermiso[2].checked){
				MM_showHideLayers ('divAdminP','','show');
			}else{
				MM_showHideLayers ('divAdminP','','hidden');
			}
			MM_showHideLayers ('divSocio','','hidden');
		}
		else{
			if (document.frmCajitas.cboNivel.value=="3"){
				MM_showHideLayers ('divWeb','','hidden');
				MM_showHideLayers ('divAdmin','','hidden');
				MM_showHideLayers ('divAdmin2','','show');
				MM_showHideLayers ('divAdminP','','show');
				MM_showHideLayers ('divSocio','','hidden');
			}else{
				if (document.frmCajitas.cboNivel.value=="4"){
					MM_showHideLayers ('divWeb','','hidden');
					MM_showHideLayers ('divAdmin','','hidden');
					MM_showHideLayers ('divAdmin2','','hidden');
					MM_showHideLayers ('divAdminP','','hidden');
					MM_showHideLayers ('divSocio','','show');
				}
			}
		}
	}
}
//****************************************
function fVerPerisosGestorProyectos (intCual){
	//alert(document.frmCajitas.chkPermiso[intCual].checked);
	if (document.frmCajitas.chkPermiso[intCual].checked){
		MM_showHideLayers ('divAdminP','','show');
	}else{MM_showHideLayers ('divAdminP','','hidden');}
}
//****************************************
function fAseguraBorrarUsuarios (){
	intCuantos = document.frmLista.Cuantos.value;
	sw=0;
	if (intCuantos == "1"){
		if (document.frmLista.chkUser.checked){sw=1;}
	}else{
		i=0;
		while(i<intCuantos){
			if (document.frmLista.chkUser[i].checked){sw=1;i=intCuantos;}
			i++;
		}
	}
	if(sw=="0"){alert(fM("SeleccioneUsuariosBorrar"));return;}
	else{
		if(confirm(fM("SeguroBorrarUsuarios"))){
			document.frmLista.submit();
		}else{return;}
	}
}
//****************************************
//function fAseguraBorrarClientes (){
//	intCuantos = document.frmLista.Cuantos.value;
//	sw=0;
//	if (intCuantos == "1"){
//		if (document.frmLista.chkCliente.checked){sw=1;}
//	}else{
//		i=0;
//		while(i<intCuantos){
//			if (document.frmLista.chkCliente[i].checked){sw=1;i=intCuantos;}
//			i++;
//		}
//	}
//	if(sw=="0"){alert("Seleccione el o los clientes que desea borrar");return;}
//	else{
//		if(confirm("** AVISO: Si borrar un cliente se borrarán los usuarios relacionados\n¿Está seguro que desea borrar los clientes seleccionados?")){
//			document.frmLista.submit();
//		}else{return;}
//	}
//}
//****************************************
function fDarDeBajaAlta (intCodigo,intCodigo2){
	if (intCodigo2!=""){
		if(eval("document.frmLista.chkEstado"+intCodigo+".checked")){
			location.href="index.asp?pg=12&estado=0&CodUsuario="+intCodigo+"&CodCliente="+intCodigo2;
		}else{
			location.href="index.asp?pg=12&estado=1&CodUsuario="+intCodigo+"&CodCliente="+intCodigo2;
		}
	}else{
		if(eval("document.frmLista.chkEstado"+intCodigo+".checked")){
			location.href="index.asp?pg=11&estado=0&CodCliente="+intCodigo;
		}else{
			location.href="index.asp?pg=11&estado=1&CodCliente="+intCodigo;
		}
	}
}
//****************************************
function fDarDeBajaAltaSinFormulario (intEstado,intCodigo,intCodigo2){
	if (intCodigo2!=""){
		location.href="index.asp?pg=12&estado="+intEstado+"&CodUsuario="+intCodigo+"&CodCliente="+intCodigo2;
	}else{
		location.href="index.asp?pg=11&estado="+intEstado+"&CodCliente="+intCodigo+"&donde=1";
	}
}
//****************************************
function fSeleccionCliente (strOpcion){
	intCuantos = document.frmLista.Cuantos.value;
	sw=0;
	if (intCuantos == "1"){
		if (document.frmLista.rdbCliente.checked){
			intCodigo = document.frmLista.rdbCliente.value;
			sw=1;
		}
	}else{
		i=0;
		while(i<intCuantos){
			if (document.frmLista.rdbCliente[i].checked){
				intCodigo = document.frmLista.rdbCliente[i].value;
				sw=1;i=intCuantos;
			}
			i++;
		}
	}
	if(sw=="0"){alert(fM("SeleccioneCliente"));return;}
	else{
		if (strOpcion =="usu"){location.href="index.asp?pg=5&CodCliente="+intCodigo;}
		else{
			if (strOpcion =="pro"){location.href="../../proyectos/mant/index.asp?pg=1&cboCliente="+intCodigo;}
		}
	}
}
//**********************************************
function fLimpiarBuscador (intTipo){
	document.frmBuscar.txtNombre.value="";
	if (intTipo=="1"){document.frmBuscar.cboNivel.value=0;}
	else{document.frmBuscar.cboProvincia.value=0;}
	return;
}
//***************************************
function fAseguraBorrarUnUsuario (intCodUsuario,intCodCliente){
	if(confirm(fM("SeguroBorrarUsuario"))){
		location.href="index.asp?pg=13&CodUsuario="+intCodUsuario+"&CodCliente="+intCodCliente;
	}else{return;}
}
//***************************************
function fCargarPermisos (i,b){
	fVaciarLista('cboFuera');
	intCodCliente=document.frmCajitas.cboCliente.value;
	if (intCodCliente!="0"){
		a=0
		while (a < i) {
			intLongitud = frmCajitas.cboFuera.length
			if (aGrupos[a][0]==intCodCliente){
				document.frmCajitas.cboFuera.options[intLongitud]=new Option('-- '+aGrupos[a][1]+' --',aGrupos[a][0]);
				document.frmCajitas.cboFuera.options[intLongitud].className="textog";
				z=0
				intGrupo = aGrupos[a][0]
				while (z <= b){
					if (aGruposUsuarios[intGrupo][z] != undefined){
						intLongitud = frmCajitas.cboFuera.length
						document.frmCajitas.cboFuera.options[intLongitud]=new Option(aUsuarios[aGruposUsuarios[intGrupo][z]],aGruposUsuarios[intGrupo][z]);
					}
					z++
				}
			}
			a++
		}
		aGruposUsuarios[0]=new Array ()
		aGrupos[i+1]=new Array ()
	}
}
//***************************************
function fValidarDescuento (){document.frmDescuento.submit();}
//***************************************
function fAseguraQuitarDescuento (){
	if(confirm(fM("SeguroQuitarDescuento"))){
		document.frmDescuento.action="index.asp?pg=16"
		document.frmDescuento.submit();
	}else{return;}
}

