var global_cadena = "";
var ruta = "http://www.infofeina.com/";

function mostra_aspiracions()
{
	document.getElementById("div_aspiracions").className = "mostra_aspiracions";
	if( document.getElementById("aspiracions").value == "A convenir amb l'empresa")
	{
		document.getElementById("aspiracions").value = "";
	}
}

function oculta_aspiracions()
{
	document.getElementById("div_aspiracions").className = "oculta_aspiracions";
	document.getElementById("negociable").checked = false;
	document.getElementById("aspiracions").value = "";
}

function pas_seguent( pag )
{
	var nom_formulari = document.getElementById('pas').value;
	document.getElementById('pas_seguent').value = pag;
	//document.getElementById(nom_formulari).submit();
	activa_camps(nom_formulari);
	document.getElementById('alta_candidat').innerHTML = "<div id=\"carregant_publicacio\"><img src=\"../img/carregant.gif\" /><p>Validant Dades Personals...</p></div>";
}

function pas_anterior( pag )
{
	var nom_formulari = document.getElementById('pas').value;
	document.getElementById('pas_seguent').value = pag;
	//document.getElementById().submit();
	activa_camps(nom_formulari);
}

var con_carrega_recomenacions = new XHConn();
var fin_carrega_recomenacions = function (oXML) { document.getElementById('alta_candidat').innerHTML = oXML.responseText; }; 
function func_carrega_recomenacions( cadena )
{
//	document.getElementById('alta_candidat').innerHTML = "<img src=\"../img/carregant.gif\" /><p>Validant dades...</p>";
	con_carrega_recomenacions.connect('recomenacions.php', 'POST', cadena, fin_carrega_recomenacions);
}

var con_carrega_usuari_existent = new XHConn();
var fin_carrega_usuari_existent = function (oXML) { document.getElementById('alta_candidat').innerHTML = oXML.responseText; }; 
function func_carrega_usuari_existent ( cadena )
{
//	document.getElementById('alta_candidat').innerHTML = "<img src=\"../img/carregant.gif\" /><p>Validant dades...</p>";
	con_carrega_usuari_existent.connect('usuari_existeix.php', 'POST', cadena, fin_carrega_usuari_existent);
}

// PAS 1 DADES PERSONALS

//Carreguem el formulari de dades personals

var con_carrega_dades_personals = new XHConn();
var fin_carrega_dades_personals = function (oXML) { document.getElementById('alta_candidat').innerHTML = oXML.responseText; };
function func_carrega_dades_personals( cadena )
{	
//	document.getElementById('alta_candidat').innerHTML = "<div id=\"carregant_publicacio\"><img src=\"../img/carregant.gif\" /><p>Carregant formulari de formació...</p></div>";		
	document.getElementById('alta_candidat').innerHTML = "<div id=\"carregant_publicacio\"><img src=\"../img/carregant.gif\" /><p>Carregant formulari d'alta de candidat...</p></div>";
	con_carrega_dades_personals.connect('dades_personals.php', 'POST', cadena, fin_carrega_dades_personals);
}

function nomes_num( evt )
{
    var charCode = ( evt.which ) ? evt.which : evt.keyCode;
    if ( charCode > 31 && ( charCode < 48 || charCode > 57 ) )
	{
    	return false;
	} 
	else 
	{
    	return true;
	}
}

function limit_caracter_inscripcio(camp) {
	if(document.getElementById(camp).value.length > 350) {
	  document.getElementById(camp).value = document.getElementById(camp).value.substring(0,350);
	}
}

function nomes_alfanum( evt )
{
    var charCode = ( evt.which ) ? evt.which : evt.keyCode;
    if ( ( ( charCode >= 65 && charCode <= 90 ) || (charCode >= 97 && charCode <= 122) || (charCode >= 48 && charCode <= 57) ) || charCode == 8 ||  charCode == 127 || charCode == 241 || charCode == 231 || charCode == 199 || charCode == 209 )
	{
    	return true;
	} 
	else 
	{
    	return false;
	}
}

