<div id="main">
<?php
// side bar
require('F_mainsidebar.php');
?>

<!--MAIN PART-->
<div id="mainpartwrapper">
<div id="mainpart">
<?php
require('F_searchmenu.php');
?> 
<div id="content-menu">				
<?php
	
	$task_filenames=array("1385_020100"=>"INF-EMAIL-Appointment.pdf","1385_040101"=>"INF-EMAIL-Help-a-friend.pdf","1395_040101"=>"INF-LETTER-See-a-friend.pdf","1395_020300"=>"INF-LETTER-Contact-a-friend.pdf","1395_010300"=>"INF-LETTER-Information-on-lang-courses.pdf","1365_050401"=>"FORM-LETTER-Information-on-lang-courses.pdf","1365_050402"=>"INF-LETTER-Cooking-with-teacher.pdf","1365_020300"=>"INF-LETTER-Answer-wedding-invitation.pdf","1365_040501"=>"INF-LETTER-Help-a-friend-Work.pdf","1325_040300-2"=>"INF-LETTER-Help-with-chats.pdf","1325_040300-1"=>"FORM-LETTER-Experiences-lang-learning.pdf","1325_030300-2"=>"FORM-LETTER-Complaint-hotel.pdf","1325_020401-2"=>"FORM-LETTER-Information-request-cooking.pdf","1325_030300-1"=>"FORM-LETTER-Information-on-aid-project.pdf","1325_020400-1"=>"FORM-LETTER-Application-internship-company.pdf","1325_020401-1"=>"FORM-LETTER-Application-internship-fashion-sector.pdf","1071_020200"=>"INF-EMAIL-Help-request-apartment.pdf","1071_120302"=>"INF-EMAIL-Appointment-GER.pdf","1071_030101"=>"INF-LETTER-Congratulations.pdf","1091_0610301"=>"FORM-LETTER-Housing-office.pdf","1091_0650102"=>"INF-LETTER-Request-pet-sitting.pdf","1091_0690403"=>"INF-LETTER-Offer-a-ticket.pdf","1061_110101"=>"INF-LETTER-New-years-wishes.pdf","1061_130101"=>"INF-LETTER-Announce-a-visit.pdf","1061_170900"=>"INF-LETTER-Congratulations-birthday.pdf","1023_080401"=>"FORM-LETTER-Information-request-Aupair-agency.pdf","1023_100303"=>"FORM-LETTER-Complaint-Aupair-Agency.pdf","1023_120301"=>"FORM-LETTER-Application-internship.pdf","1031_010300"=>"FORM-ESSAY-Learning-German.pdf","1031_030301"=>"FORM-POSTING-traditions-and-assimilation.pdf","1031_050300"=>"FORM-REPORT-housing-situation.pdf","A2PS0102_oslava"=>"INF-EMAIL-Answer-an-invitation.pdf","A2PS0202_more"=>"INF-DESCRIPTION-swimming.pdf","A2PS0101_hotel"=>"FORM-EMAIL-hotel.pdf","A2PS0201_hriste"=>"INF-DESCRIPTION-playground.pdf","A2PS0200_zena"=>"INF-DESCRIPTION-situation-at-the-window.pdf","1_Alena"=>"INF-EMAIL-Answer-to-a-friend_A.pdf","2_Jana"=>"INF-EMAIL-Answer-to-a-friend_J.pdf","3_Jana"=>".pdf","4_Katerina"=>"FORM-EMAIL-Information-request-Tandem-Agency.pdf","B2PS0200_doma"=>"ESSAY-everywhere-well-but.pdf","B2PS0202_kolace"=>"ESSAY-No-pain-no-gain.pdf","B2PS0202_pritel"=>"ESSAY-Friend-in-need.pdf","B2PS0201_hlava"=>"ESSAY-More-people-know-more.pdf","B2PS0200_skola"=>"ESSAY-School-basis-for-life.pdf","B2PS0201_saty"=>"ESSAY-Clothes-make-the-man.pdf");
		
	echo '<button onclick="history.go(-1);">'.$trans['back_docs'][$_SESSION['lang']].'</button><br>';
	echo '<p>'.$trans['how_to_feats'][$_SESSION['lang']].'</p><br>';
	/*echo '<form action="back">';
	echo '<button type="submit" value="back">back to list</button>';
	echo '</form>';*/
	
	if(isset($_POST)){
		if(array_key_exists("author_id", $_POST) && ! empty($_POST["author_id"])){
			echo "<h4>".$trans['author_id'][$_SESSION['lang']].":</h4> <p>".$_POST["author_id"].' <button onclick="copyToClipboard(\''.$_POST["author_id"].'\');">'.$trans['copy_id'][$_SESSION['lang']].'</button>'."</p><br>";
				
			if(array_key_exists("searchin", $_POST)){
				if($_POST['searchin'] == 'th1'){
					if(array_key_exists("th1", $_POST) && ! empty($_POST["th1"])){
						echo "<h4>".$trans['th1_out'][$_SESSION['lang']].":</h4>";
						echo "<p>".$_POST['th1']."</p>";
						echo "<br>";
						echo "<h4>".$trans['ltext_out'][$_SESSION['lang']].":</h4>";
						$format_text = $_POST['text'];
						$format_text = preg_replace('/\\n/', '<br>', $format_text);
						$format_text = preg_replace('/  /', '&nbsp;&nbsp;', $format_text);
						echo "<p>".$format_text."</p>";
						echo "<br>";
					}
				}
				else if($_POST['searchin'] == 'th2'){
					if(array_key_exists("th2", $_POST) && ! empty($_POST["th2"])){
						echo "<h4>".$trans['th2_out'][$_SESSION['lang']].":</h4>";
						echo "<p>".$_POST['th2']."</p>";
						echo "<br>";
						echo "<h4>".$trans['ltext_out'][$_SESSION['lang']].":</h4>";
						$format_text = $_POST['text'];
						$format_text = preg_replace('/\\n/', '<br>', $format_text);
						$format_text = preg_replace('/  /', '&nbsp;&nbsp;', $format_text);
						echo "<p>".$format_text."</p>";
						echo "<br>";
					}
				}
				else if($_POST['searchin'] == 'text'){
					if(array_key_exists("text", $_POST) && ! empty($_POST["text"])){
						echo "<h4>".$trans['ltext_out'][$_SESSION['lang']].":</h4>";
						$format_text = $_POST['text'];
						$format_text = preg_replace('/\\n/', '<br>', $format_text);
						$format_text = preg_replace('/  /', '&nbsp;&nbsp;', $format_text);
						echo "<p>".$format_text."</p>";
						echo "<br>";
						echo "<h4>".$trans['th1_out'][$_SESSION['lang']].":</h4>";
						echo "<p>".$_POST['th1']."</p>";
						echo "<br>";
						echo "<h4>".$trans['th2_out'][$_SESSION['lang']].":</h4>";
						echo "<p>".$_POST['th2']."</p>";
						echo "<br>";
					}
				}
			}
			else{
				if(array_key_exists("th1", $_POST) && ! empty($_POST["th1"])){
					echo "<h4>".$trans['th1_out'][$_SESSION['lang']].":</h4>";
					echo "<p>".$_POST['th1']."</p>";
					echo "<br>";
					echo "<h4>".$trans['ltext_out'][$_SESSION['lang']].":</h4>";
					$format_text = $_POST['text'];
					$format_text = preg_replace('/\\n/', '<br>', $format_text);
					$format_text = preg_replace('/  /', '&nbsp;&nbsp;', $format_text);
					echo "<p>".$format_text."</p>";
					echo "<br>";
				}
				else if(array_key_exists("th2", $_POST) && ! empty($_POST["th2"])){
					echo "<h4>".$trans['th2_out'][$_SESSION['lang']].":</h4>";
					echo "<p>".$_POST['th2']."</p>";
					echo "<br>";
					echo "<h4>".$trans['ltext_out'][$_SESSION['lang']].":</h4>";
					$format_text = $_POST['text'];
					$format_text = preg_replace('/\\n/', '<br>', $format_text);
					$format_text = preg_replace('/  /', '&nbsp;&nbsp;', $format_text);
					echo "<p>".$format_text."</p>";
					echo "<br>";
				}
				else if(array_key_exists("text", $_POST) && ! empty($_POST["text"])){
					echo "<h4>".$trans['ltext_out'][$_SESSION['lang']].":</h4>";
					$format_text = $_POST['text'];
					$format_text = preg_replace('/\\n/', '<br>', $format_text);
					$format_text = preg_replace('/  /', '&nbsp;&nbsp;', $format_text);
					echo "<p>".$format_text."</p>";
					echo "<br>";
					echo "<h4>".$trans['th1_out'][$_SESSION['lang']].":</h4>";
					echo "<p>".$_POST['th1']."</p>";
					echo "<br>";
				}			
			}
		}
		else if(array_key_exists("metadata", $_POST) && ! empty($_POST["metadata"])){
			//echo("<script>console.log('entered');</script>");
			
			$str_var = $_POST["metadata"];
			$meta_array = unserialize(base64_decode($_POST["metadata"]));
			//echo("<script>console.log(".json_encode($_POST['metadata'][0]['_test_language']).");</script>");
			echo "<h2>".$trans['meta_general'][$_SESSION['lang']].":</h2>";
			echo "<table>";
			echo "<tr><td><p class='boldp'>".$trans['author_id'][$_SESSION['lang']].":</p></td><td> ".$meta_array['_author_id'].' <button onclick="copyToClipboard(\''.$meta_array['_author_id'].'\');">'.$trans['copy_id'][$_SESSION['lang']].'</button></td></tr>';
			echo "<tr><td><p class='boldp'>".$trans['test_lang'][$_SESSION['lang']].":</p></td><td> ".$trans[$meta_array['_test_language']][$_SESSION['lang']]."</td></tr>";
			echo "<tr><td><p class='boldp'>".$trans['cefr_test'][$_SESSION['lang']].":</p></td><td> ".$meta_array['_test_level_cefr']."</td></tr>";
			echo "<tr><td><p class='boldp'>".$trans['task_type'][$_SESSION['lang']].":</p></td><td> <a href='docs/".$task_filenames[$meta_array['_task_id']]."' target='_blank'>".$trans[$meta_array['_task_id']][$_SESSION['lang']]."</a>".'<a href="#" class="clickTip" title="'.$trans['tt_task_type_meta'][$_SESSION['lang']].'"><img class="helpicon" src="img/icon_info.png" ></a></td></tr>';
			echo "<tr><td><p class='boldp'>".$trans['l1'][$_SESSION['lang']].":</p></td><td> ".$trans[$meta_array['_author_L1']][$_SESSION['lang']]."</td></tr>";
			echo "<tr><td><p class='boldp'>".$trans['age'][$_SESSION['lang']].":</p></td><td> ".$meta_array['_author_age']."</td></tr>";
			echo "<tr><td><p class='boldp'>".$trans['sex'][$_SESSION['lang']].":</p></td><td> ".$trans[$meta_array['_author_gender']][$_SESSION['lang']]."</td></tr>";
			echo "</table>";
			
			echo "<h2>".$trans['meta_rating'][$_SESSION['lang']].":</h2>";
			echo "<table>";
			echo "<tr><td><p class='boldp'>".$trans['cefr_rated'][$_SESSION['lang']].":</p></td><td> ".$meta_array['_rating_fair_cefr']."</td></tr>";
			echo "<tr><td><p class='boldp'>".$trans['gram_accuracy'][$_SESSION['lang']].":</p></td><td> ".$meta_array['_rating_grammatical_accuracy']."</td></tr>";
			echo "<tr><td><p class='boldp'>".$trans['orth'][$_SESSION['lang']].":</p></td><td> ".$meta_array['_rating_orthography']."</td></tr>";
			echo "<tr><td><p class='boldp'>".$trans['voc_range'][$_SESSION['lang']].":</p></td><td> ".$meta_array['_rating_vocabulary_range']."</td></tr>";
			echo "<tr><td><p class='boldp'>".$trans['voc_control'][$_SESSION['lang']].":</p></td><td> ".$meta_array['_rating_vocabulary_control']."</td></tr>";
			echo "<tr><td><p class='boldp'>".$trans['coh'][$_SESSION['lang']].":</p></td><td> ".$meta_array['_rating_coherence']."</td></tr>";
			echo "<tr><td><p class='boldp'>".$trans['soc_approp'][$_SESSION['lang']].":</p></td><td> ".$meta_array['_rating_sociolinguistic_appropriateness']."</td></tr>";
			echo "</table>";
		}
	}
?>
<!--### IFRAME PART END-->  
</div>		  
</div>
</div>
<!--MAIN PART END-->
</div>