// JavaScript Document
function cambiaIdioma(lang){
	document.getElementById('frmAcciones').src='acciones/cambiaLang.php?l='+lang;
}

function cambiaEdad(){

	var dia=document.getElementById('dia').value;
	var mes=document.getElementById('mes').value;
	var ano=document.getElementById('any').value;
	var Fedad = 0;

	//calculo la fecha de hoy
	hoy=new Date();

	//resto los aņos de las dos fechas
	edad=hoy.getFullYear()- ano - 1; //-1 porque no se si ha cumplido aņos ya este aņo

	//si resto los meses y me da menor que 0 entonces no ha cumplido aņos. Si da mayor si ha cumplido
	if (hoy.getMonth() + 1 - mes < 0){
		Fedad =  edad;
	}
	if (hoy.getMonth() + 1 - mes > 0) {
		Fedad =  edad+1;
	}
	if (hoy.getMonth() + 1 - mes == 0) {
		if (hoy.getUTCDate() - dia >= 0)
			Fedad =  edad + 1;
		else
			Fedad =  edad ;
	}
	//entonces es que eran iguales. miro los dias
	//si resto los dias y me da menor que 0 entonces no ha cumplido aņos. Si da mayor o igual si ha cumplido
	   
	document.getElementById('edad').value = Fedad;
	if (Fedad < 15) {
		document.getElementById('capaMenor14').style.display = 'block';
	} else {
		document.getElementById('capaMenor14').style.display = 'none';
	}

}

function inscripcioAmbXip(valor){
	var laselect = document.getElementById('centro');
	
	if(valor != '') {
		if(laselect.length > 8)
			removeOptionLast();
	}else {
		appendOptionLast();
	}
	
}

function appendOptionLast() {
  var elOptNew = document.createElement('option');
  elOptNew.text = 'Otros';
  elOptNew.value = 'no puc';
  var elSel = document.getElementById('centro');

  try {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }
}

function removeOptionLast() {
  var elSel = document.getElementById('centro');
  if (elSel.length > 0)  {
    elSel.remove(elSel.length - 1);
  }
}
