var bfbMenuWithChildren = new Array();

function showALLBFBMenu() {
	
	var decor = (arguments.length == 2) ? arguments[1] : 'bfbMenuDecor';
	var tempArray = (decor == "bfbMenuDecor") ? bfbMenuWithChildren : iaskMenuWithChildren;
	
	for(i=0;i<tempArray.length;i++) {
		if(tempArray[i]) {
			bullet = $(decor+':subcatsRepeat:' + i + ':expbullet');
			panel = $(decor+':subcatsRepeat:' + i + ':children');
			
			showBFBPanel(bullet, panel, decor);	
		}
	}
	
	hideShowAllDiv(decor);
}

function hideALLBFBMenu(){
	var decor = (arguments.length == 2) ? arguments[1] : 'bfbMenuDecor';
	var tempArray = (decor == "bfbMenuDecor") ? bfbMenuWithChildren : iaskMenuWithChildren;
	
	for(i=0;i<tempArray.length;i++) {
		if(tempArray[i]) {
			bullet = $(decor+':subcatsRepeat:' + i + ':expbullet');
			panel = $(decor+':subcatsRepeat:' + i + ':children');
			
			hideBFBPanel(bullet, panel, decor);			
		}
	}
	
	appearShowAllDiv(decor);	
}

function bfbToggleBodyPanel(bullet, panel) {
	if(panel.style.display == 'none') {
		Effect.SlideDown(panel, {
			duration: 0.1,
			afterFinish: function() {
                saveSwitchOff('bfbPanelMin')
				bullet.src = "/ida/img/components/" + color + "/btn_minimise_y.gif";
			}
		});
	} else {
		Effect.SlideUp(panel, {
			duration: 0.1,
			afterFinish: function() {
                saveSwitchOn('bfbPanelMin')
				bullet.src = "/ida/img/components/" + color + "/btn_expand_y.gif";
			}
		});
	}
}

function bfbTogglePanel(bullet, panel) {
	
	var decor = (arguments.length == 3) ? arguments[2] : "bfbMenuDecor";
	if(panel.style.display == 'none') {
		showBFBPanel(bullet, panel, decor);
	} else {
		hideBFBPanel(bullet, panel, decor);
	}
}

function sectionTogglePanel(bullet, panel) {
	if(panel.style.display == 'none') {
        panel.style.display = 'block'
		// Effect.SlideDown(panel, {
		// 	duration: 0.1,
		// 	afterFinish: function() {
                saveSwitchOff(panel.id + 'Min')
				bullet.src = "/ida/img/components/btn_minimise.gif";
        //     }
		// });
	} else {
        panel.style.display = 'none'
		// Effect.SlideUp(panel, {
		// 	duration: 0.1,
		// 	afterFinish: function() {
                saveSwitchOn(panel.id + 'Min')
				bullet.src = "/ida/img/components/btn_expand.gif";
        //     }
		// });
	}
}

function showBFBPanel(bullet, panel, decor) {
	
	Effect.SlideDown(panel, {
		duration: 0.1,
		afterFinish: function() {
            saveSwitchOn(panel.id)
			bullet.src = "/ida/img/components/" + color + "/bullet2.gif";

			//if all panels are opened, show Hide All
			var numChild = 0;
			var counter = 0;
			var tempArray = (decor == "bfbMenuDecor") ? bfbMenuWithChildren : iaskMenuWithChildren;

			for(j=0;j<tempArray.length;j++) {
				if(tempArray[j]) {
					numChild++;
					
					if($(decor+':subcatsRepeat:'+j+':children').style.display != "none") {
						counter++;
					}
				}
			}
			
			if(numChild == counter){
				hideShowAllDiv(decor);
			}
		}
	});
}

function hideBFBPanel(bullet, panel, decor){
	Effect.SlideUp(panel, {
		duration: 0.1,
		afterFinish: function() {
            saveSwitchOff(panel.id)
			bullet.src = "/ida/img/components/" + color + "/bullet.gif";
	
			if($(decor+':hideAllLink').style.display != "none"){
				appearShowAllDiv(decor);
			}
		}
	});
}

function hideShowAllDiv(decor){
	
	$(decor+':showAllLink').hide();	
	$(decor+':hideAllLink').show();			
}

function appearShowAllDiv(decor){
	$(decor+':showAllLink').show();	
	$(decor+':hideAllLink').hide();
}

function toggleExpBtn(bullet, panel) {
	
	if(panel.style.display == 'none') {
        panel.style.display = 'block'
		bullet.src = "/ida/img/components/btn_minimise.gif";
        
	} else {
        panel.style.display = 'none'
		bullet.src = "/ida/img/components/btn_expand.gif";
        
	}
}