// JavaScript Document 

/* Funciones para control de que los registros con valores correctos */
// Variables de tipo de datos
var validNumP = ".0123456789";
var validNumCom = ",0123456789";
var validNumComSpc = " ,0123456789";
var validNumComSpcg = "- ,0123456789";
var validNum = "0123456789";
var validNumTel = " 0123456789";
var validRef = "0123456789";
var validFecha = "-0123456789";
var validTexto = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
var validMail = "abcdefghijklmnopqrstuvwxyz@ABCDEFGHIJKLMNOPQRSTUVWXYZ_-1234567890(). ";

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe contener un e-mail correcto.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' debe contener un número.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' debe contener un numero enter '+min+' y '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es requerido.\n'; }
  } if (errors) alert('Recuerde que:\n'+errors);
  document.MM_returnValue = (errors == '');
}

// Funciones de Comprobaciónn de tipo de datos
function checkMail(field,option) {
	var valid= eval ("valid"+option);
	var ok = "yes";
	var temp;
	p=field.value.indexOf('@');
    if (p<1 || p==(field.value.length-1)) { ok="no"; } //no existe este símbolo en la cadena
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no") {
		alert("Este Campo requiere un E-mail correcto.");
		field.value="";
		field.focus();
		return false;
	}
}

function check(field,option) {
	var valid= eval ("valid"+option);
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no") {
		alert("Este Campo sólo acepta los siguientes caracteres: ("+valid+")");
		field.value="";
		field.focus();
		//if (option == "Ref") return(checkRef(field));
		if (option=="Num")   	return(checkNum(field));
		if (option=="NumTel")   return(checkNumTel(field));
		if (option=="NumP") 	return(checkNumP(field));
		return false;
	}
	if (option=="NumTel") 		return(checkNumTel(field));
	if (option == "Num")   		return(checkNum(field));
	else if (option == "NumP")  return(checkNumP(field));
	else if (option =="Fecha")  return(checkFecha(field));
	return true;
}

function checkNum(field){
 if (field.value==""){field.value="";}
 return true;
}

function checkRef(field){
 if (field.value==""){field.value="";}
 return true;
}

function checkNumTel(field){
 if (field.value==""){field.value="";}
 return true;
}

function checkNumP(field){
 if ((field.value=="")||(field.value=="0")||(field.value==".0")||(field.value=="0.")||(field.value==".00")||(field.value==".")||(field.value=="0.0")){field.value="0.00";}
 return true;
}

function checkFecha(field){
if (field.value!=""){
 var fecha=field.value.split("-");
 if ((fecha[0]>0) && (fecha[0]<32) && (fecha[1]>0) && (fecha[1]<13) && (fecha[2]>1980) && (field.value.length==10) )	return true;
 else {alert('La fecha Introducida es incorrecta, verifique que sea una fecha, con número de día comprendido entre 00 y 31, número de mes comprendido entre 00 y 12 y número de año superior al 1980'); return false;}
 }
}

/* Funciones para ver Provincias y Localidades. */
function verSusLocalidades(inForm,selected) {
var selectedArray = eval("ArrayL" + selected);
while (selectedArray.length < inForm.localidad.options.length) {
inForm.localidad.options[(inForm.localidad.options.length - 1)] = null;
}
for (var i=0; i < selectedArray.length; i++) {
	eval("inForm.localidad.options[i]=" + "new Option" + selectedArray[i]);
}
if (inForm.provincia.options[0].value == '') {
	inForm.provincia.options[0]= null;
	if ( navigator.appName == 'Netscape') {
		if (parseInt(navigator.appVersion) < 4) {
			window.history.go(0);
		}else {   	
			if (navigator.platform == 'Win32' || navigator.platform == 'Win16') {
			window.history.go(0);
            }
         }
    }
 }
document.f.localidad.options.selectedIndex=document.f.localidad.options[0];
}

function seleccionaProvincia(inForm,cadena){
 for (var i=0; i < inForm.provincia.options.length; i++) {
	if (inForm.provincia.options[i].value != ''){
		if (inForm.provincia.options[i].value == cadena) {
			inForm.provincia.selectedIndex=i;
		}
	}else{		inForm.provincia.selectedIndex=0;}
 }
}
function seleccionaProvinciaNombre(inForm,cadena){
 for (var i=0; i < inForm.provincia.options.length; i++) {
	if (inForm.provincia.options[i].value != ''){
		if (inForm.provincia.options[i].text == cadena) {
			inForm.provincia.selectedIndex=i;
		}
	}else{		inForm.provincia.selectedIndex=0;}
 }
}
function seleccionaLocalidad(inForm,cadena){
 for (var i=0; i < inForm.localidad.options.length; i++) {
	if (inForm.localidad.options[i].value != ''){
		if (inForm.localidad.options[i].value == cadena) {
			inForm.localidad.selectedIndex=i;
		}
	}else{		inForm.localidad.selectedIndex=0;}
 }
}
function seleccionaLocalidadNombre(inForm,cadena){
 for (var i=0; i < inForm.localidad.options.length; i++) {
	if (inForm.localidad.options[i].value != ''){
		if (inForm.localidad.options[i].text == cadena) {
			inForm.localidad.selectedIndex=i;
		}
	}else{		inForm.localidad.selectedIndex=0;}
 }
}

