ÿþ/ /   S e t s   c o o k i e   v a l u e .   E x p i r a t i o n   d a t e   i s   o p t i o n a l  
 f u n c t i o n   s e t C o o k i e ( n a m e ,   v a l u e ,   e x p i r e d a y s )   {  
 	 v a r   E x p i r e D a t e   =   n e w   D a t e   ( ) ;  
 	 E x p i r e D a t e . s e t T i m e ( E x p i r e D a t e . g e t T i m e ( )   +   ( e x p i r e d a y s   *   2 4   *   3 6 0 0   *   1 0 0 0 ) ) ;  
 	 d o c u m e n t . c o o k i e   =   n a m e   +   " = "   +   e s c a p e ( v a l u e )   +   ( ( E x p i r e D a t e   = =   n u l l )   ?   " "   :   ( " ; e x p i r e s = "   +   E x p i r e D a t e . t o G M T S t r i n g ( ) ) ) ;  
 	 / / a l e r t ( " s e t C o o k i e : " + n a m e + " = " + v a l u e ) ;  
 }  
 / /   G e t s   c o o k i e   v a l u e  
 f u n c t i o n   g e t C o o k i e ( n a m e )   {  
 	 v a r   s e a r c h   =   n a m e   +   " = "   ;  
 	 i f   ( d o c u m e n t . c o o k i e . l e n g t h   >   0 )   {  
 	 / /   i f   t h e r e   a r e   a n y   c o o k i e s  
 	 	 o f f s e t   =   d o c u m e n t . c o o k i e . i n d e x O f ( s e a r c h ) ;  
 	 	 i f   ( o f f s e t   ! =   - 1 )   {  
 	 	 / /   i f   c o o k i e   e x i s t s  
 	 	 	 o f f s e t   + =   s e a r c h . l e n g t h ;  
 	 	 / /   s e t   i n d e x   o f   b e g i n n i n g   o f   v a l u e  
 	 	 	 e n d   =   d o c u m e n t . c o o k i e . i n d e x O f ( " ; " ,   o f f s e t ) ;  
 	 	 / /   s e t   i n d e x   o f   e n d   o f   c o o k i e   v a l u e  
 	 	 	 i f   ( e n d   = =   - 1 ) e n d   =   d o c u m e n t . c o o k i e . l e n g t h ;  
 	 	 	 / / a l e r t ( " g e t C o o k i e : " + n a m e + " = " + ( u n e s c a p e ( d o c u m e n t . c o o k i e . s u b s t r i n g ( o f f s e t ,   e n d ) ) ) ) ;  
 	 	 	 r e t u r n   u n e s c a p e ( d o c u m e n t . c o o k i e . s u b s t r i n g ( o f f s e t ,   e n d ) ) ;  
 	 	 }  
 	 }  
 }  
 / /   D e l e t e   a   c o o k i e   b y   s e t t i n g   a   p a s t   e x p i r a t i o n   d a t e  
 f u n c t i o n   d e l e t e C o o k i e ( n a m e )   {  
 	 v a r   E x p i r e D a t e   =   n e w   D a t e   ( ) ;  
 	 E x p i r e D a t e . s e t T i m e ( E x p i r e D a t e . g e t T i m e ( )   -   ( 2 4   *   3 6 0 0   *   1 0 0 0 ) ) ;  
 	 d o c u m e n t . c o o k i e   =   n a m e   +   " = "   +   " e x p i r e d "   +   " ; e x p i r e s = "   +   E x p i r e D a t e . t o G M T S t r i n g ( ) ;  
 	 / / a l e r t ( " d e l e t e C o o k i e : " + n a m e ) ;  
 }  
  
  
 f u n c t i o n   w r i t e C o o k i e ( n a m e ,   v a l u e )   {  
 	 d o c u m e n t . c o o k i e   =   n a m e   +   " = "   +   v a l u e ;  
 }  
 f u n c t i o n   r e a d C o o k i e ( n a m e )   {  
 	 v a r   s e a r c h   =   n a m e   +   " = "   ;  
 	 i f   ( d o c u m e n t . c o o k i e . l e n g t h   >   0 )   {  
 	 	 o f f s e t   =   d o c u m e n t . c o o k i e . i n d e x O f ( s e a r c h ) ;  
 	 	 i f   ( o f f s e t   ! =   - 1 )   {  
 	 	 	 o f f s e t   + =   s e a r c h . l e n g t h ;  
 	 	 	 e n d   =   d o c u m e n t . c o o k i e . i n d e x O f ( " ; " ,   o f f s e t ) ;  
 	 	 	 i f   ( e n d   = =   - 1 ) e n d   =   d o c u m e n t . c o o k i e . l e n g t h ;  
 	 	 	 r e t u r n   d o c u m e n t . c o o k i e . s u b s t r i n g ( o f f s e t ,   e n d ) ;  
 	 	 }  
 	 }  
 }  
 
