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