 <!-- #include file="functions.asp" -->

<% ' Edit.asp
   ' This page is used to edit existing database content.
   ' The id variable holds the row number of the document
   ' to be edited.  %>

<% ' The id variable is requested from the querystring 
   ' and stored for use in the database query
	  Dim id, edit_title, edit_html, edit_id, sql
	  id = Request.QueryString("id") %>

<% If trim(Request.Form("submit")) = "Save" Then   
		' Declare variables, and store data from fields in contentEdit.asp
		' All data is checked, using the function SQLFilter, to ensure that
		' it is SQL safe.
 
			edit_title = SQLFilter(Request.Form("edit_title"))
			edit_html  = SQLFilter(Request.Form("edit_html"))
			edit_id    = Request.Form("edit_id") 

			If edit_title = "" then Response.Redirect("error.asp") 

		' Creates SQL statement based on above variables and executes then
		' the command    
			SQL = "UPDATE wysiwyg_tbl SET cat_id='" & cat_id &"', edit_title = '" & edit_title & "', edit_html = '" & edit_html & "' WHERE edit_id = " & edit_id
			DBConnect SQL

		' Redirects to main table of contents page when finished
			Response.Redirect(default_page)
	
	Else

		' Assuming that the id is non-empty, the content is 
		' retrieved from the database.  Assuming that the query
		' is non-empty (ie the row exists), the data is displayed
		' using the eWebEditPro object. 
   
		If id <> "" Then
		DBConnect "SELECT * FROM wysiwyg_tbl WHERE edit_id = " & id
			If Not obJRS.EOF Then
				edit_title = objRS("edit_title")
				edit_html  = objRS("edit_html") %>
			
				<html>
				<STYLE>
BODY {SCROLLBAR-FACE-COLOR: #5e5ebe; SCROLLBAR-HIGHLIGHT-COLOR: #5e5ebe; SCROLLBAR-SHADOW-COLOR: #5e5ebe; SCROLLBAR-3DLIGHT-COLOR: #5e5ebe; SCROLLBAR-ARROW-COLOR:  #6666CC; SCROLLBAR-TRACK-COLOR: #E3E3E3; SCROLLBAR-DARKSHADOW-COLOR: #666666; }
</STYLE>
<head>
				<title>Edit Document</title>
					<!-- #include virtual="/ewebeditpro/ewebeditpro.asp" -->
				</head>
		
				<body>
	
						<table border=0 width=100%>
						<tr>
							<td colspan=3>
								<font face="Verdana" size="3">
									<b>Edit Document</b>
								</font>
							</td>
						</tr>
						
						<tr>
							<td>
								<font face="Verdana" size="2">
									Title:
								</font>
							</td>
			
							<td align=left>
								<% ' The existing title is taken from the database and
								   ' displayed in this text field.  %>
								<form name="frmMain" action="edit.asp" method="post">
								<input type=hidden name="edit_id" value="<% = id %>">
									<% ' A hidden field containing the id is used to 
									   ' to indicate to the posting page exactly which 
									   ' row is to be updated.  %>
								<input type="text" size=50 maxlength=255 name="edit_title" value="<% = edit_title %>">
	
							</td>

							<td align=right> 
								<input type=submit name="submit" value="Save">
								<input type="Button" name="btnCancle" value="Cancel" onclick="eWebEditPro.actionOnUnload=EWEP_ONUNLOAD_NOSAVE; location.href='index.asp';">						
							</td>
						</tr>
									
						<tr>
							<td colspan=3>
								<font face="Verdana" size="2">
									Body:
								</font>
							</td>
						</tr>
						</table>
						
							<% ' The following line creates the an editor object,
							   ' specifying edit_html as the field to copy data into
							   ' once the submit button has been activated.  Notice
							   ' that the existing content, contained in objRS object,
							   ' is copied into that editor.  %>

								<% =eWebEditProEditor("edit_html", "100%", "75%", edit_html) %><br>
								<script language="JavaScript1.2">
								eWebEditPro.onready = "initTransferMethod(eWebEditPro.event.srcName)";
								function initTransferMethod(sEditor)
								{
									eWebEditPro[sEditor].MediaFile().setProperty("TransferMethod", "mediamanager.asp");
								}
								</script>
								
					</form>
				</body>
				</html>	
		<% End If %>

	<% ' At the end of each page's script portion, the DBClose 
	   ' function ought to be called to close and destroy the
	   ' recordset objects
		DBClose %>
		
	<% End If %>
<% End If %>