function ponAccion(key)

{		

	document.forms["formCuestionarioVAPM"].accion.value=key;

	document.forms["formCuestionarioVAPM"].submit();

}



function onLoadPage(){

	var today = new Date();

	var anyoActual = Number(today.getFullYear());

	var antig60= String(anyoActual-61);

	var antig3059=String(anyoActual-60) + " a " + String(anyoActual-31); 

	var antig1029=String(anyoActual-30) + " a " + String(anyoActual-11);

	var antig9=String(anyoActual-9);



	//Pregunta 1

	document.all["textPrevAnyoActual"].innerHTML=(document.all["textPrevAnyoActual"].innerHTML).replace("%v",anyoActual);

	document.all["textPrevAnyoActual2"].innerHTML=(document.all["textPrevAnyoActual2"].innerHTML).replace("%v",anyoActual);

	//Pregunta 2

	document.all["textPrevAnyosSig"].innerHTML=(document.all["textPrevAnyosSig"].innerHTML).replace("%i",anyoActual+1);

	document.all["textPrevAnyosSig"].innerHTML=(document.all["textPrevAnyosSig"].innerHTML).replace("%f",anyoActual+4);

	document.all["textPrevAnyosSig2"].innerHTML=(document.all["textPrevAnyosSig2"].innerHTML).replace("%i",anyoActual+1);

	document.all["textPrevAnyosSig2"].innerHTML=(document.all["textPrevAnyosSig2"].innerHTML).replace("%f",anyoActual+4);

	//Pregunta 3

	document.all["textAlqAnyoPasado"].innerHTML=(document.all["textAlqAnyoPasado"].innerHTML).replace("%v","31/12/"+(anyoActual-1));

	//Pregunta 5

	document.all["textSituacion"].innerHTML=(document.all["textSituacion"].innerHTML).replace("%v","31/12/"+(anyoActual-1));

	//Pregunta 7

	document.all["textAntig60"].innerHTML=(document.all["textAntig60"].innerHTML).replace("%v",antig60);

	document.all["textAntig3059"].innerHTML=(document.all["textAntig3059"].innerHTML).replace("%v",antig3059);

	document.all["textAntig1029"].innerHTML=(document.all["textAntig1029"].innerHTML).replace("%v",antig1029);

	document.all["textAntig9"].innerHTML=(document.all["textAntig9"].innerHTML).replace("%v",antig9);

	

	if (document.forms["formCuestionarioVAPM"].elements["accion"].value = "KEY_GUARDAR")

	{

		if (document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(prv1a)"][1].checked)

		{

			mostrarSubapartado("sub1");

		}

		if (document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(prv4a)"][1].checked)

		{

			mostrarSubapartado("sub2");

		}

		if (document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(talq)"][1].checked)

		{

			mostrarSubapartado("sub3");

		}

		if (document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(adqvi1)"][1].checked && document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(adqvi1)"][1].disabled == false)

		{

			habilitarCampo('numAdquirirAnyoAct');

		}

		if (document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(provi1)"][1].checked && document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(provi1)"][1].disabled == false)

		{

			habilitarCampo('numPromoverAnyoAct');

		}

		if (document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(otrvi1)"][1].checked && document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(otrvi1)"][1].disabled == false)

		{

			habilitarCampo('numDestinarAnyoAct');

		}

		if (document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(adqvi4)"][1].checked && document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(adqvi4)"][1].disabled == false)

		{

			habilitarCampo('numAdquirirAnyosSig');

		}

		if (document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(provi4)"][1].checked && document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(provi4)"][1].disabled == false)

		{

			habilitarCampo('numPromoverAnyosSig');

		}

		if (document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(otrvi4)"][1].checked && document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(otrvi4)"][1].disabled == false)

		{

			habilitarCampo('numDestinarAnyosSig');

		}

		if (document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(talq)"][1].checked && document.forms["formCuestionarioVAPM"].elements["cuestionarioVAPM(talq)"][1].disabled == false)

		{

			habilitarCampo('numAlqAnyoPasado');

		}

		

	}

}



/**************************************************/

//Ponerlo para todos los navegadores

/**************************************************/



function mostrarSubapartado(idSubapartado){

	document.all[idSubapartado].style.display="block";

}



