var useragent = navigator.userAgent; 
 var bName = (useragent.indexOf('Opera') > -1) ? 'Opera' : navigator.appName; 
 var pos = useragent.indexOf('MSIE'); 
 if (pos > -1) { 
   bVer = useragent.substring(pos + 5); 
   var pos = bVer.indexOf(';'); 
   var bVer = bVer.substring(0,pos); 
 } 
 var pos = useragent.indexOf('Opera'); 
 if (pos > -1)    { 
   bVer = useragent.substring(pos + 6); 
   var pos = bVer.indexOf(' '); 
   var bVer = bVer.substring(0, pos); 
 } 
 if (bName == "Netscape") { 
   var bVer = useragent.substring(8); 
   var pos = bVer.indexOf(' '); 
   var bVer = bVer.substring(0, pos); 
 } 
 if (bName == "Netscape" && parseInt(navigator.appVersion) >= 5) { 
   var pos = useragent.lastIndexOf('/'); 
   var bVer = useragent.substring(pos + 1); 
 } 
function primernivel(posicion){
		if (bName == "Netscape"){
			alert(bVer);
			if (bVer>=7){
			window.document.datos0.SetVariable("posicion", posicion);
			window.document.datos0.SetVariable("browser", "Netscape");
			}else{
						window.document.datos0.SetVariable("posicion", "21");
			window.document.datos0.SetVariable("browser", "Netscape");
			}
		}else{
		window.document.datos0.SetVariable("posicion", posicion);
		window.document.datos0.SetVariable("browser", "otro");
		}
}


function Anadir(){
//window.open('http://localhost/anzemp.php','BUSQUEDA','resizable=no,width=550, scrollbars=no,height=220')
window.open('/anzemp.php','BUSQUEDA','resizable=no,width=550, scrollbars=no,height=220');
}


function validapuesto(){
doc=document.forms[0]; 
mensaje="";
if (doc.dnpuesto.value==""){
mensaje = "Debe de indicar el nombre del puesto";
doc.dnpuesto.focus();}
if((mensaje=="") & (doc.mesinicio.selectedIndex==0)){
mensaje = "Debe de seleccionar el mes de Inicio";}
if((mensaje=="") & (doc.annoinicio.selectedIndex==0)){
mensaje = "Debe de indicar el año de inicio";}
if((mensaje=="") & (doc.dscgeneral.value=="")){
mensaje = "Debe de indicar una descripcion general del puesto";
doc.dscgeneral.focus();}
if((mensaje=="") & (doc.funciones.value=="")){
mensaje = "Debe indicar las funciones desempeñadas en el puesto";
doc.funciones.focus();}
if (mensaje!=""){
	alert (mensaje);}
else doc.submit();}

// AQUI EMPIEZA LO NUEVO BORRAR LO ANTERIOR

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function fpulsado(cual){
/*	pag_web=window.location
	alert (pag_web);
	location.href=cual*/
	//
	donde_ir=cual
	donde = location.href
	adonde = donde.split ("/");
	if (adonde[adonde.length-1]=="cv_maker_personales.php"){
		validaPersonales(cual)
	}else{
		location.href=cual
	}
	//
}



function validaPersonales(cual){
  document.getElementById("cvmarker").action ="seletia_php/altadpersonales.php?donde="+cual;
  mensaje="";
  doc=document.forms[0];
  //if (ValidarEmail(doc.email.value)==true){
  /*if(doc.Nombre.value==""){mensaje="Debe de indicar el nombre";doc.Nombre.focus();}
  if((mensaje=="") && (doc.apellido1.value=="")){mensaje="Debe de indicar el Apellido 1";doc.apellido1.focus();}
  if((mensaje=="") && (doc.apellido2.value=="")){mensaje="Debe de indicar el Apellido 2";doc.apellido2.focus();}
  if((mensaje=="") && (doc.telf1.value=="")){mensaje="Debe de indicar el Telefono 1";doc.telf1.focus();}
  if((mensaje=="") && (doc.email.value=="")){mensaje="Debe de indicar un Email";doc.email.focus();}
  if(mensaje!=""){alert(mensaje)}
  else*/ doc.submit();}//}
 


