function formCheck(formobj){
	// Enter name of mandatory fields
	var fieldRequired = Array("spol", "imepriimek", "datumrojstva", "naslov", "telefon", "email", "kategorija", "starost", "program", "stopnja", "datumzacetka");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Spol", "Ime in priimek", "Datum rojstva", "Naslov", "Telefonska številka", "E-mail", "Kategorija", "Starost", "Program", "Stopnja", "Datum pri&#269;etka");
	// dialog message
	var alertMsg = "Pozabili ste vnesti naslednja polja:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}

function formCheck2(formobj){
	// Enter name of mandatory fields
	var fieldRequired = Array("imepriimek", "email", "sporocilo");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Ime in priimek", "E-mail naslov", "Sporocilo");
	// dialog message
	var alertMsg = "Pozabili ste vnesti naslednja polja:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}

function validatePwd() {
var invalid = " "; // Invalid character is a space
var minLength = 4; // Minimum length
var pw1 = document.oglas.password.value;
var pw2 = document.oglas.password2.value;
// check for a value in both fields.
if (pw1 == '' || pw2 == '') {
alert('Prosimo, vnesite geslo dvakrat.');
return false;
}
// check for minimum length
if (document.oglas.password.value.length < minLength) {
alert('Vaše geslo mora biti vsaj' + minLength + 'znakov dolgo. Poskusite znova!');
return false;
}
// check for spaces
if (document.oglas.password.value.indexOf(invalid) > -1) {
alert("Presledki v geslu niso dovoljeni!");
return false;
}
else {
if (pw1 != pw2) {
alert ("Niste vnesli enakih gesel. Poskusite znova!");
return false;
}
else {
//alert('Nice job.');
return true;
      }
   }
}
