<% @ Language=VBScript %>
<% Option Explicit %>
<!--#include file="common.asp" -->
<%
'Set the response buffer to true
Response.Buffer = True

'Dimension variables
Dim strMode		'holds the mode of the page, set to true if changes are to be made to the database
Dim strDateFormat	'Holds the date format
Dim strYearFormat	'Holds the year format
Dim intTimeFormat	'Holds the time format
Dim strDateSeporator	'Holds the date seporator between the day/month/year
Dim saryMonth(12)	'Array holding each of the months
Dim strMorningID	'Holds the identifier to show for morning in 12 hour clock
Dim strAfternoonID	'Holds the identifier to show for afternoon in 12 hour clock
Dim intMonthLoopCounter	'Loop counter for the months

'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT " & strDbTable & "DateTimeFormat.* From " & strDbTable & "DateTimeFormat;"
'Set the cursor type property of the record set to Dynamic so we can navigate through the record set
rsCommon.CursorType = 2
'Set the Lock Type for the records so that the record set is only locked when it is updated
rsCommon.LockType = 3
'Query the database
rsCommon.Open strSQL, adoCon
'If the user is changing the date/time setup then update the database
If Request.Form("postBack") Then
	With rsCommon
		'Update the recordset
		.Fields("Date_Format") = Request.Form("dateFormat")
		.Fields("Year_format") = Request.Form("yearFormat")
		.Fields("Time_format") = Request.Form("timeFormat")
		.Fields("Seporator") = Request.Form("seporator")
		.Fields("am") = Request.Form("am")
		.Fields("pm") = Request.Form("pm")
		'Upadet the months (arrays start at 0 in VBScript but for simplisity we are not using location 1)
		For intMonthLoopCounter = 1 to 12
			.Fields("Month" & intMonthLoopCounter) = Request.Form("month" & intMonthLoopCounter)
		Next
		'Update the database with the new user's details
		.Update
		'Re-run the query to read in the updated recordset from the database
		.Requery
	End With
	'Empty the application level array holding the date and time format so that any changes are visable in the main forum
	Application("saryAppDateTimeData") = null
End If

'Read in the deatils from the database
If NOT rsCommon.EOF Then
	'Read in the date/time setup from the database
	'Update the recordset
	strDateFormat = rsCommon("Date_Format")
	strYearFormat = rsCommon("Year_format")
	intTimeFormat = CInt(rsCommon("Time_format"))
	strDateSeporator = rsCommon("Seporator")
	strMorningID = rsCommon("am")
	strAfternoonID = rsCommon("pm")
	'Update the months (arrays start at 0 in VBScript but for simplisity we are not using location 1)
	For intMonthLoopCounter = 1 to 12
		saryMonth(intMonthLoopCounter) = rsCommon.Fields("Month" & intMonthLoopCounter)
	Next
End If
'Reset Server Objects
rsCommon.Close
Set rsCommon = Nothing
adoCon.Close
Set adoCon = Nothing
%>
<html>
<head>
<title>FORUM DATE & TIME SETTINGS</title>

<!-- Check the from is filled in correctly before submitting -->
<script  language="JavaScript">
<!-- Hide from older browsers...

//Function to check form is filled in correctly before submitting
function CheckForm () {

	//Intialise variables
	var errorMsg = "";
	var errorMsgLong = "";

	//Check for all the month fields having values
	for (var count = 3; count <= 15; ++count){
		if (document.frmDateTime.elements[count].value == ""){

			var monthName;

			//get the month
			if (count == 3) {monthName = "January\t";}
			else if (count == 4) {monthName = "February\t";}
			else if (count == 5) {monthName = "March\t";}
			else if (count == 6) {monthName = "April\t";}
			else if (count == 7) {monthName = "May\t";}
			else if (count == 8) {monthName = "June\t";}
			else if (count == 9) {monthName = "July\t";}
			else if (count == 10) {monthName = "August\t";}
			else if (count == 11) {monthName = "September";}
			else if (count == 12) {monthName = "October\t";}
			else if (count == 13) {monthName = "Nevember";}
			else if (count == 14) {monthName = "December";}

			//Wriet the error message
			errorMsg += "\n\t" + monthName + " \t- Enter a value for " + monthName;
		}
	}

	//If there is aproblem with the form then display an error
	if ((errorMsg != "") || (errorMsgLong != "")){
		msg = "___________________________________________________________________\n\n";
		msg += "Your settings have not been updated because there are problem(s) with the form.\n";
		msg += "Please correct the problem(s) and re-submit the form.\n";
		msg += "___________________________________________________________________\n\n";
		msg += "The following field(s) need to be corrected: -\n";

		errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);
		return false;
	}

	return true;
}
// -->
</script>
</head>
<body bgcolor="#FFFFFF">
<body bgcolor="#FFFFFF">
<font face='verdana' style='font size:7pt; font face:bold ;color:#b50000'>
	FORUM DATE & TIME SETTINGS
