function show_folder(i, elementName) {
 f = document.getElementById(elementName + "_f_" + i);
 pm = document.getElementById(elementName + "_pm_" + i);
 if (f.style.display == 'none')
 {
   f.style.display = 'block';
   pm.src = '/images/folders_minus.gif';
 }
 else if (f.style.display == 'block')
 {
   f.style.display = 'none';
   pm.src = '/images/folders_plus.gif';
 }
}

function check_all_sub(object, old_i, old_id) {
	id = object.id;
	checked = object.checked;

	i = 1;
	while ( document.getElementById(id + '_' + i) ) {
		document.getElementById(id + '_' + i).checked = checked;
		if ( document.getElementById(id + '_' + i + '_1') ) { tmp = check_all_sub(document.getElementById(id + '_' + i), i, id); i = tmp[0]; id = tmp[1]; }
		i = i + 1;
	}
	
	// deselect all of the parent checkboxes if we are deselecting
	if ( checked == false ) {
		arr = id.split("_");
		arr.splice(arr.length-1, 1);
		for(i = arr.length-1; i >= 0 && document.getElementById(arr.join("_")); i--) {
			document.getElementById(arr.join("_")).checked = false;
			arr.splice(arr.length-1, 1);		
		}
	}
	
	result = new Array(2);
	result[0] = old_i;
	result[1] = old_id;
	return result;
}

function expand_folder(i, elementName) {
   f = document.getElementById(elementName + "_f_" + i);
   pm = document.getElementById(elementName + "_pm_" + i);
   if (f != null ) f.style.display = 'block';
   if (pm != null )pm.src = '/images/folders_minus.gif';
 }
 
 var global_last_selected;
 
 function multi_expand(i, elementName) {
	
	if(global_last_selected != null) global_last_selected.style.background ='';
	
	global_last_selected = document.getElementById('sel_item_' + elementName + i);
	global_last_selected.style.background = '#ccc';
	
	var SplitResult = i.split("_");
	var tmp = '';
	
	for(i = 1; i < SplitResult.length; i++){
		tmp +=	'_'+SplitResult[i];	
		expand_folder(tmp, elementName);
	}
 
 }