function modificaForma(tipo){
valores=0;mensaje="";seleccionados="";
if(document.forms[0].elimina.length!=null){valores=document.forms[0].elimina.length;}

	if(valores==0){if(document.forms[0].elimina.checked==false){
		if(tipo=="E"){
		mensaje="Para eliminar un dato debe de seleccionarlo";}
		else mensaje="Para modificar un dato de seleccionarlo";}
		else{seleccionados=document.forms[0].elimina.value + ";";}
		}
	
	if(valores>0){
		for(x=0;x<valores;x++){
			if(document.forms[0].elimina[x].checked==true){
				seleccionados=seleccionados + document.forms[0].elimina[x].value + ";";
			}
		}
		if(seleccionados==""){
			if(tipo=="E"){
			mensaje="Para eliminar un dato debe de seleccionarlo";}
		else mensaje="Para modificar un dato debe de seleccionarlo";
		}	
	}

	datose=seleccionados.split(";");
	if(datose.length>2){
		if(tipo=="F"){mensaje="Para modificar solo debe de elegir un dato";}
		if(tipo=="E"){mensaje="Para eliminar solo debe de elegir un dato";}}
if(mensaje!=""){alert(mensaje)}
else{
document.forms[0].accion.value=tipo;
document.forms[0].valores.value=seleccionados;
document.forms[0].submit();}}
function recarga(){
document.frames['formacion'].location.reload();}
function recargaFrame(ruta){
parent.document.frames['formacion'].document.location.href=ruta;}
function nuevaTitu(){
document.forms[0].titulacion.value="";	
document.forms[0].titulacionant.value="";
document.forms[0].incio_mes[0].selected=true;
document.forms[0].inicio_anio[26].selected=true;
document.forms[0].fin_mes[0].selected=true;
document.forms[0].fin_anio[26].selected=true;
document.forms[0].centro.value="";}
function novaEmpresa(){
document.forms[0].empresa.disabled=false;
document.forms[0].empresa.value="";document.forms[0].empresa.focus();}
function novoPuesto(){
doc=document.forms[0];
doc.incio_mes[0].selected=true;
doc.inicio_anio[26].selected=true;
doc.fin_mes[0].selected=true;
doc.fin_anio[26].selected=true;
doc.puesto.value="";
doc.descripcion.value="";
doc.empresaant.value="";
doc.puestoant.value="";
doc.funciones1.value="";doc.funciones2.value="";doc.funciones3.value="";
doc.funciones4.value="";doc.funciones5.value="";}
function modificaInf(){
alert("NOI");}
function avisoidioma(){
alert('El idioma o nivel elegido ya existe');}
function nuevoIdioma(){
fr=document.forms[0];
fr.Idioma[0].selected=true;fr.nivel[0].selected=true;fr.titulacion.value="";fr.estancias.value="";
fr.idiomaant.value="";
}
function ValidarEmail(email){         
  var cadena;   
    cadena = "Email No Valido: " + email 
      +  "\n Por favor reviselo."; 
   if(  email.indexOf(';',0) != -1
       || email.indexOf(' ',0) != -1 || email.indexOf('/',0) != -1 
     || email.indexOf(';',0) != -1 || email.indexOf('<',0) != -1 
     || email.indexOf('>',0) != -1 || email.indexOf('*',0) != -1 
     || email.indexOf('|',0) != -1 || email.indexOf('`',0) != -1 
     || email.indexOf('&',0) != -1 || email.indexOf('$',0) != -1 
     || email.indexOf('!',0) != -1 || email.indexOf('"',0) != -1 
     || email.indexOf(',',0) != -1 || email.indexOf('#',0) != -1 
     || email.indexOf('{',0) != -1 || email.indexOf('=',0) != -1 
     || email.indexOf('(',0) != -1 || email.indexOf(')',0) != -1 
     || email.indexOf(':',0) != -1  || email.indexOf('%',0)!=-1
     || email.indexOf('@',0) <= 0  ) //Para validar @ 

       { /*alert(cadena);*/ return false; } 
    else return true;}
