
function setExpActiva(source)
{
	document.form1.ExpActiva.value = source;
}
function setFacActiva(source)
{
	document.form1.FacActiva.value = source;
}
function setFnaActiva(source)
{
	document.form1.FnaActiva.value = source;
}
function setIdiActiva(source)
{
	document.form1.IdiActiva.value = source;
}
function setInfActiva(source)
{
	document.form1.InfActiva.value = source;
}


function validarDatos()
{
	var boolEnviar = true;
	if(document.form1.txtNombre.value==""){boolEnviar=false; document.form1.txtNombre.style.backgroundColor="#ffff00"; }else{document.form1.txtNombre.style.backgroundColor="white";}	
	if(document.form1.txtApellido1.value==""){boolEnviar=false; document.form1.txtApellido1.style.backgroundColor="#ffff00"; }else{document.form1.txtApellido1.style.backgroundColor="white";}
	if(document.form1.txtApellido2.value==""){boolEnviar=false; document.form1.txtApellido2.style.backgroundColor="#ffff00"; }else{document.form1.txtApellido2.style.backgroundColor="white";}
	if(document.form1.txtDireccion.value==""){boolEnviar=false; document.form1.txtDireccion.style.backgroundColor="#ffff00"; ;}else{document.form1.txtDireccion.style.backgroundColor="white";}	
	if(document.form1.selProvincia.value=="0"){boolEnviar=false; document.form1.selProvincia.style.backgroundColor="#ffff00";}else{document.form1.selProvincia.style.backgroundColor="white";}
	if(document.form1.txtLocalidad.value==""){boolEnviar=false; document.form1.txtLocalidad.style.backgroundColor="#ffff00"; }else{document.form1.txtLocalidad.style.backgroundColor="white";}
	if(!validarFecha(document.form1.txtFechaNacimiento.value)){boolEnviar=false; document.form1.txtFechaNacimiento.style.backgroundColor="#ffff00";}else{document.form1.txtFechaNacimiento.style.backgroundColor="white";}
	if(document.form1.txtTelDomicilio.value==""){boolEnviar=false; document.form1.txtTelDomicilio.style.backgroundColor="#ffff00"; }else{document.form1.txtTelDomicilio.style.backgroundColor="white";}
	if(document.form1.txtEmail.value==""){boolEnviar=false; document.form1.txtEmail.style.backgroundColor="#ffff00";}else{document.form1.txtEmail.style.backgroundColor="white";}
	//booolEnviar = curExtension();
	return boolEnviar;
}
function validarFecha(fecha)
{	
		var  arrFecha, intDiasMes, dia, mes, anyo;		 	
	 	arrFecha = fecha.split("/");
	 	dia = arrFecha[0];
	 	mes = arrFecha[1];
	 	anyo = arrFecha[2];
	 	intDiasMes = new Date(anyo,mes,0).getDate(); //Cuántos días tiene este més
		if((mes>12 || mes<=0) || (dia>intDiasMes || dia<=0) || (anyo==""))
		{
			return false;
		}else
		{
			fecha= new Date(anyo,mes -1,dia)
			if( !isNaN(fecha)){	
				return true;
			}
			else{
				return false;
			}
		
	}
}

