var ant=null;
function validar(){
	var email=true,texto=true;
//	if (document.formcontacto.nombre.value==false) ;
	if (document.formcontacto.email.value==false) {
		alert("El campo de correo electrónico no puede estar en blanco");
		email=false;
	}
	if (document.formcontacto.mensaje.value==false){
		alert("Se debe escribir un mensaje");
		texto=false;
	}
	return(email && texto);
}
function validarcat(){
	var email=true,texto=true;
//	if (document.formcontacto.nombre.value==false) ;
	if (document.formcontacto.email.value==false) {
		alert("El camp del correu electronic no es pot deixar en blanc");
		email=false;
	}
	if (document.formcontacto.mensaje.value==false){
		alert("S'ha d'escriure un missatge");
		texto=false;
	}
	return(email && texto);
}
function eliminar(cod){
	if (confirm("Quiere eliminar el mensaje")){
		document.eliminarmensaje.cod.value=cod;
		document.eliminarmensaje.submit();
	}
}

function tratarFecha(d,m,y){
	eventos=document.getElementsByTagName("div");
	if(ant!=null) {
		for(j=0;j<eventos.length;j++)
			if (eventos[j].getAttribute("name")==ant) eventos[j].className="invisible";
	}
	for(j=0;j<eventos.length;j++){
		if (eventos[j].getAttribute("name")==d)
			eventos[j].className="visible";
		}
	ant=d;
}
function tratarfecha(id){
//	alert("dentro de la funcion");
	if (id=='calpop1'){
//		alert(document.getElementById(id));
		document.getElementById(id).style.visibility='visible';
		document.getElementById('calpop2').style.visibility='hidden';
	}else{
		document.getElementById(id).style.visibility='visible';
		document.getElementById('calpop1').style.visibility='hidden';
	}
}
function esconder(id){
	parent.document.getElementById(id).style.visibility='hidden';
}
function poner_fecha(id,d,m,y,capa){
	parent.document.getElementById(id).value=d+"/"+m+"/"+y;
	esconder(capa);
}

function insertarEvento(){
	if (document.getElementById('fecini').value=="") {alert("hay que poner fechas");return false;}
	if (document.getElementById('fecfin').value==""){alert("hay que poner fechas");return false;}
	if (document.getElementById('tit').value=="") {alert("falta un titulo");return false;}
	if (document.getElementById('descrip').value=="") {alert("la descripcion no puede estar vacia");return false;}
	document.getElementById('formeventoins').submit();
}

function mensajes(){
	document.getElementById('resul').src='ver_contactop.php';
}
function nuevaObra(){
	document.getElementById('resul').src='eventop.php';	
}
function busqueda(){
	document.getElementById('ano').value=document.getElementById('selano').options[document.getElementById('selano').selectedIndex].value;
	document.getElementById('mes').value=document.getElementById('selmes').options[document.getElementById('selmes').selectedIndex].value;
	document.getElementById('formbus').submit();
}
function consultar(cod){
	document.getElementById('cod').value=cod;
	document.getElementById('ano').value=parent.document.getElementById('selano').options[parent.document.getElementById('selano').selectedIndex].value;
	document.getElementById('mes').value=parent.document.getElementById('selmes').options[parent.document.getElementById('selmes').selectedIndex].value;
		document.getElementById('consobra').submit();
}
function modificar(){
	if (document.getElementById('fecini').value=="") {alert("hay que poner fechas");return false;}
	if (document.getElementById('fecfin').value==""){alert("hay que poner fechas");return false;}
	if (document.getElementById('tit').value=="") {alert("falta un titulo");return false;}
	if (document.getElementById('descrip').value=="") {alert("la descripcion no puede estar vacia");return false;}
	document.getElementById('formobra').submit();
}
function eliminarobra(idcod){
	document.getElementById('cod').value=idcod;
	document.getElementById('consobra').submit();
}
