function ver(capa){
	capa = document.getElementById(capa);
	capa.style.display='block';	
}

function ocultar(capa){
	capa = document.getElementById(capa);
	capa.style.display='none';	
}

function muestraCapa(combo)
{
		/*
		if(combo.value == '2')
			ver('normasP');
		else if(combo.value == '6')
			ver('normas');
		else
			ocultar('normas');
			ocultar('normasP');
		*/
		if(combo.value == '6')
		{
			ocultar('normas');	
			ver('normasP');
		}
		else
		{
			ocultar('normasP');
			ver('normas');
		}
		
}

function confirmaRedireccion(mje, ruta)
{
	if(confirm(mje)) 
	{
		location=ruta;
 	} 
}

//funciones para la ordenacion de los resultados obtenidos en las tablas
function Ajax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
  		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function OrdenarPor(campo, orden){
	//especificamos en div donde se mostrará el resultado
	divListado = document.getElementById('listado');
	
	ajax=Ajax();
	//especificamos el archivo que realizará el listado
	//y enviamos las dos variables: campo y orden
	ajax.open("GET", "gestion_agencia_inscripciones.php?campo="+campo+"&orden="+orden);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divListado.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}

function revisaDatosTarj(){
	if (document.getElementById('PAYMENT').checked === true){
		var titular = document.getElementById('HOLDER').value;
		var numero = document.getElementById('CARDNUMBER').value;
		var msg = "";
		if (titular == ""){
			msg += "Debe rellenar el titular.\n";
		}
		if (numero == ""){
			msg += "Debe rellenar el número de tarjeta.\n";
		}
		var f = document.getElementById('EXPIRYDATE').value;
		var fmonth = f.substring(0, 2);
		var fyear = f.substring(3, 5);
		if (isNaN(fmonth)){//no numerico
			msg += "Fecha de caducidad erronea.";
		}else if (isNaN(fyear)){//no numerico
			msg += "Fecha de caducidad erronea.";
		}else if (fmonth < 0 || fmonth > 12){
			msg += "Fecha de caducidad erronea.";
		}else if (fyear < 8){
			msg += "Fecha de caducidad erronea.";
		}
		if (msg != ""){
			alert(msg);
			return false;
		}else{
			return true;
		}
	}else{
		return true;
	}
}