function codigoMalicioso(src,patron)
{
	if(!patron.test(src))  //  /[^\w\s\t\n.,_-?¿!¡áéíóú\/]/g
	{
		return true;
	}
	else
	{
		return false;
	}
}
function validarCodigo(){
	var strSource, return_invalid_chars, invalid_chars, boolError;
	boolError = false;
	invalid_chars = '';
	
	//validar Nºs de Telefono: Domicilio, oficina, movil
	strSource = document.form1.txtTelDomicilio.value;	
	if(!codigoMalicioso(strSource, /[^0-9]/g ) || strSource.length != 9){document.form1.txtTelDomicilio.style.backgroundColor="#ffff00";alert('Nº de teléfono incorrecto.'); return boolError;}else{document.form1.txtTelDomicilio.style.backgroundColor="white";}
	strSource = document.form1.txtTelOficina.value;	
	if(!codigoMalicioso(strSource, /[^0-9]/g ) || (strSource.length >0 && strSource.length < 9)){document.form1.txtTelOficina.style.backgroundColor="#ffff00";alert('Nº de teléfono incorrecto.'); return boolError;}else{document.form1.txtTelOficina.style.backgroundColor="white";}	
	strSource = document.form1.txtTelMovil.value;	
	if(!codigoMalicioso(strSource, /[^0-9]/g ) || (strSource.length >0 && strSource.length < 9)){document.form1.txtTelMovil.style.backgroundColor="#ffff00";alert('Nº de teléfono incorrecto.'); return boolError;}else{document.form1.txtTelMovil.style.backgroundColor="white";}
	strSource = document.form1.txtDNI.value;	
	if(!codigoMalicioso(strSource, /[^a-zA-Z0-9]/g ) || (strSource.length >0 && strSource.length < 9)){document.form1.txtDNI.style.backgroundColor="#ffff00";alert('DNI incorrecto.'); return boolError;}else{document.form1.txtDNI.style.backgroundColor="white";}
	strSource = document.form1.txtCP.value;	
	if(!codigoMalicioso(strSource, /[^0-9]/g )|| (strSource.length >0 && strSource.length < 5)){document.form1.txtCP.style.backgroundColor="#ffff00";alert('CP incorrecto.'); return boolError;}else{document.form1.txtCP.style.backgroundColor="white";}
	strSource = document.form1.txtNHijos.value;	
	if(!codigoMalicioso(strSource, /[^0-9]/g )){document.form1.txtNHijos.style.backgroundColor="#ffff00";alert('valor no admitido : ' + strSource); return boolError;}else{document.form1.txtNHijos.style.backgroundColor="white";}
	// Validar mail  
	strSource = document.form1.txtEmail.value;
	if(codigoMalicioso(strSource, /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/)){document.form1.txtEmail.style.backgroundColor="#ffff00";alert('Email incorrecto.'); return boolError;}else{document.form1.txtEmail.style.backgroundColor="white";}
	
	// validar campos contra código malicioso
	strSource = document.form1.txtNombre.value;
	if(!codigoMalicioso(strSource, /[^a-zA-Z\sáéíóú]/g )){document.form1.txtNombre.style.backgroundColor="#ffff00";alert('Valor no admitido:'   +  strSource ); return boolError;}else{document.form1.txtNombre.style.backgroundColor="white";}	
	strSource = document.form1.txtApellido1.value;
	if(!codigoMalicioso(strSource, /[^a-zA-Z\s\-áéíóú]/g )){document.form1.txtApellido1.style.backgroundColor="#ffff00";alert('Valor no admitido : '   +  strSource ); return boolError;}else{document.form1.txtApellido1.style.backgroundColor="white";}	
	strSource = document.form1.txtApellido2.value;
	if(!codigoMalicioso(strSource, /[^a-zA-Z\s\-áéíóú]/g )){document.form1.txtApellido2.style.backgroundColor="#ffff00";alert('Valor no admitido:'   +  strSource ); return boolError;}else{document.form1.txtApellido2.style.backgroundColor="white";}	
	strSource = document.form1.txtLocalidad.value;
	if(!codigoMalicioso(strSource, /[^a-zA-Z\s\-áéíóú]/g)){document.form1.txtLocalidad.style.backgroundColor="#ffff00";alert('Valor no admitido:'   +  strSource ); return boolError;}else{document.form1.txtLocalidad.style.backgroundColor="white";}	
		
	strSource = document.form1.txtObservaciones.value;
	if(!codigoMalicioso(strSource, /[^\w\s\t\n.,_\-\?¿\!¡áéíóú\/]/g )){document.form1.txtObservaciones.style.backgroundColor="#ffff00";alert('Valor no admitido:'   +  strSource ); return boolError;}else{document.form1.txtObservaciones.style.backgroundColor="white";}	
	strSource = document.form1.txtDireccion.value;
	if(!codigoMalicioso(strSource, /[^\w\s\t\nº.,_\-\?¿\!¡áéíóú\/]/g )){document.form1.txtDireccion.style.backgroundColor="#ffff00";alert('Valor no admitido:'   +  strSource ); return boolError;}else{document.form1.txtDireccion.style.backgroundColor="white";}	
	
	boolError = true;
	//Comprobar las extensiones del archivo
	if(document.form1.btnDialogo.value != '')
	boolError = checkExtension(document.form1.btnDialogo.value, 0,' el curriculum.');
	if (boolError==true)
	{
		if(document.form1.btnDialogoFoto.value != '')
		boolError = checkExtension(document.form1.btnDialogoFoto.value, 1, ' la foto.');
	}
	return boolError;
}
function checkExtension(path, intCodigo, msg)
{
	var  intLength, intLastPosition, strExt, boolErrorr;
	boolError=true;
	intLength = path.length;
	intLastPosition = path.lastIndexOf('.');
	//if(intLastPosition==-1) return false; //el archivo no tiene extensión
	strExt = path.substr(intLastPosition+1);
	if(intCodigo == 0) //curriculum=0 y foto=1
	{
		if(strExt=='doc' || strExt=='rtf' ||  strExt=='pdf' ||  strExt=='txt')
		{
			boolError=true;
		}
		else{		
			alert('Estensión ' + strExt + ' no admitida en' + msg);	
			boolError=false;
		}
	}else
	{
		if(strExt=='jpg' || strExt=='gif' || strExt=='jpeg')
		{
			boolError=true;
		}
		else{
			alert('Estensión ' + strExt + ' no admitida en' + msg);	
			boolError=false;	
		}
	}
	return boolError;
}
// Array con los datos de las experiencias
var inic=0;
var counterExp = 0;
var edit = 0;
var arrExp = new Array(15);
for(inic=0;inic<15;inic++){
	arrExp[inic] = new Array(7); //Necesario para que no de error de undefined en typeof(arr[i][0])!="undefined"
}
//arrExp[0] = new Array(7);

