/**
* @file channel_tree.js
* @copyright (c) 2005 - 2007 eifr.com
* @license http://www.gnu.org/copyleft/gpl.html gnu/gpl
* eifr is free software
*/
var C_channelTree = new Object();
C_channelTree.prefix_len = 2; //"f_,d_"
C_channelTree.prefix_folder = "f_";
C_channelTree.prefix_document = "d_";
C_channelTree.prefix_img = "fimg_";

C_channelTree.showSubTree = function(sid,img_path)
{
	
	var tagO = document.getElementsByTagName('li');
	var sidlen = sid.length;

	if (document.getElementById(C_channelTree.prefix_img + sid ).src.indexOf("folder.gif")!=-1)
	{
		document.getElementById(C_channelTree.prefix_img + sid ).src = img_path+"/tree/folder-open.gif";

		for (var ti=0;ti<tagO.length;ti++)
		{    
			if(tagO[ti].id)
			{	
	    	var ary_tmpid = tagO[ti].id.split('_');
	    	if(tagO[ti].id.substr(C_channelTree.prefix_len,sidlen)==sid)
	    		{
	    		if(tagO[ti].id.substr(0,C_channelTree.prefix_len)==C_channelTree.prefix_folder  && tagO[ti].id.length==C_channelTree.prefix_len+sidlen+2)
					{ //folder
		    		tagO[ti].style.display="";
					}
					else if(tagO[ti].id.substr(0,C_channelTree.prefix_len)==C_channelTree.prefix_document  && ary_tmpid[1]==sid)
					{ //document
						tagO[ti].style.display="";
					}
	    		}
	    	
				
			} 
	  }
	  
	}
	else
	{
		document.getElementById(C_channelTree.prefix_img + sid ).src = img_path+"/tree/folder.gif";
		
		for (var ti=0;ti<tagO.length;ti++)
		{
			if(tagO[ti].id)
			{

	    	var tmpidlen = tagO[ti].id.length;
	    	if(tmpidlen>sidlen+C_channelTree.prefix_len && tagO[ti].id.substr(C_channelTree.prefix_len,sidlen)==sid)
				{
		    	tagO[ti].style.display="none";
		    	if(tagO[ti].id.substr(0,C_channelTree.prefix_len)==C_channelTree.prefix_folder)
					{
		    		document.getElementById(C_channelTree.prefix_img + tagO[ti].id.substr(C_channelTree.prefix_len,tmpidlen)).src = img_path+"/tree/folder.gif";
					}
				}
				
				
			} 
		}
	  
	}
}


C_channelTree.initSubTree = function(sid,img_path)
{
	var tagO = document.getElementsByTagName('li');
	var sidlen = sid.length;
	for (var ti=0;ti<tagO.length;ti++)
	{    
		if(tagO[ti].id)
		{	
    	tagO[ti].style.display="";
			if(tagO[ti].id.substr(0,C_channelTree.prefix_len)==C_channelTree.prefix_folder)
			{
		   	document.getElementById(C_channelTree.prefix_img + tagO[ti].id.substr(2,tagO[ti].id.length)).src = img_path+"/tree/folder-open.gif";
			}
		} 
  }

	
}