function ocultarSubapartado(idSubapartado){

	

	/*********************************************/

	//SI NO, Al grabar, mirar si est? chequeado el NO, y limpiar entonces

	/*********************************************/



	switch(idSubapartado){

		case "sub1":

			limpiarDatosSubapartado1();

		break;

		case "sub2":

			limpiarDatosSubapartado2();

		break;

		case "sub3":

			limpiarDatosSubapartado3();

		break;

		default: break;

	}

	

	/**************************************************/

	//Antes de ocultar limpiar los campos de la capa

	/**************************************************/

	document.all[idSubapartado].style.display="none";

}



function habilitarCampo(idCampo){

	document.forms["formCuestionarioVAPM"].elements[idCampo].disabled=false;

	document.forms["formCuestionarioVAPM"].elements[idCampo].readOnly=false;



}



function deshabilitarCampoForm(idCampo){

		limpiarDatosCampo(idCampo);

		deshabilitarCampo(idCampo);

}



function deshabilitarCampo(idCampo){

	document.forms["formCuestionarioVAPM"].elements[idCampo].disabled=true;

	document.forms["formCuestionarioVAPM"].elements[idCampo].readOnly=true;

}





function limpiarDatosCampo(idCampo){

	document.forms["formCuestionarioVAPM"].elements[idCampo].value="";

}





function limpiarDatosSubapartado1(){

	document.forms["formCuestionarioVAPM"].elements["siNoAdquirirAnyoAct"][0].checked=false;

	document.forms["formCuestionarioVAPM"].elements["siNoAdquirirAnyoAct"][1].checked=false;	

	document.forms["formCuestionarioVAPM"].elements["numAdquirirAnyoAct"].value="";



	document.forms["formCuestionarioVAPM"].elements["siNoPromoverAnyoAct"][0].checked=false;

	document.forms["formCuestionarioVAPM"].elements["siNoPromoverAnyoAct"][1].checked=false;	

	document.forms["formCuestionarioVAPM"].elements["numPromoverAnyoAct"].value="";



	document.forms["formCuestionarioVAPM"].elements["siNoDestinarAnyoAct"][0].checked=false;

	document.forms["formCuestionarioVAPM"].elements["siNoDestinarAnyoAct"][1].checked=false;	

	document.forms["formCuestionarioVAPM"].elements["numDestinarAnyoAct"].value="";



	document.forms["formCuestionarioVAPM"].elements["especAnyoAct"].value="";

	document.forms["formCuestionarioVAPM"].elements["numTotalPrevAnyoActual"].value="";

}



function limpiarDatosSubapartado2(){

	document.forms["formCuestionarioVAPM"].elements["siNoAdquirirAnyosSig"][0].checked=false;

	document.forms["formCuestionarioVAPM"].elements["siNoAdquirirAnyosSig"][1].checked=false;	

	document.forms["formCuestionarioVAPM"].elements["numAdquirirAnyosSig"].value="";



	document.forms["formCuestionarioVAPM"].elements["siNoPromoverAnyosSig"][0].checked=false;

	document.forms["formCuestionarioVAPM"].elements["siNoPromoverAnyosSig"][1].checked=false;	

	document.forms["formCuestionarioVAPM"].elements["numPromoverAnyosSig"].value="";



	document.forms["formCuestionarioVAPM"].elements["siNoDestinarAnyosSig"][0].checked=false;

	document.forms["formCuestionarioVAPM"].elements["siNoDestinarAnyosSig"][1].checked=false;	

	document.forms["formCuestionarioVAPM"].elements["numDestinarAnyosSig"].value="";



	document.forms["formCuestionarioVAPM"].elements["especAnyosSig"].value="";

	document.forms["formCuestionarioVAPM"].elements["numTotalPrevAnyosSig"].value="";

}



