<html>

	<head>
		<title><?php print EDITOR_NAME; ?></title>
		<?php eval(include_namespace(HEAD_FILE)); ?>
		<script language="JavaScript">
		
			function view(ID) {
				popup("<?=$editor_index?>?page=content_view&ID=" + ID, 500, 450, "");
			}

			function edit(path, field) {
				location = "<?=$wrapper_page?>?page=content_edit&path=" + path + "&field=" + field;
			}

			function schedule(ID) {
				ajax_URL = "<?=$editor_index?>?page=content_schedule&ID=" + ID;
				success_code = "load_list(); show_feedback(ajax_response);";
				failure_code = "alert(\"There was an error scheduling the content.\");";
				ajax_request(ajax_URL, success_code, failure_code);
			}

			function publish(ID, schedule) {
				now = timestamp();
				if ((schedule < now)||(confirm("This content is scheduled for publishing on " + schedule + ". If you want to publish it immediately, click OK. Otherwise, click Cancel and it will be published automatically on the scheduled date."))) {
					ajax_URL = "<?=$editor_index?>?page=content_publish&ID=" + ID;
					success_code = "load_list(); show_feedback(ajax_response);";
					failure_code = "alert(\"There was an error publishing the content.\");";
					ajax_request(ajax_URL, success_code, failure_code);
				}
			}

			function revert(path, field) {
				if (confirm("Are you sure you wish to revert this content to the last published version?")) {
					ajax_URL = "<?=$editor_index?>?page=content_revert&path=" + path + "&field=" + field;
					success_code = "load_list(); show_feedback(ajax_response);";
					failure_code = "alert(\"There was an error reverting the content.\");";
					ajax_request(ajax_URL, success_code, failure_code);
				}
			}

			function apply_filters() {
				load_list();
			}
			
			function reset_filters() {
				for (i=0; i<filters.elements["filter_status[]"].length; i++) {
					document.filters.elements["filter_status[]"][i].checked = 0;
				}
				document.filters.filter_user.selectedIndex = 0;
			}
			
			function serialize_filters() {
				data = new Object;
				filter_status = new Array();
				for (i=0; i<document.filters.elements["filter_status[]"].length; i++) {
					if (document.filters.elements["filter_status[]"][i].checked) {
						filter_status[filter_status.length] = document.filters.elements["filter_status[]"][i].value;
					}
				}
				filter_status = filter_status.join(",");
				data["filter_status"] = filter_status;
				data["filter_user"] = document.filters.filter_user.selectedIndex;
				data["sort"] = document.filters.sort.value;
				data["start"] = document.filters.start.value;
				data["filters_submitted"] = document.filters.filters_submitted.value;
				data = ajax_serialize(data, 0);
				return data;
			}
			
			function sort(column) {
				document.filters.sort.value = column;
				load_list();
			}

			function click_pagination_link(start) {
				document.filters.start.value = start;
				load_list();
			}

			function load_list() {
				clear_feedback();
				ajax_URL = "<?=$editor_index?>?page=content_review_list&" + serialize_filters();
				success_code = "document.getElementById('list').innerHTML = ajax_response;";
				failure_code = "alert(\"There was an error loading the list.\");";
				ajax_request(ajax_URL, success_code, failure_code);
			}
			
			function select_user(user) {
				set_menu("filters", "filter_user", "value", user);
			}
			
			function show_feedback(message) {
				document.getElementById("feedback").innerHTML = message;
			}
			
			function clear_feedback() {
				document.getElementById('feedback').innerHTML = "";
			}
			
		</script>
	</head>
	
	<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
	
		<?php eval(include_namespace(HEADER_FILE)); ?>

		<p class="title">Review edits</p>
		
		<div id="feedback"></div>

		<div class="filters">
		<?php

			// get saved filter values from the database
			prepare_filters("user", $user, "content_review", "status,user");

			// display the filter options
			print "<form name=\"filters\" onsubmit=\"return false;\">\n\n";
			
			print "<p class=\"body stack_left\">View content of status...<br />\n";
			print make_checkboxes("status", "filter_status", "ID", "name", "ID=1,2,3", 0, "&nbsp;", $filter_status);
			print "</p>\n\n";

			print "<p class=\"body stack_left\">View edits by user...<br />\n";
			print make_menu("User...", "user", "filter_user", "ID", "name", 0, 1, 0, "", $filter_user);
			print "<a href=\"JavaScript:select_user($user);\">me</a>\n";
			print "</p>\n\n";
			print "<div class=\"reset\"></div>\n";
			
			print "<div class=\"reset\"></div>\n";
			
			print "<input type=\"hidden\" name=\"sort\" value=\"\">\n";
			print "<input type=\"hidden\" name=\"start\" value=\"0\">\n";
			print "<input type=\"hidden\" name=\"filters_submitted\" value=\"1\">\n";
			print "<input type=\"submit\" value=\"View\" class=\"form\" onclick=\"apply_filters()\">\n";
			print "&nbsp;<input type=\"button\" value=\"Reset\" class=\"form\" onclick=\"reset_filters()\">\n\n";
			
			print "</form>\n\n";

		?>
		</div>
		
		<div id="list" class="body">
		</div>
		
		<script language="JavaScript">
			load_list();
		</script>
		
		<?php eval(include_namespace(FOOTER_FILE)); ?>

	</body>
	
</html>