<?php
function print_section1($Qkey,$QArray,$trg_sample,$per_sample,$bnch_sample,$bper_sample,$usr_opts,$language_array,$fromdash=0) {
?>	
                <tr id="<?php echo $Qkey; ?>"   <?php if($fromdash==0) { echo  'style="display:none"'; } ?> >
                    <td>
                    <?php
					if($trg_sample<=0) {
                    ?>
                    <table width="99%" border="0" cellpadding="10" cellspacing="0" align="center">
                    	<tr>
                        	<td height="20px" width="100%">
                                
                            </td>
                        </tr>                        

                    	<tr>
                        	<td align="center">
                            
                            	<img src="pcd/images/no-data.png" title="No Data Available" align="middle" />
                                
                            </td>
                        </tr>
                    	<tr>
                        	<td height="20px">
                                
                            </td>
                        </tr>                        
					</table>                    
                    <?php
					}
					else {
					?>
                    <table width="99.9%" cellpadding="3">
                    	<?php if($fromdash==0) {  // Print only graph ?>  
                    
                    
                    	<tr>
                        	<td height="0px" width="2%"></td>
                            <td width="34%"></td>
                            <td width="34%"></td>
                            <td width="5%"></td>
                            <td width="5%"></td>
                            <td width="5%"></td>
                            <td width="5%"></td>
                            <td width="5%"></td>
                            <td width="5%"></td>
                        </tr>
                        <tr>
                          <td colspan="2" rowspan="2" align="<?php if($_SESSION["seas_brd_language"]==2) echo "right"; else "left"; ?>" valign="top" class="tbl_cellHdr"><strong><?php echo $QArray[0]; ?></strong></td>
                          <td rowspan="2" align="center" valign="top" class="tbl_cellHdr"><?php 
						  if(strlen($_SESSION["seas_brd_filter_text"])>0) {
						   echo $_SESSION["seas_brd_filter_text"]."<br />"; 
						  }
						  echo $_SESSION["seas_brd_target_sample_text"];

							 if($trg_sample <=50) { 
								echo "<br><font color='red'>". $language_array['caution_small_sample_size'] ."</font>";	
							 }
						 
						  echo "<br>";
						  echo $_SESSION["seas_brd_benchmark_sample_text"];
						  
						  ?>


                            </td>
                          <td height="25" colspan="6" align="center" valign="top" class="tbl_cellHdr"><strong><?php  
							echo $language_array['opinion'];
							?></strong></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <?php if($usr_opts[0]==1) { ?><td height="25" align="center" valign="top" bgcolor="#9BFF9B" class="tbl_cellHdr_str"><strong><?php  
						  	echo $language_array['strength'];
							?></strong></td><?php } ?>
                          <?php if($usr_opts[1]==1) { ?>
                          <td align="center" valign="top" class="tbl_cellHdr_chr"><strong><?php  
						  	echo $language_array['tone'];
							?></strong></td><?php } ?>
                          <?php if($usr_opts[2]==1) { ?><td align="center" valign="top" bgcolor="#FFFFCC" class="tbl_cellHdr_pos"><strong><?php  
						  	echo $language_array['positive'];
							?></strong></td><?php } ?>
                          <?php if($usr_opts[3]==1) { ?><td align="center" valign="top" bgcolor="#FFFFCC" class="tbl_cellHdr_neg"><strong><?php  
						  	echo $language_array['negative'];
							?></strong></td><?php } ?>
                          <?php if($usr_opts[4]==1) { ?><td align="center" valign="top" bgcolor="#FFFFCC" class="tbl_cellHdr_avg"><strong><?php  
						  	echo $language_array['average'];
							?></strong></td><?php } ?>
                        </tr>
                       
						   <tr>
						     <td height="5" colspan="2" align="center" valign="top" class="tbl_cell">&nbsp;</td>
						     <td align="center" valign="middle" class="tbl_cell" style="vertical-align: middle">
						       <img src="pcd/images/scale.png" align="middle" />
						    </td>
						     <td colspan="6"  align="<?php if($_SESSION["seas_brd_language"]==2) echo "right"; else "left"; ?>" nowrap="nowrap" class="tbl_cell">&nbsp;</td>
				      </tr>
                       
                       <?php
						if($_SESSION["seas_brd_language"]==2) {
							$alpha =array("ا","ب","ج","د","ه","و","ز","ح","ط","ي","ك","ل","م","ن","س","ع","ف","ص","ق","ر","ش","ت","ث","خ","ذ","ض");
						}
						else {
							$alpha =array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
						}
					   
					   $icnt=0;
				   
					   foreach($QArray[1] as $QKy=>$QText) {
						   ?>						   

						   <tr>
							  <td height="30" align="center" valign="top" class="tbl_cell"><?php if($Qkey!="Q99") echo $alpha[$QKy]; ?></td>
							  <td align="<?php if($_SESSION["seas_brd_language"]==2) echo "right"; else "left"; ?>" valign="top" class="tbl_cell"><?php echo $QText; ?></td>
							  <td align="center" valign="middle" class="tbl_cell" style="vertical-align: middle"><?php createGraph($QArray[3][$QKy]); ?></td>
                              <td  align="<?php if($_SESSION["seas_brd_language"]==2) echo "right"; else "left"; ?>" nowrap="nowrap" class="tbl_cell"><?php  
						  	echo $language_array['tgt'];
							?><br /><?php if(strlen($_SESSION["seas_brd_bnch_filter_condition"])>0) 
							{ 
						  	echo $language_array['bmk'];
							echo "<br />"; } ?><?php  
							echo $language_array['idx'];
							?></td>
					        <?php if($usr_opts[0]==1) { ?><td align="center" valign="top" class="tbl_cell"><?php echo pr_target($QArray[3][$QKy][2],$language_array); echo pr_benchmark($QArray[3][$QKy][9],$language_array); echo pr_index($QArray[4][$QKy][0],$language_array); ?></td><?php } ?>
							  <?php if($usr_opts[1]==1) { ?><td align="center" valign="top" class="tbl_cell"><?php echo pr_target($QArray[3][$QKy][3],$language_array); echo pr_benchmark($QArray[3][$QKy][10],$language_array); echo pr_index($QArray[4][$QKy][1],$language_array); ?></td><?php } ?>
							  <?php if($usr_opts[2]==1) { ?><td align="center" valign="top" class="tbl_cell"><?php echo pr_target($QArray[3][$QKy][0],$language_array); echo pr_benchmark($QArray[3][$QKy][7],$language_array); echo pr_index($QArray[4][$QKy][4],$language_array); ?></td><?php } ?>
							  <?php if($usr_opts[3]==1) { ?><td align="center" valign="top" class="tbl_cell"><?php echo pr_target($QArray[3][$QKy][1],$language_array); echo pr_benchmark($QArray[3][$QKy][8],$language_array); echo pr_index($QArray[4][$QKy][3],$language_array); ?></td><?php } ?>
							  <?php if($usr_opts[4]==1) { ?><td align="center" valign="top" class="tbl_cell"><?php echo pr_target($QArray[3][$QKy][4],$language_array); echo pr_benchmark($QArray[3][$QKy][11],$language_array); echo pr_index($QArray[4][$QKy][2],$language_array); ?></td><?php } ?>
						  </tr>
						  <?php
							$icnt++;
					   }
					   if($icnt>1) {  // Print only if there is multiple questions in that group
						  ?>
						   <tr>
							  <td height="30" align="center" valign="top" class="tbl_cell">&nbsp;</td>
					        <td align="<?php if($_SESSION["seas_brd_language"]==2) echo "right"; else "left"; ?>" valign="top" class="tbl_cell"><strong><?php echo $QArray[2]; ?></strong></td>
							  <td align="center" valign="middle" class="tbl_cell" style="vertical-align: middle"><?php  $qs=array(0,0,$QArray[5][0],$QArray[5][1],0,0,0,0,0,$QArray[5][5],$QArray[5][6]); createGraph($qs); ?></td>
                              <td  align="<?php if($_SESSION["seas_brd_language"]==2) echo "right"; else "left"; ?>" nowrap="nowrap" class="tbl_cell"><?php  
						  	echo $language_array['tgt'];
							?><br /><?php if(strlen($_SESSION["seas_brd_bnch_filter_condition"])>0) 
							{ 
						  	echo $language_array['bmk'];
							echo "<br />"; } ?><?php  
							echo $language_array['idx'];
							?></td>
					        <?php if($usr_opts[0]==1) { ?><td align="center" valign="top" class="tbl_cell"><?php echo pr_target($QArray[5][0],$language_array); echo pr_benchmark($QArray[5][5],$language_array); echo pr_index($QArray[6][0],$language_array); ?></td><?php } ?>
						     <?php if($usr_opts[1]==1) { ?><td align="center" valign="top" class="tbl_cell"><?php echo pr_target($QArray[5][1],$language_array); echo pr_benchmark($QArray[5][6],$language_array); echo pr_index($QArray[6][1],$language_array); ?></td><?php } ?>
						     <?php if($usr_opts[2]==1) { ?><td align="center" valign="top" class="tbl_cell"><?php echo pr_target($QArray[5][2],$language_array); echo pr_benchmark($QArray[5][7],$language_array); echo pr_index($QArray[6][2],$language_array); ?></td><?php } ?>
						     <?php if($usr_opts[3]==1) { ?><td align="center" valign="top" class="tbl_cell"><?php echo pr_target($QArray[5][3],$language_array); echo pr_benchmark($QArray[5][8],$language_array); echo pr_index($QArray[6][3],$language_array); ?></td><?php } ?>
							  <?php if($usr_opts[4]==1) { ?><td align="center" valign="top" class="tbl_cell"><?php echo pr_target($QArray[5][4],$language_array); echo pr_benchmark($QArray[5][9],$language_array); echo pr_index($QArray[6][4],$language_array); ?></td><?php } ?>
						  </tr>                      
						  <?php
					   }
					  ?>

					  <?php
					   if($icnt>5) {  // Print only if there is questions more than 5 in that group
					  ?>
						   <tr>
						     <td height="5" colspan="2" align="center" valign="top" class="tbl_cell">&nbsp;</td>
						     <td align="center" valign="middle" class="tbl_cell" style="vertical-align: middle">
						       <img src="pcd/images/scale.png" align="middle" />
						    </td>
						     <td colspan="6"  align="<?php if($_SESSION["seas_brd_language"]==2) echo "right"; else "left"; ?>" nowrap="nowrap" class="tbl_cell">&nbsp;</td>
				      </tr>                      
                        <tr>
                          <td colspan="2" rowspan="2" align="<?php if($_SESSION["seas_brd_language"]==2) echo "right"; else "left"; ?>" valign="top" class="tbl_cellHdr"><strong><?php echo $QArray[0]; ?></strong></td>
                          <td rowspan="2" align="center" valign="top" class="tbl_cellHdr"><?php 
						  if(strlen($_SESSION["seas_brd_filter_text"])>0) {
						   echo $_SESSION["seas_brd_filter_text"]."<br />"; 
						  }
						  echo $_SESSION["seas_brd_target_sample_text"];

							 if($trg_sample <=50) { 
								echo "<br><font color='red'>Caution :Small Sample Size</font>";	
							 }
						 
						  echo "<br>";
						  echo $_SESSION["seas_brd_benchmark_sample_text"];
						  
						  ?></td>
                            <td>&nbsp;</td>
                          <?php if($usr_opts[0]==1) { ?><td height="25" align="center" valign="top" bgcolor="#9BFF9B" class="tbl_cellHdr_str"><strong>
                            <?php  
						  	echo $language_array['strength'];
							?>
                          </strong></td><?php } ?>
                          <?php if($usr_opts[1]==1) { ?>
                          <td align="center" valign="top" class="tbl_cellHdr_chr"><strong>
                            <?php  
						  	echo $language_array['tone'];
							?>
                          </strong></td><?php } ?>
                          <?php if($usr_opts[2]==1) { ?><td align="center" valign="top" bgcolor="#FFFFCC" class="tbl_cellHdr_pos"><strong>
                            <?php  
						  	echo $language_array['positive'];
							?>
                          </strong></td><?php } ?>
                          <?php if($usr_opts[3]==1) { ?><td align="center" valign="top" bgcolor="#FFFFCC" class="tbl_cellHdr_neg"><strong>
                            <?php  
						  	echo $language_array['negative'];
							?>
                          </strong></td><?php } ?>
                          <?php if($usr_opts[4]==1) { ?><td align="center" valign="top" bgcolor="#FFFFCC" class="tbl_cellHdr_avg"><strong>
                            <?php  
						  	echo $language_array['average'];
							?>
                          </strong></td>
             <?php } ?>           </tr>
                        <tr>
                          <td height="25" colspan="6" align="center" valign="top" class="tbl_cellHdr"><strong>
                            <?php  
						  	echo $language_array['opinion'];
							?>
                          </strong></td>

                        </tr> 
                      <?php
					   }
					   
						} // Print only graph
						else {
							
							$icnt =2;
						}
						
					   if($icnt>1) {  // Print only if there is multiple questions in that group
					  ?>
                      
                        <tr>
                            <td colspan="9" align="center" style="background-color:#FFF; border:thin dotted">
                                <?php
								
								$P_Avg=array();
								$N_Avg=array();
								$S_Avg=array();
								$C_Avg=array();
								$A_Avg=array();
								$lbls =array();

								foreach($QArray[3] as $QScore) {
									$P_Avg[] = $QScore[0];
									$N_Avg[] = $QScore[1];
									$S_Avg[] = $QScore[2];
									$C_Avg[] = $QScore[3];
									$A_Avg[] = $QScore[4];
									
									//For benchmark
									if(strlen($_SESSION["seas_brd_bnch_filter_condition"])>0) {
										$P_Avg[] = $QScore[7];
										$N_Avg[] = $QScore[8];
										$S_Avg[] = $QScore[9];
										$C_Avg[] = $QScore[10];
										$A_Avg[] = $QScore[11];
									}
								}
								
								if($_SESSION["seas_brd_language"]==2) {
									$alpha =array("ا","ب","ج","د","ه","و","ز","ح","ط","ي","ك","ل","م","ن","س","ع","ف","ص","ق","ر","ش","ت","ث","خ","ذ","ض");
								}
								else {
									$alpha =array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
								}
								$alcount=0;
								$alphatext = "";
								foreach($QArray[1] as $lb) {
									if($Qkey!="Q99") {
										$alphatext = $alpha[$alcount] . ". ";		
									}
									else {
										$alphatext = "";
									}
									
									$lbls[]  =  $alphatext . $lb;	
									if(strlen($_SESSION["seas_brd_bnch_filter_condition"])>0) {
										if($Qkey=="Q99") {
											$qr = explode(".",$lb);
											$alphatext = $qr[0].". ";
										}
										$lbls[]  = $alphatext . $language_array['benchmark'];	
									}
									$alcount++;
								}
								
								
								// Labels for overall
								$lbls[]  = $language_array['qes_gen_1'];
								if(strlen($_SESSION["seas_brd_bnch_filter_condition"])>0) {
									$lbls[]  = $language_array['benchmark'];
								}
								
								foreach($lbls as $kylb=>$lbs) {
									if($_SESSION["seas_brd_language"]==2) {
										$lbls[$kylb] = wordwrap($lbs,70,"\n");	
									}
									else {
										$lbls[$kylb] = wordwrap($lbs,50,"\n");
									}
								}
								$P_Avg[] = $QArray[5][2];
								$N_Avg[] = $QArray[5][3];
								$S_Avg[] = $QArray[5][0];
								$C_Avg[] = $QArray[5][1];
								$A_Avg[] = $QArray[5][4];								

								//For benchmark
								if(strlen($_SESSION["seas_brd_bnch_filter_condition"])>0) {
									$P_Avg[] = $QArray[5][7];
									$N_Avg[] = $QArray[5][8];
									$S_Avg[] = $QArray[5][5];
									$C_Avg[] = $QArray[5][6];
									$A_Avg[] = $QArray[5][9];		
								}

								CreateRadar($S_Avg,$C_Avg,$P_Avg,$N_Avg,$A_Avg,$lbls,$QArray[0]);
								
                                ?>
                            </td>
                        </tr>
                       <?php
					   }
					   ?>
                     </table>
                     <?php
					}
					?>
</td>
                </tr>
<?php
}
?>