function comparaFechas(mes1,ani1,mes2,ani2){
mensa="";
if(ani2!=""){
 if(ani1>ani2){
 mensa="La fecha de inicio no puede ser mayor que la fecha fin";}}
 if(mensa==""){
  if((mes2!="") & (ani2!="")){
   if((mes1>mes2) & ((ani1>ani2) | (ani1==ani2))){mensa="La fecha de inicio no puede ser mayor que la fecha fin";}
 }}
return mensa;}
function nuevaArea(){
	fr=document.forms[0];
	fr.area[0].selected=true;
	fr.concimiento1.value="";fr.concimiento2.value="";fr.concimiento3.value="";fr.concimiento4.value="";
	fr.concimiento5.value="";fr.concimiento6.value="";fr.concimiento7.value="";fr.concimiento8.value="";
	fr.concimiento9.value="";fr.concimiento10.value="";fr.comentarios.value="";}
function nuevoDato(){
document.forms[0].dato.value="";
document.forms[0].comentarios.value="";}

function guardaOtros(){
if(document.forms[0].dato.value==""){
alert("Debe indicar un dato");document.forms[0].dato.focus();}	
else {
document.frames[0].document.open(); 
document.frames[0].document.write("<head><link href='../style_candidatos.css' rel='stylesheet' type='text/css'>" + 
"<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' /></head>");
document.frames[0].document.write("<body bgcolor='E2E6E9'><form name='datosinteres' method='POST' action='seletia_php/altainteres.php'>");
document.frames[0].document.write("<input type='hidden' name='datoant' value='"+document.forms[0].datoant.value+"' id='datoant'><br><br><span class='formulario_texto2'>Añadiendo datos de interés.......</span>");
document.frames[0].document.write("<input name='dato' type='hidden' id='dato' value='"+document.forms[0].dato.value+"'>");
document.frames[0].document.write("<input name='comentarios' type='hidden' id='comentarios' value='"+document.forms[0].comentarios.value+"'></form></body>");

document.forms[0].dato.value="";
document.forms[0].comentarios.value="";
document.frames[0].document.forms[0].submit();
document.frames[0].document.close(); }}

function ini(daton)
{
elige="";
if (daton=="7") {elige="formacion";}
if (daton=="6") {elige="formacion";}
/*document.getElementById(elige).width =
window.frames.formacion.document.body.offsetWidth +
window.frames.formacion.document.body.scrollWidth; ancho */
document.getElementById(elige).height =
eval("window.frames."+elige+".document.body.scrollHeight");//alto
}
function guardaIdioma(){
mensaje="";
posi=document.forms[0].Idioma.selectedIndex;
document.forms[0].posidioma.value=posi;
pose=document.forms[0].nivel.selectedIndex;
document.forms[0].posnivel.value=pose;
if(posi==0){mensaje="Debe elegir un idioma";}
if((mensaje=="") & (pose==0)){mensaje="Debe elegir un nivel";}
if(mensaje!=""){alert(mensaje);}
else {
document.frames[0].document.open(); 
document.frames[0].document.write("<head><link href='../style_candidatos.css' rel='stylesheet' type='text/css'></head>");
document.frames[0].document.write("<body bgcolor='E2E6E9'><form name='datosinteres' method='post' action='seletia_php/altaidiomas.php'>");
document.frames[0].document.write("<br><br><span class='formulario_texto2'>Añadiendo idiomas.......</span>");	
document.frames[0].document.write("<input name='Idioma' type='hidden' id='Idioma' value='"+document.forms[0].Idioma.value+"'>");
document.frames[0].document.write("<input name='nivel' type='hidden' id='nivel' value='"+document.forms[0].nivel.value+"'>");
document.frames[0].document.write("<input name='titulacion' type='hidden' id='titulacion' value='"+document.forms[0].titulacion.value+"'>");
document.frames[0].document.write("<input name='estancias' type='hidden' id='estancias' value='"+document.forms[0].estancias.value+"'>");
document.frames[0].document.write("<input name='posidioma' type='hidden' id='posidioma' value='"+document.forms[0].posidioma.value+"'>");
document.frames[0].document.write("<input name='posnivel' type='hidden' id='posnivel' value='"+document.forms[0].posnivel.value+"'>");
document.frames[0].document.write("<input name='nivelant' type='hidden' id='nivelant' value='"+document.forms[0].nivelant.value+"'>");
document.frames[0].document.write("<input name='idio' type='hidden' id='idio' value='"+document.forms[0].idio.value+"'>");
document.frames[0].document.write("<input name='idiomaant' type='hidden' id='idiomaant' value='"+document.forms[0].idiomaant.value+"'></form></body>");
document.frames[0].document.forms[0].submit();
document.frames[0].document.close();}}

