var list2 = null;

function color(id){
if(id != ulist){
var test = document.getElementById('sub'+id);
	if(test != null ){
		var elem = document.getElementById('sub'+id).style.display;
		if(elem == "block"){
			document.getElementById(id).style.backgroundColor = "#142B6D";
			document.getElementById('link'+id).style.color = "#ffffff";
		}
		
		if(ulist != null){
			var doc = document.getElementById('sub'+ ulist);
			if(doc != null){
				document.getElementById('sub'+ ulist).style.display = "none";
			}				
			document.getElementById(ulist).style.backgroundColor = "";	
			document.getElementById('link'+ ulist).style.color = "#142B6D";
			}
			
			if(list != null){
				var docli = document.getElementById('sub2'+ list);
				if(docli != null){
					document.getElementById('sub2'+ list).style.display = "none";
				}	

				document.getElementById('linksub'+list).style.backgroundColor = "";				
				document.getElementById('linksub'+list).style.color = "#142B6D";
				list = null;
			}
			if(li2 != null){
				var docli = document.getElementById('sub2'+ list);
				if(docli != null){
					document.getElementById('sub2'+ list).style.display = "none";
				}	
				var doc3 = document.getElementById('sub3'+ li2);
				if(doc3 != null){
					document.getElementById('sub3'+ li2).style.display = "none";
				}				
		
				document.getElementById('sub'+li2).style.backgroundColor = "";
				document.getElementById('linksub2'+li2).style.backgroundColor = "";				
				document.getElementById('linksub2'+li2).style.color = "#142B6D";
			}
			if(li3 != null){
				var doc3 = document.getElementById('sub3'+ li2);
				if(doc3 != null){
					document.getElementById('sub3'+ li2).style.display = "none";
				}				
				document.getElementById('submenu3'+li3).style.backgroundColor = "";
				document.getElementById('linksub3'+li3).style.backgroundColor = "";				
				document.getElementById('linksub3'+li3).style.color = "#142B6D";	
			}					

	if(ulist != id ){
			ulist = id;
		}else{
			ulist = null;
		}	
	}else{
		if(ulist != null){
			var doc = document.getElementById('sub'+ ulist);
			if(doc != null){
				document.getElementById('sub'+ ulist).style.display = "none";
			}	
			document.getElementById(ulist).style.backgroundColor = "";	
			document.getElementById('link'+ ulist).style.color = "#142B6D";	
		}
		document.getElementById(id).style.backgroundColor = "#142B6D";
		document.getElementById('link'+id).style.color = "#ffffff";
		ulist = id;
	}
}
}

///////////////////////////////Sub Menu/////////////////////////////////////////
/*
function colorli(id){
	var sub = document.getElementById('sub'+id);
	var sub2 = document.getElementById('linksub'+id).parentNode;

	if(list2 != null && sub != null && list2 != sub){
		document.getElementById(list2).style.display = 'none';
	}
	if(sub != null && list2 != sub){
		list2 = sub.id;
	}else{
		list2 = null;
	}

	list = id;
	document.getElementById('linksub'+id).style.backgroundColor = "#FFEEA8";
	document.getElementById('linksub'+id).style.color = "#142B6D";
}
//		string = tabs[i].split( ";" );
	  //campo_select.options[i] = new Option( string[0], string[1] );
//	alert(tabs);
//	alert(tabs[0]);

*/
tabs = new Array();
subTop = null;
//
total = null;
function colorli(id){
	var sub = document.getElementById('sub'+id);
	if(sub != null){
		var total = tabs.length;
		i = total++;
		tabs[i] = sub.id;

		if(tabs != ''){
			for (y=0;y<tabs.length;y++){
				if(tabs[y] != sub.parentNode.id && sub.parentNode.id != subTop){
					document.getElementById(tabs[y]).style.display = "none";
				}
			}	
		}
		subTop = 'sub'+id;
	}else{//vem de outro menu
		var parent = document.getElementById('linksub'+id).parentNode.id;
		if(tabs != ''){
			total = tabs.length;
			i = total -1;
			if(tabs[i] != parent){
				document.getElementById(tabs[i]).style.display = "none";
			}
		}
	}
	if(list != null){
		document.getElementById('linksub'+list).style.backgroundColor = '#FFEEA8';	
	}
	document.getElementById('linksub'+id).style.backgroundColor = '#FFCC00';
	list = id;
	
}
////////////////////////////////////////////////////////////////////////////////////////////////

function escSt(item){
	var t = document.getElementById(item);
	if(t != null){
		var st = document.getElementById(item).style.display;
		if(st == "none"){
			document.getElementById(item).style.display = "block";
			if(item == "formMenu"){
				var handle = document.getElementById('bar');
				handle.innerHTML = "<a href='logout.php'><img src=images/ed_delete.gif align='right' /></a><img src=images/minus.gif border=0 style=cursor:pointer; onclick=javascript:escSt('formMenu');tam('Form'); align='right' />";
			}
		}
		else{
			document.getElementById(item).style.display = "none";
			if(item == "formMenu"){
				var handle1 = document.getElementById('bar');
				handle1.innerHTML = "<a href='logout.php'><img src=images/ed_delete.gif align='right' /></a><img src=images/+.gif border=0 style=cursor:pointer; onclick=javascript:escSt('formMenu');tam('"+lastForm+"'); align='right' />";
			}
		}
	}
}