﻿ var i,j,k,randnum
 var display = new Array()
 var display_color = new Array()
 var bg_image = new Array()
 var ans = new Array()
 var ques = new Array()
 var text_pattern = new Array()
 var collect = ''
 var newId = new Array()
 var dateString = "" // Change this for different week
 var puzzleNum = "-"               // Change this for different week
 var now = new Date();
 var puzzleWeek = "Week#" + getWeek(y2k(now.getYear()),now.getMonth(),now.getDate());//this is a custom function      
 var offset_week_num = 43  //change this to start at different week
 var number_of_puzzles = 8 //total number of puzzles
                  /////////////////////////////////////////////////////////////////////////////////////////////////////
 newId[0] = "" // Explanations:
 newId[1] = "" // newId[2] = "a25" first letter 'a' corresponds to that particular fortnight a=first, b=second, etc  
 newId[2] = "" //                  second character '2' corresponds to the number of the puzzle, puzzle#2 in this case   
                 //                  third character '5' corresponds to the type of puzzle, 5 being a blank in the middle
                  /////////////////////////////////////////////////////////////////////////////////////////////////////
 
 
 week_num = getWeek(y2k(now.getYear()),now.getMonth(),now.getDate())
 if ( week_num - offset_week_num < 1 ) 
 { week_num = week_num+52
   while ( week_num - offset_week_num > number_of_puzzles ) 
   { offset_week_num = offset_week_num + number_of_puzzles
   }
 } 
 
 ans[0] = ""
 ans[1] = ""
 ans[2] = ""
 ans[3] = ""
 ans[4] = ""
 ans[5] = ""
 ans[6] = ""
 ans[7] = ""
 ans[8] = ""

 ques[0] = "&nbsp;"
 ques[1] = "&nbsp;"
 ques[2] = "&nbsp;"
 ques[3] = "&nbsp;"
 ques[4] = "&nbsp;"
 ques[5] = "&nbsp;"

//to create realtime week number since there's no getWeek()
function y2k(number) { return (number < 1000) ? number + 1900 : number; };
function getWeek(year,month,day) 
{var when = new Date(year,month,day);
 var newYear = new Date(year,0,1);
 var offset = 7 + 1 - newYear.getDay();
 if (offset == 8) offset = 1;
 var daynum = ((Date.UTC(y2k(year),when.getMonth(),when.getDate(),0,0,0) - Date.UTC(y2k(year),0,1,0,0,0)) /1000/60/60/24) + 1;
 var weeknum = Math.floor((daynum-offset+7)/7);
 if (weeknum == 0) 
 {year--;
  var prevNewYear = new Date(year,0,1);
  var prevOffset = 7 + 1 - prevNewYear.getDay();
  if (prevOffset == 2 || prevOffset == 8) weeknum = 53; else weeknum = 52;
 }
 return weeknum;
}

