ÿþ/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 	 C o p y r i g h t   ( c )   2 0 0 1 - 2 0 0 3   G e i r   L a n d r P  ( d r o p @ d e s t r o y d r o p . c o m )  
 	 J a v a S c r i p t   T r e e   -   w w w . d e s t r o y d r o p . c o m / h j a v a s c r i p t s / t r e e /  
 	 V e r s i o n   0 . 9 6 	  
  
 	 T h i s   s c r i p t   c a n   b e   u s e d   f r e e l y   a s   l o n g   a s   a l l   c o p y r i g h t   m e s s a g e s   a r e  
 	 i n t a c t .  
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /  
  
 / /   A r r a y s   f o r   n o d e s   a n d   i c o n s  
 v a r   n o d e s 	 	 	 =   n e w   A r r a y ( ) ; ;  
 v a r   o p e n N o d e s 	 =   n e w   A r r a y ( ) ;  
 v a r   i c o n s 	 	 	 =   n e w   A r r a y ( 6 ) ;  
  
 / /   L o a d s   a l l   i c o n s   t h a t   a r e   u s e d   i n   t h e   t r e e  
 f u n c t i o n   p r e l o a d I c o n s ( )   {  
 	 i c o n s [ 0 ]   =   n e w   I m a g e ( ) ;  
 	 i c o n s [ 0 ] . s r c   =   " i m g / p l u s . g i f " ;  
 	 i c o n s [ 1 ]   =   n e w   I m a g e ( ) ;  
 	 i c o n s [ 1 ] . s r c   =   " i m g / p l u s b o t t o m . g i f " ;  
 	 i c o n s [ 2 ]   =   n e w   I m a g e ( ) ;  
 	 i c o n s [ 2 ] . s r c   =   " i m g / m i n u s . g i f " ;  
 	 i c o n s [ 3 ]   =   n e w   I m a g e ( ) ;  
 	 i c o n s [ 3 ] . s r c   =   " i m g / m i n u s b o t t o m . g i f " ;  
 	 i c o n s [ 4 ]   =   n e w   I m a g e ( ) ;  
 	 i c o n s [ 4 ] . s r c   =   " i m g / f o l d e r . g i f " ;  
 	 i c o n s [ 5 ]   =   n e w   I m a g e ( ) ;  
 	 i c o n s [ 5 ] . s r c   =   " i m g / f o l d e r o p e n . g i f " ;  
 }  
 / /   C r e a t e   t h e   t r e e  
 f u n c t i o n   c r e a t e T r e e ( a r r N a m e ,   s t a r t N o d e ,   o p e n N o d e )   {  
 	 n o d e s   =   a r r N a m e ;  
 	 i f   ( n o d e s . l e n g t h   >   0 )   {  
 	 	 p r e l o a d I c o n s ( ) ;  
 	 	 i f   ( s t a r t N o d e   = =   n u l l )   s t a r t N o d e   =   0 ;  
 	 	 i f   ( o p e n N o d e   ! =   0   | |   o p e n N o d e   ! =   n u l l )   s e t O p e n N o d e s ( o p e n N o d e ) ;  
 	  
 	 	 i f   ( s t a r t N o d e   ! = 0 )   {  
 	 	 	 v a r   n o d e V a l u e s   =   n o d e s [ g e t A r r a y I d ( s t a r t N o d e ) ] . s p l i t ( " | " ) ;  
 	 	 	 d o c u m e n t . w r i t e ( " < a   h r e f = \ " "   +   n o d e V a l u e s [ 3 ]   +   " \ "   o n m o u s e o v e r = \ " w i n d o w . s t a t u s = ' "   +   n o d e V a l u e s [ 2 ]   +   " ' ; r e t u r n   t r u e ; \ "   o n m o u s e o u t = \ " w i n d o w . s t a t u s = '   ' ; r e t u r n   t r u e ; \ " > < i m g   s r c = \ " i m g / f o l d e r o p e n . g i f \ "   a l i g n = \ " a b s b o t t o m \ "   a l t = \ " \ "   / > "   +   n o d e V a l u e s [ 2 ]   +   " < / a > " ) ;  
 	 	 }   e l s e   d o c u m e n t . w r i t e ( " " ) ;  
 	  
 	 	 v a r   r e c u r s e d N o d e s   =   n e w   A r r a y ( ) ;  
 	 	 a d d N o d e ( s t a r t N o d e ,   r e c u r s e d N o d e s ) ;  
 	 }  
 }  
 / /   R e t u r n s   t h e   p o s i t i o n   o f   a   n o d e   i n   t h e   a r r a y  
 f u n c t i o n   g e t A r r a y I d ( n o d e )   {  
 	 f o r   ( i = 0 ;   i < n o d e s . l e n g t h ;   i + + )   {  
 	 	 v a r   n o d e V a l u e s   =   n o d e s [ i ] . s p l i t ( " | " ) ;  
 	 	 i f   ( n o d e V a l u e s [ 0 ] = = n o d e )   r e t u r n   i ;  
 	 }  
 }  
 / /   P u t s   i n   a r r a y   n o d e s   t h a t   w i l l   b e   o p e n  
 f u n c t i o n   s e t O p e n N o d e s ( o p e n N o d e )   {  
 	 f o r   ( i = 0 ;   i < n o d e s . l e n g t h ;   i + + )   {  
 	 	 v a r   n o d e V a l u e s   =   n o d e s [ i ] . s p l i t ( " | " ) ;  
 	 	 i f   ( n o d e V a l u e s [ 0 ] = = o p e n N o d e )   {  
 	 	 	 o p e n N o d e s . p u s h ( n o d e V a l u e s [ 0 ] ) ;  
 	 	 	 s e t O p e n N o d e s ( n o d e V a l u e s [ 1 ] ) ;  
 	 	 }  
 	 }    
 }  
 / /   C h e c k s   i f   a   n o d e   i s   o p e n  
 f u n c t i o n   i s N o d e O p e n ( n o d e )   {  
 	 f o r   ( i = 0 ;   i < o p e n N o d e s . l e n g t h ;   i + + )  
 	 	 i f   ( o p e n N o d e s [ i ] = = n o d e )   r e t u r n   t r u e ;  
 	 r e t u r n   f a l s e ;  
 }  
 / /   C h e c k s   i f   a   n o d e   h a s   a n y   c h i l d r e n  
 f u n c t i o n   h a s C h i l d N o d e ( p a r e n t N o d e )   {  
 	 f o r   ( i = 0 ;   i <   n o d e s . l e n g t h ;   i + + )   {  
 	 	 v a r   n o d e V a l u e s   =   n o d e s [ i ] . s p l i t ( " | " ) ;  
 	 	 i f   ( n o d e V a l u e s [ 1 ]   = =   p a r e n t N o d e )   r e t u r n   t r u e ;  
 	 }  
 	 r e t u r n   f a l s e ;  
 }  
 / /   C h e c k s   i f   a   n o d e   i s   t h e   l a s t   s i b l i n g  
 f u n c t i o n   l a s t S i b l i n g   ( n o d e ,   p a r e n t N o d e )   {  
 	 v a r   l a s t C h i l d   =   0 ;  
 	 f o r   ( i = 0 ;   i <   n o d e s . l e n g t h ;   i + + )   {  
 	 	 v a r   n o d e V a l u e s   =   n o d e s [ i ] . s p l i t ( " | " ) ;  
 	 	 i f   ( n o d e V a l u e s [ 1 ]   = =   p a r e n t N o d e )  
 	 	 	 l a s t C h i l d   =   n o d e V a l u e s [ 0 ] ;  
 	 }  
 	 i f   ( l a s t C h i l d = = n o d e )   r e t u r n   t r u e ;  
 	 r e t u r n   f a l s e ;  
 }  
 / /   A d d s   a   n e w   n o d e   t o   t h e   t r e e  
 f u n c t i o n   a d d N o d e ( p a r e n t N o d e ,   r e c u r s e d N o d e s )   {  
 	 f o r   ( v a r   i   =   0 ;   i   <   n o d e s . l e n g t h ;   i + + )   {  
  
 	 	 v a r   n o d e V a l u e s   =   n o d e s [ i ] . s p l i t ( " | " ) ;  
 	 	 i f   ( n o d e V a l u e s [ 1 ]   = =   p a r e n t N o d e )   {  
 	 	 	  
 	 	 	 v a r   l s 	 =   l a s t S i b l i n g ( n o d e V a l u e s [ 0 ] ,   n o d e V a l u e s [ 1 ] ) ;  
 	 	 	 v a r   h c n 	 =   h a s C h i l d N o d e ( n o d e V a l u e s [ 0 ] ) ;  
 	 	 	 v a r   i n o   =   i s N o d e O p e n ( n o d e V a l u e s [ 0 ] ) ;  
  
 	 	 	 / /   W r i t e   o u t   l i n e   &   e m p t y   i c o n s  
 	 	 	 f o r   ( g = 0 ;   g < r e c u r s e d N o d e s . l e n g t h ;   g + + )   {  
 	 	 	 	 i f   ( r e c u r s e d N o d e s [ g ]   = =   1 )   d o c u m e n t . w r i t e ( " < i m g   s r c = \ " i m g / l i n e . g i f \ "   a l i g n = \ " a b s b o t t o m \ "   a l t = \ " \ "   / > " ) ;  
 	 	 	 	 e l s e     d o c u m e n t . w r i t e ( " < i m g   s r c = \ " i m g / e m p t y . g i f \ "   a l i g n = \ " a b s b o t t o m \ "   a l t = \ " \ "   / > " ) ;  
 	 	 	 }  
  
 	 	 	 / /   p u t   i n   a r r a y   l i n e   &   e m p t y   i c o n s  
 	 	 	 i f   ( l s )   r e c u r s e d N o d e s . p u s h ( 0 ) ;  
 	 	 	 e l s e   r e c u r s e d N o d e s . p u s h ( 1 ) ;  
  
 	 	 	 / /   W r i t e   o u t   j o i n   i c o n s  
 	 	 	 i f   ( h c n )   {  
 	 	 	 	 i f   ( l s )   {  
 	 	 	 	 	 d o c u m e n t . w r i t e ( " < a   h r e f = \ " j a v a s c r i p t :   o c ( "   +   n o d e V a l u e s [ 0 ]   +   " ,   1 ) ; \ " > < i m g   i d = \ " j o i n "   +   n o d e V a l u e s [ 0 ]   +   " \ "   s r c = \ " i m g / " ) ;  
 	 	 	 	 	   	 i f   ( i n o )   d o c u m e n t . w r i t e ( " m i n u s " ) ;  
 	 	 	 	 	 	 e l s e   d o c u m e n t . w r i t e ( " p l u s " ) ;  
 	 	 	 	 	 d o c u m e n t . w r i t e ( " b o t t o m . g i f \ "   a l i g n = \ " a b s b o t t o m \ "   a l t = \ " O p e n / C l o s e   n o d e \ "   / > < / a > " ) ;  
 	 	 	 	 }   e l s e   {  
 	 	 	 	 	 d o c u m e n t . w r i t e ( " < a   h r e f = \ " j a v a s c r i p t :   o c ( "   +   n o d e V a l u e s [ 0 ]   +   " ,   0 ) ; \ " > < i m g   i d = \ " j o i n "   +   n o d e V a l u e s [ 0 ]   +   " \ "   s r c = \ " i m g / " ) ;  
 	 	 	 	 	 	 i f   ( i n o )   d o c u m e n t . w r i t e ( " m i n u s " ) ;  
 	 	 	 	 	 	 e l s e   d o c u m e n t . w r i t e ( " p l u s " ) ;  
 	 	 	 	 	 d o c u m e n t . w r i t e ( " . g i f \ "   a l i g n = \ " a b s b o t t o m \ "   a l t = \ " O p e n / C l o s e   n o d e \ "   / > < / a > " ) ;  
 	 	 	 	 }  
 	 	 	 }   e l s e   {  
 	 	 	 	 i f   ( l s )   d o c u m e n t . w r i t e ( " < i m g   s r c = \ " i m g / j o i n b o t t o m . g i f \ "   a l i g n = \ " a b s b o t t o m \ "   a l t = \ " \ "   / > " ) ;  
 	 	 	 	 e l s e   d o c u m e n t . w r i t e ( " < i m g   s r c = \ " i m g / j o i n . g i f \ "   a l i g n = \ " a b s b o t t o m \ "   a l t = \ " \ "   / > " ) ;  
 	 	 	 }  
  
 	 	 	 / /   S t a r t   l i n k  
 	 	 	 d o c u m e n t . w r i t e ( " < a   h r e f = \ " "   +   n o d e V a l u e s [ 3 ]   +   " \ "   o n m o u s e o v e r = \ " w i n d o w . s t a t u s = ' "   +   n o d e V a l u e s [ 2 ]   +   " ' ; r e t u r n   t r u e ; \ "   o n m o u s e o u t = \ " w i n d o w . s t a t u s = '   ' ; r e t u r n   t r u e ; \ " > " ) ;  
 	 	 	  
 	 	 	 / /   W r i t e   o u t   f o l d e r   &   p a g e   i c o n s  
 	 	 	 i f   ( h c n )   {  
 	 	 	 	 d o c u m e n t . w r i t e ( " < i m g   i d = \ " i c o n "   +   n o d e V a l u e s [ 0 ]   +   " \ "   s r c = \ " i m g / f o l d e r " )  
 	 	 	 	 	 i f   ( i n o )   d o c u m e n t . w r i t e ( " o p e n " ) ;  
 	 	 	 	 d o c u m e n t . w r i t e ( " . g i f \ "   a l i g n = \ " a b s b o t t o m \ "   a l t = \ " F o l d e r \ "   / > " ) ;  
 	 	 	 }   e l s e   d o c u m e n t . w r i t e ( " < i m g   i d = \ " i c o n "   +   n o d e V a l u e s [ 0 ]   +   " \ "   s r c = \ " i m g / p a g e . g i f \ "   a l i g n = \ " a b s b o t t o m \ "   a l t = \ " P a g e \ "   / > " ) ;  
 	 	 	  
 	 	 	 / /   W r i t e   o u t   n o d e   n a m e  
 	 	 	 d o c u m e n t . w r i t e ( n o d e V a l u e s [ 2 ] ) ;  
  
 	 	 	 / /   E n d   l i n k  
 	 	 	 d o c u m e n t . w r i t e ( " < / a > < b r   / > " ) ;  
 	 	 	  
 	 	 	 / /   I f   n o d e   h a s   c h i l d r e n   w r i t e   o u t   d i v s   a n d   g o   d e e p e r  
 	 	 	 i f   ( h c n )   {  
 	 	 	 	 d o c u m e n t . w r i t e ( " < d i v   i d = \ " d i v "   +   n o d e V a l u e s [ 0 ]   +   " \ " " ) ;  
 	 	 	 	 	 i f   ( ! i n o )   d o c u m e n t . w r i t e ( "   s t y l e = \ " d i s p l a y :   n o n e ; \ " " ) ;  
 	 	 	 	 d o c u m e n t . w r i t e ( " > " ) ;  
 	 	 	 	 a d d N o d e ( n o d e V a l u e s [ 0 ] ,   r e c u r s e d N o d e s ) ;  
 	 	 	 	 d o c u m e n t . w r i t e ( " < / d i v > " ) ;  
 	 	 	 }  
 	 	 	  
 	 	 	 / /   r e m o v e   l a s t   l i n e   o r   e m p t y   i c o n    
 	 	 	 r e c u r s e d N o d e s . p o p ( ) ;  
 	 	 }  
 	 }  
 }  
 / /   O p e n s   o r   c l o s e s   a   n o d e  
 f u n c t i o n   o c ( n o d e ,   b o t t o m )   {  
 	 v a r   t h e D i v   =   d o c u m e n t . g e t E l e m e n t B y I d ( " d i v "   +   n o d e ) ;  
 	 v a r   t h e J o i n 	 =   d o c u m e n t . g e t E l e m e n t B y I d ( " j o i n "   +   n o d e ) ;  
 	 v a r   t h e I c o n   =   d o c u m e n t . g e t E l e m e n t B y I d ( " i c o n "   +   n o d e ) ;  
 	  
 	 i f   ( t h e D i v . s t y l e . d i s p l a y   = =   ' n o n e ' )   {  
 	 	 i f   ( b o t t o m = = 1 )   t h e J o i n . s r c   =   i c o n s [ 3 ] . s r c ;  
 	 	 e l s e   t h e J o i n . s r c   =   i c o n s [ 2 ] . s r c ;  
 	 	 t h e I c o n . s r c   =   i c o n s [ 5 ] . s r c ;  
 	 	 t h e D i v . s t y l e . d i s p l a y   =   ' ' ;  
 	 }   e l s e   {  
 	 	 i f   ( b o t t o m = = 1 )   t h e J o i n . s r c   =   i c o n s [ 1 ] . s r c ;  
 	 	 e l s e   t h e J o i n . s r c   =   i c o n s [ 0 ] . s r c ;  
 	 	 t h e I c o n . s r c   =   i c o n s [ 4 ] . s r c ;  
 	 	 t h e D i v . s t y l e . d i s p l a y   =   ' n o n e ' ;  
 	 }  
 }  
 / /   P u s h   a n d   p o p   n o t   i m p l e m e n t e d   i n   I E  
 i f ( ! A r r a y . p r o t o t y p e . p u s h )   {  
 	 f u n c t i o n   a r r a y _ p u s h ( )   {  
 	 	 f o r ( v a r   i = 0 ; i < a r g u m e n t s . l e n g t h ; i + + )  
 	 	 	 t h i s [ t h i s . l e n g t h ] = a r g u m e n t s [ i ] ;  
 	 	 r e t u r n   t h i s . l e n g t h ;  
 	 }  
 	 A r r a y . p r o t o t y p e . p u s h   =   a r r a y _ p u s h ;  
 }  
 i f ( ! A r r a y . p r o t o t y p e . p o p )   {  
 	 f u n c t i o n   a r r a y _ p o p ( ) {  
 	 	 l a s t E l e m e n t   =   t h i s [ t h i s . l e n g t h - 1 ] ;  
 	 	 t h i s . l e n g t h   =   M a t h . m a x ( t h i s . l e n g t h - 1 , 0 ) ;  
 	 	 r e t u r n   l a s t E l e m e n t ;  
 	 }  
 	 A r r a y . p r o t o t y p e . p o p   =   a r r a y _ p o p ;  
 }  
 
