function agregar_experiencia_cv() {
	var objEmpresa=document.getElementById('Empresa');
	var objCargo=document.getElementById('Cargo');
	var celda=document.getElementById('lista_experiencias');
	var tabla=document.getElementById('tabla_experiencias');
	
	var empresa=objEmpresa.value;
	var cargo=objCargo.value;
	var referencia=document.getElementById('Referencia').value;
	var descripcion=document.getElementById('Descripcion del Cargo').value;
	
	if(empresa=='') {
		alert('Debe ingresar el nombre de la empresa donde tuvo la experiencia laboral');
		objEmpresa.focus();
		return false;
	}
	if(cargo=='') {
		alert('Debe ingresar su cargo en la empresa donde tuvo la experiencia laboral');
		objCargo.focus();
		return false;
	}
	
	var cant_experiencias=tabla.rows.length;
	var id_linea='linExp'+cant_experiencias;
	
	if(cant_experiencias==0) {
		if(navigator.appName=="Microsoft Internet Explorer") {
			document.getElementById('linea_experiencias').style.display='block';
		} else {
			document.getElementById('linea_experiencias').style.display='table-row';
		}
	}
	
	var linea=tabla.insertRow(-1);
	var celda1=linea.insertCell(-1);
	var celda2=linea.insertCell(-1);
	
	linea.setAttribute('id',id_linea);

	celda1.style.width='385px';
	celda1.style.textAlign='left';
	celda1.style.color='#000000';
	celda1.className='Arial10Normal';
	celda1.style.borderBottom='1px solid #333333';
	celda1.innerHTML='<b>Empresa: </b>'+empresa+'<br><b>Cargo: </b>'+cargo;
	if(referencia!='') {
		celda1.innerHTML+='<br><b>Referencia: </b>'+referencia;
	}
	if(descripcion!='') {
		celda1.innerHTML+='<br><b>Descripción del cargo: </b>'+descripcion;
	}
	
	celda2.style.width='50px';
	celda2.style.textAlign='center';
	celda2.style.color='#FF0000';
	celda2.style.cursor='pointer';
	celda2.className='Arial12Normal';
	celda2.style.borderBottom='1px solid #333333';
	if(navigator.appName=="Microsoft Internet Explorer") {
		celda2.onclick=function() { borrar_experiencia_cv(id_linea); };
	} else {
		celda2.setAttribute('onClick','borrar_experiencia_cv(\''+id_linea+'\')');
	}
	celda2.innerHTML='Borrar';
	
	listar_experiencias_cv();
		
	objEmpresa.value='';
	objCargo.value='';
	document.getElementById('Referencia').value='';
	document.getElementById('Descripcion del Cargo').value='';
	objEmpresa.focus();
	return true;
}

function agregar_titulo_cv() {
	var objTitulo=document.getElementById('titulo');
	var celda=document.getElementById('lista_titulos');
	var tabla=document.getElementById('tabla_titulos');
	
	var titulo=objTitulo.value;
	if(titulo=='') {
		alert('Debe ingresar el título obtenido');
		objTitulo.focus(); 
		return false;
	}
	
	var cant_titulos=tabla.rows.length;
	var id_linea='linTit'+cant_titulos;
	
	if(cant_titulos==0) {
		if(navigator.appName=="Microsoft Internet Explorer") {
			document.getElementById('linea_titulos').style.display='block';
		} else {
			document.getElementById('linea_titulos').style.display='table-row';
		}
	}
	
	var linea=tabla.insertRow(-1);
	var celda1=linea.insertCell(-1);
	var celda2=linea.insertCell(-1);
	
	linea.setAttribute('id',id_linea);

	celda1.style.width='385px';
	celda1.style.textAlign='left';
	celda1.style.color='#000000';
	celda1.className='Arial10Normal';
	celda1.style.borderBottom='1px solid #333333';
	celda1.innerHTML=titulo;
	
	celda2.style.width='50px';
	celda2.style.textAlign='center';
	celda2.style.color='#FF0000';
	celda2.style.cursor='pointer';
	celda2.className='Arial12Normal';
	celda2.style.borderBottom='1px solid #333333';
	if(navigator.appName=="Microsoft Internet Explorer") {
		celda2.onclick=function() { borrar_titulo_cv(id_linea); };
	} else {
		celda2.setAttribute('onClick','borrar_titulo_cv(\''+id_linea+'\')');
	}
	celda2.innerHTML='Borrar';
	
	listar_titulos_cv();
		
	objTitulo.value='';
	objTitulo.focus();
	return true;
}

function borrar_experiencia_cv(id_linea) {
	var tabla=document.getElementById('tabla_experiencias');
	for(x=0;x<tabla.rows.length;x++) {
		if(tabla.rows[x].id==id_linea) {
			var indice=x;
			break;
		}
	}
	tabla.deleteRow(indice);
	listar_experiencias_cv();
	if(tabla.rows.length==0) {
		document.getElementById('linea_experiencias').style.display='none';
	}
	document.getElementById('Empresa').focus();
	return true;
}

function borrar_titulo_cv(id_linea) {
	var tabla=document.getElementById('tabla_titulos');
	for(x=0;x<tabla.rows.length;x++) {
		if(tabla.rows[x].id==id_linea) {
			var indice=x;
			break;
		}
	}
	tabla.deleteRow(indice);
	listar_titulos_cv();
	if(tabla.rows.length==0) {
		document.getElementById('linea_titulos').style.display='none';
	}
	document.getElementById('titulo').focus();
	return true;
}

function listar_experiencias_cv() {
	document.getElementById('Experiencias Laborales').value='';
	for(x=0;x<document.getElementById('tabla_experiencias').rows.length;x++) {
		if(x>0) {
			document.getElementById('Experiencias Laborales').value+='<br>';
		}
		document.getElementById('Experiencias Laborales').value+='<br>'+document.getElementById('tabla_experiencias').rows[x].cells[0].innerHTML;
	}
}

//Genera la lista de títulos para el objeto hidden
function listar_titulos_cv() {
	document.getElementById('Titulos Obtenidos').value='';
	for(x=0;x<document.getElementById('tabla_titulos').rows.length;x++) {
		if(x>0) {
			document.getElementById('Titulos Obtenidos').value+="  --  ";
		}
		document.getElementById('Titulos Obtenidos').value+=document.getElementById('tabla_titulos').rows[x].cells[0].innerHTML;
	}
}
