function isBlank(val) {
	if (val == null) {
		return true;
	}
	if( val.length == 0) {
		return true;
	}
	return false;
}

function checkAll(myForm, eventi)
{
	var thereIsSomething = false;
	if (eventi == 1) {
		if (myForm.elements[0].checked) {
			thereIsSomething = true;
		}
	} else {
		for (i = 0; i < myForm.elements.length; i++) {
			if (myForm.elements[i].checked) {
				thereIsSomething = true;
			}
		}
	}
	return thereIsSomething;
}

function imposta_select() {
	document.getElementById('coloreTitolo').selectedIndex = 0;
	document.getElementById('dimensioneTitolo').selectedIndex = 2;
	document.getElementById('coloreSottotitolo').selectedIndex = 8;
	document.getElementById('dimensioneSottotitolo').selectedIndex = 1;
}

function checkFormEvento() {
	if (isBlank(document.aggiungiEvento.titolo.value)) {
		alert('Inserisci il titolo dell\'evento');
		return false;
	} else if (isBlank(document.aggiungiEvento.dimensioneTitolo.value)) {
		alert('Inserisci la dimensione del testo del titolo dell\'evento');
		return false;
	} else if (isBlank(document.aggiungiEvento.sottotitolo.value)) {
		alert('Inserisci il sottotitolo dell\'evento');
		return false;
	} else if (isBlank(document.aggiungiEvento.data.value)) {
		alert('Inserisci la data dell\'evento');
		return false;
	} else if (isBlank(document.aggiungiEvento.luogo.value)) {
		alert('Inserisci il luogo dell\'evento');
		return false;
	} else if (isBlank(document.aggiungiEvento.mappa.value)) {
		alert('Inserisci la mappa dell\'evento');
		return false;
	} else if (isBlank(document.aggiungiEvento.descrizione1.value)) {
		alert('Inserisci una descrizione dell\'evento');
		return false;
	} else if (isBlank(document.aggiungiEvento.image.value)) {
		alert('Inserisci un\'immagine dell\'evento');
		return false;
	}
	return true;
}

function checkFormEventoModifica() {
	if (isBlank(document.modificaEvento.titolo.value)) {
		alert('Inserisci il titolo dell\'evento');
		return false;
	} else if (isBlank(document.modificaEvento.dimensioneTitolo.value)) {
		alert('Inserisci la dimensione del testo del titolo dell\'evento');
		return false;
	} else if (isBlank(document.modificaEvento.sottotitolo.value)) {
		alert('Inserisci il sottotitolo dell\'evento');
		return false;
	} else if (isBlank(document.modificaEvento.data.value)) {
		alert('Inserisci la data dell\'evento');
		return false;
	} else if (isBlank(document.modificaEvento.luogo.value)) {
		alert('Inserisci il luogo dell\'evento');
		return false;
	} else if (isBlank(document.modificaEvento.mappa.value)) {
		alert('Inserisci la mappa dell\'evento');
		return false;
	} else if (isBlank(document.modificaEvento.descrizione1.value)) {
		alert('Inserisci una descrizione dell\'evento');
		return false;
	}
	return true;
}

var aryClassElements = new Array();

function getElementsByClassName( strClassName, obj ) {
    if ( obj.className == strClassName ) {
        aryClassElements[aryClassElements.length] = obj;
    }
    for ( var i = 0; i < obj.childNodes.length; i++ ) {
        getElementsByClassName( strClassName, obj.childNodes[i] );
	}
}

function mostraEventiPassati(eventi, eventiPassati) {
    aryClassElements.length = 0;
    getElementsByClassName("box ghost", document.getElementById("content") );

    for ( var i = 0; i < aryClassElements.length; i++ ) {
	if (document.getElementById("visualizzaNascondiEventi").firstChild.data == 'Visualizza gli eventi passati') {
	        aryClassElements[i].style.display = 'block';
	} else {
	        aryClassElements[i].style.display = 'none';
	}	
    }
    if (document.getElementById("visualizzaNascondiEventi").firstChild.data == 'Visualizza gli eventi passati') {
    	document.getElementById("numeroEventi").firstChild.data = eventi;
    	document.getElementById("visualizzaNascondiEventi").firstChild.data = 'Nascondi gli eventi passati';
    } else {
    	document.getElementById("numeroEventi").firstChild.data = eventiPassati;
	document.getElementById("visualizzaNascondiEventi").firstChild.data = 'Visualizza gli eventi passati';
    }

}