function addExperiencia(tableID){
	edit = 0;	 // edit=0, Se va a añadir una línea; edit=1 se va a editar una línea
	setExpActiva(counterExp);
	arrExp[counterExp] = new Array(7);
	//alert('counter: ' + counterExp);
	MM_openBrWindow('../Pags/datosExp.htm','datos','scrollbars=yes,width=440,height=250');	
}
// Array con los datos de form academica
var counterFac = 0;
var editFac = 0;
var arrFac = new Array(15);
for(inic=0;inic<15;inic++){
	arrFac[inic] = new Array(6);//Necesario para que no de error de undefined en typeof(arr[i][0])!="undefined"
}
function addFac(tableID){
	editFac = 0;	 // edit=0, Se va a añadir una línea; edit=1 se va a editar una línea
	setFacActiva(counterFac);
	arrFac[counterFac] = new Array(6);
	//alert('counter: ' + counterFac);
	MM_openBrWindow('../Pags/datosFormAc.htm','datos','scrollbars=yes,width=440,height=250');	
}
// Array con los datos de form academica
var counterFna = 0;
var editFna = 0;
var arrFna = new Array(15);
for(inic=0;inic<15;inic++){
	arrFna[inic] = new Array(5);//Necesario para que no de error de undefined en typeof(arr[i][0])!="undefined"
}
function addFna(tableID){
	editFna = 0;	 // edit=0, Se va a añadir una línea; edit=1 se va a editar una línea
	setFnaActiva(counterFna);
	arrFna[counterFna] = new Array(5);
	//alert('counter: ' + counterFna);
	MM_openBrWindow('../Pags/datosFormNoAc.htm','datos','scrollbars=yes,width=440,height=250');	
}
// Array con los datos de idiomas
var counterIdi = 0;
var editIdi = 0;
var arrIdi = new Array(15);
for(inic=0;inic<15;inic++){
	arrIdi[inic] = new Array(5);//Necesario para que no de error de undefined en typeof(arr[i][0])!="undefined"
}
function addIdi(tableID){
	editIdi = 0;	 // edit=0, Se va a añadir una línea; edit=1 se va a editar una línea
	setIdiActiva(counterIdi);
	arrIdi[counterIdi] = new Array(5);
	//alert('counter: ' + counterIdi);
	MM_openBrWindow('../Pags/datosIdiomas.htm','datos','scrollbars=yes,width=440,height=250');	
}
// Array con los datos de informatica
var counterInf = 0;
var editInf = 0;
var arrInf = new Array(15);
for(inic=0;inic<15;inic++){
	arrInf[inic] = new Array(4);//Necesario para que no de error de undefined en typeof(arr[i][0])!="undefined"
}
function addInf(tableID){
	editInf = 0;	 // edit=0, Se va a añadir una línea; edit=1 se va a editar una línea
	setInfActiva(counterInf);
	arrInf[counterInf] = new Array(4);
	//alert('counter: ' + counterInf);
	MM_openBrWindow('../Pags/datosInformatica.htm','datos','scrollbars=yes,width=440,height=250');	
}
function renombrarID(str)
{
	var strPrefijo, strTotal, strSufijo;
	var itHidden, itTable;	
	strPrefijo = str;	
	//Renombrar <a>-s
	strSufijo = '_aLabel1';//'_aEmpresa';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
	strSufijo = '_aLabel2';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
	strSufijo = '_imgEdit';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
	strSufijo = '_imgBorrar';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
}
function renombrarIDFac(str)
{
	var strPrefijo, strTotal, strSufijo;
	var itHidden, itTable;	
	strPrefijo = str;	
	//Renombrar <a>-s
	strSufijo = '_aFac1';//'_aEmpresa';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
	strSufijo = '_aFac2';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
	strSufijo = '_imgFacEdit';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
	strSufijo = '_imgFacBorrar';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
}
function renombrarIDFna(str)
{
	var strPrefijo, strTotal, strSufijo;
	var itHidden, itTable;	
	strPrefijo = str;	
	//Renombrar <a>-s
	strSufijo = '_aFna1';//'_aEmpresa';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
	strSufijo = '_aFna2';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
	strSufijo = '_imgFnaEdit';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
	strSufijo = '_imgFnaBorrar';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
}
function renombrarIDIdi(str)
{
	var strPrefijo, strTotal, strSufijo;
	var itHidden, itTable;	
	strPrefijo = str;	
	//Renombrar <a>-s
	strSufijo = '_aIdi1';//'_aEmpresa';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
	//strSufijo = '_aIdi2';
	//strTotal = strPrefijo  + strSufijo;
	//itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	//itHidden.id = strTotal;
	strSufijo = '_imgIdiEdit';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
	strSufijo = '_imgIdiBorrar';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
}
function renombrarIDInf(str)
{
	var strPrefijo, strTotal, strSufijo;
	var itHidden, itTable;	
	strPrefijo = str;	
	//Renombrar <a>-s
	strSufijo = '_aInf1';//'_aEmpresa';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
	//strSufijo = '_aInf2';
	//strTotal = strPrefijo  + strSufijo;
	//itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	//itHidden.id = strTotal;
	strSufijo = '_imgInfEdit';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
	strSufijo = '_imgInfBorrar';
	strTotal = strPrefijo  + strSufijo;
	itHidden = document.all ? document.all[strSufijo] : document.getElementById(strSufijo);
	itHidden.id = strTotal;
}
function editRow()
{
	var intFila;
	intFila = window.event.srcElement.id;
	intFila = intFila.split('_',1);	
	setExpActiva(intFila);
	//alert('editar : ' + intFila);
	edit = 1;  //para editar
	MM_openBrWindow('../Pags/datosExp.htm','datos','scrollbars=yes,width=440,height=250');
}
function editRowFac()
{
	var intFila;
	intFila = window.event.srcElement.id;
	intFila = intFila.substr(0,1);
	setFacActiva(intFila);
	//alert('editar : ' + intFila);
	editFac = 1;  //para editar
	MM_openBrWindow('../Pags/datosFormAc.htm','datos','scrollbars=yes,width=440,height=250');
}
function editRowFna()
{
	var intFila;
	intFila = window.event.srcElement.id;
	intFila = intFila.split('_',1);
	setFnaActiva(intFila);
	//alert('editar : ' + intFila);
	editFna = 1;  //para editar
	MM_openBrWindow('../Pags/datosFormNoAc.htm','datos','scrollbars=yes,width=440,height=250');
}
function editRowIdi()
{
	var intFila;
	intFila = window.event.srcElement.id;
	intFila = intFila.split('_',1);
	setIdiActiva(intFila);
	//alert('editar : ' + intFila);
	editIdi = 1;  //para editar
	MM_openBrWindow('../Pags/datosIdiomas.htm','datos','scrollbars=yes,width=440,height=250');
}
function editRowInf()
{
	var intFila;
	intFila = window.event.srcElement.id;
	intFila = intFila.split('_',1);
	setInfActiva(intFila);
	//alert('editar : ' + intFila);
	editInf = 1;  //para editar
	MM_openBrWindow('../Pags/datosInformatica.htm','datos','scrollbars=yes,width=440,height=250');
}
//variable global ExpCounter
var counterExp = 0;
function ActualizarCounter(code)
{
	if(code==0)	counterExp++;
	else if(code==1) counterExp--;
}
function ActualizarCounterFac(code)
{
	if(code==0)	counterFac++;
	else if(code==1) counterFac--;
}
function ActualizarCounterFna(code)
{
	if(code==0)	counterFna++;
	else if(code==1) counterFna--;
}
function ActualizarCounterIdi(code)
{
	if(code==0)	counterIdi++;
	else if(code==1) counterIdi--;
}
function ActualizarCounterInf(code)
{
	if(code==0)	counterInf++;
	else if(code==1) counterInf--;
}
function addRow(tableID,html)
{
	var itTable, itRow, itCell;			
	itTable = window.document.getElementById(tableID);
 	itRow = itTable.insertRow(itTable.rows.length);//document.all.mytable.insertRow(rowLength + 1);
	itCell = itRow.insertCell(0);
	itCell.innerHTML = html;
}
function deleteRow(){	
	var tableID = 'tblExp';
	var intFila,itTable,itRow;
	intFila = window.event.srcElement.id;
	intFila = intFila.split('_',1);
	rebuildArray(intFila);
	rebuildTabla(tableID)
}
function deleteRowFac(){	
	var tableID = 'TblFac';
	var intFila,itTable,itRow;
	intFila = window.event.srcElement.id;
	intFila = intFila.split('_',1);
	rebuildArrayFac(intFila);
	rebuildTablaFac(tableID)
}
function deleteRowFna(){	
	var tableID = 'TblFna';
	var intFila,itTable,itRow;
	intFila = window.event.srcElement.id;
	intFila = intFila.split('_',1);
	rebuildArrayFna(intFila);
	rebuildTablaFna(tableID)
}
function deleteRowIdi(){	
	var tableID = 'TblIdi';
	var intFila,itTable,itRow;
	intFila = window.event.srcElement.id;
	intFila = intFila.split('_',1);
	rebuildArrayIdi(intFila);
	rebuildTablaIdi(tableID)
}
function deleteRowInf(){	
	var tableID = 'TblInf';
	var intFila,itTable,itRow;
	intFila = window.event.srcElement.id;
	intFila = intFila.split('_',1);
	rebuildArrayInf(intFila);
	rebuildTablaInf(tableID)
}
var arrAux
function rebuildArray(intFila)
{
	var i,j, intIndice;
	 arrAux= new Array(15);
	//se copia el array al auxiliar
	//for(i=intFila;typeof(arrExp[i])!="undefined";i++)
	//{	
		//arrAux[i] = new Array(7);
		//for(j=0;j<7;j++)
		//{				
			//arrAux[i][j] = arrExp[i][j];
		//}
	//}
	arrAux = arrExp.slice(0, -1);
	
	for(i=intFila;typeof(arrAux[i])!="undefined";i++)
	{	
		intIndice = ++i ; // intIndice = i + 1 lo toma como cadena= 'o1'
		i--;
		for(j=0;j<7;j++)
		{
			if(typeof(arrAux[intIndice])=="undefined")
			{ //si es el último el que se borra
				arrExp[i] = new Array(7);	
			}			
			else
			{//si el que se borra es uno intermedio
				arrExp[i][j] = arrAux[intIndice][j];				
			}		
		}		
	}
	ActualizarCounter(1); // restar al contador 1 fila
}
function rebuildArrayFac(intFila)
{
	var i,j, intIndice;
	 arrAux= new Array(15);	
	arrAux = arrFac.slice(0, -1);
	
	for(i=intFila;typeof(arrAux[i])!="undefined";i++)
	{	
		intIndice = ++i ; // intIndice = i + 1 lo toma como cadena= 'o1'
		i--;
		for(j=0;j<6;j++)
		{
			if(typeof(arrAux[intIndice])=="undefined")
			{ //si es el último el que se borra
				arrFac[i] = new Array(6);	
			}			
			else
			{//si el que se borra es uno intermedio
				arrFac[i][j] = arrAux[intIndice][j];				
			}		
		}		
	}
	ActualizarCounterFac(1); // restar al contador 1 fila
}
function rebuildArrayFna(intFila)
{
	var i,j, intIndice;
	 arrAux= new Array(15);	
	arrAux = arrFna.slice(0, -1);
	
	for(i=intFila;typeof(arrAux[i])!="undefined";i++)
	{	
		intIndice = ++i ; // intIndice = i + 1 lo toma como cadena= 'o1'
		i--;
		for(j=0;j<5;j++)
		{
			if(typeof(arrAux[intIndice])=="undefined")
			{ //si es el último el que se borra
				arrFna[i] = new Array(5);	
			}			
			else
			{//si el que se borra es uno intermedio
				arrFna[i][j] = arrAux[intIndice][j];				
			}		
		}		
	}
	ActualizarCounterFna(1); // restar al contador 1 fila
}
function rebuildArrayIdi(intFila)
{
	var i,j, intIndice;
	 arrAux= new Array(15);	
	arrAux = arrIdi.slice(0, -1);
	
	for(i=intFila;typeof(arrAux[i])!="undefined";i++)
	{	
		intIndice = ++i ; // intIndice = i + 1 lo toma como cadena= 'o1'
		i--;
		for(j=0;j<5;j++)
		{
			if(typeof(arrAux[intIndice])=="undefined")
			{ //si es el último el que se borra
				arrIdi[i] = new Array(5);	
			}			
			else
			{//si el que se borra es uno intermedio
				arrIdi[i][j] = arrAux[intIndice][j];				
			}		
		}		
	}
	ActualizarCounterIdi(1); // restar al contador 1 fila
}
function rebuildArrayInf(intFila)
{
	var i,j, intIndice;
	 arrAux= new Array(15);	
	arrAux = arrInf.slice(0, -1);
	
	for(i=intFila;typeof(arrAux[i])!="undefined";i++)
	{	
		intIndice = ++i ; // intIndice = i + 1 lo toma como cadena= 'o1'
		i--;
		for(j=0;j<4;j++)
		{
			if(typeof(arrAux[intIndice])=="undefined")
			{ //si es el último el que se borra
				arrInf[i] = new Array(4);	
			}			
			else
			{//si el que se borra es uno intermedio
				arrInf[i][j] = arrAux[intIndice][j];				
			}		
		}		
	}
	ActualizarCounterInf(1); // restar al contador 1 fila
}
//
var html;
html = '<table width=\"99%\" border=\"0\" align=\"right\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#eeeeee\">';
		html = html + '<tr>';
			html = html + '<td width=\"34\"><a href=\"javascript:;\"  onClick=\"javascript:editRow();\"><img id=\"_imgEdit\" src=\"../imagenes/edit.gif\" alt=\"Editar\" width=\"14\" height=\"17\" border=\"0\"></a></td>';
			html = html + '<td width=\"356\"><font id=\"_aLabel1\" >' +  'Puesto'  + '</font>&nbsp;&nbsp;&nbsp;&nbsp;';				
							html = html + '<font id=\"_aLabel2\" >' + 'Empresa' + '</font></td>';
			html = html + '<td width=\"26\"> </td>';
            html = html + '<td width=\"30\"> <a href=\"javascript:;\"  onClick=\"javascript:deleteRow();\" ><img id=\"_imgBorrar\" src=\"../imagenes/papelera.gif\" alt=\"Borrar\" width=\"14\" height=\"17\" border=\"0\"></a></td>';
         html = html + '</tr>';
    html = html + '</table>';