function guardaInforma(){
	fr=document.forms[0];mensaje="";
	seleccionado=fr.area[fr.area.selectedIndex].text;
	if((seleccionado.indexOf('.')==0) | (seleccionado.indexOf('>')>0) | (seleccionado=="")){
	alert("El area seleccionado no es valido");}else {
document.frames[0].document.open(); 
document.frames[0].document.write("<head><link href='../style_candidatos.css' rel='stylesheet' type='text/css'></head>");
document.frames[0].document.write("<body bgcolor='E2E6E9'><form name='datosinteres' method='post' action='seletia_php/altaconoinf.php'>");
document.frames[0].document.write("<br><br><span class='formulario_texto2'>Añadiendo conocimientos informáticos.......</span>");	
document.frames[0].document.write("<input name='area' type='hidden' id='area' value='"+document.forms[0].area.value+"'>");
document.frames[0].document.write("<input name='concimiento1' type='hidden' id='concimiento1' value='"+document.forms[0].concimiento1.value+"'>");		
document.frames[0].document.write("<input name='concimiento2' type='hidden' id='concimiento2' value='"+document.forms[0].concimiento2.value+"'>");		
document.frames[0].document.write("<input name='concimiento3' type='hidden' id='concimiento3' value='"+document.forms[0].concimiento3.value+"'>");		
document.frames[0].document.write("<input name='concimiento4' type='hidden' id='concimiento4' value='"+document.forms[0].concimiento4.value+"'>");		
document.frames[0].document.write("<input name='concimiento5' type='hidden' id='concimiento5' value='"+document.forms[0].concimiento5.value+"'>");		
document.frames[0].document.write("<input name='concimiento6' type='hidden' id='concimiento6' value='"+document.forms[0].concimiento6.value+"'>");		
document.frames[0].document.write("<input name='concimiento7' type='hidden' id='concimiento7' value='"+document.forms[0].concimiento7.value+"'>");		
document.frames[0].document.write("<input name='concimiento8' type='hidden' id='concimiento8' value='"+document.forms[0].concimiento8.value+"'>");		
document.frames[0].document.write("<input name='concimiento9' type='hidden' id='concimiento9' value='"+document.forms[0].concimiento9.value+"'>");		
document.frames[0].document.write("<input name='concimiento10' type='hidden' id='concimiento10' value='"+document.forms[0].concimiento10.value+"'>");		
document.frames[0].document.write("<input name='comentarios' type='hidden' id='comentarios' value='"+document.forms[0].comentarios.value+"'>");		
document.frames[0].document.write("<input name='areaant' type='hidden' id='areaant' value='"+document.forms[0].areaant.value+"'></form></body>");		
document.forms[0].areaant.value="";
document.frames[0].document.forms[0].submit();
document.frames[0].document.close();}}


