var msn_errores;
var msn_obligatorio;
var msn_y;
var msn_num;
var msn_email;
var msm_checkbox;
var smsmenosuno;
var msm_cantidad;
var msn_boton;

	
function cargaridioma(idioma){
if (idioma=='E'){
		msn_errores="Hurrengo erroreak aurkitu dira:" ;
		msn_obligatorio=" beharrezkoa da" ;		
		msn_y=" eta " ;
		msn_num=" zenbakia izan behar da";
		msn_email=" baliodun bat izan behar da";
		msm_cantidad = "zenbakien kopurua ez da zuzena";
		msm_checkbox = " zure entitatean erabakitako hutsunea hartu egin duzu, hau sartu egingo dugu entitatean";
		smsmenosuno = "gitxinienez bat aukeratu behar duzu";
	}
	else{
		msn_errores="Se han detectado los siguientes errores:";
		msn_obligatorio=" es necesario";
		msn_y=" y ";
		msn_num=" debe ser número";
		msn_email=" debe contener una dirección de e-mail válida";
		msm_cantidad = " no tiene tantos números/letras como debe";
		smsmenosuno ="Tiene que seleccionar al menos una opción."		
		msn_boton="Pulsación de botón no permitida";
	}
} 

//Elegir idioma de entrada
function validaridioma(formulario,idioma)
{
	document.forms[formulario].idioma.value=idioma;
	document.forms[formulario].submit();
}


function cambio(capa,valor,opcion){
	valores = opcion.split("/");	
	
	document.getElementById(capa).style.visibility="hidden";
	document.getElementById(capa).style.height="0";
	
	for (x=0;x<valores.length;x++){		
		if (valor==valores[x]) {
			 document.getElementById(capa).style.visibility="visible"; 
			 document.getElementById(capa).style.height="auto";
		}	
     }
	 
}
	 
function  CambAmbito(capa,valor,campos){
	var valores, x;
	
	valores = campos.split(",");

	for (x=0;x<valores.length;x++){
		 if (valores[x]==valor) {
			 
			document.getElementById(capa+valores[x]).style.visibility="visible"; 
   		 	document.getElementById(capa+valores[x]).style.height="auto";
         	}	
		else{
        	 document.getElementById(capa+valores[x]).style.visibility="hidden";
   			 document.getElementById(capa+valores[x]).style.height="0";
        	 }
	}
}

function imprimir(capa)
	{
	var ficha = document.getElementById(capa);	
	var ventimp = window.open('../impresion.asp', 'impresion','left=2px,top:2px,width=900px,height=900px');

	ventimp.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n');
	ventimp.document.write('<html xmlns="http://www.w3.org/1999/xhtml">\n');
	ventimp.document.write('<head>\n');
	ventimp.document.write('<title> Inprimitu - Imprimir</title>\n');
	ventimp.document.write('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\n');
    ventimp.document.write('<link rel="stylesheet" type="text/css" media="print" href="../estilos/encuestaImp.css">\n');
    ventimp.document.write('<link rel="stylesheet" type="text/css" media="screen" href="../estilos/encuestaImp.css">\n');
	ventimp.document.write('</head>\n');
	ventimp.document.write('<body>\n');
	ventimp.document.write('<div id=\"impreso\">\n');
	ventimp.document.write( ficha.innerHTML );	
	ventimp.document.write('</div>\n');
	ventimp.document.write('</body>\n');
	ventimp.document.write('</html>\n');
	
	//ventimp.opener.focus();
	ventimp.focus(); 
	ventimp.document.close();
	ventimp.print( );	
	ventimp.close();	
	} 
	
function numerico(aki){
	var campo = document.getElementById(aki).value;	
	campo = document.getElementById(aki).value;		
	var tam = campo.length;	
	if (tam>0) {
		var letra = campo.substring(tam-1,tam);	
		if ( isNaN(parseInt(letra)) && (letra.replace(" ","")!="," && letra.replace(" ","")!=".") )	{

			if (tam>0)	{document.getElementById(aki).value = campo.substring(0,tam-1);}
			else{document.getElementById(aki).value = "";}
		}	
	}		
}



function TotalMas(valor, dondes){
	var valores, x;
	
	valores = dondes.split("/");
	for (x=0;x<valores.length;x++){
		document.getElementById(valores[x]).value=valor;
		}
}


function SumaTotales(total,sum1,sum2)
{
	//pregunta 14
	var s1;
	var s2;
	var tot;

	s1=document.getElementById(sum1).value;
	s2=document.getElementById(sum2).value;

	if(s1==''){s1=0;}
	if(s2==''){s2=0;}
	tot=eval(s1) + eval(s2);
	document.getElementById(total).value=tot;
}

function ControlTotSexo(total,sum1,sum2,sms)
{
	//pregunta 14
	var s1;
	var s2;
	var tot;

	s1=document.getElementById(sum1).value;
	s2=document.getElementById(sum2).value;
	
	
	if(s1==''){s1=0;}
	if(s2==''){s2=0;}
	if((s1!=0) || (s2!=0))
	{
		alert(sms);
		document.getElementById(total).value='';
	}
	
}

function tamanyo(cual, tam){
	var tamcampo = document.getElementById(cual).value;
	
	if (tamcampo!=""){
		if (eval(tamcampo.length) !=tam){ 
			alert(msm_cantidad +": "+tam  );
				document.getElementById(cual).focus();
				document.getElementById(cual).select();
			}
 		}
}

function noPasar(cual, tam){
	var tamcampo = document.getElementById(cual).value;
	
	if (tamcampo!=""){
		if (eval(tamcampo.length) !=tam){ 
			alert(msm_cantidad +": "+tam  );
			document.getElementById(cual).focus();
			document.getElementById(cual).select();
			}
		else{document.getElementById("frprime").submit();
		}
 	}
}

function Fecha(cual){
	mes = document.getElementById("mes"+cual).value;
	dia = document.getElementById("dia"+cual).value;
	
	//alert("dia: " +dia + "  mes: " +mes);
	
	aux = 0;
	if ((mes!="") && (dia!="")) {
		if ((mes==2) && (dia>29)) {
			aux=1;
			}
		else if (  ( (mes%2)==0 && (mes!=8) )&& (dia==31)){
			aux=1;
			}
		
		if (aux==1){alert("Fecha incorrecta");}
	}
}