/* Funciones para ver Provincias y Localidades para el Filtrado. */
function verSusLocalidadesFiltros(inForm,selected) {
var selectedArray = eval("ArrayL" + selected);
while (selectedArray.length < inForm.localidad_soc.options.length) {
inForm.localidad_soc.options[(inForm.localidad_soc.options.length - 1)] = null;
}
for (var i=0; i < selectedArray.length; i++) {
	eval("inForm.localidad_soc.options[i]=" + "new Option" + selectedArray[i]);
}
if (inForm.provincia_soc.options[0].value == '') {
	inForm.provincia_soc.options[0]= null;
	if ( navigator.appName == 'Netscape') {
		if (parseInt(navigator.appVersion) < 4) {
			window.history.go(0);
		}else {   	
			if (navigator.platform == 'Win32' || navigator.platform == 'Win16') {
			window.history.go(0);
            }
         }
    }
 }
document.f.localidad_soc.options.selectedIndex=document.f.localidad_soc.options[0];
}

function seleccionaProvinciaFiltros(inForm,cadena){
 for (var i=0; i < inForm.provincia_soc.options.length; i++) {
	if (inForm.provincia_soc.options[i].value != ''){
		if (inForm.provincia_soc.options[i].value == cadena) {
			inForm.provincia_soc.selectedIndex=i;
		}
	}else{		inForm.provincia_soc.selectedIndex=0;}
 }
}
function seleccionaLocalidadFiltros(inForm,cadena){
 for (var i=0; i < inForm.localidad_soc.options.length; i++) {
	if (inForm.localidad_soc.options[i].value != ''){
		if (inForm.localidad_soc.options[i].value == cadena) {
			inForm.localidad_soc.selectedIndex=i;
		}
	}else{		inForm.localidad_soc.selectedIndex=0;}
 }
}

/* Funciones para Abrir Ventanas.*/ 
function abreVentanaImg(url){ w=330; h=270; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open(url,'IMAGEN',settings); 
}
            
function abre_Ficha(idper,nombre,apellidos,edad_ini,edad_fin,telefono,provincia,localidad,idest,idpuesto,orden){ w=800; h=550; l=30; t=30;
  //var direccion='ver_rrhh.php?idper='+idper+'&nom='+nombre+'&ape='+apellidos+'&edad_ini='+edad_ini+'&edad_fin='+edad_fin+'&tel='+telefono+'&provincia='+provincia+'&localidad='+localidad+'&estudios='+idest+'&puesto='+idpuesto+'&orden='+orden;
  var direccion='ver_rrhh.php?idper='+idper;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open(direccion,'CONSULTAR',settings); 
} 
function abre_FichaSoc(idsoc,creaSocio){ w=800; h=550; l=30; t=30;
  var direccion='nuevo_soc.php?idsoc='+idsoc+'creaSocio='+creaSocio;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open(direccion,'CONSULTAR',settings); 
} 
function abre_Curriculum(url){ w=800; h=550; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open(url,'CURRICULUM',settings); 
}

function abre_Boletin(url){ w=800; h=550; l=30; t=30;
  //var direccion='../nuevo_cons.php?idb='+idb;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open(url,'BOLETINES',settings); 
}

function abre_Consejo(url){ w=800; h=550; l=30; t=30;
  //var direccion='../nuevo_cons.php?idb='+idb;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open(url,'CONSEJOS',settings); 
}

function abre_Tecnologia(url){ w=800; h=550; l=30; t=30;
  //var direccion='../nueva_tec.php?idb='+idb;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open(url,'TECNOLOGIA',settings); 
}

function abre_ListaBoletin(url){ w=800; h=550; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open(url,'BOLETINES',settings); 
}

function abre_ListaConsejo(url){ w=800; h=550; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open(url,'CONSEJOS',settings); 
}

function abre_ListaTecnologia(url){ w=800; h=550; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open(url,'TECNOLOGIA',settings); 
}

function abre_ListaSocImp(nombre_soc,apellidos_soc,telefono_soc,edad_ini,edad_fin,provincia_soc,localidad_soc,profesion_soc,numpie_soc,li){ w=780; h=550; l=20; t=20;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open("lista_soc.php?nombre_soc="+nombre_soc+"&apellidos_soc="+apellidos_soc+"&telefono_soc="+telefono_soc+"&edad_ini="+edad_ini+"&edad_fin="+edad_fin+"&provincia_soc="+provincia_soc+"&localidad_soc="+localidad_soc+"&profesion_soc="+profesion_soc+"&numpie_soc="+numpie_soc+"&li="+li,'IMPRIMIR_LISTA',settings); 
}