function rebuildTabla(tableID){
	var i, aItem, iTable, strTotal;
	//Borrar toda la tabla
	iTable = document.getElementById(tableID)	
	while(iTable.rows.length>2)
	{			
		iTable.deleteRow(2);
	}
	for(i=0;typeof(arrExp[i][0])!="undefined";i++)
	{		
		addRow('tblExp',html);
		renombrarID(i);
		//poner valore a los <a>
		strTotal = i + '_aLabel1';
		aItem = document.getElementById(strTotal);
		aItem.innerText = arrExp[i][1];
		strTotal = i + '_aLabel2';
		aItem = document.getElementById(strTotal);
		aItem.innerText = arrExp[i][2];
	}
}
var htmlFac;
htmlFac = '<table width=\"99%\" border=\"0\" align=\"right\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#eeeeee\">';
		htmlFac = htmlFac + '<tr>';
			htmlFac = htmlFac + '<td width=\"34\"><a href=\"javascript:;\"  onClick=\"javascript:editRowFac();\"><img id=\"_imgFacEdit\" src=\"../imagenes/edit.gif\" alt=\"Editar\" width=\"14\" height=\"17\" border=\"0\"></a></td>';
			htmlFac = htmlFac + '<td width=\"356\"><font id=\"_aFac1\" >' +  'Titulo'  + '</font>&nbsp;&nbsp;&nbsp;&nbsp;';				
							htmlFac = htmlFac + '<font id=\"_aFac2\" >' + '' + '</font></td>';
			htmlFac = htmlFac + '<td width=\"26\"> </td>';
            htmlFac = htmlFac + '<td width=\"30\"> <a href=\"javascript:;\"  onClick=\"javascript:deleteRowFac();\" ><img id=\"_imgFacBorrar\" src=\"../imagenes/papelera.gif\" alt=\"Borrar\" width=\"14\" height=\"17\" border=\"0\"></a></td>';
         htmlFac = htmlFac + '</tr>';
    htmlFac = htmlFac + '</table>';
