<div class="BodyContainer">
<form action="%%GLOBAL_FormAction%%" method="POST" onsubmit="return checkForm(this);">
	<table class="OuterPanel" id="outerpanel" cellspacing="0" cellpadding="0" border="0" width="100%">
	<tr>
		<td class="Heading1">%%LNG_AdvancedSearch%%</td>
	</tr>
	<tr>
		<td>
			<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td class="Intro">
					<div>
					%%LNG_AdvancedSearchIntro%%
					</div>
				</td>
			</tr>
			<tr>
				<td>
				%%GLOBAL_Message%%
				</td>
			</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<input type="submit" value="%%LNG_Search%%" class="formbutton">
			<input type="reset" value="%%LNG_Cancel%%" class="formbutton">
		</td>
	</tr>
	<tr>
		<td class="gap">&nbsp;</td>
	</tr>
	<tr>
		<td>
			<table width="100%" border="0" cellpadding="0" cellspacing="0" >
			<tr>
				<td>
					<table class="Panel"  style="padding:50px;">
					<tr>
						<td class="Heading2" colspan="2">%%LNG_AdvancedSearch%%: </td>
					</tr>
					<tr>
						<td class="FieldLabel">%%LNG_Keyword%%: </td>
						<td>
							<input name="q" id="q" class="Field308" value="%%GLOBAL_SearchQuery%%">
						</td>
					</tr>
					<tr>
						<td class="FieldLabel">%%LNG_QuestionCategories%%: </td>
						<td>
							<select name="categories[]" class="Field308" size="10" multiple>
								%%GLOBAL_CategoryOptions%%
							</select>
						</td>
					</tr>
					<tr style="%%GLOBAL_ShowStatus%%">
						<td class="FieldLabel">%%LNG_QuestionStatus%%: </td>
						<td>
							%%GLOBAL_StatusOptions%%
						</td>
					</tr>
					<tr>
						<td class="FieldLabel">%%LNG_QuestionViews%%: </td>
						<td>
							<select name="viewedop" class="Field250">
								%%GLOBAL_viewedOp%%
							</select>
							<input class="Field50" name="viewed" id="viewed" value="%%GLOBAL_viewed%%">
						</td>
					</tr>
					<tr>
						<td class="FieldLabel">%%LNG_QuestionLastUpdated%%: </td>
						<td valign="top">
							<select name="lastupdatedop" class="Field175">
								%%GLOBAL_lastupdatedOp%%
							</select>
							<input type="text" id="lastupdated" name="lastupdated" value="%%GLOBAL_lastupdated%%" size="10" class="Field75" style="margin-left: 4px;" readonly>
							<img src="images/calbtn.gif" align="top" width="34" height="22" alt="toggle calendar" onclick="toggleCal();" style="margin-left: 4px;">
							<span id="lastupdatedCal" style="display: none; position: absolute; margin-left: 5px;"></span>
						</td>
					</tr>
					<tr>
						<td class="FieldLabel">%%LNG_QuestionRating%%: </td>
						<td>
							<select name="ratedop" class="Field250">
								%%GLOBAL_ratedOp%%
							</select>
							<select name="rated" class="Field50">
								%%GLOBAL_ratedBrackets%%
							</select>
						</td>
					</tr>
					<tr>
						<td class="FieldLabel">%%LNG_Visible%%: </td>
						<td>
							<input type="radio" name="visible" value="yes" id="yes" %%GLOBAL_VisibleYesChecked%%><label for="yes">%%LNG_YYes%%</label>
							<input type="radio" name="visible" value="no" id="no" %%GLOBAL_VisibleNoChecked%%><label for="no">%%LNG_NNo%%</label>
							<input type="radio" name="visible" value="both" id="both" %%GLOBAL_VisibleBothChecked%%><label for="both">%%LNG_Both%%</label>
						</td>
					</tr>
					<tr>
						<td class="FieldLabel">%%LNG_Featured%%: </td>
						<td>
							<input type="radio" name="featured" value="yes" id="yes" %%GLOBAL_FeaturedYesChecked%%><label for="yes">%%LNG_YYes%%</label>
							<input type="radio" name="featured" value="no" id="no" %%GLOBAL_FeaturedNoChecked%%><label for="no">%%LNG_NNo%%</label>
							<input type="radio" name="featured" value="both" id="both" %%GLOBAL_FeaturedBothChecked%%><label for="both">%%LNG_Both%%</label>
						</td>
					</tr>
					<tr>
						<td class="gap"></td>
					</tr>
					<tr>
						<td>
							&nbsp;
						</td>
						<td>
							<input type="submit" value="%%LNG_Search%%" class="formbutton"> <input type="reset" value="%%LNG_Cancel%%" class="formbutton">
						</td>
					</tr>
					<tr>
						<td class="gap"></td>
					</tr>
					</table>
				</td>
			</tr>
			</table>
		</td>
	</tr>
	</table>
	</form>
</div>
	<script type="text/javascript">
		function checkForm(f)
		{
			// If they have filled in something for viewed
			if (FV('viewed').length > 0) {
				if (isNaN(parseInt(FV('viewed')))) {
					alert('%%LNG_ErrorViewsMustBeNumber%%');
					$('#viewed').focus();
					$('#viewed').select();
					return false;
				}
			}

			return true;
		}

		function toggleCal()
		{
			if (document.getElementById('lastupdatedCal').style.display == 'inline') {
				document.getElementById('lastupdatedCal').style.display = 'none';
			} else {
				document.getElementById('lastupdatedCal').style.display = 'inline';
				document.getElementById('lastupdatedCal').style.position = 'absolute';
			}
		}

		function updateDate()
		{
			if (dp.getDate() == null) {
				document.getElementById('lastupdated').value = '';
				// We dont need to delay hiding the cal here since they are
				// deselecting the date
				toggleCal();
			} else {
				document.getElementById('lastupdated').value = getFullISODateString(dp.getDate());
				if (dp.getDate().getMonth() == lastMonth) {
					// We do a delayed hide so the user can see their date get
					// selected in the calendar
					setTimeout('toggleCal()', 100);
				} else {
					lastMonth = dp.getDate().getMonth();
				}
			}
		}

		window.onload = function ()
		{
			// When the page loads we need to setup the date picker
			document.getElementById('lastupdatedCal').appendChild(dp.create());
			dp.onchange = updateDate;

			// We also want the focus to go to the search box
			document.getElementById('q').focus();
		}

		// Make the days of the week capital letters
		DatePicker.days = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];

		if ("%%GLOBAL_jsLastupdated%%" == '') {
			var dp = new DatePicker(null);
		} else {
			var d = new Date(%%GLOBAL_jsLastupdated%%);
			var dp = new DatePicker(d);
		}

		if (dp.getDate() != null) {
			var lastMonth = dp.getDate().getMonth();
		} else {
			var today = new Date();
			var lastMonth = today.getMonth();
		}
	</script>
