<?php
if(!isset($_SESSION)) session_start();
include("config.php");

require_once("demosettings.php");
include("loginCheckPoint.php");

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; Charset=UTF-8"  />
<title>IntuScan Station</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="jquery-ui/development-bundle/themes/base/jquery.ui.all.css">
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="jquery-ui/js/jquery-1.7.1.min.js"></script>

<!--<script type="text/javascript" src="js/script.js"></script>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="jquery/jquery-ui.custom.js" type="text/javascript"></script>
<script src="js/jquery.cookie.js" type="text/javascript"></script>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="jquery/jquery-ui.custom.js" type="text/javascript"></script>
<script src="js/jquery.cookie.js" type="text/javascript"></script>
<script type="text/javascript" src="jquery-ui/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="jquery-ui/js/jquery-ui-1.8.17.custom.min.js"></script>
<script src="jquery-ui/development-bundle/ui/jquery.ui.autocomplete.js"></script>
<script src="jquery-ui/development-bundle/ui/jquery.effects.core.js"></script>
<script src="jquery-ui/development-bundle/ui/jquery.effects.blind.js"></script> -->
<script src="js/ivcommon.js"></script>
<script type="text/javascript">
var ajax_load = "<p align=center><img src='images/loader.gif' alt='loading...' /></p>";

  function bringTable(){
	  	var t = document.getElementById('OtherEntitiesParameterSelect').value;
		$.ajax({
			url: "jsonRequest.php?table=" + t ,
			type: 'GET',
			success: function(data) {
					//var obj = jQuery.parseJSON(data);
					//alert(data);	
				
				    var val = data;
				    var sel = document.getElementById('OtherEntitiesSelect');
				    var count = sel.length;
				    for (var i=1; i<count; i++){					    				    	
				    	sel.remove(1);
				    	//var x = document.getElementById("mySelect");				    	
				    }
				    var obj = jQuery.parseJSON(data);	
				    var i = 1;			    
				    for (var s in obj){			
				    	opt = document.createElement("option");
		                //opt.value = i++;
		                opt.value = obj[s];
		                opt.text = obj[s];
		                sel.appendChild(opt);		    				    				    
				    }				    
					//$("#label").html(data);												
				}				
	  		}
		
	  	);
		document.getElementById("OtherEntitiesSelect").selectedIndex = 0;	
		changeLable();	
		//document.getElementById('label').innerHTML = "test2";
	}
	
//function bringTable(){	
//	alert(document.getElementById('OtherEntitiesarameterSelect').value);
		
//}

function search(){		
	var searchLable = document.getElementById('searchLable').value;
	var searchDateofWriting = document.getElementById("searchDateofWriting").value;
	var searchDatsMentioned = document.getElementById("searchDateMentioned").value;
	var searchDateofAnalysis = document.getElementById("searchDateofAnalysis").value;
	var searchWithinResults = "<?php echo $_REQUEST["searchWithinResults"];?>";
	
	if (document.getElementById('PlacesMentionedCheckbox').checked === true)
		var searchPlaces = document.getElementById('searchPlaces').value;
	else
		var searchPlaces = "";
	if (document.getElementById('PersonMentionedCheckbox').checked === true)
		var searchPerson = document.getElementById('searchPerson').value;
	else
		var searchPerson = "";
	if (document.getElementById('FreeTextCheckbox').checked === true)
		var searchFreeText = document.getElementById('searchFreeText').value;
	else
		var searchFreeText = "";	
	if (document.getElementById('SentimentCheckbox').checked === true)		
		var searchSentiment = document.getElementById('SentimentSelect').value + "^" + document.getElementById('SentimentParameterSelect').value + "^" + document.getElementById('SentimentText').value;
	else
		var searchSentiment = "";
	if (document.getElementById('OrganizationMentionedCheckbox').checked === true)
		var searchOrganization = document.getElementById('searchOrganization').value;
	else
		var searchOrganization = "";
	if (document.getElementById('OtherEntitiesCheckbox').checked === true)
		var searchOther = document.getElementById("OtherEntitiesParameterSelect").value + "=" + document.getElementById("OtherEntitiesSelect").value;
	else
		var searchOther = "";
	if (document.getElementById('EventsCheckbox').checked === true)
		var searchEvents = document.getElementById("searchEvents").value;
	else
		var searchEvents = "";
	if (document.getElementById('EventsCheckbox').checked === true)
		var searchEvents = document.getElementById("searchEvents").value;
	else
		var searchEvents = "";	
	if (document.getElementById('userNotesCheckbox').checked === true){
		var searchUserNotesUser = document.getElementById("userNotesSelect").value;
		var searchUserNotesText = document.getElementById("userNotesText").value;
	}
	else{
		var searchUserNotesUser = "";
		var searchUserNotesText = "";
	}
		
	
	//if (searchLable === "")
	//	alert("You need to choose what you want to search");
	//else	
		//alert(search);
	gotoPage("searchResults", {"searchLable": searchLable, "searchPlaces": searchPlaces,
		"searchPerson": searchPerson, "searchFreeText": searchFreeText, "searchSentiment": searchSentiment,
		"searchOrganization": searchOrganization, "searchEvents": searchEvents, "searchOther": searchOther, 
		"searchDateofWriting": searchDateofWriting, "searchDateMentioned": searchDatsMentioned,
		"searchWithinResults": searchWithinResults, "searchUserNotesUser": searchUserNotesUser, "searchUserNotesText": searchUserNotesText,
		"searchDateofAnalysis": searchDateofAnalysis});
/*
	window.location.href = "PageLoader.php?PageName=searchResults&searchLable=" + encodeURIComponent(searchLable)
											+ "&searchPlaces=" + encodeURIComponent(searchPlaces)
											+ "&searchPerson=" + encodeURIComponent(searchPerson)
											+ "&searchFreeText=" + encodeURIComponent(searchFreeText)
											+ "&searchSentiment=" + encodeURIComponent(searchSentiment)											
											+ "&searchOrganization=" + encodeURIComponent(searchOrganization)
											+ "&searchEvents=" + encodeURIComponent(searchEvents)
											+ "&searchOther=" + encodeURIComponent(searchOther)
											+ "&searchDateofWriting=" + encodeURIComponent(searchDateofWriting)
											+ "&searchDateMentioned=" + encodeURIComponent(searchDatsMentioned)
											+ "&searchWithinResults=" + encodeURIComponent(searchWithinResults)
											+ "&searchUserNotesUser=" + encodeURIComponent(searchUserNotesUser)
											+ "&searchUserNotesText=" + encodeURIComponent(searchUserNotesText)
											+ "&searchDateofAnalysis=" + encodeURIComponent(searchDateofAnalysis);												
*/
};