function rebuildTablaFac(tableID){
	var i, aItem, iTable, strTotal;
	//Borrar toda la tabla
	iTable = document.getElementById(tableID)	
	while(iTable.rows.length>2)
	{			
		iTable.deleteRow(2);
	}
	for(i=0;typeof(arrFac[i][0])!="undefined";i++)
	{		
		addRow('TblFac',htmlFac);
		renombrarIDFac(i);
		//poner valore a los <a>		
		strTotal = i + '_aFac1';
		aItem = document.getElementById(strTotal);
		aItem.innerText = arrFac[i][2];
	}
}
var htmlFna;
htmlFna = '<table width=\"99%\" border=\"0\" align=\"right\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#eeeeee\">';
		htmlFna = htmlFna + '<tr>';
			htmlFna = htmlFna + '<td width=\"34\"><a href=\"javascript:;\"  onClick=\"javascript:editRowFna();\"><img id=\"_imgFnaEdit\" src=\"../imagenes/edit.gif\" alt=\"Editar\" width=\"14\" height=\"17\" border=\"0\"></a></td>';
			htmlFna = htmlFna + '<td width=\"356\"><font id=\"_aFna1\" >' +  'Curso'  + '</font>&nbsp;&nbsp;&nbsp;&nbsp;';				
							htmlFna = htmlFna + '<font id=\"_aFna2\" >' + 'Centro' + '</font></td>';
			htmlFna = htmlFna + '<td width=\"26\"> </td>';
            htmlFna = htmlFna + '<td width=\"30\"> <a href=\"javascript:;\"  onClick=\"javascript:deleteRowFna();\" ><img id=\"_imgFnaBorrar\" src=\"../imagenes/papelera.gif\" alt=\"Borrar\" width=\"14\" height=\"17\" border=\"0\"></a></td>';
         htmlFna = htmlFna + '</tr>';
    htmlFna = htmlFna + '</table>';
