function selectedValue (dropdown) {
	var i;
	for (i = 0; i < dropdown.length; i++) {
		if (dropdown[i].selected) {
			return dropdown[i].value;
		}
	}
}

function isChecked (checkboxes) {
	var i;
	for (i = 0; i < checkboxes.length; i++) {
		if (checkboxes[i].checked) {
			return true;
		}
	}
	return false;
}

function disableEnableElement (sender, disableValue, target) {
	if (sender.value == disableValue) {
		target.disabled = true;
	}
	else {
		target.disabled = false;
	}
}

function disableEnableElements (sender, disableValue, target1, target2) {
	if (sender.value == disableValue) {
		target1.disabled = true;
		target2.disabled = true;
	}
	else {
		target1.disabled = false;
		target2.disabled = false;
	}
}

function checkForm (forma) {
	
	if (document.forma.uid.value === "") {
		alert ("Molimo upišite korisničko ime!");
		return false;
	}
	
	if (document.forma.pass.value === "") {
		alert ("Molimo upišite lozinku!");
		return false;
	}
	
	if (document.forma.pass.value !== document.forma.pass_ponovo.value) {
		alert ("Lozinke ne odgovaraju!");
		return false;
	}
	
	if (document.forma.ime.value === "") {
		alert ("Molimo upišite ime!");
		return false;
	}
	
	if (document.forma.adresa.value === "" || document.forma.grad.value === "" || document.forma.postanskibroj.value === "") {
		alert ("Molimo upišite potpunu adresu!");
		return false;
	}
	
	if (document.forma.email.value === "" || document.forma.email.value.indexOf("@") == -1 || document.forma.email.value.indexOf(".") == -1) {
		alert ("Molimo upišite ispravnu email adresu!");
		return false;
	}
	
	if (document.forma.telefon.value === "") {
		alert ("Molimo upišite broj telefona!");
		return false;
	}
	
	if (document.forma.opis.value === "") {
		alert ("Molimo upišite kratak opis organizacije!");
		return false;
	}
	
	podrucja = document.forma.elements["podrucje[]"];
	if (isChecked (podrucja) === false && document.forma.podrucjetxt.value === "") {
		alert ("Molimo označite područje djelovanja!");
		return false;
	}
	
	if (selectedValue (document.forma.vrsta) === "0") {
		alert ("Molimo označite vrstu organizacije!");
		return false;
	}
	
	if (document.forma.godinaosnivanja.value === "") {
		alert ("Molimo upišite godinu osnivanja organizacije!");
		return false;
	}
	
	if (document.forma.kontaktosoba.value === "") {
		alert ("Molimo upišite kontakt osobu!");
		return false;
	}
	
	if (document.forma.funkcija.value === "") {
		alert ("Molimo upišite funkciju kontakt osobe u organizaciji!");
		return false;
	}
	
	if (selectedValue (document.forma.ukljucivali) === "2") {
		alert ("Molimo označite da li ste već uključivali volontere u Vaš rad!");
		return false;
	}
	
	if (selectedValue (document.forma.vczedukacija) === "2") {
		alert ("Molimo označite da li ste prisustvovali na VCZ edukaciji o radu s volonterima!");
		return false;
	}
	
	if (selectedValue (document.forma.drugaedukacija) === "2") {
		alert ("Molimo označite da li ste prisustvovali nekoj drugoj edukaciji!");
		return false;
	}
	
	if (selectedValue (document.forma.drugaedukacija) === "1" && document.forma.drugaedukacijatxt.value === "") {
		alert ("Molimo upišite na kojoj ste drugoj edukaciji sudjelovali!");
		return false;
	}
	
	if (selectedValue (document.forma.strucnapomoc) === "2") {
		alert ("Molimo označite da li Vaša organizacija treba stručnu pomoć u radu s volonterima!");
		return false;
	}
	
	if (selectedValue (document.forma.primatiglasilo) === "2") {
		alert ("Molimo označite da li želite primati glasilo VCZ-a!");
		return false;
	}
	
	return true;
}
