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