function abre_ListaRecursosImp(nom,ape,edad_ini,edad_fin,tel,provincia,localidad,estudios,puesto,li){ w=780; h=550; l=20; t=20;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open("lista_rrhh.php?nom="+nom+"&ape="+ape+"&tel="+tel+"&edad_ini="+edad_ini+"&edad_fin="+edad_fin+"&provincia="+provincia+"&localidad="+localidad+"&estudios="+estudios+"&puesto="+puesto+"&li="+li,'IMPRIMIR_LISTA',settings); 
}

function verImg(imagen) {
 w=600; h=500; l=50; t=50; 
 var direccion='verimagen.php?imagen='+imagen;
 settings ='height='+h+',width='+w+',top='+t+',left='+l+',scrollbars=yes,resizable=yes' ;
 win = window.open(direccion,'IMAGEN',settings);
}

function abrePagRRHH(){ w=800; h=550; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open("rrhh.php",'CURRICULUM',settings); 
}
function abreRecursosHumanos(){ w=800; h=550; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open("rrhh.htm",'CURRICULUM',settings); 
}
function abreRecursosHumanos_Form(){ w=800; h=550; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open("rrhh_formulario.php",'CURRICULUM_Form',settings); 
}


function abreContactar(){ w=460; h=670; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open("contactar.php",'CONTACTAR',settings); 
}

function abrePagConsejos(){ w=800; h=600; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open("consejos.php",'CONSEJOS',settings); 
}
function abreConsejo(num){ w=800; h=600; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open("consejos.php?idc="+num,'CONSEJOS',settings); 
}
function abreConsejos(num){ w=800; h=650; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open("consejos.php?idc="+num,'CONSEJOS',settings); 
}

function enviaConsejo(num,titulo){ w=450; h=420; l=100; t=100;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=no,resizable=no' 
  win = window.open("consejosenviar.php?idc="+num+"&ti="+titulo,'CONSEJOS_envia',settings); 
}

function abrePagBoletines(){ w=800; h=550; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open("boletines.php",'OFERTAS',settings); 
}

function abrePagTecnologia(){ w=800; h=650; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open("tecnologia.php",'TECNOLOGIA',settings); 
}
function abreTecnologia(num){ w=800; h=600; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open("tecnologia.php?idt="+num,'TECNOLOGIA',settings); 
}
function enviaTecnologia(num,titulo){ w=450; h=420; l=100; t=100;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=no,resizable=no' 
  win = window.open("tecnologiaenviar.php?idt="+num+"&ti="+titulo,'TECNOLOGIA_envia',settings); 
}

function abrePagClub(){ w=800; h=550; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open("socios.php",'RUMBOCLUB',settings); 
}
function abreClubClientes(){ w=975; h=750; l=0; t=0;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open("socios.htm",'RUMBOCLUB',settings); 
}
function abreClubClientes_Form(){ w=800; h=600; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=yes,resizable=yes' 
  win = window.open("socios.php",'RUMBOCLUB_Form',settings); 
}
function abreBoletin(num){ w=800; h=690; l=30; t=5;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',scrollbars=no,resizable=yes' 
  win = window.open("boletines.php?idb="+num,'BOLETIN',settings);
}
function enviaBoletin(num,titulo){ w=450; h=420; l=100; t=100;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=no,resizable=no' 
  win = window.open("boletines/boletinesenviar.php?idb="+num+"&ti="+titulo,'BOLETIN_envia',settings); 
}
function abreImprimir(url){ w=400; h=220; l=30; t=30;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=no,scrollbars=no,resizable=no' 
  win = window.open(url,'...IMPRIMIR...',settings); 
}
function imprimirPagina(pagina){
 w=400; h=220; l=100; t=100;
 var settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=no,scrollbars=no,resizable=no' 
 var win = window.open(pagina,'imprimir',settings); 
} 

function abreListaSocios(pagina){
 w=400; h=4000; l=100; t=100;
 var settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=no,scrollbars=yes,resizable=yes' 
 var win = window.open(pagina,'LISTADO_SOCIOS',settings); 
} 
function abreFormulario(num,titulo){ w=450; h=420; l=100; t=100;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=no,resizable=no' 
  win = window.open("boletines/boletinesenviar.php?idb="+num+"&ti="+titulo,'BOLETIN_envia',settings); 
}
function abreOficinasC(num,titulo){ w=500; h=400; l=100; t=100;
  settings ='height='+h+',width='+w+',top='+t+',left='+l+',status=yes,scrollbars=no,resizable=no' 
    win = window.open("mapa.htm",'MAPA',settings); 
}