function rebuildTablaFna(tableID){
	var i, aItem, iTable, strTotal;
	//Borrar toda la tabla
	iTable = document.getElementById(tableID)	
	while(iTable.rows.length>2)
	{			
		iTable.deleteRow(2);
	}
	for(i=0;typeof(arrFna[i][0])!="undefined";i++)
	{		
		addRow('TblFna',htmlFna);
		renombrarIDFna(i);
		//poner valore a los <a>
		strTotal = i + '_aFna1';
		aItem = document.getElementById(strTotal);
		aItem.innerText = arrFna[i][1];
		strTotal = i + '_aFna2';
		aItem = document.getElementById(strTotal);
		aItem.innerText = arrFna[i][2];
	}
}
var htmlIdi;
htmlIdi = '<table width=\"99%\" border=\"0\" align=\"right\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#eeeeee\">';
		htmlIdi = htmlIdi + '<tr>';
			htmlIdi = htmlIdi + '<td width=\"34\"><a href=\"javascript:;\"  onClick=\"javascript:editRowIdi();\"><img id=\"_imgIdiEdit\" src=\"../imagenes/edit.gif\" alt=\"Editar\" width=\"14\" height=\"17\" border=\"0\"></a></td>';
			htmlIdi = htmlIdi + '<td width=\"356\"><font id=\"_aIdi1\" >' +  'Idioma'  + '</font>&nbsp;&nbsp;&nbsp;&nbsp;';				
							htmlIdi = htmlIdi + '<font id=\"_aIdi2\" >' + '' + '</font></td>';
			htmlIdi = htmlIdi + '<td width=\"26\"> </td>';
            htmlIdi = htmlIdi + '<td width=\"30\"> <a href=\"javascript:;\"  onClick=\"javascript:deleteRowIdi();\" ><img id=\"_imgIdiBorrar\" src=\"../imagenes/papelera.gif\" alt=\"Borrar\" width=\"14\" height=\"17\" border=\"0\"></a></td>';
         htmlIdi = htmlIdi + '</tr>';
    htmlIdi = htmlIdi + '</table>';