//FUNCIÓ PER CARREGAR CAMP NIF AUTORITZANT
var con_func_16_18a = new XHConn();
var fin_func_16_18a = function (oXML) { document.getElementById('cont_adver').innerHTML = oXML.responseText; };
function func_16_18a(dia,mes,any)
{
	if(dia != 0 && mes != 0 && any != 0)
	{		
	
	var data_actual = new Date();
	data_limit = data_actual.getMonth()+1+'\/'+data_actual.getDate()+'\/'+((data_actual.getFullYear())-18);
	//alert(data_limit);
		
	data_candidat=mes+'\/'+dia+'\/'+any;
	//alert(data_candidat);
	f1=new Date(data_candidat);
	f2=new Date(data_limit);
	if (f1>f2)
	{
		//alert("El candidat es menor d'edat");
		document.getElementById('cont_adver').innerHTML = "<div id=\"carregant_select\"><img src=\""+ruta+"img/carregant_select.gif\" /></div>";
	con_func_16_18a.connect(ruta+'dinamic/camp_nif_autoritza.php', 'POST', '', fin_func_16_18a);
	}
	else
	{
		//alert("El candidat es major d'edat");
		document.getElementById('cont_adver').innerHTML = "";
	
	}
	
	}
}

// Carrega localitats amb ajax en funció de la provincia triada
var con_carrega_poblacions = new XHConn();
var fin_carrega_poblacions = function (oXML) { document.getElementById('div_poblacio').innerHTML = oXML.responseText; };
function func_carrega_poblacions(idprovincia)
{
	document.getElementById('div_poblacio').innerHTML = "<div id=\"carregant_select\"><img src=\""+ruta+"/img/carregant_select.gif\" /><p>&nbsp;</p></div>";
	con_carrega_poblacions.connect('../dinamic/mostra_poblacions.php', 'POST', 'idprovincia=' + idprovincia, fin_carrega_poblacions);
}

//Només permet clickar treballo o atur, mai les dues
function func_check_situacio_actual(situacio)
{
	if( situacio == 'treballo' )
	{
		document.getElementById('atur').checked=0;
	}
	if( situacio == 'atur' )
	{	
		document.getElementById('treballo').checked=0;
	}
}


/********** PAS 2 FORMACIO ********************/

function mostra_any_finalitzacio(valor_finalitzat,nom_div)
{
	if( valor_finalitzat.checked == true )
	{
		document.getElementById(nom_div).innerHTML = "Any de finalitzaci&oacute;";
		document.getElementById(nom_div+"_input").className = "mostra_any";
	}
	else
	{
		document.getElementById(nom_div).innerHTML = "&nbsp;";
		document.getElementById(nom_div+"_input").className = "oculta_any";
	}
}

// Carrega formulari de formació
var con_carrega_formacio = new XHConn();
//Quan acaba de recarregar el formulari treiem el carregant que hem posat
var fin_carrega_formacio = function (oXML) { document.getElementById('alta_candidat').innerHTML = oXML.responseText; };
function func_carrega_formacio(cadena, num_estudis, num_estudis_no_reglats, num_idiomes, num_informatics)
{
//	document.getElementById('alta_candidat').innerHTML = "<div id=\"carregant_publicacio\"><img src=\"../img/carregant.gif\" /><p>Carregant formulari de formació...</p></div>";		
	con_carrega_formacio.connect('formacio.php', 'POST', cadena+'&num_estudis=' + num_estudis+'&num_estudis_no_reglats=' + num_estudis_no_reglats+'&num_idiomes=' + num_idiomes+'&num_informatics=' + num_informatics, fin_carrega_formacio);
}

