Comment based on a condition

I want to comment 2 lines based on a condition. If THEN occurs immediately after WHEN then i have to comment both the lunes

For example :

 
$cat file1.txt
CASE
   WHEN
        THEN  1
   WHEN
         c1= 'I'
       AND c2= '0'
        THEN  2

So in this example i want to comment the lines as shown below.

SO the required output :

 
 
$cat file1.txt
CASE
  # WHEN
   #    THEN  1
   WHEN
             c1= 'I'
       AND c2= '0'
       THEN  2

thru sed.. (note: after \n there are 8 spaces, which is equal to a TAB space)

sed '/WHEN/{N;s/WHEN\n        THEN/#WHEN\n\t#THEN/g}' inputfile > outfile

With the assumption that 'THEN 1' is typed after a TAB space in the inputfile/file1.txt

or

sed '/WHEN/{N;s/WHEN\n *THEN/#WHEN\n\t#THEN/}' inputfile > outfile
sed '/WHEN/{N;/WHEN[[:space:]]*THEN/s/[ \t]*[WT]HEN/# &/g;}' infile
sed '/WHEN/{N;s/\(WHEN[[:space:]]*\)THEN/# \1# THEN/;}' infile