function limpiarDatosSubapartado3(){

	//Pregunta 4

	document.forms["formCuestionarioVAPM"].elements["numSupUtil45"].value="";

	document.forms["formCuestionarioVAPM"].elements["mediaSupUtil45"].value="";

	document.forms["formCuestionarioVAPM"].elements["numSupUtil4575"].value="";

	document.forms["formCuestionarioVAPM"].elements["mediaSupUtil4575"].value="";

	document.forms["formCuestionarioVAPM"].elements["numSupUtil7690"].value="";

	document.forms["formCuestionarioVAPM"].elements["mediaSupUtil7690"].value="";

	document.forms["formCuestionarioVAPM"].elements["numSupUtil90"].value="";

	document.forms["formCuestionarioVAPM"].elements["mediaSupUtil90"].value="";

	document.forms["formCuestionarioVAPM"].elements["numSupUtilTotal"].value="";

	document.forms["formCuestionarioVAPM"].elements["mediaSupUtilTotal"].value="";

	//Pregunta 5

	document.forms["formCuestionarioVAPM"].elements["numOcupadas"].value="";

	document.forms["formCuestionarioVAPM"].elements["numDesocupadas"].value="";

	document.forms["formCuestionarioVAPM"].elements["numObras"].value="";

	document.forms["formCuestionarioVAPM"].elements["numInaccesibles"].value="";

	document.forms["formCuestionarioVAPM"].elements["especSituacion"].value="";

	document.forms["formCuestionarioVAPM"].elements["numTotalSituacion"].value="";

	//Pregunta 6

	document.forms["formCuestionarioVAPM"].elements["numLibre"].value="";

	document.forms["formCuestionarioVAPM"].elements["numVPO"].value="";

	document.forms["formCuestionarioVAPM"].elements["numVS"].value="";

	document.forms["formCuestionarioVAPM"].elements["numVPOT"].value="";

	document.forms["formCuestionarioVAPM"].elements["numDotacional"].value="";

	document.forms["formCuestionarioVAPM"].elements["numRealojo"].value="";

	document.forms["formCuestionarioVAPM"].elements["numVTMG"].value="";

	document.forms["formCuestionarioVAPM"].elements["numVTME"].value="";

	document.forms["formCuestionarioVAPM"].elements["numTotalRegimen"].value="";

	//Pregunta 7

	document.forms["formCuestionarioVAPM"].elements["numAntig60"].value="";

	document.forms["formCuestionarioVAPM"].elements["numAntig3059"].value="";

	document.forms["formCuestionarioVAPM"].elements["numAntig1029"].value="";

	document.forms["formCuestionarioVAPM"].elements["numAntig9"].value="";

	document.forms["formCuestionarioVAPM"].elements["numTotalAntig"].value="";

	//Pregunta 8

	document.forms["formCuestionarioVAPM"].elements["observaciones"].value="";

}





function calcularTotalPrevAnyoActual(){

	var sum1 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numAdquirirAnyoAct"].value != "" ){sum1 = Number(document.forms["formCuestionarioVAPM"].elements["numAdquirirAnyoAct"].value);}

	var sum2 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numPromoverAnyoAct"].value != "" ){sum2 = Number(document.forms["formCuestionarioVAPM"].elements["numPromoverAnyoAct"].value);}

	var sum3 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numDestinarAnyoAct"].value != "" ){sum3 = Number(document.forms["formCuestionarioVAPM"].elements["numDestinarAnyoAct"].value);}

	var total = sum1 + sum2 + sum3;

	document.forms["formCuestionarioVAPM"].elements["numTotalPrevAnyoActual"].value = total;

}



function calcularTotalPrevAnyosSig(){

	var sum1 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numAdquirirAnyosSig"].value != "" ){sum1 = Number(document.forms["formCuestionarioVAPM"].elements["numAdquirirAnyosSig"].value);}

	var sum2 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numPromoverAnyosSig"].value != "" ){sum2 = Number(document.forms["formCuestionarioVAPM"].elements["numPromoverAnyosSig"].value);}

	var sum3 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numDestinarAnyosSig"].value != "" ){sum3 = Number(document.forms["formCuestionarioVAPM"].elements["numDestinarAnyosSig"].value);}

	var total = sum1 + sum2 + sum3;

	document.forms["formCuestionarioVAPM"].elements["numTotalPrevAnyosSig"].value = total;

}





function calcularTotalNumSuperficie(){

	var sum1 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numSupUtil45"].value != "" ){sum1 = Number(document.forms["formCuestionarioVAPM"].elements["numSupUtil45"].value);}

	var sum2 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numSupUtil4575"].value != "" ){sum2 = Number(document.forms["formCuestionarioVAPM"].elements["numSupUtil4575"].value);}

	var sum3 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numSupUtil7690"].value != "" ){sum3 = Number(document.forms["formCuestionarioVAPM"].elements["numSupUtil7690"].value);}

	var sum4 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numSupUtil90"].value != "" ){sum4 = Number(document.forms["formCuestionarioVAPM"].elements["numSupUtil90"].value);}

	var total = sum1 + sum2 + sum3 + sum4;

	document.forms["formCuestionarioVAPM"].elements["numSupUtilTotal"].value = total;

}