function carregant_afegir()
{
	if( document.getElementById('carrega_mes_feines') )
		document.getElementById('carrega_mes_feines').innerHTML = "<div id=\"carregant_select_afegir\"><img src=\""+ruta+"/img/carregant_select.gif\" /><p>Carregant...</div>";	
	if( document.getElementById('carrega_mes_informatic') )
		document.getElementById('carrega_mes_informatic').innerHTML = "<div id=\"carregant_select_afegir\"><img src=\""+ruta+"/img/carregant_select.gif\" /><p>Carregant...</div>";		
	if( document.getElementById('carrega_mes_estudi') )
		document.getElementById('carrega_mes_estudi').innerHTML = "<div id=\"carregant_select_afegir\"><img src=\""+ruta+"/img/carregant_select.gif\" /><p>Carregant...</div>";		
	if( document.getElementById('carrega_mes_estudi_no_reglat') )
		document.getElementById('carrega_mes_estudi_no_reglat').innerHTML = "<div id=\"carregant_select_afegir\"><img src=\""+ruta+"/img/carregant_select.gif\" /><p>Carregant...</div>";		
	if( document.getElementById('carrega_mes_idioma') )
		document.getElementById('carrega_mes_idioma').innerHTML = "<div id=\"carregant_select_afegir\"><img src=\""+ruta+"/img/carregant_select.gif\" /><p>Carregant...</div>";
	if( document.getElementById('carrega_elimina_feina') )
		document.getElementById('carrega_elimina_feina').innerHTML = "<div id=\"carregant_select_afegir\"><img src=\""+ruta+"/img/carregant_select.gif\" /><p>Carregant...</div>";
	if( document.getElementById('carrega_elimina_estudi') )
		document.getElementById('carrega_elimina_estudi').innerHTML = "<div id=\"carregant_select_afegir\"><img src=\""+ruta+"/img/carregant_select.gif\" /><p>Carregant...</div>";		
	if( document.getElementById('carrega_elimina_estudi_no_reglat') )
		document.getElementById('carrega_elimina_estudi_no_reglat').innerHTML = "<div id=\"carregant_select_afegir\"><img src=\""+ruta+"/img/carregant_select.gif\" /><p>Carregant...</div>";
	if( document.getElementById('carrega_elimina_idioma') )
		document.getElementById('carrega_elimina_idioma').innerHTML = "<div id=\"carregant_select_afegir\"><img src=\""+ruta+"/img/carregant_select.gif\" /><p>Carregant...</div>";
	if( document.getElementById('carrega_elimina_informatic') )
		document.getElementById('carrega_elimina_informatic').innerHTML = "<div id=\"carregant_select_afegir\"><img src=\""+ruta+"/img/carregant_select.gif\" /><p>Carregant...</div>";
			
}

function carrega_nivells( idcamp, idioma, ididioma )
{
	if ( idioma == 1 )
	{
		idcamp_altre = idcamp;
		document.getElementById('nom_altre_idioma_'+idcamp).className = "oculta_any";
		document.getElementById('nom_altre_idioma_'+idcamp).innerHTML = "";	
		document.getElementById('div_idi_altre_'+idcamp).className = "oculta_any";
		document.getElementById('nivell_'+idcamp).className = "nivell_idioma";
		
		idcamp = 'idi_nivell_idioma_'+idcamp;
	}
	var con_carrega_nivells = new XHConn();
	var fin_carrega_nivells = function (oXML) { document.getElementById('div_'+idcamp).innerHTML = oXML.responseText; if ( ididioma == 12 && idioma == 1 ) { carrega_altres_idiomes(idcamp_altre) } };

	con_carrega_nivells.connect('carrega_nivells.php', 'POST', 'id_camp='+idcamp+"&idioma="+idioma, fin_carrega_nivells );
}

function carrega_altres_idiomes( idcamp )
{
	document.getElementById('nom_altre_idioma_'+idcamp).className = "mostra_any";
	document.getElementById('nom_altre_idioma_'+idcamp).innerHTML = "Indica l'idioma:";
	document.getElementById('div_idi_altre_'+idcamp).className = "mostra_any";
	document.getElementById('nivell_'+idcamp).className = "";	
}