function information(){	
	var degel = 0;
	var searchPlaces = "";
	var searchPerson = "";
	var searchOrganization ="";
	if (document.getElementById('PlacesMentionedCheckbox').checked === true){
		searchPlaces = document.getElementById('searchPlaces').value;
		degel++;
	}	
	if (document.getElementById('PersonMentionedCheckbox').checked === true){
		searchPerson = document.getElementById('searchPerson').value;
		degel++;
	}			
	if (document.getElementById('OrganizationMentionedCheckbox').checked === true){
		searchOrganization = document.getElementById('searchOrganization').value;
		degel++;
	}

	if (degel == 0){
		alert("Please choose person, organization or places");
		return;
	}
	if (degel > 1){
		alert("Please One choose person, organization or places");
		return;
	}
	if (searchPlaces == "" && searchPerson == "" && searchOrganization == ""){
		alert("The field is empty");
		return;
	}
	gotoPage("information", {"searchPlaces": searchPlaces, "searchPerson": searchPerson, "searchOrganization": searchOrganization});
};

function analayze(){
	var searchtext = document.getElementById("searchtext").value;
	if (searchtext.length == 0){
		$("#searchtext").css({'background-color' : 'pink'});
		return;
	}else{
		$("#searchtext").css({'background-color' : 'white'});
	}

	$("#analyze").html(ajax_load).load("PageLoader.php?PageName=searchResults&searchtext=" + encodeURIComponent(searchtext) +
												"&analyze=yes",
									function(){});
};

function toggle(div) {
		var ele = document.getElementById(div);		
		if(ele.style.display == "block")
	    	ele.style.display = "none";
		else
			ele.style.display = "block";
		changeLable();
};

function MetadataChange(){
	if (document.getElementById("MetadataCheckbox").checked === true){
		document.getElementById("MetadataDiv").style.display = "block";
		var ele = document.getElementById("MetadataSelect");
		if (ele.value === "FileSize"){			
			document.getElementById("FileSizeDiv").style.display = "block";
			document.getElementById("FileSizeTextDiv").style.display = "block";
			document.getElementById("NumberOfLineDiv").style.display = "none";	
			document.getElementById("NumberOfLineTextDiv").style.display = "none";						
		}else if (ele.value === "NumberOfLine"){
			document.getElementById("NumberOfLineDiv").style.display = "block";	
			document.getElementById("NumberOfLineTextDiv").style.display = "block";
			document.getElementById("FileSizeDiv").style.display = "none";	
			document.getElementById("FileSizeTextDiv").style.display = "none";			
		} else{
			document.getElementById("FileSizeDiv").style.display = "none";	
			document.getElementById("FileSizeTextDiv").style.display = "none";
			document.getElementById("NumberOfLineDiv").style.display = "none";	
			document.getElementById("NumberOfLineTextDiv").style.display = "none";
		}
	}else{
		document.getElementById("MetadataDiv").style.display = "none";
		document.getElementById("FileSizeDiv").style.display = "none";	
		document.getElementById("FileSizeTextDiv").style.display = "none";
		document.getElementById("NumberOfLineDiv").style.display = "none";
		document.getElementById("NumberOfLineTextDiv").style.display = "none";
	}	
	changeLable();			
};

function EntityChange(){
	
};

