function over(t)
{
	//alert('over');
	t.style.backgroundColor= "#e7eefc";
	//t.style.cursor = "hand";
}

function out(t)
{
	t.style.backgroundColor= "#fbf1dc";
}	
	
function SubOver(t)
{
	t.style.backgroundColor = "#e7eefc";
}
	
function SubOut(t)
{
	t.style.backgroundColor = "#ffe5b5";
}	

function SubSubOver(t)
{
	t.style.backgroundColor = "#e7eefc"	;
}

function SubSubOut(t)
{
	t.style.backgroundColor = "#ffe5b5"	;
}	

	
//funkcija kojoj se šalje parametar tipa b07 i
//ona prema njemu retke koji imaju idb07... sakrije ili prikaže ovisno
//o trenutnom stanju
/*
function flip (det) 
{
	var chaptab = document.getElementById("chaptab");
	prom=""
	for(props in chaptab.rows)
	{
		var row = chaptab.rows[props];
		if(row != null && row.id !=null)
		{
		
			if (row.id.substring(0,det.length) == det)
			{
				if (row.style.display == "block")
					row.style.display="none";
				else
				{
					prom = row;
					prom.style.display="block";
				}
			}
		}
	}
	
	if (prom != null && prom.hasChildren)
		//ako prvi nivo ima djece onda zamijeni zadnju sličicu
		if(prom.childNodes[1].childNodes.length > 0)prom.childNodes[1].childNodes[0].src = "../images/lead2.gif"

}


function flip2 (det)
{
    var chaptab = document.getElementById("chaptab");
	prom = "";
	for (props in chaptab.rows)
	{
		var row = chaptab.rows[props];
		if (row != null && row.id != null && row.id.substring(0,det.length) == det)
		{
			if (row.style.display == "block") row.style.display="none";
			else
			{
				prom = row;
				row.style.display="block";
			}
		}
	}

	if (det.substr(0,1)=="c")
    {
		//ako drugi nivo ima djece onda zamijeni zadnju sličicu
		if(prom.childNodes.item(1).childNodes.length > 0)
			prom.childNodes.item(1).childNodes.item(0).src = "../images/lead4.gif"

	}
}

function flip3 (det)
{
	var chaptab = document.getElementById("chaptab");

	for (props in chaptab.rows)
	{
		if (props.substring(0,det.length) == det)
		{
			if (chaptab.rows.item(props).style.display == "block")
				chaptab.rows.item(props).style.display="none";
		}
		//alert(props);
	}

}
*/
//U hidden polje koje se zove "polje" upisuje ID kliknutog retka
function prikaz(red)
{
	var t = red.id;
	var polje = document.getElementById("polje");
	polje.value=t;
}


//funkcija koja prikazuje u izborniku ono što je odabrano(otvara menu) radi i za drugi i treći level

function prikazi()
{


/*
	var polje = document.getElementById("polje");

	if (polje.value != 'i')
	{
		setAll('c', 'none');//Sakrij sve treće level-e koji su otvoreni.
		var t = polje.value;
		t = t.substr(1, 2);

		var TRows =document.getElementsByTagName("TR");
		broj= TRows.length;


		//kontrola
		//alert("broj = " + broj);

		var prom="";
		var prom_3_level = "";
		for (var j=0;j<=broj-1;j++)
		{
			var v = TRows.item(j).id
			//alert('j=' + j + ' v=' + v + ' t=' + t)
			var l = v.substr(1,2)

			if (l==t) //Ako je iz id-a npr. b07d2 ovaj 07 jednak trenutnom u petlji tada...
			{
				if (v.substr(0,1) == 'b') //Ako je prvi znak id-a jednak 'b' što znači drugi level
				{
					prom = TRows.item(j)//Ovo je trenutni redak u tablici a na kraju petlje biit će unutra zadnji i njemu će se kasnije zamijeniti sličica za kraj (2. level)
					TRows.item(j).style.display= "block";//Prikaži redak
				}
				else if (v.substr(0,1) == 'c' &&(polje.value.substr(0,1)=='c'))
				//Ako je prvi znak id-a jednak 'c' što znači treći level i ako je u hidden polju id koji počinje sa C 
				//tako da ne prikazuje traći level ako nije kliknut član iz rrećeg levela
				{
					prom_3_level = document.all.tags("TR")(j)//Ovo je trenutni redak u tablici a na kraju petlje biit će unutra zadnji i njemu će se kasnije zamijeniti sličica za kraj (3. level)
					document.all.tags("TR")(j).style.display= "block";//Prikaži redak
				}
					
			}

		}

			
		if(prom.childNodes.item(1).childNodes.length > 0)prom.childNodes.item(1).childNodes.item(0).src = "../images/lead2.gif"

		if (prom_3_level != "")
		{
			if(prom_3_level.childNodes)prom_3_level.childNodes.item(1).childNodes.item(0).src = "../images/lead4.gif"
			}
	}
	//ShowAll()
	
	*/
	
	var polje = document.getElementById("polje");
	if(polje != null && polje.value != "i")
	{	
		var div = document.getElementById(polje.value);
		if (div == null) return;
		
		//otktij strukturu
		var parentDiv = div.parentNode.parentNode;
		var chaptab =  document.getElementById("chaptab");
		while(parentDiv != null && parentDiv != chaptab)
		{
			expand(parentDiv);
			parentDiv = parentDiv.parentNode;
		}
		
		div.style.color = "#0000FF";
	}
	
}