// Carrega titulacions amb ajax en funció del nivell estudis triat
function func_carrega_titulacions( idnivell_estudis, num_titulacio )
{
	var con_carrega_titulacions = new XHConn();
	var fin_carrega_titulacions = function (oXML) { document.getElementById('div_titulacio_'+num_titulacio).innerHTML = oXML.responseText; desactiva_titulacions( idnivell_estudis, num_titulacio); };

	//document.getElementById('div_titulacio_1').innerHTML = "<div id=\"carregant_select\"><img src=\"../img/carregant_select.gif\" /></div>";
	con_carrega_titulacions.connect('../dinamic/mostra_titulacions.php', 'POST', 'idnivell_estudis=' + idnivell_estudis+'&num_titulacio=' + num_titulacio, fin_carrega_titulacions);
}

function desactiva_titulacions( idnivell_estudis, num_titulacio)
{
	if ( idnivell_estudis != "0" )
	{
		document.getElementById("est_especialitzacio_"+num_titulacio).disabled = false;
		document.getElementById("est_especialitzacio_"+num_titulacio).className = "";
		document.getElementById("est_especialitzacio_"+num_titulacio).value = "";
		document.getElementById("est_any_finalitzacio_"+num_titulacio).disabled = false;
		document.getElementById("est_any_finalitzacio_"+num_titulacio).className = "any_finalitzacio";//class que dona el width
		document.getElementById("est_nom_centre_"+num_titulacio).disabled = false;
		document.getElementById("est_nom_centre_"+num_titulacio).className = "";
	}
	if ( idnivell_estudis != "0" && document.getElementById("est_titulacio_"+num_titulacio).disabled==true )
	{
		document.getElementById("est_especialitzacio_"+num_titulacio).disabled = true;
		document.getElementById("est_especialitzacio_"+num_titulacio).value = "";
		document.getElementById("est_especialitzacio_"+num_titulacio).className = "desactivat_input";
	}
	if ( idnivell_estudis == "20" )
	{
		document.getElementById("est_especialitzacio_"+num_titulacio).disabled = false;
		document.getElementById("est_especialitzacio_"+num_titulacio).className = "";
		document.getElementById("est_especialitzacio_"+num_titulacio).value = "";
	}
}

// Carrega camp nom programa al triar Altres com a programa
function carrega_nom_programa(valor,registre)
{
	if(valor == 0)
	{
		var con_carrega_nom_programa = new XHConn();
		var fin_carrega_nom_programa = function (oXML) { 
		document.getElementById('div_titol_programa_'+registre).innerHTML = "<p>Nom del Programa</p><p>Nivell</p>";	document.getElementById('div_nom_programa_'+registre).innerHTML = oXML.responseText; };
		document.getElementById('div_nom_programa_'+registre).className = "class_titulacio";
		con_carrega_nom_programa.connect('../dinamic/mostra_nom_programa.php', 'POST', 'registre=' + registre, fin_carrega_nom_programa);
	}
	else
	{
		document.getElementById('div_titol_programa_'+registre).innerHTML = "<p >Nivell</p><p>&nbsp;</p>";	
		document.getElementById('div_nom_programa_'+registre).innerHTML = "";
		document.getElementById('div_nom_programa_'+registre).className = "class_titulacio_oculta";
	}
}



//---ESTUDIS----------------
function afegeix_estudi(  cant_estudis, cant_estudis_no_reglat, cant_idiomes, cant_informatics )
{
	carregant_afegir();
	document.getElementById('esborra_estudi').value=-1;
	document.getElementById('num_estudis').value=cant_estudis+1;
	document.getElementById('num_estudis_no_reglats').value=cant_estudis_no_reglat;
	document.getElementById('num_idiomes').value=cant_idiomes;
	document.getElementById('num_informatics').value=cant_informatics;

	activa_camps( "formacio" );
}

function esborra_estudi( id, cant_estudis, cant_estudis_no_reglat, cant_idiomes, cant_informatics )
{
	carregant_afegir();
	document.getElementById('esborra_estudi').value=id;
	document.getElementById('num_estudis').value=cant_estudis-1;
	document.getElementById('num_estudis_no_reglats').value=cant_estudis_no_reglat;
	document.getElementById('num_idiomes').value=cant_idiomes;
	document.getElementById('num_informatics').value=cant_informatics;
	
	activa_camps( "formacio" );
}