function rebuildTablaIdi(tableID){
	var i, aItem, iTable, strTotal;
	//Borrar toda la tabla
	iTable = document.getElementById(tableID)	
	while(iTable.rows.length>2)
	{	
		iTable.deleteRow(2);
	}
	for(i=0;typeof(arrIdi[i][0])!="undefined";i++)
	{					
		addRow('TblIdi',htmlIdi);
		renombrarIDIdi(i);
		//poner valore a los <a>
		strTotal = i + '_aIdi1';
		aItem = document.getElementById(strTotal);
		aItem.innerText = arrIdi[i][1];		
	}
}
var htmlInf;

htmlInf = '<table width=\"99%\" border=\"0\" align=\"right\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#eeeeee\">';
		htmlInf = htmlInf + '<tr>';
			htmlInf = htmlInf + '<td width=\"34\"><a href=\"javascript:;\"  onClick=\"javascript:editRowInf();\"><img id=\"_imgInfEdit\" src=\"../imagenes/edit.gif\" alt=\"Editar\" width=\"14\" height=\"17\" border=\"0\"></a></td>';
			htmlInf = htmlInf + '<td width=\"356\"><font id=\"_aInf1\" >' +  'Infoma'  + '</font>&nbsp;&nbsp;&nbsp;&nbsp;';				
							htmlInf = htmlInf + '<font id=\"_aInf2\" >' + '' + '</font></td>';
			htmlInf = htmlInf + '<td width=\"26\"> </td>';
            htmlInf = htmlInf + '<td width=\"30\"> <a href=\"javascript:;\"  onClick=\"javascript:deleteRowInf();\" ><img id=\"_imgInfBorrar\" src=\"../imagenes/papelera.gif\" alt=\"Borrar\" width=\"14\" height=\"17\" border=\"0\"></a></td>';
         htmlInf = htmlInf + '</tr>';
    htmlInf = htmlInf + '</table>';