//funkcija koja prikazuje ili sakriva cijeli level, det je varijabla koja može biti b ili c
//(drugi ili treći nivo) a viz je 'none'  ili 'block' što znači sakrij ili prikaži
/*
function setAll (det,viz)
{
	var chaptab = document.getElementById("chaptab");
	for (props in chaptab.rows)
	{
		var row = chaptab.rows[props];
		if (row != null && row.id != null && row.id.substring(0,det.length) == det)
			row.style.display = viz;
	}
}
*/

//funkcija koja prikazuje cijelu strukturu
function ShowAll ()
{
/*
	var _ids = "showAll\r\n";
	var chaptab = document.getElementById("chaptab");
	for (props in chaptab.rows)
	{
		var row = chaptab.rows[props];
		if (row != null && row.id != null)
		{
			_ids = _ids + row.id + "\r\n";
			if (row.id.substring(0,1) == "c") row.style.display = "block";
			if (row.id.substring(0,1) == "b") row.style.display = "block";
		}
	}
	
*/

	expandAll(document.getElementById("chaptab"));
}

//funkcija koja sakriva cijelu strukturu
function HideAll () 
{
/*
	var _ids = "hideAll\r\n";
	var chaptab = document.getElementById("chaptab");
	for (props in chaptab.rows)
	{
		var row = chaptab.rows[props];
		if (row != null && row.id != null)
		{
			_ids = _ids + row.id + "\r\n";
			if (row.id.substring(0,1) == "c") row.style.display = "none";
			if (row.id.substring(0,1) == "b") row.style.display = "none";
		}
	}
*/
	collapseChildren(document.getElementById("chaptab"));
}



/*
function flip_2 (det) 
{
	var chaptab3 = document.getElementById("chaptab3");
	for (props in chaptab3.rows)
	{
		var row = chaptab3.rows[props];
		if (row != null && row.id .substring(0,det.length) == det)
			row.style.display="block";
	}
}


function flip_3 (det) 
{
	var chaptab3 = document.getElementById("chaptab3");
	for (props in chaptab3.rows)
	{
		var row = chaptab3.rows[props];
		if (row != null && row.id .substring(0,det.length) == det)
			row.style.display="none";
	}
}

function HideAlll () 
{
  for (props in document.all.chaptab3.rows){
    if (props.substring(0,1) == "c"){
         document.all[props].style.display = "none";
	} 
    if (props.substring(0,1) == "b"){
         document.all[props].style.display = "none";
	}
  }
}
*/

function odabran()
{
/*	var chaptab = document.getElementById("chaptab");
	var polje = document.getElementById("polje");
	broj = chaptab.rows.length;
	
	//alert(chaptab.getElementsByTagName != null
	var rows = chaptab.getElementsByTagName("TR");
	for (var j=0;j<=broj-1;j++)
	{
		var prvi= rows[j].id;
		var drugi=polje.value;
		
		if (prvi.length==7)
		{
			prvi=prvi.substr(0,5)
		}
		else
		{
			prvi=prvi.substr(0,6)
		}
		
		if (prvi == drugi)
		{
			rows[j].cells.item(1).style.color="#0000FF";
	//		tx=chaptab.all.tags("TR")(j).cells(1).innerHTML;
	//		chaptab.all.tags("TR")(j).cells(1).innerHTML=tx+"<img src='../images/bul.gif'></img>";
	     }
	}
	*/
}


function toggleChildren(item)
{
	if(item == null) return;
	var fDiv = null;
	for(i in item.childNodes)
	{
		var t = item.childNodes[i];
		if (t != null && t.tagName != null && t.tagName.toLowerCase() == "div")
		{
			fDiv = t;
			break;
		}
	}
	
	if(fDiv == null) return;
	if (fDiv.style.display != "block") 
	{
		//ako radim ekspand -> treba collpase sve ostale djece
		var parentDiv = item.parentNode;
		if (parentDiv != null ) collapseChildren(parentDiv);
		expand(item);
	}
	else collapse(item);
}


function collapse(item)
{
	for(i in item.childNodes)
	{
		var ch = item.childNodes[i];
		if(ch != null && ch.style != null && ch.tagName.toLowerCase()=="div")
			ch.style.display = "none";
	}
}

function collapseChildren(item)
{
	for(i in item.childNodes)
	{
		var ch = item.childNodes[i];
		if(ch != null && ch.style != null  && ch.tagName.toLowerCase() == "div")
			collapse(ch);
	}
}


function expand(item)
{
	if(item == null) return;
	item.style.display = "block";
	for(i in item.childNodes)
	{
		var ch = item.childNodes[i];
		
		if(ch != null && ch.style != null && ch.tagName.toLowerCase() == "div")
			ch.style.display = "block";
	}
}

function expandAll(item)
{
	if(item == null) return;
	item.style.display = "block";
	for(i in item.childNodes)
	{
		var ch = item.childNodes[i];
		if(ch != null && ch.style != null && ch.tagName.toLowerCase() == "div")
			expandAll(ch);
	}
}