function changeLable(){
	//var type = document.getElementById("documentSelect").value;
	//if (type === "None")
	//	document.getElementById('label').value = "";
	//else if (type === "Document"){
		document.getElementById("searchLable").value = "";
		document.getElementById('label').innerHTML = "<b>Search for Document</b>";
		if (document.getElementById('FreeTextCheckbox').checked === true){
			document.getElementById("FreeTextTextDiv").style.display = "block";
			document.getElementById("searchFreeText").value = document.getElementById("FreeTextText").value;
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b> Free text:" + "<b>" + document.getElementById("FreeTextText").value + "</b>";
		}
		if (document.getElementById('PrioritylevelCheckbox').checked === true){
			document.getElementById("PrioritylevelDiv").style.display = "block";			
			document.getElementById("searchLable").value = document.getElementById("searchLable").value + ";threat_rating=" + document.getElementById("PrioritylevelSelect").value
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b> Priority level:" + "<b>" + document.getElementById("PrioritylevelSelect").value + "<b>";
		}		
		if (document.getElementById('PersonMentionedCheckbox').checked === true){
			document.getElementById("PersonMentionedTextDiv").style.display = "block";
			document.getElementById("searchPerson").value = document.getElementById("PersonMentionedText").value;
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b> Person Mentioned:" + "<b>" + document.getElementById("PersonMentionedText").value + "</b>";
		}
		if (document.getElementById('OrganizationMentionedCheckbox').checked === true){
			document.getElementById("OrganizationMentionedTextDiv").style.display = "block";
			document.getElementById("searchOrganization").value = document.getElementById("OrganizationMentionedText").value;
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b> Organization Mentioned:" + "<b>" + document.getElementById("OrganizationMentionedText").value + "</b>";
		}
		if (document.getElementById('PlacesMentionedCheckbox').checked === true){
			document.getElementById("PlacesMentionedTextDiv").style.display = "block";			
			document.getElementById("searchPlaces").value = document.getElementById("PlacesMentionedText").value;
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b> Place Mentioned:" + "<b>" + document.getElementById("PlacesMentionedText").value + "</b>";
		}
		if (document.getElementById('SentimentCheckbox').checked === true){
			document.getElementById("SentimentParameterSelectDiv").style.display = "block";
			document.getElementById("SentimentSelectDiv").style.display = "block";		
			document.getElementById("SentimentTextDiv").style.display = "block";		
			document.getElementById("searchSentiment").value = document.getElementById("SentimentSelect").value + "," + document.getElementById("SentimentParameterSelect").value;
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b> Sentiment:" + "<b>" + document.getElementById("SentimentSelect").value + " - " + document.getElementById('SentimentParameterSelect')[document.getElementById('SentimentParameterSelect').selectedIndex].innerHTML + " - " + document.getElementById("SentimentText").value + "</b>";
		}
		if (document.getElementById('AuthorCheckbox').checked === true){
			document.getElementById("AuthorTextDiv").style.display = "block";			
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b> Author:" + "<b>" + document.getElementById("AuthorText").value + "</b>";
		}
		if (document.getElementById('TheaterCheckbox').checked === true){
			document.getElementById("TheaterTextDiv").style.display = "block";
			document.getElementById("searchLable").value = document.getElementById("searchLable").value + ";counted_theatre=" + document.getElementById("TheaterText").value
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b> Theater:" + "<b>" + document.getElementById("TheaterText").value + "</b>";
		}		
		if (document.getElementById('PoliticalOrientationCheckbox').checked === true){
			document.getElementById("PoliticalOrientationTextDiv").style.display = "block";
			document.getElementById("searchLable").value = document.getElementById("searchLable").value + ";ideological_stream=" + document.getElementById("PoliticalOrientationText").value
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b> Political Orientation:" + "<b>" + document.getElementById("PoliticalOrientationText").value + "</b>";
		}
		if (document.getElementById('ReligiousAffiliationCheckbox').checked === true){
			document.getElementById("ReligiousAffiliationTextDiv").style.display = "block";
			document.getElementById("searchLable").value = document.getElementById("searchLable").value + ";islamic_sect=" + document.getElementById("ReligiousAffiliationText").value
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b> Religious Affiliation:" + "<b>" + document.getElementById("ReligiousAffiliationText").value + "</b>";
		}
		if (document.getElementById('LanguageCheckbox').checked === true){
			document.getElementById("LanguageDiv").style.display = "block";
			document.getElementById("searchLable").value = document.getElementById("searchLable").value + ";languages=" + document.getElementById("LanguageSelect").value
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b> Language:" + "<b>" + document.getElementById("LanguageSelect").value + "</b>";
		}
		if (document.getElementById('userNotesCheckbox').checked === true){
			document.getElementById("userNotesDiv").style.display = "block";
			document.getElementById("userNotesTextDiv").style.display = "block";
			document.getElementById("SearchUserNotesUser").value = document.getElementById("userNotesSelect").value
			document.getElementById("SearchUserNotesText").value = document.getElementById("userNotesText").value
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b> userNotes:" + "<b>" + document.getElementById("userNotesSelect").value +  
			"-" + document.getElementById("userNotesText").value + "</b>";			
		}	
		if (document.getElementById('DocumentNameCheckbox').checked === true){
			document.getElementById("DocumentNameTextDiv").style.display = "block";
			document.getElementById("searchLable").value = document.getElementById("searchLable").value + ";filename=" + document.getElementById("DocumentNameText").value
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b> Document Name:" + "<b>" + document.getElementById("DocumentNameText").value + "</b>";
		}
		if (document.getElementById('EventsCheckbox').checked === true){
			document.getElementById("EventsTextDiv").style.display = "block";			
			document.getElementById("searchEvents").value = document.getElementById("EventsText").value;
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b> Events:" + "<b>" + document.getElementById("EventsText").value + "</b>";
		}							
		if (document.getElementById('OtherEntitiesCheckbox').checked === true){	
			if (document.getElementById("OtherEntitiesParameterSelect").value != "0"){
				if (document.getElementById("OtherEntitiesSelect").value != "0"){		
					//document.getElementById("searchLable").value = document.getElementById("searchLable").value + ";" + document.getElementById("OtherEntitiesParameterSelect").value + "=" + document.getElementById("OtherEntitiesSelect").value
					document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
					" <b><span style=\"color: red\"> AND</span></b>" + " " + document.getElementById("OtherEntitiesParameterSelect").value + ":" + "<b>" + document.getElementById("OtherEntitiesSelect").value + "</b>";
				}
				else{
					//document.getElementById("searchLable").value = document.getElementById("searchLable").value + ";" + document.getElementById("OtherEntitiesParameterSelect").value + "=" + "All"
					document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
					" <b><span style=\"color: red\"> AND</span></b>" + " " + document.getElementById("OtherEntitiesParameterSelect").value + ":" + "<b>" + "All" + "</b>";
				}					
			}
		}		
		if (document.getElementById('DateofWritingCheckbox').checked === true){
			document.getElementById("DateofWritingTextDiv").style.display = "block";
			document.getElementById("searchDateofWriting").value = document.getElementById("DateofWritingDayFromSelect").value + 
			"_" + document.getElementById("DateofWritingMonthFromSelect").value + "_" + document.getElementById("DateofWritingYearFromSelect").value + "_" + document.getElementById("DateofWritingDayToSelect").value + 
			"_" + document.getElementById("DateofWritingMonthToSelect").value + "_" + document.getElementById("DateofWritingYearToSelect").value;
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b> Date of Writing: " + "<b>" + "From- " + "d(" + document.getElementById("DateofWritingDayFromSelect").value + 
			")m(" + document.getElementById("DateofWritingMonthFromSelect").value + ")y(" + document.getElementById("DateofWritingYearFromSelect").value + ")" 
			+ " To- " + "d(" + document.getElementById("DateofWritingDayToSelect").value + 
			")m(" + document.getElementById("DateofWritingMonthToSelect").value + ")y(" + document.getElementById("DateofWritingYearToSelect").value + ")" + "</b>";	
		}else
			document.getElementById("searchDateofWriting").value = "";
		if (document.getElementById('DatesMentionedCheckbox').checked === true){
			document.getElementById("DatesMentionedTextDiv").style.display = "block";
			document.getElementById("searchDateMentioned").value = document.getElementById("DatesMentionedDayFromSelect").value + 
			"_" + document.getElementById("DatesMentionedMonthFromSelect").value + "_" + document.getElementById("DatesMentionedYearFromSelect").value + "_" + document.getElementById("DatesMentionedDayToSelect").value + 
			"_" + document.getElementById("DatesMentionedMonthToSelect").value + "_" + document.getElementById("DatesMentionedYearToSelect").value;
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b>  Dates Mentioned: " + "<b>" + "From- " + "d(" + document.getElementById("DatesMentionedDayFromSelect").value + 
			")m(" + document.getElementById("DatesMentionedMonthFromSelect").value + ")y(" + document.getElementById("DatesMentionedYearFromSelect").value + ")" 
			+ " To- " + "d(" + document.getElementById("DatesMentionedDayToSelect").value + 
			")m(" + document.getElementById("DatesMentionedMonthToSelect").value + ")y(" + document.getElementById("DatesMentionedYearToSelect").value + ")" + "</b>";	
		}else
			document.getElementById("searchDateMentioned").value = "";
		if (document.getElementById('DateofAnalysisCheckbox').checked === true){
			document.getElementById("DateofAnalysisTextDiv").style.display = "block";
			document.getElementById("searchDateofAnalysis").value = document.getElementById("DateofAnalysisDayFromSelect").value + 
			"_" + document.getElementById("DateofAnalysisMonthFromSelect").value + "_" + document.getElementById("DateofAnalysisYearFromSelect").value + "_" + document.getElementById("DateofAnalysisDayToSelect").value + 
			"_" + document.getElementById("DateofAnalysisMonthToSelect").value + "_" + document.getElementById("DateofAnalysisYearToSelect").value;
			document.getElementById('label').innerHTML = document.getElementById('label').innerHTML + 
			" <b><span style=\"color: red\"> AND</span></b>  Dates Mentioned: " + "<b>" + "From- " + "d(" + document.getElementById("DateofAnalysisDayFromSelect").value + 
			")m(" + document.getElementById("DateofAnalysisMonthFromSelect").value + ")y(" + document.getElementById("DateofAnalysisYearFromSelect").value + ")" 
			+ " To- " + "d(" + document.getElementById("DateofAnalysisDayToSelect").value + 
			")m(" + document.getElementById("DateofAnalysisMonthToSelect").value + ")y(" + document.getElementById("DateofAnalysisYearToSelect").value + ")" + "</b>";	
		}else
			document.getElementById("searchDateofAnalysis").value = "";
		
		
	//}
	//else if (type === "Entity"){
	//	document.getElementById('label').innerHTML = "Type: Entity";
	//}
	//else{
	//	document.getElementById('label').innerHTML = "Type: Sentiment";
	//}		
}

function documentChange(){
	onload();
	//var ele = document.getElementById("documentSelect");
	//if (ele.value === "Document"){			
		document.getElementById("documentDetailsDiv").style.display = "block";
	//	document.getElementById("EntityDiv").style.display = "none";		
	//}
	//else if (ele.value === "Entity"){		
	//	document.getElementById("documentDetailsDiv").style.display = "none";
	//	document.getElementById("EntityDiv").style.display = "block";	
	//}else{
	//	document.getElementById("documentDetailsDiv").style.display = "none";
	//	document.getElementById("EntityDiv").style.display = "none";	
	//}
	changeLable();
};
function sentimentChange(){
	toggle("SentimentSelectDiv");
	toggle("SentimentParameterSelectDiv");
	toggle("SentimentTextDiv");
};
function OtherEntitiesChange(){
	toggle("OtherEntitiesSelectDiv");
	toggle("OtherEntitiesParameterSelectDiv");
};

function onload(){
	if (document.getElementById('OtherEntitiesCheckbox').checked === true)
	{
		var ele = document.getElementById('OtherEntitiesSelectDiv');
		ele.style.display = "block";
		ele = document.getElementById('OtherEntitiesParameterSelectDiv');
		ele.style.display = "block";
		bringTable();		
	}
};

</script>
<style>
td {
	border-right: 0px solid #C1DAD7;
	border-bottom: 0px solid #C1DAD7;
	background: #fff;
	padding: 6px 6px 6px 12px;
	color: black;
}
</style>
</head>


<body>
<div class="main">
 <div class="top-banner">
	 <a href="javascript:gotoPage('home', {})"><img src="images/intuscan-img.png" style="border:0;"/></a>
	 <p style="padding:0 10px 10px 10px; float:right;"><b>version 1</b></p>
	 <p style="padding:0 10px 10px 10px; float:right;">Hi, <?php echo $_SESSION["username"] ?></p>
	 <p style="padding:0 10px 10px 10px; float:right;"><a style="color:red;" href="javascript:gotoPage('logoff', {})">logoff</a></p>
 </div>
  <div class="header">

    <div class="header_block">

      <div class="clr"></div>
      <?php
      	include('general-toolbar.php');
      ?>
      <div class="clr"></div>
    </div>
    <div class="clr"></div>
  </div>
  <div class="content">
      <div id="mainbar">
        <div class="article" >
        	<div class="search">
          			<span>
          				<span style="vertical-align: middle;">
          					<div id="SearchRequest" style="display:block">
          						<label id="label"></label><br></br>
          						<input type="hidden" id="searchLable" name="searchLable" value="">          						
          						<input type="hidden" id="searchPlaces" name="searchPlaces" value="">
          						<input type="hidden" id="searchPerson" name="searchPerson" value="">
          						<input type="hidden" id="searchFreeText" name="searchFreeText" value="">          						
          						<input type="hidden" id="searchOrganization" name="searchOrganization" value="">
          						<input type="hidden" id="searchSentiment" name="searchSentiment" value="">
          						<input type="hidden" id="searchOther" name="searchOther" value="">
          						<input type="hidden" id="searchEvents" name="searchEvents" value="">
          						<input type="hidden" id="searchDateofWriting" name="searchDatsMentionede" value="">
          						<input type="hidden" id="searchDateMentioned" name="searchDatsMentionede" value="">
          						<input type="hidden" id="searchDateofAnalysis" name="searchDatsMentionede" value="">
          						<input type="hidden" id="searchWithinResults" name="searchWithinResults" value="">          						
          						<input type="hidden" id="SearchUserNotesUser" name="SearchUserNotes" value="">
          						<input type="hidden" id="SearchUserNotesText" name="SearchUserNotes" value="">
          					</div>
          					<input type="button" id="searchBut" onclick="javascript:search();" value="Search">          				          					        				          				
          					<input type="button" id="informationBut" onclick="javascript:information();" value="Information">
          					<!-- <div id="documentDiv">
          					 	
	          					<select  onchange="documentChange()" name="documentSelect" id="documentSelect">
	          						  <option value="None"></option>
									  <option value="Document">Document</option>
									  <option value="Entity">Entity</option>
									  <option value="Sentiment">Sentiment</option>									 
								</select> 
          					</div> -->
	          					<div id="documentDetailsDiv" style="display:none">	     
	          						<div >  	          						
	          						<table>
	          							<tr>
	          								<td><b>&nbsp;&nbsp;&nbsp;Document Features</b></td>
	          								
	          								<td><b>&nbsp;&nbsp;&nbsp;Concepts</b></td>
	          							</tr>
	          							</tr>
	          							<tr>	
	          								<td valign="top">
	          									<div style="border:1px solid gray;width:380px;"> 			
	          									<table>	          						
	          										<tr>	          								
				          						  		<td>
				          						  			<input type="checkbox" name="PrioritylevelCheckbox" id="PrioritylevelCheckbox" onchange="toggle(&#34;PrioritylevelDiv&#34;)"/>
						       									Priority level
						       							</td>
						       							<td>
						       								<div id="PrioritylevelDiv" style="display:none">
						       									<select name="PrioritylevelSelect" id="PrioritylevelSelect" onchange="changeLable()">
									          						  <option value="High" selected="selected">High 1-3</option>
																	  <option value="Medium">Medium 4-6</option>
																	  <option value="Low">Low 7-9</option>													 									
																</select>
						       								</div>
						       							</td>
						       						</tr>
						       						<tr>
						       							<td>
						       								<input type="checkbox" name="TheaterCheckbox" id="TheaterCheckbox" onchange="toggle(&#34;TheaterTextDiv&#34;)"/>
						       									Theater
						       							</td>
						       							<td>		       							
						       								<div id="TheaterTextDiv" style="display:none">		       											       								
																<input type="text" id="TheaterText" name="TheaterText" onchange="changeLable()"/>
															</div>
														</td>
						       						</tr>						       												       						
						       						<tr>
						       							<td>
						       								<input type="checkbox" name="AuthorCheckbox" id="AuthorCheckbox" onchange="toggle(&#34;AuthorTextDiv&#34;)"/>
						       									Document Author
						       							</td>
						       							<td>		       							
						       								<div id="AuthorTextDiv" style="display:none">		       											       								
																<input type="text" id="AuthorText" name="AuthorText" onchange="changeLable()"/>
															</div>
														</td>
						       						</tr>
						       						<tr>
						       							<td>
						       								<input type="checkbox" name="PoliticalOrientationCheckbox" id="PoliticalOrientationCheckbox" onchange="toggle(&#34;PoliticalOrientationTextDiv&#34;)"/>
						       									Political Orientation
						       							</td>
						       							<td>		       							
						       								<div id="PoliticalOrientationTextDiv" style="display:none">		       											       								
																<input type="text" id="PoliticalOrientationText" name="PoliticalOrientationText" onchange="changeLable()"/>
															</div>
														</td>
						       						</tr>
						       						<tr>
						       							<td>
						       								<input type="checkbox" name="ReligiousAffiliationCheckbox" id="ReligiousAffiliationCheckbox" onchange="toggle(&#34;ReligiousAffiliationTextDiv&#34;)"/>
						       									Religious Affiliation
						       							</td>
						       							<td>		       							
						       								<div id="ReligiousAffiliationTextDiv" style="display:none">		       											       								
																<input type="text" id="ReligiousAffiliationText" name="ReligiousAffiliationText" onchange="changeLable()"/>
															</div>
														</td>
						       						</tr>							       												       												       						
				          							<tr>
						       							<td>
						       								<input type="checkbox" name="FreeTextCheckbox" id="FreeTextCheckbox" onchange="toggle(&#34;FreeTextTextDiv&#34;)"/>
						       									Free text Search
						       							</td>
						   								<td>		       							
						       								<div id="FreeTextTextDiv" style="display:none">		       											       								
																<input type="text" id="FreeTextText" name="FreeTextText" onchange="changeLable()"/>
															</div>
														</td>
						       						</tr>
			       								</table>
			       								</div>
			       							</td>			       							
			       							<td valign="top">
			       								<div style="border:1px solid gray;width:510px;"> 				       										       					
				       							<table>	 
				       								<tr>
						       							<td>
						       								<input type="checkbox" name="PlacesMentionedCheckbox" id="PlacesMentionedCheckbox" onchange="toggle(&#34;PlacesMentionedTextDiv&#34;)"/>
						       									Places
						       							</td>
						       							<td>		       							
						       								<div id="PlacesMentionedTextDiv" style="display:none">		       											       								
																<input type="text" id="PlacesMentionedText" name="PlacesMentionedText" onchange="changeLable()"/>
															</div>
														</td>
						       						</tr>         						
						       						<tr>
						       							<td>
						       								<input type="checkbox" name="PersonMentionedCheckbox" id="PersonMentionedCheckbox" onchange="toggle(&#34;PersonMentionedTextDiv&#34;)"/>
						       									Person
						       							</td>
						       							<td>		       							
						       								<div id="PersonMentionedTextDiv" style="display:none">		       											       								
																<input type="text" id="PersonMentionedText" name="PersonMentionedText" onchange="changeLable()"/>
															</div>
														</td>
						       						</tr>
						       						<tr>
						       							<td>
						       								<input type="checkbox" name="OrganizationMentionedCheckbox" id="OrganizationMentionedCheckbox" onchange="toggle(&#34;OrganizationMentionedTextDiv&#34;)"/>
						       									Organization
						       							</td>
						       							<td>		       							
						       								<div id="OrganizationMentionedTextDiv" style="display:none">		       											       								
																<input type="text" id="OrganizationMentionedText" name="OrganizationMentionedText" onchange="changeLable()"/>
															</div>
														</td>
						       						</tr>
						       						<tr>
						       							<td>
						       								<input type="checkbox" name="EventsCheckbox" id="EventsCheckbox" onchange="toggle(&#34;EventsTextDiv&#34;)"/>
						       									Events
						       							</td>
						       							<td>		       							
						       								<div id="EventsTextDiv" style="display:none">		       											       								
																<input type="text" id="EventsText" name="EventsText" onchange="changeLable()"/>
															</div>
														</td>
						       						</tr>						       						
						       						<tr>
						       							<td>
						       								<input type="checkbox" name="OtherEntitiesCheckbox" id="OtherEntitiesCheckbox" onchange="OtherEntitiesChange()"/>
						       									Other Content						       								
						       							</td>
						       							<td>
					       									<div id="OtherEntitiesSelectDiv" style="display:none">						       								
						       									<select style="width:150px;" name="OtherEntitiesParameterSelect" id="OtherEntitiesParameterSelect" onchange="bringTable()">
						       									<?php
						       										echo "<option value=\"0\"></option>";
						       										require_once 'allConceptsData.php';
																	require_once 'parseUtils.php';
																	require_once 'settings.php';
																	$settings_class =  new Settings($mysqli, $_SESSION["username"]);
																	$allConceptArrDB = $settings_class->getAllConceptsArr();
																	
																	
																	$concept_class = new AllConceptsData($mysqli, $allConceptArrDB, null, $_SESSION["username"]);
					       										    foreach($concept_class->getMergedData()  as $element){
						       										    $tableName = str_replace("-","_",$element['name']);
						       										    echo "<option value=\"$tableName\">$tableName</option>";
					       										    }
						       										
// 						       										include_once("annotations.php");
						       										
// 						       										$annotCount = $annotElements->length;	
// 						       										for($i = 0 ; $i < $annotCount ; $i++){
// 						       											$element = $annotElements->item($i);
// 						       											$tableName = str_replace("-","_",$element->getAttribute("name"));
// 						       											echo "<option value=\"$tableName\">$tableName</option>";
// 						       										}						       												       																			          					
																?>																	 
																</select>
															</div>						       								
					       								</td>
						       							<td>	
					       									<div id="OtherEntitiesParameterSelectDiv" style="display:none">					       														       									
																<select style="width:150px;" name="OtherEntitiesSelect" id="OtherEntitiesSelect" onchange="changeLable()">
									          						<option value="0">All</option>																	 
																</select>	
															</div>					       																							
					       								</td>
						       						</tr>
						       					</table>
						       					<table>	
						       						<tr>
						       							<td>
						       								<input type="checkbox" name="SentimentCheckbox" id="SentimentCheckbox" onchange="sentimentChange()"/>
						       									Sentiment
						       							</td>						       							
						       								<td>
						       									<div id="SentimentSelectDiv" style="display:none">						       								
							       									<select name="SentimentSelect" id="SentimentSelect" onchange="changeLable()">
										          						  <option value="All">All</option>
																		  <option value="Positive">Positive</option>
																		  <option value="Negative">Negative</option>																	 
																	</select>	
																</div>						       								
						       								</td>						       								
						       								<td>	
						       									<div id="SentimentParameterSelectDiv" style="display:none">					       								
							       									<select name="SentimentParameterSelect" id="SentimentParameterSelect" onchange="changeLable()">
							       										<option value="place_object">Places</option>	
							       										<option value="person_object">Person</option>
																		<option value="organizational_identity">Organization</option>
																		<option value="Events">Events</option>													 
																	</select>
																</div>					       																							
						       								</td>	
						       								<td>	
						       									<div id="SentimentTextDiv" style="display:none">		       											       								
																	<input type="text" id="SentimentText" name="SentimentText" onchange="changeLable()"/>
																</div>				       																							
						       								</td>						       													       							
						       						</tr>					       							          										       						
				       							</table>
				       							</div>
				       						</td>
				       					</table>			       					
			       					</div>
			       					<br></br>			       								       					
			       					<div style="border:1px solid gray"	>
			       						<b>&nbsp;&nbsp;&nbsp;Document Dates</b>
				       					<table>				       								       					
				       						<tr>
				       							<td>
				       								<input type="checkbox" name="DateofWritingCheckbox" id="DateofWritingCheckbox" onchange="toggle(&#34;DateofWritingTextDiv&#34;)"/>
				       									Date of Writing
				       							</td>
				       							<td>		       							
				       								<div id="DateofWritingTextDiv" style="display:none">				       											       											       							
														
															<b>From</b>&nbsp;&nbsp;&nbsp;
															Day&nbsp;&nbsp;
															<select name="DateofWritingDayFromSelect" id="DateofWritingDayFromSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		for ($i = 1; $i <= 31; $i++){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
															Month&nbsp;&nbsp;
															<select name="DateofWritingMonthFromSelect" id="DateofWritingMonthFromSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		for ($i = 1; $i <= 12; $i++){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
															Year&nbsp;&nbsp;
															<select name="DateofWritingYearFromSelect" id="DateofWritingYearFromSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		$year = date("Y");
								          						  		for ($i = $year; $i >= 1900; $i--){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
															&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
															<b>To</b>&nbsp;&nbsp;&nbsp;
															Day&nbsp;&nbsp;
															<select name="DateofWritingDayToSelect" id="DateofWritingDayToSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		for ($i = 1; $i <= 31; $i++){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
															Month&nbsp;&nbsp;
															<select name="DateofWritingMonthToSelect" id="DateofWritingMonthToSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		for ($i = 1; $i <= 12; $i++){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
															Year&nbsp;&nbsp;
															<select name="DateofWritingYearToSelect" id="DateofWritingYearToSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		$year = date("Y");
								          						  		for ($i = $year; $i >= 1900; $i--){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
													</div>
												</td>
				       						</tr>
				       						<tr>
				       							<td>
				       								<input type="checkbox" name="DatesMentionedCheckbox" id="DatesMentionedCheckbox" onchange="toggle(&#34;DatesMentionedTextDiv&#34;)"/>
				       									Dates Mentioned
				       							</td>
				       							<td>		       							
				       								<div id="DatesMentionedTextDiv" style="display:none">				       											       											       																					
															<b>From</b>&nbsp;&nbsp;&nbsp;
															Day&nbsp;&nbsp;
															<select name="DatesMentionedDayFromSelect" id="DatesMentionedDayFromSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		for ($i = 1; $i <= 31; $i++){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
															Month&nbsp;&nbsp;
															<select name="DatesMentionedMonthFromSelect" id="DatesMentionedMonthFromSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		for ($i = 1; $i <= 12; $i++){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
															Year&nbsp;&nbsp;
															<select name="DatesMentionedYearFromSelect" id="DatesMentionedYearFromSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		$year = date("Y");
								          						  		for ($i = $year; $i >= 1900; $i--){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
															&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
															<b>To</b>&nbsp;&nbsp;&nbsp;
															Day&nbsp;&nbsp;
															<select name="DatesMentionedDayToSelect" id="DatesMentionedDayToSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		for ($i = 1; $i <= 31; $i++){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
															Month&nbsp;&nbsp;
															<select name="DatesMentionedMonthToSelect" id="DatesMentionedMonthToSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		for ($i = 1; $i <= 12; $i++){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
															Year&nbsp;&nbsp;
															<select name="DatesMentionedYearToSelect" id="DatesMentionedYearToSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		$year = date("Y");
								          						  		for ($i = $year; $i >= 1900; $i--){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
													</div>
												</td>
				       						</tr> 									       						
				       					</table>
			       					</div>
			       					<br></br>
			       					<div style="border:1px solid gray"	>
			       					<b>&nbsp;&nbsp;&nbsp;Document Metadata</b>
			       					<table>				       								       					
			       						<tr>
			       							<td>
			       								<input type="checkbox" name="DocumentNameCheckbox" id="DocumentNameCheckbox" onchange="toggle(&#34;DocumentNameTextDiv&#34;)"/>
			       									File Name
			       							</td>
			   								<td>		       							
			       								<div id="DocumentNameTextDiv" style="display:none">		       											       								
													<input type="text" id="DocumentNameText" name="DocumentNameText" onchange="changeLable()"/>
												</div>
											</td>
			       						</tr>	
			       						<tr>
			       							<td>
			       								<input type="checkbox" name="LanguageCheckbox" id="LanguageCheckbox" onchange="toggle(&#34;LanguageDiv&#34;)"/>
			       									Languages
			       							</td>
			       							<td>
			       								<div id="LanguageDiv" style="display:none">
			       									<select name="LanguageSelect" id="LanguageSelect" onchange="changeLable()">
						          						  <option value="arabic">Arabic</option>
														  <option value="english">English</option>
														  <option value="french">French</option>
														  <option value="indonesian">Indonesian</option>									 
														  <option value="spanish">Spanish</option>
														  <option value="urdu">Urdu</option>
													</select>
			       								</div>
			       							</td>	
			       						</tr>		       						
			       						<tr>
			       							<td>
			       								<input type="checkbox" name="MetadataCheckbox" id="MetadataCheckbox" onchange="MetadataChange()"/>
			       									File Properties
			       							</td>
			       							<td>
			       								<div id="MetadataDiv" style="display:none">
			       									<select name="MetadataSelect" id="MetadataSelect" onchange="MetadataChange()">
			       										  <option value="Null"> </option> 					          						  
														  <option value="FileCreationDate">File creation date</option>
														  <option value="FileSize">File size</option>
														  <option value="FileLastAccessedDate">File last accessed date</option>
														  <option value="FileModifiedAccessedDate">File modified accessed date</option>
														  <option value="NumberOfLine">Number of line</option>
														  <option value="NumberOfToken">Number of token</option>													  									 
													</select>
			       								</div>
			       							</td>
			       							<td>		       							
			       								<div id="FileSizeDiv" style="display:none">		       								
				       								<select name="FileSizeSelect" id="FileSizeSelect">			       										
							          						<option value="equelTo">Equel to</option>
															<option value="greaterThan">Greater than</option>
															<option value="lessthan">Less than</option>															  											 
													</select>																						
			       								</div>
			       							</td>		       							
			       							<td>
			       								<div id="FileSizeTextDiv" style="display:none">	
													<input type="text" id="FileSizeText" name="FileSizeText"/> KB
												</div>
											</td>
											<td>		       							
			       								<div id="NumberOfLineDiv" style="display:none">		       								
				       								<select name="NumberOfLineSelect" id="NumberOfLineSelect">			       										
							          						<option value="equelTo">Equel to</option>
															<option value="greaterThan">Greater than</option>
															<option value="lessthan">Less than</option>															  											 
													</select>																						
			       								</div>
			       							</td>	
											<td>		       							
			       								<div id="NumberOfLineTextDiv" style="display:none">		       											       								
													<input type="text" id="NumberOfLineText" name="NumberOfLineText"/>
												</div>
											</td>
											<td>		       							
			       								<div id="DocumentTypeDiv" style="display:none">
			       									<select name="DocumentTypeSelect" id="DocumentTypeSelect" onchange="changeLable()">
						          						  <option value="txt">txt</option>
														  <option value="pdf">pdf</option>
														  <option value="doc">doc</option>
														  <option value="docx">docx</option>									 
													</select>
			       								</div>
											</td>
			       						</tr>
			       						<tr>
			       							<td>
				       								<input type="checkbox" name="DateofAnalysisCheckbox" id="DateofAnalysisCheckbox" onchange="toggle(&#34;DateofAnalysisTextDiv&#34;)"/>
				       									Date of Analysis
				       							</td>
				       							<td>		       							
				       								<div id="DateofAnalysisTextDiv" style="display:none">				       											       											       																					
															<b>From</b>&nbsp;&nbsp;&nbsp;
															Day&nbsp;&nbsp;
															<select name="DateofAnalysisDayFromSelect" id="DateofAnalysisDayFromSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		for ($i = 1; $i <= 31; $i++){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
															Month&nbsp;&nbsp;
															<select name="DateofAnalysisMonthFromSelect" id="DateofAnalysisMonthFromSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		for ($i = 1; $i <= 12; $i++){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
															Year&nbsp;&nbsp;
															<select name="DateofAnalysisYearFromSelect" id="DateofAnalysisYearFromSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		$year = date("Y");
								          						  		for ($i = $year; $i >= 1900; $i--){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
															&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
															<b>To</b>&nbsp;&nbsp;&nbsp;
															Day&nbsp;&nbsp;
															<select name="DateofAnalysisDayToSelect" id="DateofAnalysisDayToSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		for ($i = 1; $i <= 31; $i++){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
															Month&nbsp;&nbsp;
															<select name="DateofAnalysisMonthToSelect" id="DateofAnalysisMonthToSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		for ($i = 1; $i <= 12; $i++){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
															Year&nbsp;&nbsp;
															<select name="DateofAnalysisYearToSelect" id="DateofAnalysisYearToSelect" onchange="changeLable()">
								          						  <option value="None"></option>
								          						  <?php
								          						  		$year = date("Y");
								          						  		for ($i = $year; $i >= 1900; $i--){
								          						  			echo "<option value=\"$i\">$i</option>";
								          						  		}								          						  		
								          						  ?>																 																	
															</select>
													</div>
												</td>
			       						</tr>	
			       						<tr>
			       							<td>
			       								<input type="checkbox" name="userNotesCheckbox" id="userNotesCheckbox" onchange="toggle(&#34;userNotesDiv&#34;);toggle(&#34;userNotesTextDiv&#34;)"/>
			       									User Notes
			       							</td>
			       							<td>
			       								<div id="userNotesDiv" style="display:none">
			       									Who wrote the notes:
			       									<select name="userNotesSelect" id="userNotesSelect" >
			       									<?php
			       											echo "<option value=\"All\">All</option>";
			       											$mysqli = new mysqli($databaseHost, $databaseUser, $databasePass, $databaseName);
			       											$sql = "SELECT username FROM usercake_users ORDER BY username";
															$res = $mysqli->query($sql);
															if (!empty($res)){	
																while ($row = $res->fetch_object()){																			
																	echo "<option value=\"" . $row->username . "\">" . $row->username ."</option>";
																	
																}  
															}
			       									?>			       										  													  												  									
													</select>
			       								</div>
			       							</td>			       								       						
			       							<td>
			       								<div id="userNotesTextDiv" style="display:none">	
													What to search: <input type="text" id="userNotesText" name="userNotesText"/>
												</div>
											</td>											
			       						</tr>		       									       									       								       									       									       											       									       					
			       					</table>
			       					</div>									 								
	          					</div>
	          					<div id="EntityDiv" style="display:none">	          					
	          						<table>
	          							<tr>	          								
	          						  		<td>
	          						  			<input type="checkbox" name="PersonEntityAttributesCheckbox" id="PersonEntityAttributesCheckbox" onchange="EntityChange()"/>
			       									Person Entity attributes
			       							</td>
			       							<td>
			       								<div id="PersonEntityAttributesDiv" style="display:none">
			       									<select name="PersonEntityAttributesSelect" id="PersonEntityAttributesSelect">
						          						  <option value="Name">Name</option>
														  <option value="Religion">Religion/Sect</option>
														  <option value="PoliticalAffiliation">Political Affiliation</option>
														  <option value="PlaceOfResidence">Place of Residence</option>
														  <option value="PlaceOfBirth">Place of birth</option>
														  <option value="Age">Age</option>
														  <option value="Relationships">Relationships</option>													 									
													</select>
			       								</div>
			       							</td>
			       						</tr>
			       						
			       					</table>									 								
	          					</div>
          				</span>          				
          			</span>
        		<!--</form>-->
	    	</div>
        </div>        
      </div>


      
  </div>

</div>
</body>
<script type="text/javascript">
	documentChange();
	MetadataChange();
</script>
</html>

