function toggle(id) {

	if(document.getElementById) {
		
		var el = document.getElementById(id);
		el.style.display = (el.style.display == 'none') ? 'block' : 'none';
	}
}

function selectKat(id){

	var list = document.form.idKatSelect;
	var table = document.getElementById("unosKat");
	var idKat = document.getElementById("idKat");
	var addKatTR = document.getElementById("addKat");
	
	if( addKatTR ){
		addKatTR.style.display = "none";
	}
	table.style.display = "";
	idKat.value = parseInt(id);
	
	for (var intI = 0; intI < list.options.length; intI++) {

		if (list.options[intI].value == id) {
			list.options[intI].selected = true;
		}
	}
}

function checkNaziv(){

	var naslov = document.getElementById("naziv_hr").value
	var error = new Array()
	submitOK = "true"
	var j
	var i = 0
	var porukaGreska
	if (naslov.length < 3){
	
		error[i] = "Naziv_hr"
		i = i + 1
		submitOK = "false"
	}
	if (submitOK == "false"){
	
		porukaGreska = "Potrebno je popuniti sljedeca polja forme, sa minimalno 3 znaka:\n\n"
		
		for(j = 0; j < i; j++){
																	
			porukaGreska += error[j] + "\n"
		}
		alert(porukaGreska)
		return false
	}
}

function delKat(id, page){
	
	var name = confirm("Brisanjem ove kategorije,\nbrisu se i pripadajuce podkategorije i proizvodi?");
	if (name == true){
	
		window.location="?page="+page+"&delete=" + id;
	}
	else{
	
		toggle(id);
	}
}

function changeURL(id, page){
	
	window.location="?page="+page+"&idKat=" + id;
}

function changeURL2(page){
	
	window.location="?page="+page;
}