for (i=0;i<1;i++)
{ if ((week_num - offset_week_num)==1) 
 { newId[0] = "a00"
   newId[1] = "a13"
   newId[2] = "a25"
   break
 }
 
else if ((week_num - offset_week_num)==2) 
 { newId[0] = "b00"
   newId[1] = "b17"
   newId[2] = "b25"
   break
 }

else if ((week_num - offset_week_num)==3) 
 { newId[0] = "c00"
   newId[1] = "c14"
   newId[2] = "c25"
   break
 }

else if ((week_num - offset_week_num)==4) 
 { newId[0] = "d00"
   newId[1] = "d11"
   newId[2] = "d25"
   break
 }
 
else if ((week_num - offset_week_num)==5) 
 { newId[0] = "e00"
   newId[1] = "e19"
   newId[2] = "e25"
   break
 }

else if ((week_num - offset_week_num)==6) 
 { newId[0] = "f00"
   newId[1] = "f19"
   newId[2] = "f25"
   break
 }

else if ((week_num - offset_week_num)==7) 
 { newId[0] = "g00"
   newId[1] = "g12"
   newId[2] = "g25"
   break
 }
 
else if ((week_num - offset_week_num)==8) 
 { newId[0] = "h00"
   newId[1] = "h17"
   newId[2] = "h25"
   break
 }

else if ((week_num - offset_week_num)==9) 
 { newId[0] = "i00"
   newId[1] = "i16"
   newId[2] = "i25"
   break
 }

else if ((week_num - offset_week_num)==10) 
 { newId[0] = "j00"
   newId[1] = "j11"
   newId[2] = "j25"
   break
 }
 
else if ((week_num - offset_week_num)==11) 
 { newId[0] = "k00"
   newId[1] = "k18"
   newId[2] = "k25"
   break
 }

else if ((week_num - offset_week_num)==12) 
 { newId[0] = "l00"
   newId[1] = "l16"
   newId[2] = "l25"
   break
 }
  
else if ((week_num - offset_week_num)==13) 
 { newId[0] = "m00"
   newId[1] = "m17"
   newId[2] = "m25"
   break
 }
 
else if ((week_num - offset_week_num)==14) 
 { newId[0] = "n00"
   newId[1] = "n14"
   newId[2] = "n25"
   break
 }

else if ((week_num - offset_week_num)==15) 
 { newId[0] = "o00"
   newId[1] = "o18"
   newId[2] = "o25"
   break
 }
 
else if ((week_num - offset_week_num)==16) 
 { newId[0] = "p00"
   newId[1] = "p18"
   newId[2] = "p25"
   break
 }
 
else if ((week_num - offset_week_num)==17) 
 { newId[0] = "q00"
   newId[1] = "q14"
   newId[2] = "q25"
   break
 }

else if ((week_num - offset_week_num)==18) 
 { newId[0] = "r00"
   newId[1] = "r16"
   newId[2] = "r25"
   break
 }
 
else if ((week_num - offset_week_num)==19) 
 { newId[0] = "s00"
   newId[1] = "s12"
   newId[2] = "s25"
   break
 }
 
else if ((week_num - offset_week_num)==20) 
 { newId[0] = "t00"
   newId[1] = "t12"
   newId[2] = "t25"
   break
 }

else if ((week_num - offset_week_num)==21) 
 { newId[0] = "u00"
   newId[1] = "u19"
   newId[2] = "u25"
   break
 } 

else if ((week_num - offset_week_num)==22) 
 { newId[0] = "v00"
   newId[1] = "v14"
   newId[2] = "v25"
   break
 }
 
else if ((week_num - offset_week_num)==23) 
 { newId[0] = "w00"
   newId[1] = "w11"
   newId[2] = "w25"
   break
 }

else if ((week_num - offset_week_num)==24) 
 { newId[0] = "x00"
   newId[1] = "x11"
   newId[2] = "x25"
   break
 }

else if ((week_num - offset_week_num)==25) 
 { newId[0] = "y00"
   newId[1] = "y11"
   newId[2] = "y25"
   break
 }
 
else if ((week_num - offset_week_num)==26) 
 { newId[0] = "z00"
   newId[1] = "z19"
   newId[2] = "z25"
   break
 }

else if ((week_num - offset_week_num)==27) 
 { newId[0] = "a00a"
   newId[1] = "a17a"
   newId[2] = "a25a"
   break
 }
  
else if ((week_num - offset_week_num)==28) 
 { newId[0] = "b00a"
   newId[1] = "b16a"
   newId[2] = "b25a"
   break
 }
 
else if ((week_num - offset_week_num)==29) 
 { newId[0] = "c00a"
   newId[1] = "c14a"
   newId[2] = "c25a"
   break
 }

else if ((week_num - offset_week_num)==30) 
 { newId[0] = "d00a"
   newId[1] = "d11a"
   newId[2] = "d25a"
   break
 }
 
else if ((week_num - offset_week_num)==31) 
 { newId[0] = "e00a"
   newId[1] = "e11a"
   newId[2] = "e25a"
   break
 }
 
else if ((week_num - offset_week_num)==32) 
 { newId[0] = "f00a"
   newId[1] = "f17a"
   newId[2] = "f25a"
   break
 }

else if ((week_num - offset_week_num)==33) 
 { newId[0] = "g00a"
   newId[1] = "g19a"
   newId[2] = "g25a"
   break
 }
 
else if ((week_num - offset_week_num)==34) 
 { newId[0] = "h00a"
   newId[1] = "h16a"
   newId[2] = "h25a"
   break
 }
 
else if ((week_num - offset_week_num)==35) 
 { newId[0] = "i00a"
   newId[1] = "i13a"
   newId[2] = "i25a"
   break
 }

else if ((week_num - offset_week_num)==36) 
 { newId[0] = "j00a"
   newId[1] = "j11a"
   newId[2] = "j25a"
   break
 }

else if ((week_num - offset_week_num)==33) 
 { newId[0] = "k00a"
   newId[1] = "k19a"
   newId[2] = "k25a"
   break
 }
 
else if ((week_num - offset_week_num)==34) 
 { newId[0] = "l00a"
   newId[1] = "l11a"
   newId[2] = "l25a"
   break
 }
 
else if ((week_num - offset_week_num)==35) 
 { newId[0] = "m00a"
   newId[1] = "m17a"
   newId[2] = "m25a"
   break
 }

else if ((week_num - offset_week_num)==36) 
 { newId[0] = "n00a"
   newId[1] = "n13a"
   newId[2] = "n25a"
   break
 }
 
else
 { newId[0] = "z00"
   newId[1] = "z19"
   newId[2] = "z25"
   break
 }   
   
} 
 
 
for (i=0;i<3;i++)
{catchNode = document.getElementById(i);
 catchNode.setAttribute('id',newId[i]); // to change the id/configuration of the puzzles
 this_icon = "icon_choice" + i
 which_icon = "image/box" + newId[i].charAt('2') +".jpg"
 catchicon_choice = document.getElementById(this_icon)
 catchicon_choice.setAttribute('src',which_icon) // to change to the right icon for the puzzles
}

 puzzleText = " Puzzle#" + puzzleNum + " " + puzzleWeek
 thisNum = document.createTextNode(puzzleText);
 numNode = document.getElementById("puzzle_number_text");
 numNode.appendChild(thisNum) // to insert the corresponding text on the title