function validaProfe(){
doc=document.forms[0];mensaje="";
if(doc.empresa.value==""){
mensaje="Debe de indicar el nombre de la empresa";doc.empresa.focus();}
if((mensaje=="") & (doc.incio_mes.selectedIndex==0)){
mensaje="Debe de indicar la fecha de inicio";}
if((mensaje=="") & (doc.inicio_anio.selectedIndex==26)){
mensaje="Debe de indicar la fecha de inicio";}
valor=doc.incio_mes.selectedIndex;
valor2=doc.inicio_anio.selectedIndex;
valorfin=doc.fin_mes.selectedIndex;
valorfin2=doc.fin_anio.selectedIndex;
if(valor2!=26){yea=doc.inicio_anio[valor2].text;}
if(valorfin2!=26){yea2=doc.fin_anio[valorfin2].text;}
if(mensaje==""){
mensaje=comparaFechas(valor,yea,valorfin,yea2);}
if((mensaje=="") & (doc.puesto.value=="")){
mensaje="Debe de indicar un puesto";doc.puesto.focus="";}
if(mensaje!=""){
alert(mensaje);}
else {
document.frames[0].document.open(); 
document.frames[0].document.write("<head><link href='../style_candidatos.css' rel='stylesheet' type='text/css'></head>");
document.frames[0].document.write("<body bgcolor='E2E6E9'><form name='exprofesional' method='post' action='seletia_php/altaexperiencias.php'>");
document.frames[0].document.write("<br><br><span class='formulario_texto2'>Añadiendo experiencia profesional.......</span>");	
// Intenta recorrer todos los items y pasarselos con una super función al frame
nombrecampo="";
for (i=0; i < document.forms[0].elements.length ; i++){
nombrecampo=doc.elements[i].name;
eval("document.frames[0].document.write(\"<input name='"+nombrecampo+"' type='hidden' id='"+nombrecampo+"' value='"+eval("doc."+nombrecampo+".value")+"'>\")");}
document.frames[0].document.write("</form></body>");
document.forms[0].puestoant.value="";
document.frames[0].document.forms[0].submit();
document.frames[0].document.close();}}


function guardarFormacion(tipo){
mensaje="";yea="";yea2="";
doc=document.forms[0];


if(doc.titulacion.value==""){
	mensaje="Debe de indicar una titulacion";doc.titulacion.focus();} 	
valor=doc.incio_mes.selectedIndex;
valor2=doc.inicio_anio.selectedIndex;
valorfin=doc.fin_mes.selectedIndex;
valorfin2=doc.fin_anio.selectedIndex;
if(valor2!=26){yea=doc.inicio_anio[valor2].text;}
if(valorfin2!=26){yea2=doc.fin_anio[valorfin2].text;}
if(mensaje==""){
mensaje=comparaFechas(valor,yea,valorfin,yea2);}
if((mensaje=="") & (valor==0)){
	mensaje="Debe de elegir la fecha de inicio";}
if((mensaje=="") & (valor2==26)){
	mensaje="Debe de elegir la fecha de inicio";}
if((mensaje=="") & (doc.centro.value=="")){
	mensaje="Debe de indicar un centro";doc.centro.focus();}
	
 if(mensaje!=""){alert(mensaje)}
 else {
document.frames[0].document.open(); 
document.frames[0].document.write("<head><link href='../style_candidatos.css' rel='stylesheet' type='text/css'></head>");
if (tipo=="1"){document.frames[0].document.write("<body bgcolor='E2E6E9'><form name='exprofesional' method='post' action='seletia_php/altacademica.php'>");}
if (tipo=="2"){document.frames[0].document.write("<body bgcolor='E2E6E9'><form name='exprofesional' method='post' action='seletia_php/altacomple.php'>");}
document.frames[0].document.write("<br><br><span class='formulario_texto2'>Añadiendo formación.......</span>");	
nombrecampo="";
for (i=0; i < document.forms[0].elements.length ; i++){
nombrecampo=doc.elements[i].name;
eval("document.frames[0].document.write(\"<input name='"+nombrecampo+"' type='hidden' id='"+nombrecampo+"' value='"+eval("doc."+nombrecampo+".value")+"'>\")");}

document.frames[0].document.write("</form></body>");	
document.forms[0].titulacionant.value="";
document.frames[0].document.forms[0].submit();
document.frames[0].document.close();
}}

