﻿// JavaScript Document

function amagamenu2() {
	var obj1= document.getElementById('menu2cont');
//	obj1.style.visibility='hidden';
	obj1.style.display='none';
}

function amagamenu2b() {
	var obj3= document.getElementById('menu2bcont');
//	obj1.style.visibility='hidden';
	obj3.style.display='none';
}

function amagamenu2c() {
	var obj3= document.getElementById('menu2ccont');
//	obj1.style.visibility='hidden';
	obj3.style.display='none';
}

function mostramenu2() {
	var obj2= document.getElementById('menu2cont');
//	obj2.style.visibility='visible';
	obj2.style.display='block';
}

function mostramenu2b() {
	var obj4= document.getElementById('menu2bcont');
//	obj2.style.visibility='visible';
	obj4.style.display='block';
}

function mostramenu2c() {
	var obj4= document.getElementById('menu2ccont');
//	obj2.style.visibility='visible';
	obj4.style.display='block';
}

function ompliremail() {
	var obj3= document.getElementById('email');
	obj3.style.color='#000000';
	obj3.value='';
}

function check_contactar() {
	if( document.formcontactar.Nom.value=='' || document.formcontactar.Email.value=='' || document.formcontactar.Assumpte.value=='' || document.formcontactar.Missatge.value=='' ) {
		alert("Tots els camps del formulari són obligatoris.");
		return false;
	} else {
		return true;
	}
}

function check_form_entitats_baix_penedes() {
	if( document.form_entitats_baix_penedes.nom.value=='' || document.form_entitats_baix_penedes.signatura.value=='' ) {
		alert("Tots els camps del formulari són obligatoris.");
		return false;
	} else {
		return true;
	}
}

function check_form_inscripcio_activitats_cepb() {
	if( document.form_inscripcio_activitats_cepb.nom.value=='' || document.form_inscripcio_activitats_cepb.signatura.value=='' ) {
		alert("Tots els camps del formulari són obligatoris.");
		return false;
	} else {
		return true;
	}
}

function check_form_plantilla_solicitud_prestecs() {
	if( !check_generic(document.form_g, null) )
		return false;
	else
		return true;
}

function check_form_entitats_baix_penedes() {
	if( !check_generic(document.form_g, null) )
		return false;
	else
		return true;
}

function check_formulari_full_inscripcio_esports_de_lleure() {
	 if( !valButton(document.form_g.Esports) )
		return false;
	else if( !check_generic(document.form_g, 'Camp i Hora') )
		return false;
	else
		return true;
}

function check_formulari_full_inscripcio_esports_d_equip() {
	if( !valButton(document.form_g.Esports) )
		return false;
	else if( !valButton(document.form_g.Sexe) )
		return false;
	else if( !check_generic(document.form_g, null) )
		return false;
	else
		return true;
}

function check_full_inscripcio_petanca() {
	if( !valButton(document.form_g.delegat) )
		return false;
	else if( !check_generic(document.form_g, null) )
		return false;
	else
		return true;
}

function check_form_full_recurs_d_adults() {
	if( !valButton(document.form_g.esport) )
		return false;
	else if( !check_generic(document.form_g, null) )
		return false;
	else
		return true;
}

function check_form_inscripcio_natacio() {
	if( !check_generic(document.form_g, null) )
		return false;
	else
		return true;
}

function check_form_annex_acta_partit() {
	if( !check_generic(document.form_g, null) )
		return false;
	else
		return true;
}

function check_form_inscripcio_esports_individuals() {
	if( document.form_g.entitat.value=='' || document.form_g.adresa.value=='' || document.form_g.localitat.value=='' || document.form_g.fax.value=='' || document.form_g.delegat.value=='' || document.form_g.telefon1.value=='' || document.form_g.telefon2.value=='' || document.form_g.e_mail.value=='' || document.form_g.signatura.value=='' ) {
		alert("Tots els camps del formulari són obligatoris.");
		return false;
	} else {
		return true;
	}
}

function check_generic(formulari, excepcio) {
	for(i=0; i<document.form_g.elements.length; i++) {
		if( document.form_g.elements[i].name!=excepcio )
		if( document.form_g.elements[i].value=='' ) {
			if( excepcio!=null )
				alert("Tots els camps del formulari són obligatoris excepte "+excepcio+".");
			else
				alert("Tots els camps del formulari són obligatoris.");
			return false;
		}
	}
	return true;
}

function valButton(btn) {
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked)
			return true;
    }
	alert("Has de sel·leccionar un valor de " + btn[0].name);
	return false;
}
        

function js_carreca_calendari(mes, any) {
	$("#ajax_loader").css("display","block");
	$("#contenidor_calendari").load("calendari.asp?any="+any+"&mes="+mes,
				function(responseText, textStatus, XMLHttpRequest) {		
					$("#ajax_loader").css("display","none");
					if (textStatus=="success") {
					} else {
						$("#contenidor_calendari").html("<b class=\"vermell\" style=\"font-size: 12px\">Error de conexi&oacute; amb el servidor.</b>");
					}
				});
}

function canvia_capa_album(capa) {
		if ($("#"+capa).css("display")=="none")
			$("#"+capa).slideToggle("normal");	
		else
			$("#"+capa).hide("normal");
}