function calcularTotalMediaSuperficie(){

	var sum1 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["mediaSupUtil45"].value != "" ){sum1 = Number(document.forms["formCuestionarioVAPM"].elements["mediaSupUtil45"].value);}

	var sum2 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["mediaSupUtil4575"].value != "" ){sum2 = Number(document.forms["formCuestionarioVAPM"].elements["mediaSupUtil4575"].value);}

	var sum3 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["mediaSupUtil7690"].value != "" ){sum3 = Number(document.forms["formCuestionarioVAPM"].elements["mediaSupUtil7690"].value);}

	var sum4 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["mediaSupUtil90"].value != "" ){sum4 = Number(document.forms["formCuestionarioVAPM"].elements["mediaSupUtil90"].value);}

	var total = sum1 + sum2 + sum3 + sum4;

	document.forms["formCuestionarioVAPM"].elements["mediaSupUtilTotal"].value = total;

}



function calcularTotalSituacion(){

	var sum1 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numOcupadas"].value != "" ){sum1 = Number(document.forms["formCuestionarioVAPM"].elements["numOcupadas"].value);}

	var sum2 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numDesocupadas"].value != "" ){sum2 = Number(document.forms["formCuestionarioVAPM"].elements["numDesocupadas"].value);}

	var sum3 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numObras"].value != "" ){sum3 = Number(document.forms["formCuestionarioVAPM"].elements["numObras"].value);}

	var sum4 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numInaccesibles"].value != "" ){sum4 = Number(document.forms["formCuestionarioVAPM"].elements["numInaccesibles"].value);}

	var total = sum1 + sum2 + sum3 + sum4;

	document.forms["formCuestionarioVAPM"].elements["numTotalSituacion"].value = total;

}



function calcularTotaLRegimen(){

	var sum1 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numLibre"].value != "" ){sum1 = Number(document.forms["formCuestionarioVAPM"].elements["numLibre"].value);}

	var sum2 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numVPO"].value != "" ){sum2 = Number(document.forms["formCuestionarioVAPM"].elements["numVPO"].value);}

	var sum3 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numVS"].value != "" ){sum3 = Number(document.forms["formCuestionarioVAPM"].elements["numVS"].value);}

	var sum4 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numVPOT"].value != "" ){sum4 = Number(document.forms["formCuestionarioVAPM"].elements["numVPOT"].value);}

	var sum5 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numDotacional"].value != "" ){sum5 = Number(document.forms["formCuestionarioVAPM"].elements["numDotacional"].value);}

	var sum6 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numRealojo"].value != "" ){sum6 = Number(document.forms["formCuestionarioVAPM"].elements["numRealojo"].value);}

	var sum7 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numVTMG"].value != "" ){sum7 = Number(document.forms["formCuestionarioVAPM"].elements["numVTMG"].value);}

	var sum8 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numVTME"].value != "" ){sum8 = Number(document.forms["formCuestionarioVAPM"].elements["numVTME"].value);}

	var total = sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7 + sum8;

	document.forms["formCuestionarioVAPM"].elements["numTotalRegimen"].value = total;



}



function calcularTotalAntiguedad(){

	var sum1 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numAntig60"].value != "" ){sum1 = Number(document.forms["formCuestionarioVAPM"].elements["numAntig60"].value);}

	var sum2 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numAntig3059"].value != "" ){sum2 = Number(document.forms["formCuestionarioVAPM"].elements["numAntig3059"].value);}

	var sum3 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numAntig1029"].value != "" ){sum3 = Number(document.forms["formCuestionarioVAPM"].elements["numAntig1029"].value);}

	var sum4 = 0;

	if( document.forms["formCuestionarioVAPM"].elements["numAntig9"].value != "" ){sum4 = Number(document.forms["formCuestionarioVAPM"].elements["numAntig9"].value);}

	var total = sum1 + sum2 + sum3 + sum4;

	document.forms["formCuestionarioVAPM"].elements["numTotalAntig"].value = total;

}