//---ESTUDIS NO REGLATS----------------
function afegeix_estudi_no_reglat(  cant_estudis, cant_estudis_no_reglat, cant_idiomes, cant_informatics )
{
	carregant_afegir();
	document.getElementById('esborra_estudi_no_reglat').value=-1;
	document.getElementById('num_estudis_no_reglats').value=cant_estudis_no_reglat+1;
	document.getElementById('num_estudis').value=cant_estudis;
	document.getElementById('num_idiomes').value=cant_idiomes;
	document.getElementById('num_informatics').value=cant_informatics;

	activa_camps( "formacio" );
}

function esborra_estudi_no_reglat( id, cant_estudis, cant_estudis_no_reglat, cant_idiomes, cant_informatics )
{	
	carregant_afegir();
	document.getElementById('esborra_estudi_no_reglat').value=id;
	document.getElementById('num_estudis_no_reglats').value=cant_estudis_no_reglat-1;
	document.getElementById('num_estudis').value=cant_estudis;
	document.getElementById('num_idiomes').value=cant_idiomes;
	document.getElementById('num_informatics').value=cant_informatics;	
	
	activa_camps( "formacio" );
}

function activa_camps ( formulari )
{
	var num_elements = document.getElementById(formulari).length;
	for( var i=0; i<num_elements; i++ )
	{
		document.getElementById(formulari).elements[i].disabled = false;
	}
	document.getElementById(formulari).submit();
}

//---IDIOMES----------------
function afegeix_idioma( cant_estudis, cant_estudis_no_reglat, cant_idiomes, cant_informatics )
{
	carregant_afegir();
	document.getElementById('esborra_idioma').value=-1;
	document.getElementById('num_estudis').value=cant_estudis;
	document.getElementById('num_estudis_no_reglats').value=cant_estudis_no_reglat;
	document.getElementById('num_idiomes').value=cant_idiomes+1;
	document.getElementById('num_informatics').value=cant_informatics;
	activa_camps( "formacio" );
}

function esborra_idioma( id, cant_estudis, cant_estudis_no_reglat, cant_idiomes, cant_informatics )
{
	carregant_afegir();	
	document.getElementById('esborra_idioma').value=id;
	document.getElementById('num_estudis').value=cant_estudis;
	document.getElementById('num_estudis_no_reglats').value=cant_estudis_no_reglat;
	document.getElementById('num_idiomes').value=cant_idiomes-1;
	document.getElementById('num_informatics').value=cant_informatics;
	activa_camps( "formacio" );
}

//---INFORMATICS----------------

function afegeix_informatic( cant_estudis, cant_estudis_no_reglat, cant_idiomes, cant_informatics )
{
	carregant_afegir();
	document.getElementById('esborra_informatic').value=-1;
	document.getElementById('num_estudis').value=cant_estudis;
	document.getElementById('num_estudis_no_reglats').value=cant_estudis_no_reglat;
	document.getElementById('num_idiomes').value=cant_idiomes;
	document.getElementById('num_informatics').value=cant_informatics+1;
	activa_camps( "formacio" );
}

function esborra_informatic( id, cant_estudis, cant_estudis_no_reglat, cant_idiomes, cant_informatics )
{
	carregant_afegir();
	document.getElementById('esborra_informatic').value=id;
	document.getElementById('num_estudis').value=cant_estudis;
	document.getElementById('num_estudis_no_reglats').value=cant_estudis_no_reglat;
	document.getElementById('num_idiomes').value=cant_idiomes;
	document.getElementById('num_informatics').value=cant_informatics-1;
	activa_camps( "formacio" );
}




/********* PAS 3 EXPERIENCIA ******************/

// Carreguem el formulari principal de l'experiencia laboral quan esta en atur
var con_carrega_experiencia = new XHConn();
var fin_carrega_experiencia = function (oXML) { document.getElementById('alta_candidat').innerHTML = oXML.responseText; }; 
function func_carrega_experiencia( cadena )
{	
	global_cadena = cadena;
//	document.getElementById('alta_candidat').innerHTML = "<div id=\"carregant_publicacio\"><img src=\"../img/carregant.gif\" /><p>Carregant formulari d'experičncia laboral...</p></div>";
	con_carrega_experiencia.connect('experiencia_laboral.php', 'POST', cadena, fin_carrega_experiencia);
}

