# this is ~flds.js
\
||ifdef||script_block||	\
<script id="||script_block||">\
||endif||\
\
\
||if(and(istrue(alt_account),not(istrue(labels_force_allow))))||\
  ||define||no_labels||true||\
||endif||\
||define||ftree||true||\
set_folders('<ul class="ftree">'\
||begin_list_folders|| \
# Supply nested list tags around each folder (for collapsability)
# // LOOPSTART level=||level|| level_down=||level_down|| level_up=||level_up|| name=||nfld_id||
\
  ||ifdef||level_down|| ||define||foreach||level_down|| ||begin_list_foreach||+'<ul>'||end_list_foreach||\
  ||else||||ifdef||level_up|| ||define||foreach||level_up|| ||begin_list_foreach||+'</ul></li>'||end_list_foreach||\
  ||else||||iftrue(done_some)|| +'</li>'\
  ||endif||||endif||||endif||\
# // LOOPMID level=||level|| level_down=||level_down|| level_up=||level_up|| name=||nfld_id||
\
#	Some preparatory formatting
#  ||define||info1||<div class="info1">1 S</div>||
  ||if(or(equal(ftree_node,(open)),equal(ftree_node,(closed))))|| ||define||evt||onclick="return fld_expand(event)"|| ||else|| ||undef||evt|| ||endif||\
  ||define||icon||folder_icon||\
  ||iftrue(nfld_active)|| ||define||icon||folder_icon_active|| ||endif||\
  ||iftrue(nfld_shared)|| ||define||icon||folder_icon_shared|| ||endif||\
  ||define||icons_etc||(<div class="tree_icons"><div class="tog" ||evt||></div><div class="||icon||"></div></div>||info1||)||\
\
  ||if(equal(nfld_id,(INBOX)))|| ||define((inbox_unread),nfld_unread)|| ||endif||\
  ||if(greater_than(nfld_unread,0))|| ||define||unread_x||( (||nfld_unread||) )|| ||else|| ||define||unread_x|||| ||endif||  ||define||unread||( <b id="unread_||nfld_id||"> ||unread_x||</b> )||\
# Actually output folder information
  ||if(equal(level,(0)))||\
#	Customise icons if required\
  	||define||icons_etc||(<div class="tree_icons folder_icons_top"><div class="tog" ||evt||></div><div class="||icon||"></div></div>||info1||)||\
\
# 	Deal with display of special folders	
	||undef||extra||\
	||if(and(equal(nfld_id,(More Folders)),istrue(folder_fake)))|| 
	  +'<li class="myfld fake ||if(equal(pref_fldopen,(open)))||open||else||closed||endif||"><div class="full_cursor" style="padding-left:||mul(level,16)||px;">||icons_etc||<div class="folder top_lev_folder"><i>$$st_ftree_more_fld$$</i> ||extra||'
	  +'<a href="#" class="flist_link" onclick="manage_folders(event)">$$st_ftree_manage$$</a>'\
	||else||
	  +'<li class="||ftree_node||" fld_id="||web_encode_js(nfld_id)||" fld_short="||web_encode_js(nfld_short_name)||" fld_type="||fld_type||" fld_active="||nfld_active||"><div class="full_cursor" style="padding-left:||mul(level,16)||px;">||icons_etc||<div class="part_cursor folder top_lev_folder">||web_encode_js(nfld_short_name)|| ||web_encode_js(unread)||'\
	||endif||\
\
# 	Add extra links
	||if(equal(fld_type,1))||
	  +'<a href="#" class="flist_link" onclick="refresh(event)">$$st_ftree_refresh_inbox$$</a>'
# 			  Trash folder
	||else|| ||if(or(equal(fld_type,4),equal(fld_type,6)))|| 
	  +'<a href="#" class="flist_link" onclick="do_purge(event)">$$st_ftree_purge$$</a>'
	||endif|| ||endif||

	  +'</div></div>'
	
  ||else||
# 	Deal with display of normal folders	
	  +'<li class="||ftree_node||" fld_id="||web_encode_js(nfld_id)||" fld_short="||web_encode_js(nfld_short_name)||" fld_type="||fld_type||"><div class="full_cursor" style="padding-left:||mul(level,16)||px;">||icons_etc||<div class="part_cursor folder ||nfld_missing||">||web_encode_js(nfld_short_name)|| ||web_encode_js(unread)||</div></div>'
  ||endif||
  ||define||done_some||true||
# // LOOPEND level=||level|| level_down=||level_down|| level_up=||level_up|| name=||nfld_id|| folder_fake=||folder_fake||
||end_list_folders|| 
# Apply end of list formatting
#// AFTER level=||level|| level_down=||level_down|| level_up=||level_up|| name=||nfld_id|| folder_fake=||folder_fake|| fld_type = ||fld_type||
||if(and(not(blank(level_up)),equal(folder_fake,(yes))))||
	  +'<ul>'
||endif||
||ifdef||level_up|| ||define||foreach||level_up|| ||begin_list_foreach||+'</ul>'||end_list_foreach|| ||endif|| 
	  +'<div class="fld_text_spacer"></div>'

||ifndef||labels_disable|| ||ifndef||no_labels||
# *** List of Labels ***
||if(equal(pref_fldopen_label,(open)))|| ||define((ftree_node),(open))|| ||else||	||define((ftree_node),(closed))|| ||endif||
||define||evt||onclick="return fld_expand(event)"||
||define||icons_etc||(<div class="tree_icons"><div class="tog" ||evt||></div><div class="folder_icon  label_icon"></div></div>||info1||)||
||define((level),(0))||
	  +'<li class="ltree fake ||ftree_node|| folders_green_text"><div class="full_cursor" style="padding-left:||mul(level,16)||px;">||icons_etc||<div class="part_cursor folder">$$st_ftree_labels$$' 
	  +  '<a href="#" class="flist_link" onclick="manage_labels(event)">$$st_ftree_manage$$</a>'
	  +  '</div></div>'
	  +	'<ul>'
||define((ftree_node),(leaf))||	||undef||evt||
||define((level),(1))||
||begin_list_labels||\
  ||if(not(istrue(label_hidden)))||\
  ||iftrue(imap_label)|| ||define||the_icon||label_icon|| ||else|| ||define||the_icon||label_icon3|| ||endif||
  ||define||icons_etc||(<div class="tree_icons"><div class="tog" ||evt||></div><div class="folder_icon ||the_icon||"></div></div>||info1||)||
	  + '<li class="||ftree_node||" labelid="||web_encode_js(label_name)||" label_type="||iftrue(imap_label)||imap||else||surgeweb||endif||">'
	  +'<div class="full_cursor" style="padding-left:||mul(level,16)||px;">||icons_etc||<div class="part_cursor folder">||web_encode_js(label_name)||</div></div>'\

  ||endif||
||end_list_labels|| 
	  +	'</ul>'
	  +'</li>'
	  +'<div class="fld_text_spacer"></div>'
||endif|| ||endif||

# *** List of Saved Searches ***
||if(equal(pref_fldopen_search,(open)))|| ||define((ftree_node),(open))|| ||else||	||define((ftree_node),(closed))|| ||endif||
||define||evt||onclick="return fld_expand(event)"||
||define||icons_etc||(<div class="tree_icons"><div class="tog" ||evt||></div><div class="folder_icon search_icon_tree"></div></div>||info1||)||
||define((level),(0))||
	  +'<li class="stree fake ||ftree_node|| folders_green_text"><div class="full_cursor" style="padding-left:||mul(level,16)||px;">||icons_etc||<div class="part_cursor folder" title="$$st_ftree_searches_tt$$">$$st_ftree_searches$$</div></div>'
	  +	'<ul>'
||define((ftree_node),(leaf))||	||undef||evt||
||define||icons_etc||(<div class="tree_icons"><div class="tog" ||evt||></div><div class="folder_icon search_icon_tree"></div></div>||info1||)||
||define((level),(1))||
	+ '<li class="||ftree_node||" srchid="||web_encode_js((star))||" fld_type="||fld_type||"><div class="full_cursor" style="padding-left:||mul(level,16)||px;">||icons_etc||<div class="part_cursor folder">$$st_ftree_searches_str$$</div></div>'
||ifndef||labels_disable|| ||ifndef||no_labels||
	  + '<li class="||ftree_node||" srchid="||web_encode_js((label))||" fld_type="||fld_type||"><div class="full_cursor" style="padding-left:||mul(level,16)||px;">||icons_etc||<div class="part_cursor folder">$$st_ftree_searches_lbl$$</div></div>'
||endif|| ||endif||
||begin_list_saved_searches|| 
	  + '<li class="||ftree_node||" srchid="custom" search_rule="||web_encode_js(web_encode(search_rule))||">'\
		+'<span class="cm_right">'\
		+'<img src="||www_base||shared/img/1pixel.gif" class="smart_folder_delete" title="$$st_lblmng_del_search$$" onclick="delete_search(event,\'||web_encode_js(search_name)||\')">'\
		+'</span>'\
	  +	'<div class="full_cursor" style="padding-left:||mul(level,16)||px;">||icons_etc||<div class="part_cursor folder">||web_encode_js(search_name)||</div></div>'\
||end_list_saved_searches|| 
	  +	'</ul>'
	  +'</li>'

+ '</ul>');

update_fld_names({||fld_names||});
update_ssb_status('||inbox_unread||');
update_alt_account('||alt_account||','||labels_force_allow||');

||ifdef||script_block||	
</script>
||endif||	