/*
 nextDate = document.createTextNode(dateString);
 dateNode = document.getElementById("puzzle_number_notes_text");
 dateNode.appendChild(nextDate); // to change to the date for the next puzzle
*/

 

function mouseover(thisId)
{var changethis ="choice" + thisId.charAt('1')
 var changethistoo = "select_content" + thisId.charAt('1')
 document.getElementById(changethis).style.backgroundColor = '#1a4d91'; // to change the background color of the menu when it is selected
 document.getElementById(changethistoo).style.color='#e4e4ea'; // to change the color of the text when it is selected
}

function mouseout(thisId)
{var changethis ="choice" + thisId.charAt('1')
 var changethistoo = "select_content" + thisId.charAt('1')
 document.getElementById(changethis).style.backgroundColor = '#e4e4ea'; // to change back the background color when unselected
 document.getElementById(changethistoo).style.color='black'; //  to change the back the color of the text when it is unselected
}

function fetch(thisId) // this is called when the selection is clicked
{var fetchthis = "puzzle_" + thisId + ".htm"
 window.open(fetchthis,"_self") // to open the corresponding puzzle file
}

function mouseoverhome(thisId)
{document.getElementById("choice" + thisId).style.backgroundColor = '#1a4d91'; // to change the background color of the menu when it is selected
 document.getElementById("select_content" + thisId).style.color='#e4e4ea'; // to change the color of the text when it is selected
}

function mouseouthome(thisId)
{document.getElementById("choice" + thisId).style.backgroundColor = '#e4e4ea'; // to change the background color of the menu when it is selected
 document.getElementById("select_content" + thisId).style.color='black'; // to change the color of the text when it is selected
}

function fetchhome()// this is called when home is clicked
{ window.open("index.htm","_self") // to open the corresponding puzzle file
}

for (var num = 0; num < 3; num++) // to generate randum image for left, center and right islet
 { randnum=Math.random()*4-0.5;
   randnum=Math.round(randnum);
   if (num==0) i=randnum;
   if (num==1) j=randnum;
   if (num==2) k=randnum;
   if (num==2 && j==k) num = 1;
 }