function ampliar_informacio( valor, camp )
{
	if ( valor == true )
	{
		document.getElementById("mes_informacio_"+camp).className = "mes_informacio";
	}
	else	
	{
		document.getElementById("mes_informacio_"+camp).className = "oculta_mes_informacio";
	}
}

// Carreguem el formulari principal de l'experiencia laboral quan esta treballant 
var con_carrega_experiencia_actual = new XHConn();
var fin_carrega_experiencia_actual = function (oXML) { document.getElementById('alta_candidat').innerHTML = oXML.responseText; }; 
function func_carrega_experiencia_actual( cadena )
{	
//	document.getElementById('alta_candidat').innerHTML = "<div id=\"carregant_publicacio\"><img src=\"../img/carregant.gif\" /><p>Carregant formulari d'experičncia laboral...</p></div>";
	con_carrega_experiencia_actual.connect('experiencia_laboral_actual.php', 'POST', cadena, fin_carrega_experiencia_actual);
}

// Mostrem formulari d'experiencia laboral 
//Per defecte carreguem un d'experiencia anterior
var con_carrega_experiencia_laboral = new XHConn();
var fin_carrega_experiencia_laboral = function (oXML) { document.getElementById('experiencia').innerHTML = oXML.responseText; };
function func_carrega_experiencia_laboral( cadena, num )
{
	document.getElementById('esborra').value = -1;
//	document.getElementById('experiencia').innerHTML = "<div id=\"carregant_publicacio\"><img src=\"../img/carregant.gif\" /><p>Carregant formulari d'experičncia laboral...</p></div>";
	con_carrega_experiencia_laboral.connect('mostra_experiencia_laboral.php', 'POST', 'cantitat_experiencia='+num+'&'+cadena, fin_carrega_experiencia_laboral);
}

function mostra_experiencia( )
{
	var cadena = 'xml_candidat='+document.getElementById('xml_candidat').value;
	if ( document.getElementById('experiencia_profesional_anterior').checked )
	{
		func_carrega_experiencia_laboral( cadena , 0 );
	}
	else
	{
		func_oculta_experiencia_laboral( );
	}
}

function func_oculta_experiencia_laboral( )
{
	document.getElementById('experiencia').innerHTML = "";
}

function afegeix_feina( cant )
{
	carregant_afegir();
	document.getElementById('esborra').value = -1;
	document.getElementById('cantitat_experiencia').value = cant+1;
	document.getElementById('experiencia_profesional').submit();
}

function esborra_feina( id, cant )
{
	carregant_afegir();
	document.getElementById('esborra').value=id;
	document.getElementById('cantitat_experiencia').value=cant-1;
	
	document.getElementById('experiencia_profesional').submit();
}



/*********** PAS 4 ALTRES DADES ***************************/

// Carreguem el formulari principal de l'experiencia laboral 
var con_carrega_altres_dades = new XHConn();
var fin_carrega_altres_dades = function (oXML) { document.getElementById('alta_candidat').innerHTML = oXML.responseText; }; 
function func_carrega_altres_dades( cadena )
{	
	document.getElementById('alta_candidat').innerHTML = "<div id=\"carregant_publicacio\"><img src=\"../img/carregant.gif\" /><p>Carregant formulari d'altres dades...</p></div>";
	con_carrega_altres_dades.connect('altres_dades.php', 'POST', cadena, fin_carrega_altres_dades);
}


/*********** PAS 5 FOTOS Y CV ***************************/