</font>
<br><br>
<font face='verdana' style='font size:7pt'>
	From here you can configure the format of date and time settings in the forum.
</font>

<form method="post" name="frmDateTime" action="date_time_configure.asp" onSubmit="return CheckForm();">
	<table width="100%" border="0" cellpadding="4" cellspacing="0">
		<tr align="left" bgcolor="#dfdfdf">
			<td height="20" colspan="2">
				<font face='verdana' style='font size:7pt; font face:bold ;color:#b50000'>
					DATE SETTING
				</font>
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td width="77%" align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
					DATE FORMAT :
				</font>
			</td>
			<td valign="top"> 
				<select name="dateFormat" style="width: 130px; font-family: Arial; font-size: 8pt; font-weight: bold">
					<option value="dd/mm/yy" <% If strDateFormat = "dd/mm/yy" Then Response.Write("selected") %>>Day/Month/Year</option>
					<option value="mm/dd/yy" <% If strDateFormat = "mm/dd/yy" Then Response.Write("selected") %>>Month/Day/Year</option>
					<option value="yy/mm/dd" <% If strDateFormat = "yy/mm/dd" Then Response.Write("selected") %>>Year/Month/Day</option>
					<option value="yy/dd/mm" <% If strDateFormat = "yy/dd/mm" Then Response.Write("selected") %>>Year/Day/Month</option>
				</select>
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td width="59%" align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
				SEPARATOR :
				</font>
				<br>
				<font face='verdana' style='font size:7pt'>
					This is the separator between the date
					<br>
					eg: 12/12/2003, 12-12-2003, etc.
				</font>
			</td>
			<td valign="top"> 
				<select name="seporator" style="width: 130px; font-family: Arial; font-size: 8pt; font-weight: bold">
					<option value="&amp;nbsp;" <% If strDateSeporator = "&nbsp;" Then Response.Write("selected") %>>&lt;space&gt;</option>
					<option value="/" <% If strDateSeporator = "/" Then Response.Write("selected") %>>/</option>
					<option value="\" <% If strDateSeporator = "\" Then Response.Write("selected") %>>\</option>
					<option value="-" <% If strDateSeporator = "-" Then Response.Write("selected") %>>-</option>
					<option value="&amp;nbsp;-&amp;nbsp;" <% If strDateSeporator = "&nbsp;-&nbsp;" Then Response.Write("selected") %>>&nbsp;-&nbsp;</option>
					<option value="." <% If strDateSeporator = "." Then Response.Write("selected") %>>.</option>
				</select>
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
					YEAR FORMAT :
				</font>
				<br>
				<font face='verdana' style='font size:7pt'>
					This is whether you want the date in 4 digits (2003) or in 2 digits (02)
				</font>
			</td>
			<td valign="top"> 
				<select name="yearFormat" style="width: 130px; font-family: Arial; font-size: 8pt; font-weight: bold">
					<option value="long" <% If strYearFormat = "long" Then Response.Write("selected") %>>yyyy</option>
					<option value="short" <% If strYearFormat = "short" Then Response.Write("selected") %>>yy</option>
				</select>
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
					JANUARY* :
				</font>
				<br>
				<font face='verdana' style='font size:7pt'>
					This is what you would like displayed for January eg: 01, 1, Jan, etc.
				</font>
			</td>
			<td valign="top"> 
				<input type="text" name="month1" style="font-family: Arial; font-size: 8pt; font-weight: bold" maxlength="15" value="<% = saryMonth(1) %>" size="15" >
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
					FEBRUARY* :
				</font>
			</td>
			<td valign="top"> 
				<input type="text" name="month2" style="font-family: Arial; font-size: 8pt; font-weight: bold" maxlength="15" value="<% = saryMonth(2) %>" size="15" >
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
					MARCH *:
				</font>
			</td>
			<td valign="top"> 
				<input type="text" name="month3" style="font-family: Arial; font-size: 8pt; font-weight: bold" maxlength="15" value="<% = saryMonth(3) %>" size="15" >
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
					APRIL* :
				</font>
			</td>
			<td valign="top"> 
				<input type="text" name="month4" style="font-family: Arial; font-size: 8pt; font-weight: bold" maxlength="15" value="<% = saryMonth(4) %>" size="15" >
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
				MAY* :
				</font>
			</td>
			<td valign="top"> 
			    <input type="text" name="month5" style="font-family: Arial; font-size: 8pt; font-weight: bold" maxlength="15" value="<% = saryMonth(5) %>" size="15" >
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
					JUNE* :
				</font>
			</td>
			<td valign="top"> 
				<input type="text" name="month6" style="font-family: Arial; font-size: 8pt; font-weight: bold" maxlength="15" value="<% = saryMonth(6) %>" size="15" >
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
				JULY* :
				</font>
			</td>
			<td valign="top"> 
				<input type="text" name="month7" style="font-family: Arial; font-size: 8pt; font-weight: bold" maxlength="15" value="<% = saryMonth(7) %>" size="15" >
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
					AUGUST* :
				</font>
			</td>
			<td valign="top"> 
				<input type="text" name="month8" style="font-family: Arial; font-size: 8pt; font-weight: bold" maxlength="15" value="<% = saryMonth(8) %>" size="15" >
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
					SEPTEMBER* :
				</font>
			</td>
			<td valign="top"> 
				<input type="text" name="month9" style="font-family: Arial; font-size: 8pt; font-weight: bold" maxlength="15" value="<% = saryMonth(9) %>" size="15" >
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
					OCTOBER* :
				</font>
			</td>
			<td valign="top"> 
				<input type="text" name="month10" style="font-family: Arial; font-size: 8pt; font-weight: bold" maxlength="15" value="<% = saryMonth(10) %>" size="15" >
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
					NOVEMBER* :
				</font>
			</td>
			<td valign="top"> 
				<input type="text" name="month11" style="font-family: Arial; font-size: 8pt; font-weight: bold" maxlength="15" value="<% = saryMonth(11) %>" size="15" >
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
					DECEMBER* :
				</font>
			</td>
			<td valign="top"> 
				<input type="text" name="month12" style="font-family: Arial; font-size: 8pt; font-weight: bold" maxlength="15" value="<% = saryMonth(12) %>" size="15" >
			</td>
		</tr>
		<tr bgcolor="#dfdfdf">
			<td height="20" colspan="2" align="left">
	      		<font face='verdana' style='font size:7pt; font face:bold ;color:#b50000'>
					TIME SETTING
				</font>
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
					TIME FORMAT :
				</font>
				<br>	
				<font face='verdana' style='font size:7pt;'>
					For 12 hour clock set to 12 for military time (24 hour clock) set to 24
				</font>
			</td>
			<td valign="top"> 
				<select name="timeFormat" style="width: 130px; font-family: Arial; font-size: 8pt; font-weight: bold">
					<option value="12" <% If intTimeFormat = 12 Then Response.Write("selected") %>>12 Hour Clock</option>
					<option value="24" <% If intTimeFormat = 24 Then Response.Write("selected") %>>24 Hour Clock</option>
				</select>
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
					MORNING IDENTIFIER FOR 12 HOUR CLOCK TIMES :
				</font>
				<br>	
				<font face='verdana' style='font size:7pt;'>
					example: am
				</font>
			</td>
			<td valign="top"> 
				<input type="text" name="am" style="font-family: Arial; font-size: 8pt; font-weight: bold" maxlength="5" value="<% = strMorningID %>" size="5" >
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td align="left">
				<font face='verdana' style='font size:7pt; font face:bold'>
					AFTERNOON IDENTIFIER FOR 12 HOUR CLOCK TIMES :
				</font>
				<br>	
				<font face='verdana' style='font size:7pt;'>
					example: pm
				</font>
			</td>
			<td valign="top"> 
				<input type="text" name="pm" style="font-family: Arial; font-size: 8pt; font-weight: bold" maxlength="5" value="<% = strAfternoonID %>" size="5" >
			</td>
		</tr>
		<tr bgcolor="#efefef"> 
			<td height="2" colspan="2" valign="top" align='right'> 
				<input type="hidden" name="postBack" value="true">
				<input type="submit" name="Submit" value="SAVE" style="font-size: 7pt; font-family: verdana; font face:bold; width: 60px; height:20">
				<input type="reset" name="Reset" value="RESET" style="font-size: 7pt; font-family: verdana; font face:bold; width: 60px; height:20">
			</td>
		</tr>
	</table>
</form>
</body>
</html>