which_image = "image/bg_puzzle_center" + i +".jpg"
change_center_islet = document.getElementById("puzzle_center")
change_center_islet.setAttribute("src",which_image) 

 
 // self generate new Arrays
 for (i = 0; i < 9; i++)
  { display[i] = '?'           //initialise array member with "?"
    display_color[i] = 'black' //initialise array member with "black"
    bg_image[i] = 'text'           //initialise array member with "text"	
  }

 for (i = 0; i < 6; i++)
  { text_pattern[i] =''        //initialise array member with ""
  }

 document.forms.fun_puzzle.typein[0].focus() //to select first column initially
 tell(document.forms.fun_puzzle);
 
 function tell(puzzle,which)
{ var gather = ""
  var total_letter_correct = 0
  var bg = ""
 
  doc = window.open("","right")
  doc.document.close()
 
  doc1 = window.open("","left")
  doc1.document.close()

//check whether input to any textbox form[0].typein[i].value is correct and process color and background accordingly
  if(which!='typein'&& which!='select1'&& which!='select2'&& which!='select3'&&which!='select4'&&which!='select5'
     &&which!='select6'&&which!='select7'&&which!='select8'&&which!='select9')//such that onfocus or onblur will not reveal answer
 {for (i = 0; i < 6; i++)
  { text_pattern[i] ='normal'        //initialise array member with "normal"
  }
  for (i = 0; i < 9; i++)
  { if (puzzle.typein[i].value != "")
   { if (puzzle.typein[i].value == ans[i])
     { display[i] = ans[i]
       display_color[i] = 'black'
       bg_image[i] = 'id="tick"'
       total_letter_correct = total_letter_correct + 1
     } 
     else
     { display[i] = puzzle.typein[i].value
       display_color[i] = 'black'
       bg_image[i] = 'id="wrong"'
     } 
   }
   else
   { display[i] = "?"
     display_color[i] = 'black'
     bg_image[i] = 'id="text"'
   }
  }
 
 for (i = 0; i < 2; i++)
  { gather = ""//reset gather otherwise gather will be twice gathered
    if (i == 0)
   { bg = "bg_puzzle_side" + j + ".jpg"
   }
   if(i == 1)
   { bg = "bg_puzzle_side" + k + ".jpg"
   }
 //gathering text and table to print results on the left and the right  
 gather += "<html><head><style type='text/css'>"
 gather += "p{font-size:15;font-weight:600;font-family:Comic Sans MS,Microsoft Sans Serif;text-align:center};"
 gather += "p#before_results{position:relative;top:43;margin-top:0}"
 gather += "table#puzzle_table{position:relative;top:43}"
 gather += "#style1{height:21;width:5;background-color:#1a4d91};#style1short{height:5;background-color:#1a4d91}"
 gather += "td#tick{width:21;border:3px inset;background-image:url('image/tick.gif')};"
 gather += "td#normal{width:21};td#empty{height:21; width:5}"
 gather += "td#text{width:21;border:3px inset;background-color:#e4e4ea}"
 gather += "td#wrong{width:21;border:3px inset;background-image:url('image/wrong.jpg')}"
 gather += "body{background-image:url('image/" + bg + "')};</style></head>"
 gather += '<body><table id="puzzle_table" align="center" border="0" cellpadding="0" cellspacing="0">'
 
 gather += '<tr><td id="normal"></td><td id="empty"></td>'
 gather += '<td id="normal"><p>1d</td><td id="empty"></td>'
 gather += '<td id="normal"><p>2d</td><td id="empty"></td>'
 gather += '<td id="normal"><p>3d</td><td id="empty"></td></tr>'
 
 gather += '<tr><td></td><td id="style1short" colspan="7"></td></tr>'
 gather += '<tr><td id="normal"><p style="text-align:left;color:' + display_color[9] + '">1a</td>'
 gather += '<td id="style1"></td>'
 gather += '<td ' + bg_image[0] + '><p " style="color:' + display_color[0] + '">' + display[0] + '</td>'
 gather += '<td id="style1"></td>'
 gather += '<td ' + bg_image[1] + '><p " style="color:' + display_color[1] + '">' + display[1] + '</td>'
 gather += '<td id="style1"></td>'
 gather += '<td ' + bg_image[2] + '><p " style="color:' + display_color[2] + '">' + display[2] + '</td>'
 gather += '<td id="style1"></td></tr>'
    
 gather += '<tr><td></td><td id="style1short" colspan="7"></td></tr>'
 gather += '<tr><td id="normal"><p style="text-align:left;color:' + display_color[10] + '">2a</td>'
 gather += '<td id="style1"></td>'
 gather += '<td ' + bg_image[3] + '><p " style="color:' + display_color[3] + '">' + display[3] + '</td>'
 gather += '<td id="style1"></td>'
 gather += '<td ' + bg_image[4] + '><p " style="color:' + display_color[4] + '">' + display[4] + '</td>'
 gather += '<td id="style1"></td>'
 gather += '<td ' + bg_image[5] + '><p " style="color:' + display_color[5] + '">' + display[5] + '</td>'
 gather += '<td id="style1"></td></tr>'
    
 gather += '<tr><td></td><td id="style1short" colspan="7"></td></tr>'
 gather += '<tr><td id="normal"><p style="text-align:left;color:' + display_color[11] + '">3a</td>'
 gather += '<td id="style1"></td>'
 gather += '<td ' + bg_image[6] + '><p " style="color:' + display_color[6] + '">' + display[6] + '</td>'
 gather += '<td id="style1"></td>'
 gather += '<td ' + bg_image[7] + '><p " style="color:' + display_color[7] + '">' + display[7] + '</td>'
 gather += '<td id="style1"></td>'
 gather += '<td ' + bg_image[8] + '><p " style="color:' + display_color[8] + '">' + display[8] + '</td>'
 gather += '<td id="style1"></td></tr>'
    
 gather += '<tr><td></td><td id="style1short" colspan="7"></td></tr>'
     
 gather += "</table>"
 
 if(total_letter_correct == 9)
   { gather += '<p id="before_results" style="color:blue">Congratulations, you have solved the puzzle!</p></body></html>'
   }
 else
   { gather += '<p id="before_results">&nbsp;&nbsp;&nbsp;Results</p></body></html>'
   }
 
 if (i == 0)
   { doc.document.write(gather);
   }
 if(i == 1)
   { doc1.document.write(gather);
   }
  }
 //change color of question text if the answer is correct
  if(puzzle.typein[0].value == ans[0] && puzzle.typein[1].value == ans[1] && puzzle.typein[2].value == ans[2])
  { text_pattern[0] = 'correct'
  }
  else if(puzzle.typein[0].value && puzzle.typein[1].value && puzzle.typein[2].value)
  { text_pattern[0] = 'wrong'
  }
  if(puzzle.typein[3].value == ans[3] && puzzle.typein[4].value == ans[4] && puzzle.typein[5].value == ans[5])
  { text_pattern[1] = 'correct'
  }
  else if(puzzle.typein[3].value && puzzle.typein[4].value && puzzle.typein[5].value)
  { text_pattern[1] = 'wrong'
  }
  if(puzzle.typein[6].value == ans[6] && puzzle.typein[7].value == ans[7] && puzzle.typein[8].value == ans[8])
  { text_pattern[2] = 'correct'
  }
  else if(puzzle.typein[6].value && puzzle.typein[7].value && puzzle.typein[8].value)
  { text_pattern[2] = 'wrong'
  }
  if(puzzle.typein[0].value == ans[0] && puzzle.typein[3].value == ans[3] && puzzle.typein[6].value == ans[6])
  { text_pattern[3] = 'correct'
  }
  else if(puzzle.typein[0].value && puzzle.typein[3].value && puzzle.typein[6].value)
  { text_pattern[3] = 'wrong'
  }
  if(puzzle.typein[1].value == ans[1] && puzzle.typein[4].value == ans[4] && puzzle.typein[7].value == ans[7])
  { text_pattern[4] = 'correct'
  }
  else if(puzzle.typein[1].value && puzzle.typein[4].value && puzzle.typein[7].value)
  { text_pattern[4] = 'wrong'
  }
  if(puzzle.typein[2].value == ans[2] && puzzle.typein[5].value == ans[5] && puzzle.typein[8].value == ans[8])
  { text_pattern[5] = 'correct'
  } 
  else if(puzzle.typein[2].value && puzzle.typein[5].value && puzzle.typein[8].value)
  { text_pattern[5] = 'wrong'
  }
 }
 
 
 
  var collect = ""
  var i = 0
  
  
  //to highlight the appropriate question based on which box is selected
  for(i = 0; i < 6; i++) //if text_pattern[i] is not correct reset to black otherwise highlight will remain!
   { if(text_pattern[i] != 'correct'&& text_pattern[i] != 'wrong')
     { text_pattern[i] = 'normal'
     }
   }
  
  
  if(which == 'select1') 
  { if(text_pattern[0] != 'correct') 
    {text_pattern[0] = 'highlight'
    }
    if(text_pattern[3] != 'correct')
    {text_pattern[3] = 'highlight'
    }
  }
  
  else if(which == 'select2') 
  { if(text_pattern[0] != 'correct') 
    {text_pattern[0] = 'highlight'
    }
    if(text_pattern[4] != 'correct')
    {text_pattern[4] = 'highlight'
    }
  }
  
  else if(which == 'select3') 
  { if(text_pattern[0] != 'correct') 
    {text_pattern[0] = 'highlight'
    }
    if(text_pattern[5] != 'correct')
    {text_pattern[5] = 'highlight'
    }
  }
  else if(which == 'select4') 
  { if(text_pattern[1] != 'correct') 
    {text_pattern[1] = 'highlight'
    }
    if(text_pattern[3] != 'correct')
    {text_pattern[3] = 'highlight'
    }
  }
  else if(which == 'select5') 
  { if(text_pattern[1] != 'correct') 
    {text_pattern[1] = 'highlight'
    }
    if(text_pattern[4] != 'correct')
    {text_pattern[4] = 'highlight'
    }
  }
  else if(which == 'select6') 
  { if(text_pattern[1] != 'correct') 
    {text_pattern[1] = 'highlight'
    }
    if(text_pattern[5] != 'correct')
    {text_pattern[5] = 'highlight'
    }
  }
  else if(which == 'select7') 
  { if(text_pattern[2] != 'correct') 
    {text_pattern[2] = 'highlight'
    }
    if(text_pattern[3] != 'correct')
    {text_pattern[3] = 'highlight'
    }
  }
  else if(which == 'select8') 
  { if(text_pattern[2] != 'correct') 
    {text_pattern[2] = 'highlight'
    }
    if(text_pattern[4] != 'correct')
    {text_pattern[4] = 'highlight'
    }
  }
  else if(which == 'select9') 
  { if(text_pattern[2] != 'correct') 
    {text_pattern[2] = 'highlight'
    }
    if(text_pattern[5] != 'correct')
    {text_pattern[5] = 'highlight'
    }
  }
  
  
  doc2 = window.open("","middle")
  doc2.document.close()
  //Collecting Questions for printing
  collect += "<html><head><style type='text/css'>"
  collect += "#init{font-size:16;font-weight:400;font-family:Comic Sans MS,Microsoft Sans Serif;text-decoration:underline;text-align:center};"
  collect += "div{padding:0;margin:0;border:0;text-align:left;font-weight:400;font-family:Comic Sans MS,Microsoft Sans Serif;}"
  collect += "#normal{color:black};#highlight{color:#0000cc};#colorstrip{background-color:#1a4d91};"
  collect += "div#wrong{color:#cc0000};div#correct{color:#00cc00};"
  collect += "body{background-image:url('image/bg_middle.jpg')};td#laminate{vertical-align:top;padding-right:3px;padding-left:3px;border:inset;background-image:url('image/laminate_middle.jpg')};"
  collect += "</style></head><body>"
  collect += '<table width="779" align="center" border="0" cellspacing="0" cellpadding="0">'
  collect += '<tr><td height="4" width="8"></td><td id="colorstrip" colspan="3"></td><td width="8"></td>'
  collect += '<td id="colorstrip" colspan="3"></td><td width="8"></td></tr>'
  collect += '<tr><td width="8"></td><td id="colorstrip" width="4"></td><td valign="middle" id="laminate" width="369">'
  collect += '<div id="">move your mouse over <img src="image/select_small.jpg"/> '
  collect += 'to select a puzzle.</div>'
  collect += '<div id="' + text_pattern[0] +'">' + ques[0] + '</div>'
  collect += '<div id="' + text_pattern[1] +'">' + ques[1] + '</div>'
  collect += '<div id="' + text_pattern[2] +'">' + ques[2] + '</div></td>'
  collect += '<td id="colorstrip" width="4"></td><td width="8"></td><td id="colorstrip" width="4"></td>'
  collect += '<td id="laminate" width="369">'
  collect += '<div id="">move your mouse over <img src="image/select_small.jpg"/> '
  collect += 'to select a puzzle.</div>'
  collect += '<div id="' + text_pattern[3] +'">' + ques[3] + '</div>'
  collect += '<div id="' + text_pattern[4] +'">' + ques[4] + '</div>'
  collect += '<div id="' + text_pattern[5] +'">' + ques[5] + '</div></td>'
  collect += '<td id="colorstrip" width="4"></td><td width="8"></td></tr>'
  collect += '<tr><td height="4" width="8"></td><td id="colorstrip" colspan="3"></td><td width="8"></td>'
  collect += '<td id="colorstrip" colspan="3"></td><td width="8"></td></tr>'
  collect += '</table></body></html>'
  doc2.document.write(collect);
}