// Carreguem el formulari principal de l'experiencia laboral 
var con_carrega_foto_video = new XHConn();
var fin_carrega_foto_video = function (oXML) { document.getElementById('alta_candidat').innerHTML = oXML.responseText; }; 
function func_carrega_foto_video( cadena, num )
{	
	global_cadena = cadena;
	document.getElementById('alta_candidat').innerHTML = "<div id=\"carregant_publicacio\"><img src=\"../img/carregant.gif\" /><p>Carregant formulari de la foto i CV...</p></div>";
	con_carrega_foto_video.connect('foto_video.php', 'POST', 'cantitat_curriculum='+num+'&'+cadena, fin_carrega_foto_video);
}

function inserir_fotografia()
{
	document.getElementById('alta_candidat').innerHTML = "<div id=\"carregant_publicacio\"><img src=\"../img/carregant.gif\" /><p>Enviant fotografía...</p></div>";
	document.getElementById('foto_cv').action = "inserir_arxiu.php";
	document.getElementById('foto_cv').submit();
}

function afegeix_curriculum( cant , ultim_input )
{
/*	var ultim_id = ultim_input-1;
	//Comprovem el camp hidden que conté el text nom de l'archiu del cv
	if( document.getElementById('cv_text_candidat_'+ultim_id).value != "" || ultim_id == 0 )	
	{
*/		
	carregant_afegir();
	document.getElementById('esborra').value = -1;
	document.getElementById('cantitat_curriculum').value = cant+1;
	document.getElementById('foto_cv').submit();
	
}

function esborra_curriculum( id, cant )
{
	document.getElementById('esborra').value=id;
	document.getElementById('cantitat_curriculum').value=cant-1;
	
	document.getElementById('foto_cv').submit();
}

function esborra_imatge( cant )
{
	if ( confirm( "Segur que vols esborrar la imatge?" ) )
	{
		document.getElementById('esborra_imatge').value=1;
		document.getElementById('esborra').value = -1;
		document.getElementById('esborra_video').value=0;
		document.getElementById('cantitat_curriculum').value=cant;
		
		document.getElementById('foto_cv').submit();
	}
}
function esborra_video( cant )
{
	if ( confirm( "Segur que vols esborrar el vídeo?" ) )
	{
		document.getElementById('esborra').value = -1;
		document.getElementById('esborra_video').value=1;
		document.getElementById('esborra_imatge').value=0;
		document.getElementById('cantitat_curriculum').value=cant;
		
		document.getElementById('foto_cv').submit();
	}
}

/************** PAS 6 FINALITZAR ALTA ********************/

var con_finalitza_alta = new XHConn();
var fin_finalitza_alta = function (oXML) { document.getElementById('alta_candidat').innerHTML = oXML.responseText; }; 
function func_finalitza_alta( cadena )
{	
	document.getElementById('alta_candidat').innerHTML = "<div id=\"carregant_publicacio\"><img src=\"../img/carregant.gif\" /><p>Enviant dades...</p></div>";
	con_finalitza_alta.connect('finalitzar.php', 'POST', cadena, fin_finalitza_alta);
}

function valida_finalitzar( pas )
{
	
	if ( document.getElementById('acepto').checked == true )
	{
		//Ocultem el botó amb id boto_finalitza_empresa que es el finalitzar
		document.getElementById('boto_finalitza_candidat').style.visibility = 'hidden';
		pas_seguent( pas );
	}
	else
	{	
		alert ( "Sisplau, has d'acceptar la política de privadesa");
	}
}

// Funció que mostra la finestra emergent per missatges informatius
var con_mostra_privadesa = new XHConn();
var fin_mostra_privadesa = function (oXML) { document.getElementById('finestra').innerHTML = oXML.responseText; };
function mostra_privadesa(titol)
{
	var carregant = "<div id=\"breu_descripcio\"><img src=\""+ruta+"/img/sup_toltip_llistat.gif\"  />";
	carregant += "<p id=\"descripcio_titol\">&nbsp;</p><p id=\"text\"><img src=\""+ruta+"/img/carregant_select.gif\" /></p><img src=\""+ruta+"/img/inf_toltip_llistat.gif\"  /></div>";
	document.getElementById('finestra').innerHTML = carregant;
	con_mostra_privadesa.connect(ruta+'candidats/finestra_missatges.php', 'POST', 'titol=' + titol , fin_mostra_privadesa);
}