function rebuildTablaInf(tableID){
	var i, aItem, iTable, strTotal;
	//Borrar toda la tabla
	iTable = document.getElementById(tableID)	
	while(iTable.rows.length>2)
	{			
		iTable.deleteRow(2);
	}
	
	for(i=0;typeof(arrInf[i][0])!="undefined";i++)
	{		
		addRow('TblInf',htmlInf);
		renombrarIDInf(i);
		//poner valore a los <a>
		strTotal = i + '_aInf1';
		aItem = document.getElementById(strTotal);
		aItem.innerText = arrInf[i][1];		
	}
}
function setHiddens()
{
	var i, itTable, itRow, itCelda, itHidden;
	itTable = document.getElementById('tblHidden');  //todas las hidden en esta tabla
	//Generar la tr Experiencias
	itRow = itTable.insertRow(itTable.rows.length);
	//itRow.id = 'trExp';
	for(i=0;typeof(arrExp[i][0])!="undefined";i++)
	{			
		itCelda = itRow.insertCell(i);
		itCelda.id = 'tdExp' + i;
		itHidden = crearElemento("input","hidden","Exp" + i + '_Check',arrExp[i][0]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Exp" + i + '_Puesto',arrExp[i][1]);
		itCelda.appendChild(itHidden);		
		itHidden = crearElemento("input","hidden","Exp" + i + '_Empresa',arrExp[i][2]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Exp" + i + '_Departamento',arrExp[i][3]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Exp" + i + '_FechaInicio',arrExp[i][4]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Exp" + i + '_FechaFin',arrExp[i][5]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Exp" + i + '_Observaciones',arrExp[i][6]);
		itCelda.appendChild(itHidden);
	}
	document.form1.ExpNum.value = i;
	
	//Generar la tr Formacion
	itTable = document.getElementById('tblHidden');
	itRow = itTable.insertRow(itTable.rows.length);
	//itRow.id = 'trFac';
	for(i=0;typeof(arrFac[i][0])!="undefined";i++)	
	{			
		itCelda = itRow.insertCell(i);
		itCelda.id = 'tdFac' + i;
		itHidden = crearElemento("input","hidden","Fac" + i + '_Check',arrFac[i][0]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Fac" + i + '_Nivel',arrFac[i][1]);
		itCelda.appendChild(itHidden);		
		itHidden = crearElemento("input","hidden","Fac" + i + '_Titulo',arrFac[i][2]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Fac" + i + '_Descripcion',arrFac[i][3]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Fac" + i + '_Anyo',arrFac[i][4]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Fac" + i + '_Lugar',arrFac[i][5]);
		itCelda.appendChild(itHidden);
	}
	document.form1.FacNum.value = i;
	
	//Generar la tr Formacion no académica
	itTable = document.getElementById('tblHidden');
	itRow = itTable.insertRow(itTable.rows.length);
	//itRow.id = 'trFna';
	for(i=0;typeof(arrFna[i][0])!="undefined";i++)
	{		
		itCelda = itRow.insertCell(i);
		itCelda.id = 'tdFna' + i;
		itHidden = crearElemento("input","hidden","Fna" + i + '_Check',arrFna[i][0]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Fna" + i + '_NombreCurso',arrFna[i][1]);
		itCelda.appendChild(itHidden);		
		itHidden = crearElemento("input","hidden","Fna" + i + '_Centro',arrFna[i][2]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Fna" + i + '_Horas',arrFna[i][3]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Fna" + i + '_Anyo',arrFna[i][4]);
		itCelda.appendChild(itHidden);		
	}
	document.form1.FnaNum.value = i;
	
	//Generar la tr de idiomas
	itTable = document.getElementById('tblHidden');
	itRow = itTable.insertRow(itTable.rows.length);
	//itRow.id = 'trIdi';
	for(i=0;typeof(arrIdi[i][0])!="undefined";i++)
	{		
		itCelda = itRow.insertCell(i);
		itCelda.id = 'tdIdi' + i;
		itHidden = crearElemento("input","hidden","Idi" + i + '_Check',arrIdi[i][0]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Idi" + i + '_Idioma',arrIdi[i][1]);
		itCelda.appendChild(itHidden);		
		itHidden = crearElemento("input","hidden","Idi" + i + '_Leido',arrIdi[i][2]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Idi" + i + '_Escrito',arrIdi[i][3]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Idi" + i + '_Hablado',arrIdi[i][4]);
		itCelda.appendChild(itHidden);		
	}
	document.form1.IdiNum.value = i;
	
	//Generar la tr de inform
	itTable = document.getElementById('tblHidden');
	itRow = itTable.insertRow(itTable.rows.length);
	//itRow.id = 'trInf';
	for(i=0;typeof(arrInf[i][0])!="undefined";i++)
	{		
		itCelda = itRow.insertCell(i);
		itCelda.id = 'tdInf' + i;
		itHidden = crearElemento("input","hidden","Inf" + i + '_Check',arrInf[i][0]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Inf" + i + '_Conocimiento',arrInf[i][1]);
		itCelda.appendChild(itHidden);		
		itHidden = crearElemento("input","hidden","Inf" + i + '_Nivel',arrInf[i][2]);
		itCelda.appendChild(itHidden);
		itHidden = crearElemento("input","hidden","Inf" + i + '_Observaciones',arrInf[i][3]);
		itCelda.appendChild(itHidden);
	}
	document.form1.InfNum.value = i;
}


function crearElemento(strElemento, strTipo, strID, strValor)
{
		NewElement = document.createElement(strElemento);		
		NewElement.id = strID;	
		NewElement.name = strID;	
		NewElement.type = strTipo;
		NewElement.value = strValor;
		//NewElement.style.visibility = "hidden";
		return(NewElement);
}
