<%@ Language=VBScript %>
<% Response.Buffer = TRUE %>

<%
  ' Script Name   : aspWebHeadlines
  ' File Name     : news.asp
  ' Version       : 1.1
  ' Release Date  : 6/02/2002
  '
  ' Copyright (c) 2002 by Full Revolution, Inc., All Rights Reserved

%>
<!--#include file="news/adovbs.inc" -->
<!--#include file="news/upload.asp" -->
<%
'******** Set the Local **********************************************************

Session.LCID = 1033 'English (US)
TimeZone = "EST"
ArticleImagePath = "news/articleimages/"
FileDirectory = Server.MapPath("news/") & "\articleimages\"

'******** Open the database  *****************************************************

UseSQLServer = "NO" 'Set to YES if you are using SQL Server instead of MS Access

Dim dbc
Dim strConn

If UseSQLServer = "YES" then
  '---- SQL Connection String -----------------------------------------------------------
  strConn = "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=news; User ID=admin; Password=password;"
  Set dbc = Server.CreateObject("ADODB.Connection")
  dbc.open strConn
Else
 '------- Access Connection String -----------------------------------------------------
  strConn = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("news/news.mdb")
  Set dbc = Server.CreateObject("ADODB.Connection")
  dbc.open strConn
End If

'******* Pull in the Config from DB **********************************************

If Session("ConfigPulledIn") <> "YES" then
  SQL = "SELECT * FROM Config"
  Set RS=dbc.execute(SQL)

  Session("DefaultLayoutType") = RS("DefaultLayoutType")
  Session("DefaultArticleType") = RS("DefaultArticleLayout")

  Session("DefaultFontFace") = RS("DefaultFontFace")
  Session("DefaultFontTitleSize") = RS("DefaultFontTitleSize")
  Session("DefaultFontBodySize") = RS("DefaultFontBodySize")
  Session("DefaultFontColor") = RS("DefaultFontColor")
  Session("EmailComponent") = RS("EmailComponent")
  Session("RecordsPerPage") = RS("AdminRecordsPerPage")
  Session("AdminColor") = RS("AdminColor")
  Session("BackColorOne") = RS("AdminBackColorOne")
  Session("BackColorTwo") = RS("AdminBackColorTwo")
  Session("EmailSiteName") = RS("EmailSiteName")
  Session("EmailSiteURL") = RS("EmailSiteURL")
  Session("EmailHost") = RS("EmailHost")
  Session("BBShowSearch") = RS("BBShowSearch")
  Session("BBShowArchives") = RS("BBShowArchives")
  Session("BBShowSubmit") = RS("BBShowSubmit")
  Session("BBShowEmailAdmin") = RS("BBShowEmailAdmin")
  Session("BBShowLogin") = RS("BBShowLogin")
  Session("BBShowHome") = RS("BBShowHome")
  Session("BBShowSyndication") = RS("BBShowSyndication")
  Session("AdminEmail") = RS("AdminEmail")
  Session("SyndicationText") = RS("SyndicationText")
  Session("ConfigPulledIn") = "YES"

  AdminFolderColor = "news/adminimages/" & Session("AdminColor") & "/"

  RS.Close
  Set RS=Nothing
End If
If Session("ConfigPulledIn") = "YES" then
  DefaultLayoutType = Session("DefaultLayoutType")
  DefaultArticleType = Session("DefaultArticleLayout")

  DefaultFontFace = Session("DefaultFontFace")
  DefaultFontTitleSize = Session("DefaultFontTitleSize")
  DefaultFontBodySize = Session("DefaultFontBodySize")
  DefaultFontColor = Session("DefaultFontColor")
  EmailComponent = Session("EmailComponent")
  RecordsPerPage = Session("RecordsPerPage")
  AdminColor = Session("AdminColor")
  BackColorOne = Session("AdminBackColorOne")
  BackColorTwo = Session("AdminBackColorTwo")
  EmailSiteName = Session("EmailSiteName")
  EmailSiteURL = Session("EmailSiteURL")
  EmailHost = Session("EmailHost")
  BBShowSearch = Session("BBShowSearch")
  BBShowArchives = Session("BBShowArchives")
  BBShowSubmit = Session("BBShowSubmit")
  BBShowEmailAdmin = Session("BBShowEmailAdmin")
  BBShowLogin = Session("BBShowLogin")
  BBShowHome = Session("BBShowHome")
  BBShowSyndication = Session("BBShowSyndication")
  SyndicationText = Session("SyndicationText")
  AdminEmail = Session("AdminEmail")

  AdminFolderColor = "news/adminimages/" & AdminColor & "/"
End If

If request.querystring("action") <> "syndicate" then
%>
<SCRIPT LANGUAGE="javascript"> 

function calpopup(lnk,wi,hi) { 

windowSpecs = "height=" + hi + ",width=" + wi + ",scrollbars=no,top=300,left=210"
window.open(lnk, "calendar",windowSpecs) 
} 
</SCRIPT>
<%
End If

'******** Check the Browser Type *************************************************

Dim Browser
  Browser = Request.ServerVariables("HTTP_USER_AGENT")
If InStr(Browser, "MSIE") Then
    BrowserType = "Microsoft"
Else
    BrowserType = "OTHER"
End If

'******** Find out what we should be doing  **************************************

If request.querystring("action") = "" or request.querystring("action") = "catview" then
  Call DrawHeader
  Call NewsHomePage
  Call DrawFooter
End If

If request.querystring("action") = "detail" or request.querystring("action") = "print" then
  Call DrawHeader
  Call DetailView
  Call DrawFooter
End If

If request.querystring("action") = "login" then
  Call DrawLoginScreen
End If

If request.querystring("action") = "processlogin" then
  Call ProcessLogin
End If

If request.querystring("action") = "mainmenu" then
  Call DrawMainMenu
End If

If request.querystring("action") = "logoff" then
  Call LogOff
End If

If request.querystring("action") = "manageauthors" then
  Call ManageAuthors
End If

If request.querystring("action") = "addauthor" then
  Call AddAuthor
End If

If request.querystring("action") = "addauthorprocess" then
  Call AddAuthorProcess
End If

If request.querystring("action") = "editauthor" then
  Call EditAuthor
End If

If request.querystring("action") = "editauthorprocess" then
  Call EditAuthorProcess
End If

If request.querystring("action") = "deleteauthor" then
  Call DeleteAuthor
End If

If request.querystring("action") = "deleteauthorprocess" then
  Call DeleteAuthorProcess
End If

If request.querystring("action") = "managecategories" then
  Call ManageCategories
End If

If request.querystring("action") = "addcategory" then
  Call AddCategory
End If

If request.querystring("action") = "addcategoryprocess" then
  Call AddCategoryProcess
End If

If request.querystring("action") = "editcategory" then
  Call EditCategory
End If

If request.querystring("action") = "editcategoryprocess" then
  Call EditCategoryProcess
End If

If request.querystring("action") = "deletecategory" then
  Call DeleteCategory
End If

If request.querystring("action") = "deletecategoryprocess" then
  Call DeleteCategoryProcess
End If

If request.querystring("action") = "managearticles" then
  Call ManageArticles
End If

If request.querystring("action") = "addarticle" then
  Call AddArticle
End If

If request.querystring("action") = "addarticleprocess" then
  Call AddArticleProcess
End If

If request.querystring("action") = "editarticle" then
  Call EditArticle
End If

If request.querystring("action") = "editarticleprocess" then
  Call EditArticleProcess
End If

If request.querystring("action") = "deletearticle" then
  Call DeleteArticle
End If

If request.querystring("action") = "deletearticleprocess" then
  Call DeleteArticleProcess
End If

If request.querystring("action") = "uploadfile" then
  Call UploadFile
End If

If request.querystring("action") = "uploadfileprocess" then
  Call UploadFileProcess
End If

If request.querystring("action") = "managelayouttypes" then
  Call ManageLayoutTypes
End If

If request.querystring("action") = "addlayouttype" then
  Call AddLayoutType
End If

If request.querystring("action") = "addlayouttypeprocess" then
  Call AddLayoutTypeProcess
End If

If request.querystring("action") = "editlayouttype" then
  Call EditLayoutType
End If

If request.querystring("action") = "editlayouttypeprocess" then
  Call EditLayoutTypeProcess
End If

If request.querystring("action") = "deletelayouttype" then
  Call DeleteLayoutType
End If

If request.querystring("action") = "deletelayouttypeprocess" then
  Call DeleteLayoutTypeProcess
End If

If request.querystring("action") = "editconfig" then
  Call EditConfig
End If

If request.querystring("action") = "editconfigprocess" then
  Call EditConfigProcess
End If

If request.querystring("action") = "managearticlelayouts" then
  Call ManageArticleLayouts
End If

If request.querystring("action") = "addarticlelayout" then
  Call AddArticleLayout
End If

If request.querystring("action") = "addarticlelayoutprocess" then
  Call AddArticleLayoutProcess
End If

If request.querystring("action") = "editarticlelayout" then
  Call EditArticleLayout
End If

If request.querystring("action") = "editarticlelayoutprocess" then
  Call EditArticleLayoutProcess
End If

If request.querystring("action") = "deletearticlelayout" then
  Call DeleteArticleLayout
End If

If request.querystring("action") = "deletearticlelayoutprocess" then
  Call DeleteArticleLayoutProcess
End If

If request.querystring("action") = "archivearticles" then
  Call ArchiveArticles
End If

If request.querystring("action") = "archivearticlesprocess" then
  Call ArchiveArticlesProcess
End If

If request.querystring("action") = "searcharticles" then
  Call DrawHeader
  Call SearchArticles
  Call DrawFooter
End If

If request.querystring("action") = "searcharticlesprocess" then
  Call DrawHeader
  Call SearchArticlesProcess
  Call DrawFooter
End If

If request.querystring("action") = "archives" then
  Call DrawHeader
  Call Archives
  Call DrawFooter
End If

If request.querystring("action") = "summary" then
  Call Summary
End If

If request.querystring("action") = "email" then
  Call EmailToFriend
End If

If request.querystring("action") = "sendemail" then
  Call SendEmail
End If

If request.querystring("action") = "syndicate" then
  Call Syndicate
End If

If request.querystring("action") = "createsyndicationhtml" then
  Call CreateSyndicationHTML
End If

If request.querystring("action") = "createsyndicationhtmlprocess" then
  Call CreateSyndicationHTMLProcess
End If

If request.querystring("action") = "submitnews" then
  Call DrawHeader
  Call AddArticle
  Call DrawFooter
End If

If request.querystring("action") = "minical" then
  If request.querystring("date") = "" then
    CalendarDate = Date()
  Else
    CalendarDate = request.querystring("date")
  End If
  Call DrawMiniCalendar(CalendarDate)
End If


'******** Write out the page header ********************************************

Sub DrawHeader

If request.querystring("category") <> "" then
  SQL = "SELECT * FROM Categories WHERE CategoryID =" & request.querystring("category")
  Set RS=dbc.execute(SQL)
  CategoryLTID = RS("CategoryLayoutType")
  RS.Close
  Set RS=Nothing
  
  If CategoryLTID <> 0 then
    SQL = "SELECT * FROM LayoutTypes WHERE LTID = " & CategoryLTID
    Set RS=dbc.execute(SQL)
    Session("DefaultHeader") = RS("LTHeader")
    Session("DefaultFooter") = RS("LTFooter")
  Else
    SQL = "SELECT DefaultArticleLayout FROM Config"
    Set RS=dbc.execute(SQL)
    DefaultLayoutType = RS("DefaultArticleLayout")
    RS.Close
    Set RS=Nothing
    SQL = "SELECT * FROM LayoutTypes WHERE LTID = " & DefaultLayoutType
    Set RS=dbc.execute(SQL)

    Session("DefaultHeader") = RS("LTHeader")
    Session("DefaultFooter") = RS("LTFooter")
    RS.Close
    Set RS=Nothing
  End If
  
Else
    SQL = "SELECT DefaultLayoutType FROM Config"
    Set RS=dbc.execute(SQL)
    DefaultLayoutType = RS("DefaultLayoutType")
    RS.Close
    Set RS=Nothing
    SQL = "SELECT * FROM LayoutTypes WHERE LTID = " & DefaultLayoutType
    Set RS=dbc.execute(SQL)
    Session("DefaultHeader") = RS("LTHeader")
    Session("DefaultFooter") = RS("LTFooter")
    RS.Close
    Set RS=Nothing
End If

If request.querystring("action") = "print" then
  SQL = "SELECT * FROM LayoutTypes WHERE LTName = 'PRINT'"
  Set RS=dbc.execute(SQL)
  Session("DefaultHeader") = RS("LTHeader")
  Session("DefaultFooter") = RS("LTFooter")
End If

response.write Session("DefaultHeader")

End Sub

'******* Draw HLBox *************************************************************

Sub DrawHLBox(HLHeader, HLFooter)
  
  SQLh = "SELECT ArticleTitle, ArticleID, ArticleStartDate, ArticleEndDate FROM Articles WHERE ArticleStatus = 'PUBLISHED' ORDER BY ArticleDate DESC"
  Set RSh=dbc.execute(SQLh)

  If UseSQLServer <> "YES" then
    RSh.Filter = "ArticleStartDate <= #" & Date() & "# AND ArticleEndDate >= #" & Date() & "#"
  Else
    RSh.Filter = "ArticleStartDate <= '" & Date() & "' AND ArticleEndDate >= '" & Date() & "'"
  End If

  If NOT RSh.EOF then
    response.write HLHeader
    response.write "<FONT FACE='" & DefaultFontFace & "' SIZE='1' COLOR='black'>"
    Do While NOT RSh.EOF
      response.write "<A HREF='news.asp?action=detail&article=" & RSh("ArticleID") & "&category=" & request.querystring("category") & "'>"
      response.write RSh("ArticleTitle")
      response.write "</A><BR><BR>"
      RSh.MoveNext    
    Loop
    response.write "</FONT>"
    response.write HLFooter
  End If
  
  RSh.Close
  Set RSh = Nothing

End Sub

'******* News Home Page (Layout Style) ******************************************

Sub NewsHomePage

If request.querystring("category") = "" then
  UsingLayoutType = DefaultLayoutType
Else
  SQL = "SELECT * FROM Categories WHERE CategoryID = " & request.querystring("category")
  Set RS=dbc.execute(SQL)
  UsingLayoutType = RS("CategoryLayoutType")
  RS.Close
  Set RS=Nothing
End If 

SQL = "SELECT * FROM LayoutTypes WHERE LTID = " & UsingLayoutType
Set RS=dbc.execute(SQL)

If RS.EOF then
  SQL = "SELECT * FROM LayoutTypes WHERE LTID = 1"
  Set RS=dbc.execute(SQL)
End If

LTName = RS("LTName")
LTDescription = RS("LTDescription")
LTNumberToShow = RS("LTNumberToShow")
LTNumberofFeatures = RS("LTNumberOfFeatures")
LTShowCategorySection = RS("LTShowCategorySection")
LTShowNormalHLBox = RS("LTShowNormalHLBox")
LTDateBlockHeader = RS("LTDateBlockHeader")
LTDateBlockFooter = RS("LTDateBlockFooter")
LTLinkToDetailText = RS("LTLinkToDetailText")
LTHLLocation = RS("LTHLLocation")
LTFeaturesAcross = RS("LTFeaturesAcross")
LTShowLastUpdate = RS("LTShowLastUpdate")
LTUpdateBGColor = RS("LTUpdateBGColor")
LTTopNewsHeading = RS("LTTopNewsHeading")
LTRecentNewsHeading = RS("LTRecentNewsHeading")
LTCategoryNewsHeading = RS("LTCategoryNewsHeading")
LTArticlesAcross = RS("LTArticlesAcross")
LTCategoriesAcross = RS("LTCategoriesAcross")
LTGroupByDay = RS("LTGroupByDay")
LTDaysToShow = RS("LTDaysToShow")
LTArticlePadding = RS("LTArticlePadding")
LTShowMoreInfo = RS("LTShowMoreInfo")
LTHLBoxHeader = RS("LTHLBoxHeader")
LTHLBoxFooter = RS("LTHLBoxFooter")

RS.Close
Set RS=Nothing

If request.querystring("action") <> "catview" then
  SQL = "SELECT * FROM Articles WHERE ArticleStatus = 'PUBLISHED' ORDER BY ArticleDate DESC"
  Set RS=dbc.execute(SQL)
  If UseSQLServer <> "YES" then
    RS.Filter = "ArticleStartDate <= #" & Date() & "# AND ArticleEndDate >= #" & Date() & "#"
  Else
    RS.Filter = "ArticleStartDate <= '" & Date() & "' AND ArticleEndDate >= '" & Date() & "'"
  End If
Else
  SQLc = "SELECT * FROM ArticleCategoryLink WHERE CategoryID = " & request.querystring("category")
  Set RSc = dbc.execute(SQLc)
  Do While NOT RSc.EOF
    Articles = Articles & RSc("ArticleID") & ", "
    RSc.MoveNext
  Loop
  If Articles = "" then
    Articles = 0
  End If
  RSc.Close
  Set RSc=Nothing
  SQL = "SELECT * FROM Articles WHERE ArticleID IN(" & Articles & ") AND ArticleStatus = 'PUBLISHED' ORDER BY ArticleDate DESC"
  Set RS=Server.CreateObject("adodb.Recordset")
  RS.Open SQL, dbc, adopenstatic
  If UseSQLServer <> "YES" then
    RS.Filter = "ArticleStartDate <= #" & Date() & "# AND ArticleEndDate >= #" & Date() & "#"
  Else
    RS.Filter = "ArticleStartDate <= '" & Date() & "' AND ArticleEndDate >= '" & Date() & "'"
  End If
End If 

TotalRecords = 0
Do While NOT RS.EOF
  TotalRecords = TotalRecords + 1
  RS.MoveNext
Loop

If TotalRecords <> 0 then
  RS.MoveFirst
End If

If NOT RS.EOF then
  RS.MoveFirst
  LastUpdate = FormatDate(RS("ArticleDate"), "FULL")
End If

'----- Headline Box Start -----------------------------

If LTShowNormalHLBox = "YES" then
  response.write "<TABLE WIDTH='100%' ALIGN='center'><TR>"
  If LTHLBoxLocation = "LEFT" then
    response.write "<TD VALIGN='top' WIDTH='20%'>"
    Call DrawHLBox(LTHLBoxHeader, LTHLBoxFooter)
    response.write "</TD>"
    response.write "<TD valign='top' width='80%'>"
  Else
    response.write "<TD valign='top' WIDTH='80%'>"
  End If
End If

'----- Write last update date -------------------------

If LTShowLastUpdate = "YES" then
  response.write "<table cellSpacing='0' cellPadding='0' width='100%' border='0' bgcolor='" & LTUpdateBGColor & "'><tr><td width='100%'><font face='" & DefaultFontFace & "' size='1'><b>LAST UPDATE: </b><i>"
  response.write LastUpdate
  response.write "</i></font></td></tr></table><BR>"
End If

'----- Write out feature articles ------------------

If NOT RS.EOF then

If LTNumberOfFeatures <> 0 then

  If LTNumberOfFeatures > TotalRecords then
    LTNumberOfFeatures = TotalRecords
  End If


  response.write LTTopNewsHeading
  CellWidth = (100 \ LTFeaturesAcross)

  Counter = 0
  response.write "<TABLE width='100%' cellpadding='0' CELLSPACING='0'>"

  For I = 1 to LTNumberOfFeatures
    If Counter = 0 then
      response.write "<TR>"
    End If
    response.write "<TD valign='top' width='" & CellWidth & "%'><table border='0' cellspacing='0' width='100%' cellpadding='2'><tr>"
    If RS("ArticleImage") <> "" then
      response.write "<td valign='top' width='25%'><p align='center'><img src='" & ArticleImagePath & RS("ArticleImage") & "' border='0'></td>"
    End If
    response.write "<td width='75%' vAlign='top'><b><font face='" & DefaultFontFace & "' SIZE='" & DefaultFontTitleSize & "' COLOR='" & DefaultFontColor & "'>"
    response.write "<a href='news.asp?action=detail&article=" & RS("ArticleID") & "&category=" & request.querystring("category") & "'>"
    response.write RS("ArticleTitle")
    response.write "</a></font></b>"
    If LTShowMoreInfo = "YES" then
      response.write "<BR><FONT FACE='" & DefaultFontFace & "' SIZE='1' COLOR='" & DefaultFontColor & "'>"
      SQLa="SELECT * FROM Authors WHERE AuthorID = " & RS("ArticleAuthor")
      Set RSa = dbc.execute(SQLa)
      response.write "<A HREF='mailto:" & RSa("AuthorEmailAddress") & "'>" & RSa("AuthorFirstName") & " " & RSa("AuthorLastName") & "</A> | " & RS("ArticleSource")
      response.write "</FONT>"
      RSa.Close
      Set RSa=Nothing      
    End If
    
    response.write "<BR><font face='" & DefaultFontFace & "' SIZE='" & DefaultFontBodySize & "' COLOR='" & DefaultFontColor & "'>"
    response.write RS("ArticleSummary")
    response.write "</font>"
    If LTLinkToDetailText <> "" then
      response.write "<BR><BR><FONT FACE='" & DefaultFontFace & "' SIZE='1' COLOR='" & DefaultFontColor & "'>"
      response.write "<A HREF='news.asp?action=detail&article=" & RS("ArticleID") & "&category=" & request.querystring("category") & "'>" & LTLinkToDetailText & "</A></FONT>"
    End If
    response.write "</td></tr></table><br></TD>"
    Counter = Counter + 1
    If Counter = LTFeaturesAcross then
      response.write "</TR>"
      Counter = 0
    End If
    If NOT RS.EOF then
      RS.MoveNext
    End If
  Next
  response.write "</TABLE>"
  
End If

'----- Write Out Recent News Items -----------------------

If LTGroupByDay <> "YES" then
  response.write LTRecentNewsHeading
  LTNumberToShow = LTNumberToShow - LTNumberOfFeatures
  CellWidth = (100 \ LTArticlesAcross)

  Counter = 0
  response.write "<TABLE width='100%' cellpadding='0' CELLSPACING='0'>"

  For I = 1 to LTNumberToShow
  If NOT RS.EOF then
    If Counter = 0 then
      response.write "<TR>"
    End If
    response.write "<TD valign='top' WIDTH='" & CellWidth & "%'>"

    response.write "<table border='0' cellpadding='" & LTArticlePadding & "' cellspacing='0' width='100%'><tr>"
    response.write "<td width='100%'><font face='" & DefaultFontFace & "' SIZE='" & DefaultFontTitleSize & "' COLOR='" & DefaultFontColor & "'><b>"
    response.write "<a href='news.asp?action=detail&article=" & RS("ArticleID") & "&category=" & request.querystring("category") & "'>"
    response.write RS("ArticleTitle")
    response.write "</a></B></font>"
    
    If LTShowMoreInfo = "YES" then
      response.write "<BR><FONT FACE='" & DefaultFontFace & "' SIZE='1' COLOR='" & DefaultFontColor & "'>"
      SQLa="SELECT * FROM Authors WHERE AuthorID = " & RS("ArticleAuthor")
      Set RSa = dbc.execute(SQLa)
      response.write "<A HREF='mailto:" & RSa("AuthorEmailAddress") & "'>" & RSa("AuthorFirstName") & " " & RSa("AuthorLastName") & "</A> | " & RS("ArticleSource")
      response.write "</FONT>"
      RSa.Close
      Set RSa=Nothing      
    End If
    response.write "<BR><font  face='" & DefaultFontFace & "' SIZE='" & DefaultFontBodySize & "' COLOR='" & DefaultFontColor & "'>"
    response.write RS("ArticleSummary")
    response.write "</font>"
    If LTLinkToDetailText <> "" AND RS("ArticleBody") <> "" then
      response.write "<BR><BR><FONT FACE='" & DefaultFontFace & "' SIZE='1' COLOR='" & DefaultFontColor & "'>"
      response.write "<A HREF='news.asp?action=detail&article=" & RS("ArticleID") & "&category=" & request.querystring("category") & "'>" & LTLinkToDetailText & "</A></FONT>"
    End If
    response.write "</font></td></tr></table><br></TD>"
    Counter = Counter + 1
    If Counter = LTArticlesAcross then
      response.write "</TR>"
      Counter = 0
    End If
    If NOT RS.EOF then
      RS.MoveNext
    End If
  End If
  Next
response.write "</TABLE>"
RS.Close
Set RS=Nothing

Else
  Counter = 0
  For I = 1 to LTDaysToShow
    If NOT RS.EOF then
      If Counter = 0 then
        response.write "<TABLE width='100%' cellpadding='0' CELLSPACING='0'>"
        response.write LTDateBlockHeader
        response.write FormatDateTime(RS("ArticleDate"),1)
        response.write LTDateBlockFooter
        CurrentDate = Trim(Left(RS("ArticleDate"), 8))
      End If
      response.write "<TR>"  
      response.write "<TD valign='top' WIDTH='" & CellWidth & "%'>"

      response.write "<table border='0' cellpadding='" & LTArticlePadding & "' cellspacing='0' width='100%'><tr>"
      response.write "<td width='100%'><font face='" & DefaultFontFace & "' SIZE='" & DefaultFontTitleSize & "' COLOR='" & DefaultFontColor & "'><b>"
      response.write "<a href='news.asp?action=detail&article=" & RS("ArticleID") & "&category=" & request.querystring("category") & "'>"
      response.write RS("ArticleTitle")
      response.write "</a></B></font>"
      
      If LTShowMoreInfo = "YES" then
        response.write "<BR><FONT FACE='" & DefaultFontFace & "' SIZE='1' COLOR='" & DefaultFontColor & "'>"
        SQLa="SELECT * FROM Authors WHERE AuthorID = " & RS("ArticleAuthor")
        Set RSa = dbc.execute(SQLa)
        response.write "<A HREF='mailto:" & RSa("AuthorEmailAddress") & "'>" & RSa("AuthorFirstName") & " " & RSa("AuthorLastName") & "</A> | " & RS("ArticleSource")
        response.write "</FONT>"
        RSa.Close
        Set RSa=Nothing      
      End If

      response.write "<BR><font  face='" & DefaultFontFace & "' SIZE='" & DefaultFontBodySize & "' COLOR='" & DefaultFontColor & "'>"
      response.write RS("ArticleSummary")
      response.write "</font>"
      If LTLinkToDetailText <> "" AND RS("ArticleBody") <> "" then
        response.write "<BR><BR><FONT FACE='" & DefaultFontFace & "' SIZE='1' COLOR='" & DefaultFontColor & "'>"
        response.write "<A HREF='news.asp?action=detail&article=" & RS("ArticleID") & "&category=" & request.querystring("category") & "'>" & LTLinkToDetailText & "</A></FONT>"
      End If
      response.write "</font></td></tr></table><br></TD></TR>"

      If NOT RS.EOF then
        RS.MoveNext
        If NOT RS.EOF then
          If CurrentDate <> Trim(Left(RS("ArticleDate"), 8)) then
            response.write "</table>"
            Counter = 0
          Else
            Counter = Counter + 1
          End If
        End If
      End If
    End If
  Next

RS.Close
Set RS=Nothing

End If

Else
  response.write "<FONT FACE='" & DefaultFontFace & "' SIZE='1' COLOR='black'>There is currently no news articles in this category.</FONT><BR><BR>"
End If

'----- Write Out The News Categories ------------------

If LTShowCategorySection = "YES" then

  response.write LTCategoryNewsHeading
  CellWidth = (100 \ LTCategoriesAcross)

  SQLc = "SELECT * FROM Categories ORDER BY CategoryName"
  Set RSc=dbc.execute(SQLc)

  Counter = 0
  response.write "<TABLE width='100%' cellpadding='0' CELLSPACING='0'>"

  Do While NOT RSc.EOF
    If Counter = 0 then
      response.write "<TR>"
    End If
    response.write "<TD valign='top' WIDTH='" & CellWidth & "%'>"

    response.write "<table border='0' cellpadding='2' cellspacing='0' width='100%'><tr><td width='100%'><font face='" & DefaultFontFace & "' SIZE='2' COLOR='" & DefaultFontColor & "'><b>"
    response.write "<a href='news.asp?action=catview&category=" & RSc("CategoryID") & "'>"
    response.write RSc("CategoryName")
    response.write "</a></B></font><br><font  face='" & DefaultFontFace & "' SIZE='1' COLOR='" & DefaultFontColor & "'>"

    SQLd = "SELECT * FROM ArticleCategoryLink WHERE CategoryID = " & RSc("CategoryID")
    Set RSd = dbc.execute(SQLd)
    
    ShowCounter = 0

    Do While NOT RSd.EOF
      SQLe = "SELECT * FROM Articles WHERE ArticleID = " & RSd("ArticleID") & " AND ArticleStatus = 'PUBLISHED'"
      Set RSe=dbc.execute(SQLe)
      If UseSQLServer <> "YES" then
        RSe.Filter = "ArticleStartDate <= #" & Date() & "# AND ArticleEndDate >= #" & Date() & "#"
      Else
        RSe.Filter = "ArticleStartDate <= '" & Date() & "' AND ArticleEndDate >= '" & Date() & "'"
      End If
      If NOT RSe.EOF then
        ShowCounter = 1
        response.write " - <A HREF='news.asp?action=detail&article=" & RSe("ArticleID") & "'>" & RSe("ArticleTitle") & "</A>"
        response.write "<BR>"
      Else
      If RSd.EOF then
        ShowCounter = 1
        response.write "Currently No News"
      End If
      End If
      RSe.Close
      Set RSe=Nothing
      RSd.MoveNext
    Loop
    If ShowCounter <> 1 then
      response.write "Currently No News"
    End If
    RSd.Close
    Set RSd=Nothing
    response.write "</font></font></td></tr></table><br></TD>"
    Counter = Counter + 1
    If Counter = LTCategoriesAcross then
      response.write "</TR>"
      Counter = 0
    End If
    If NOT RSc.EOF then
      RSc.MoveNext
    End If
  Loop

response.write "</TABLE>"
RSc.Close
Set RSc=Nothing  
  
End If

If LTShowNormalHLBox = "YES" then
  If LTHLBoxLocation = "LEFT" then
    response.write "</TD>"
  Else
    response.write "</TD><TD VALIGN='top' WIDTH='20%'>"
    Call DrawHLBox(LTHLBoxHeader, LTHLBoxFooter)
    response.write "</TD>"
  End If
  response.write "</TR></TABLE>"
End If

response.write "<BR>"
Call DrawButtonBar

End Sub

'******* Detail View of an Article (Default View) *********************************

Sub DetailView

'SQL = "SELECT ArticleViews FROM Articles WHERE ArticleID = " & request.querystring("article")
'Set RS=dbc.execute(SQL)
'NumberOfViews = RS("ArticleViews") + 1
'RS.Close
'Set RS=Nothing

'SQL="UPDATE Articles Set ArticleViews = " & NumberOfViews & " WHERE [ArticleID] ="&request.querystring("article")&""
'dbc.Execute(SQL)

  '-------- Pull In Layout Type --------------------------------------------------

  If request.querystring("category") = "" then
    UsingLayoutType = DefaultLayoutType
  Else
    SQL = "SELECT * FROM Categories WHERE CategoryID = " & request.querystring("category")
    Set RS=dbc.execute(SQL)
    UsingLayoutType = RS("CategoryLayoutType")
    RS.Close
    Set RS=Nothing
  End If
  
  If request.querystring("action") = "print" then
    UsingLayoutType = "PRINT"
  End If 
  
  If UsingLayoutType <> "PRINT" then
    SQL = "SELECT * FROM LayoutTypes WHERE LTID = " & UsingLayoutType
    Set RS=dbc.execute(SQL)
  Else
    SQL = "SELECT * FROM LayoutTypes WHERE LTName = 'PRINT'"
    Set RS=dbc.execute(SQL)  
  End If
  If RS.EOF then
    SQL = "SELECT * FROM LayoutTypes WHERE LTID = 1"
    Set RS=dbc.execute(SQL)
  End If
  LTShowNormalHLBox = RS("LTShowNormalHLBox")
  LTHLLocation = RS("LTHLLocation")
  LTHLBoxHeader = RS("LTHLBoxHeader")
  LTHLBoxFooter = RS("LTHLBoxFooter")

  RS.Close
  Set RS=Nothing

  '------------ Determine the layout type -----------------------------------------
  SQL = "SELECT * FROM Articles WHERE ArticleID =" & request.querystring("article")
  Set RS=dbc.execute(SQL)
  ArticleALID = RS("ArticleLayout")
  SQLc = "SELECT * FROM ArticleCategoryLink WHERE ArticleID = " & request.querystring("article")
  Set RSc=dbc.execute(SQLc)
  If NOT RS.EOF then
    ArticleCatID = RSc("CategoryID")
  End If
  If request.querystring("category") <> "" then
    ArticleCatID = request.querystring("category")
  End If
  RSc.Close
  Set RSc=Nothing  
  RS.Close
  Set RS=Nothing
  UseALID = ArticleALID
  If ArticleALID = 0 then
    SQL = "SELECT * FROM Categories WHERE CategoryID = " & ArticleCatID
    Set RS=dbc.execute(SQL)
    CategoryALID = RS("CategoryArticleLayout")
    RS.Close
    Set RS=Nothing
    UseALID = CategoryALID
  End If
  If CateoryALID = 0 then
    SQL = "SELECT * FROM Config WHERE ConfigID = 1"
    Set RS=dbc.execute(SQL)
    DefaultALID = RS("DefaultArticleLayout")
    RS.Close
    Set RS=Nothing
    UseALID = DefaultALID
  End If
  If request.querystring("action") = "print" then
    UseALID = "PRINT"
  End If
 
  '------- Pull in the Article Layout from DB -------------------------------------
  
  If UseALID <> "PRINT" then
    SQL = "SELECT * FROM ArticleLayouts WHERE ALID = " & UseALID
    Set RS=dbc.execute(SQL)
  Else
    SQL = "SELECT * FROM ArticleLayouts WHERE ALName = 'PRINT'"
    Set RS=dbc.execute(SQL)
  End If

  If RS.EOF then
    SQL = "SELECT * FROM ArticleLayouts WHERE ALID = 1"
    Set RS=dbc.execute(SQL)
  End If
  
  ALID = RS("ALID")
  ALName = RS("ALName")
  ALDescription = RS("ALDescription")
  ALShowHeadline = RS("ALShowHeadline")
  ALShowAuthor = RS("ALShowAuthor")
  ALShowSource = RS("ALShowSource")
  ALShowDateTime = RS("ALShowDateTime")
  ALShowSummary = RS("ALShowSummary")
  ALSummaryFontSize = RS("ALSummaryFontSize")
  ALShowArticleImage = RS("ALShowArticleImage")
  ALShowEmailLink = RS("ALShowEmailLink")
  ALShowPrintButton = RS("ALShowPrintButton")
  ALShowRelatedArticles = RS("ALShowRelatedArticles")
  ALShowLine = RS("ALShowLine")
  ALPreview = RS("ALPreview")
  ALRAHeader = RS("ALRAHeader")

  RS.Close
  Set RS=Nothing
    
  '--------------------------------------------------------------------------------

  SQL = "SELECT * FROM Articles WHERE ArticleID =" & request.querystring("article")
  Set RS=dbc.execute(SQL)
  
  SQLa = "SELECT * FROM Authors WHERE AuthorID =" & RS("ArticleAuthor")
  Set RSa=dbc.execute(SQLa)
  
  AuthorFullName = RSa("AuthorFirstName") & " " & RSa("AuthorLastName")
  AuthorEmailAddress = RSa("AuthorEmailAddress")
  
  
If LTShowNormalHLBox = "YES" then
  response.write "<TABLE WIDTH='100%' ALIGN='center'><TR>"
  If LTHLBoxLocation = "LEFT" then
    response.write "<TD VALIGN='top' WIDTH='20%'>"
    Call DrawHLBox(LTHLBoxHeader, LTHLBoxFooter)
    response.write "</TD><TD valign='top' width='80%'>"
  Else
    response.write "<TD valign='top' WIDTH='80%'>"
  End If
End If
    

  response.write "<p><font FACE='" & DefaultFontFace & "'>"
  If ALShowArticleImage = "YES" then
    If RS("ArticleImage") <> "" then
      response.write "<img border='0' src='news/articleimages/" & RS("ArticleImage") & "' align='left'>"
    End If
  End If
  If ALShowHeadline = "YES" then
    response.write "<b>" & RS("ArticleTitle") & "</b>"
  End If
  response.write "</font>"
  response.write "<font FACE='" & DefaultFontFace & "' size='1'>"
  If ALShowAuthor = "YES" then
    response.write "<br>"
    response.write "By: <a href='mailto:" & AuthorEmailAddress & "'>" & AuthorFullName & "</a>"
  End If
  If ALShowSource = "YES" then
    If RS("ArticleSource") <> "" then
      response.write " | Source: "
      If RS("ArticleSourceLink") <> "" then
        response.write "<A target='_new' HREF='" & RS("ArticleSourceLink") & "'>"
      End If
      response.write RS("ArticleSource") 
      If RS("ArticleSourceLink") <> "" then
        response.write "</A>"
      End If
    End If
  End If
  If ALShowDateTime = "YES" then
    response.write "<br>"
    response.write FormatDate(RS("ArticleDate"), "FULL")
  End If
  If ALShowLine = "YES" then
    response.write "<HR SIZE='1' COLOR='black'>"
  End If
  response.write "</font></p>"

  If ALShowSummary = "YES" then
    response.write "<FONT FACE='" & DefaultFontFace & "' SIZE='" & ALSummaryFontSize & "' COLOR='black'><B>"
    response.write RS("ArticleSummary") & "<BR></B></FONT>"
  End If  
  response.write "<p align='justify'><font FACE='" & DefaultFontFace & "' size='2'>"
  
  '-------- Multi-Page Articles -------------------------------------
  If RS("ArticleMultiPage") = "YES" then
    txtArticleBodyArray = split(RS("ArticleBody"), "$$PAGE$$")
    If request.querystring("page") <> "" and request.querystring("page") <> "0" and request.querystring("page") <> "1" then
      page = request.querystring("page") - 1
      txtArticleBody = txtArticleBodyArray(page)
      TotalPages = ubound(txtArticleBodyArray)
      NextPage = page + 2
      PrevPage = page
      If Page + 1 <> TotalPages then
        txtArticleLinkArray = split(txtArticleBody, "$$")
        txtArticleBody = txtArticleLinkArray(0)
        txtArticlePageLink = txtArticleLinkArray(1)
      End If
      txtArticleBody = txtArticleBody & "<BR><BR><A HREF='news.asp?action=detail&article=" & request.querystring("article") & "&category=" & request.querystring("category") & "&page=" & PrevPage & "'>" & "Back</A>"
      If NextPage <= TotalPages then
        txtArticleBody = txtArticleBody & " | <A HREF='news.asp?action=detail&article=" & request.querystring("article") & "&category=" & request.querystring("category") & "&page=" & NextPage & "'>" & txtArticlePageLink & "</A>"
      End If
    Else
      txtArticleBody = txtArticleBodyArray(0)
      NextPage = 2
      txtArticleLinkArray = split(txtArticleBody, "$$")
      txtArticleBody = txtArticleLinkArray(0)
      txtArticlePageLink = txtArticleLinkArray(1)
      txtArticleBody = txtArticleBody & "<BR><A HREF='news.asp?action=detail&article=" & request.querystring("article") & "&category=" & request.querystring("category") & "&page=" & NextPage & "'>" & txtArticlePageLink & "</A>"
    End If
  Else
    txtArticleBody = RS("ArticleBody")
  End If
  response.write txtArticleBody
  response.write "</font></p>"

  response.write "<table width='70%' align='center'><tr>"
  If ALShowEmailLink = "YES" then
    response.write "<td width='20'><img border='0' src='news/icon_email.gif'></td>"
    response.write "<td width='50%'><a href='' "
    %>
      onClick="calpopup('news.asp?action=email&article=<%=RS("ArticleID")%>', '350', '300'); return false"> 
    <%
    response.write "<font FACE='" & DefaultFontFace & "' size='1'> Email this Article</font></a></td>"
  End If
  If ALShowPrintButton = "YES" then
    response.write "<td width='20'><img border='0' src='news/icon_print.gif'></td>"
    response.write "<td width='50%'><a target='_new' href='news.asp?action=print&article=" & RS("ArticleID") & "'><font FACE='" & DefaultFontFace & "' size='1'> Printer Friendly Version</font></a></td>"
  End If
  response.write "</tr></table>"
  
  If ALShowRelatedArticles = "YES" then
    SQLr = GenerateSQLSearch(FixString(RS("ArticleTitle")), "Articles", "ArticleTitle")
    SQLr = SQLr & " AND ArticleID <> " & RS("ArticleID")
    Set RSr=dbc.execute(SQLr)
    
    If NOT RSr.EOF then
      response.write "<BR>"
      response.write ALRAHeader
    End If
    Do While NOT RSr.EOF
      response.write "<FONT FACE='" & DefaultFontFace & "' SIZE='2' COLOR='black'>- "
      response.write "<A HREF='news.asp?action=detail&article=" & RSr("ArticleID") & "'>"
      response.write RSr("ArticleTitle")
      response.write "</A><BR>"
      RSr.MoveNext
    Loop
  End If
  
  If LTShowNormalHLBox = "YES" then
  If LTHLBoxLocation = "LEFT" then
    response.write "</TD>"
  Else
    response.write "</TD><TD VALIGN='top' WIDTH='20%'>"
    Call DrawHLBox(LTHLBoxHeader, LTHLBoxFooter)
    response.write "</TD>"
  End If
  response.write "</TR></TABLE>"
End If

response.write "<BR>"
Call DrawButtonBar

End Sub

'******* Draw Search Page ******************************************************

Sub SearchArticles

response.write "<TABLE WIDTH='100%' ALIGN='left' CELLPADDING='4' CELLSPACING='0'><TR><TD WIDTH='100%' ALIGN='left'><FORM METHOD='post' ACTION='news.asp?action=searcharticlesprocess'>"
response.write "<FONT FACE='" & DefaultFontFace & "' SIZE='1' COLOR='black'>Search For:<BR><INPUT TYPE='text' NAME='txtSearchFor' SIZE='50'><BR>"
response.write "<BR><INPUT TYPE='radio' NAME='txtAndOr' VALUE='AND'>All Words "
response.write "<INPUT TYPE='radio' NAME='txtAndOr' VALUE='OR' checked>Any Words"
response.write "<BR><BR><INPUT TYPE='submit' VALUE='Search'></FONT></FORM></TD></TR><TR><TD width='100%'>"

response.write "<BR>"
Call DrawButtonBar
response.write "</TD></TR></TABLE>"

End Sub

'******* Search Articles Process ***********************************************

Sub SearchArticlesProcess

  txtSearchFor = request.form("txtSearchFor")
  txtSearchIn = request.form("txtSearchIn")
  txtAndOr = request.form("txtAndOr")
  
  SQL = "SELECT ArticleID, ArticleTitle, ArticleSummary, ArticleDate, ArticleStatus, ArticleStartDate, ArticleEndDate FROM Articles WHERE "
  SQL = SQL & "ArticleTitle LIKE '%"
  SQL = SQL & Replace( Trim( txtSearchFor ), " ", "%' " & txtAndOr & " ArticleTitle LIKE '%") & "%'"
  SQL = SQL & " OR ArticleSummary LIKE '%"
  SQL = SQL & Replace( Trim( txtSearchFor ), " ", "%' " & txtAndOr & " ArticleSummary LIKE '%") & "%'"
  SQL = SQL & " ORDER BY ArticleDate DESC"
  Set RS=Server.CreateObject("adodb.Recordset")
  RS.Open SQL, dbc, adopenstatic
  
  RS.Filter = "ArticleStatus = 'PUBLISHED' OR ArticleStatus = 'ARCHIVED'"
  If UseSQLServer <> "YES" then
    RS.Filter = "ArticleStartDate <= #" & Date() & "# AND ArticleEndDate >= #" & Date() & "#"
  Else
    RS.Filter = "ArticleStartDate <= '" & Date() & "' AND ArticleEndDate >= '" & Date() & "'"
  End If

  response.write "<TABLE WIDTH='100%' ALIGN='left' CELLPADDING='4' CELLSPACING='0'><TR><TD WIDTH='100%' ALIGN='left'>"
  response.write "<FONT FACE='" & DefaultFontFace & "' SIZE='1' COLOR='black'>"
  response.write "Your search returned <FONT COLOR='red'><B>" & RS.RecordCount & "</B></FONT> results<BR><BR>"
  
  I = 0

  Do While NOT RS.EOF
    response.write (I + 1) & ".  <A HREF='news.asp?action=detail&article=" & RS("ArticleID") & "'>" & RS("ArticleTitle") & "</A> - " & FormatDate(RS("ArticleDate"), "FULL") & "<BR>"
    I = I + 1
    RS.MoveNext
  Loop
  
  response.write "</TD></TR><TR><TD width='100%'><BR>"
  Call DrawButtonBar
  response.write "</TD></TR></TABLE>"
End Sub

'******* Draw Archive Page ******************************************************

Sub Archives

If request.form("txtYear") <> "" then
  txtYear = request.form("txtYear")
Else
  txtYear = Year(Now)
End If

If request.form("txtMonth") <> "" then
  txtMonth = request.form("txtMonth")
Else
  txtMonth = Month(Now)
End If

If txtMonth = 4 OR txtMonth = 6 OR txtMonth = 9 OR txtMonth = 11 then
  txtDay = 30
Else
  txtDay = 31
End If

If txtMonth = 2 then
  txtDay = 28
End If

SQL = "SELECT ArticleID, ArticleTitle, ArticleDate, ArticleStartDate, ArticleEndDate FROM Articles WHERE ArticleStatus = 'ARCHIVED' ORDER BY ArticleDate DESC"
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic

If UseSQLServer <> "YES" then
  RS.Filter = "ArticleStartDate <= #" & Date() & "# AND ArticleEndDate >= #" & Date() & "#"
  RS.Filter = "ArticleDate >= #" & txtMonth & "/1/" & txtYear & "# AND ArticleDate <= #" & txtMonth & "/" & txtDay & "/" & txtYear & "#"
Else
  RS.Filter = "ArticleStartDate <= '" & Date() & "' AND ArticleEndDate >= '" & Date() & "'"
  RS.Filter = "ArticleDate >= '" & txtMonth & "/1/" & txtYear & "' AND ArticleDate <= '" & txtMonth & "/" & txtDay & "/" & txtYear & "'"
End If

response.write "<TABLE WIDTH='100%' ALIGN='left' CELLPADDING='4' CELLSPACING='0'><TR><TD WIDTH='100%' ALIGN='left'><FONT FACE='" & DefaultFontFace & "' SIZE='1' COLOR='black'>"

  response.write "<FORM METHOD='post' ACTION='news.asp?action=archives'>"
  response.write "Select A Month: "
  
  response.write "<SELECT NAME='txtMonth'>"
  response.write "<OPTION VALUE='1'"
  If request.form("txtMonth") = "1" then
    response.write " selected"
  End If
  response.write ">January</OPTION>"
  response.write "<OPTION VALUE='2'"
  If request.form("txtMonth") = "2" then
    response.write " selected"
  End If
  response.write ">February</OPTION>"
  response.write "<OPTION VALUE='3'"
  If request.form("txtMonth") = "3" then
    response.write " selected"
  End If
  response.write ">March</OPTION>"
  response.write "<OPTION VALUE='4'"
  If request.form("txtMonth") = "4" then
    response.write " selected"
  End If
  response.write ">April</OPTION>"
  response.write "<OPTION VALUE='5'"
  If request.form("txtMonth") = "5" then
    response.write " selected"
  End If
  response.write ">May</OPTION>"
  response.write "<OPTION VALUE='6'"
  If request.form("txtMonth") = "6" then
    response.write " selected"
  End If
  response.write ">June</OPTION>"
  response.write "<OPTION VALUE='7'"
  If request.form("txtMonth") = "7" then
    response.write " selected"
  End If
  response.write ">July</OPTION>"
  response.write "<OPTION VALUE='8'"
  If request.form("txtMonth") = "8" then
    response.write " selected"
  End If
  response.write ">August</OPTION>"
  response.write "<OPTION VALUE='9'"
  If request.form("txtMonth") = "9" then
    response.write " selected"
  End If
  response.write ">September</OPTION>"
  response.write "<OPTION VALUE='10'"
  If request.form("txtMonth") = "10" then
    response.write " selected"
  End If
  response.write ">October</OPTION>"
  response.write "<OPTION VALUE='11'"
  If request.form("txtMonth") = "11" then
    response.write " selected"
  End If
  response.write ">November</OPTION>"
  response.write "<OPTION VALUE='12'"
  If request.form("txtMonth") = "12" then
    response.write " selected"
  End If
  response.write ">December</OPTION>"
  response.write "</SELECT> "
  response.write "Select A Year: "
  response.write "<SELECT NAME='txtYear'>"
  response.write "<OPTION VALUE='2002'"
  If request.form("txtYear") = "2002" then
    response.write " selected"
  End If
  response.write ">2002</OPTION>"
  response.write "<OPTION VALUE='2003'"
  If request.form("txtYear") = "2003" then
    response.write " selected"
  End If
  response.write ">2003</OPTION>"
  response.write "<OPTION VALUE='2004'"
  If request.form("txtYear") = "2004" then
    response.write " selected"
  End If
  response.write ">2004</OPTION>"
  response.write "<OPTION VALUE='2005'"
  If request.form("txtYear") = "2005" then
    response.write " selected"
  End If
  response.write ">2005</OPTION>"
  response.write "<OPTION VALUE='2006'"
  If request.form("txtYear") = "2006" then
    response.write " selected"
  End If
  response.write ">2006</OPTION>"
  response.write "<OPTION VALUE='2007'"
  If request.form("txtYear") = "2007" then
    response.write " selected"
  End If
  response.write ">2007</OPTION>"
  response.write "<OPTION VALUE='2008'"
  If request.form("txtYear") = "2008" then
    response.write " selected"
  End If
  response.write ">2008</OPTION>"
  response.write "<OPTION VALUE='2009'"
  If request.form("txtYear") = "2009" then
    response.write " selected"
  End If
  response.write ">2009</OPTION>"
  response.write "<OPTION VALUE='2010'"
  If request.form("txtYear") = "2010" then
    response.write " selected"
  End If
  response.write ">2010</OPTION>"
  response.write "</SELECT> "
  response.write "<INPUT TYPE='submit' VALUE='Go -->'>"
  response.write "</FORM>"

response.write "News Archive for <FONT COLOR='blue'><B>" & MonthName(txtMonth) & ", " & txtYear & "</B></FONT><BR>"
response.write "There are (<FONT COLOR='red'><B>" & RS.RecordCount & "</B></FONT>) articles...<BR><BR>"
  
I = 0
Do While NOT RS.EOF
  response.write (I + 1) & ".  <A HREF='news.asp?action=detail&article=" & RS("ArticleID") & "'>" & RS("ArticleTitle") & "</A> - " & FormatDate(RS("ArticleDate"), "FULL") & "<BR>"
  I = I + 1
  RS.MoveNext
Loop

response.write "</FONT></TD></TR><TR><TD width='100%'>"

response.write "<BR>"
Call DrawButtonBar
response.write "</TD></TR></TABLE>"

End Sub

'******* Draw Login Screen *****************************************************

Sub DrawLoginScreen

response.write "<table align='center'>"
response.write "<tr>"
response.write "<td align='center' width='50%'>"
response.write "<img src='news/default_logo.gif' border='0'>"
response.write "</td>"
response.write "</tr>"
response.write "</table>"

response.write "<table align='center' width='300' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='100%'><font face='Verdana' size='1' color='black'><b>Please Login</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table>"

response.write "<table width='250' align='center' cellpadding='0' cellspacing='0'>"
response.write "<tr>"
response.write "<td width='100%' bgcolor='white'>"

response.write "<form method='POST' action='news.asp?action=processlogin'>"
response.write "<font face='Verdana' size='1' color='black'>"

If request.querystring("err") = "nouser" then
  response.write "<font color='red'>Sorry, you must enter a USER NAME.</font><br><br>"
End If
If request.querystring("err") = "baduser" then
  response.write "<font color='red'>Sorry, the USER NAME you entered is invalid.</font><br><br>"
End If
If request.querystring("err") = "badpass" then
  response.write "<font color='red'>Sorry, the PASSWORD you entered is invalid.</font><br><br>"
End If
If request.querystring("err") = "notlogged" then
  response.write "<font color='red'>Sorry, you must be logged in to access this feature.</font><br><br>"
End If

response.write "User Name:<br>"
response.write "<input type='text' name='txtUserName' size='30'>"
response.write "<br>"
response.write "Password:<br>"
response.write "<input type='password' name='txtPassword' size='30'>"
response.write "<br><br>"
response.write "<input type='submit' value='Login'>"
response.write "<br><br><br>"
response.write "</td>"
response.write "</form>"

End Sub

'******* Syndication Routine ******************************************************

Sub Syndicate

NumberToShow = Int(request.querystring("num"))
SyndFont = request.querystring("font")
SyndSize = request.querystring("size")
SyndColor = request.querystring("color")

If request.querystring("category") = "" then
  SQL = "SELECT * FROM Articles WHERE ArticleStatus = 'PUBLISHED' ORDER BY ArticleDate DESC"
  Set RS=dbc.execute(SQL)
  If UseSQLServer <> "YES" then
    RS.Filter = "ArticleStartDate <= #" & Date() & "# AND ArticleEndDate >= #" & Date() & "#"
  Else
    RS.Filter = "ArticleStartDate <= '" & Date() & "' AND ArticleEndDate >= '" & Date() & "'"
  End If
Else
  SQLc = "SELECT * FROM ArticleCategoryLink WHERE CategoryID = " & request.querystring("category")
  Set RSc = dbc.execute(SQLc)
  Do While NOT RSc.EOF
    Articles = Articles & RSc("ArticleID") & ", "
    RSc.MoveNext
  Loop
  If Articles = "" then
    Articles = 0
  End If
  RSc.Close
  Set RSc=Nothing
  SQL = "SELECT * FROM Articles WHERE ArticleID IN(" & Articles & ") AND ArticleStatus = 'PUBLISHED' ORDER BY ArticleDate DESC"
  Set RS=Server.CreateObject("adodb.Recordset")
  RS.Open SQL, dbc, adopenstatic
  If UseSQLServer <> "YES" then
    RS.Filter = "ArticleStartDate <= #" & Date() & "# AND ArticleEndDate >= #" & Date() & "#"
  Else
    RS.Filter = "ArticleStartDate <= '" & Date() & "' AND ArticleEndDate >= '" & Date() & "'"
  End If
End If 

Content = "<FONT FACE='" & SyndFont & "' SIZE='" & SyndSize & "' COLOR='" & SyndColor & "'>"

I = 0

Do While NOT RS.EOF
  If I >= NumberToShow then
    Exit Do
  End If
  Content = Content & "<A HREF='news.asp?action=detail&article=" & RS("ArticleID") & "'>" & RS("ArticleTitle") & "</A><BR><BR>"
  I = I + 1
  RS.MoveNext
Loop

Content = Content & SyndicationText
Content = Replace(Content, "'", "\'")
%>

function ShowSyndication() {
	var TempStr;
	TempStr = ('<%=Content%>');
	document.write(TempStr);
}

<%

End Sub

'******* Create Syndication HTML **************************************************

Sub CreateSyndicationHTML

If request.querystring("type") <> "public" then
  If Session("frUserName") = "" then
    response.redirect "news.asp?action=login&err=notlogged"
  End If
  Call DrawWelcomeBar
  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_config.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=editconfig'>Edit Configuration</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_config.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Manage Syndication</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Manage Syndication</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"
End If

response.write "<form method='POST' action='news.asp?action=createsyndicationhtmlprocess&type=" & request.querystring("type") & "'>"
response.write "<table align='center' width='97%' cellpadding='5' cellspacing='0' border='1' style='border-collapse: collapse' bordercolor='white'>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>How many articles would you like to display:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtSyndNumberOfArticles' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>What font would you like to use:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtSyndFontFace' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>What font size would you like to use:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtSyndFontSize' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>What color would you like to use:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtSyndFontColor' size='50'><br>"
response.write "</td>"
response.write "</tr>"

SQL = "SELECT * FROM Categories ORDER BY CategoryName"
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic

response.write "<tr>"
response.write "<td  vAlign='top' align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>What category would you like to show:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<select name='txtSyndCategory'>"
response.write "<option value=''>ALL</option>"

Do While NOT RS.EOF
  response.write "<option value='" & RS("CategoryID") & "'>" & RS("CategoryName") & "</option>"
  RS.MoveNext
Loop

response.write "</select>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='white'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='white'>"
response.write "<input type='submit' value='Create HTML Code'><br>"
response.write "</td>"
response.write "</tr>"

response.write "</table>"
response.write "</form>"

If request.querystring("type") = "public" then
  response.write "<BR>"
  Call DrawButtonBar
End If

End Sub

'******* Create Syndication HTML Process ******************************************

Sub CreateSyndicationHTMLProcess

SiteURL = request.servervariables("HTTP_REFERER")
SiteURLTemp = split(SiteURL, "?")
SiteURL = SiteURLTemp(0) & "?action="

SyndNumberOfArticles = request.form("txtSyndNumberOfArticles")
SyndFontFace = request.form("txtSyndFontFace")
SyndFontSize = request.form("txtSyndFontSize")
SyndFontColor = request.form("txtSyndFontColor")
SyndCategory = request.form("txtSyndCategory")

If request.querystring("type") <> "public" then
  If Session("frUserName") = "" then
    response.redirect "news.asp?action=login&err=notlogged"
  End If

  Call DrawWelcomeBar
  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_config.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=editconfig'>Edit Configuration</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_config.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Manage Syndication</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Manage Syndication</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"
End If

response.write "<form method='POST' action='news.asp?action=createsyndicationhtmlprocess'>"
response.write "<table align='center' width='97%' cellpadding='5' cellspacing='0' border='1' style='border-collapse: collapse' bordercolor='white'>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Syndication HTML:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<font face='Verdana' size='1' color='black'>Below is the HTML code that you need to use on your standard<BR> page to add our syndicated content to your website, simply<BR> copy and paste this code into your page.</font><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Syndication HTML:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtSyndicationHTML' rows='15' COLS='70'>"

%>
<!-- News Feed Code Starts HERE -->
<SCRIPT LANGUAGE="JAVASCRIPT" SRC="<%=SiteURL%>syndicate&num=<%=SyndNumberOfArticles%>&font=<%=SyndFontFace%>&size=<%=SyndFontSize%>&color=<%=SyndFontColor%>&category=<%=SyndCategory%>"></SCRIPT>
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
ShowSyndication();
//-->
</SCRIPT>
<!-- News Feed Code Ends HERE -->
<%

response.write "</TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "</table>"
response.write "</form>"

If request.querystring("type") = "public" then
  response.write "<BR>"
  Call DrawButtonBar
End If


End Sub

'******* Process Login ************************************************************

Sub ProcessLogin

  If request.form("txtUserName") = "" then
    response.redirect "news.asp?action=login&err=nouser"
  End If

  SQL = "SELECT * FROM Authors WHERE AuthorUserName = '" & request.form("txtUserName") & "'"
  Set RS=dbc.execute(SQL)

  If RS.EOF then
    response.redirect "news.asp?action=login&err=baduser"
  End If

  If RS("AuthorPassword") = request.form("txtPassword") then
    Session("frAuthorID") = RS("AuthorID")
    Session("frUserName") = RS("AuthorUserName")
    Session("frFirstName") = RS("AuthorFirstName")
    Session("frLastName") = RS("AuthorLastName")
    Session("frEmailAddress") = RS("AuthorEmailAddress")
    Session("frLevel") = RS("AuthorLevel")
    Session("frRequireApproval") = RS("AuthorRequireApproval")
    If RS("AuthorLevel") = 1 then
      Session("frRights") = "Administrator"
    Else
      Session("frRights") = "Publisher"
    End If
    response.redirect "news.asp?action=mainmenu"
  Else
    response.redirect "news.asp?action=login&err=badpass"
  End If

End Sub

'******* Draw Main Menu ***********************************************************

Sub DrawMainMenu

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

Call DrawWelcomeBar

response.write "<BR>"

If Session("frLevel") = 1 then
  response.write "<TABLE WIDTH='600' ALIGN='center' BORDER='0' CELLPADDING='0' CELLSPACING='0'>"
  response.write "<TR>"
  response.write "<TD WIDTH='300' ALIGN='center'><a href='news.asp?action=managearticles'><IMG SRC='news/mm_managearticles.gif' border='0'></A><BR>"
  response.write "<a href='news.asp?action=manageauthors'><IMG SRC='news/mm_manageauthors.gif' border='0'></A><BR>"
  response.write "<a href='news.asp?action=managecategories'><IMG SRC='news/mm_managecategories.gif' border='0'></A><BR></TD>"
  response.write "<TD WIDTH='300' ALIGN='center'><a href='news.asp?action=managelayouttypes'><IMG SRC='news/mm_managelayouttypes.gif' border='0'></A><BR>"
  response.write "<a href='news.asp?action=managearticlelayouts'><IMG SRC='news/mm_managearticlelayouts.gif' border='0'></A><BR>"
  response.write "<a href='news.asp?action=editconfig'><IMG SRC='news/mm_editconfiguration.gif' border='0'></A><BR></TD>"
  response.write "</tr></table>"
Else
  response.write "<TABLE WIDTH='600' ALIGN='center' BORDER='0' CELLPADDING='0' CELLSPACING='0'>"
  response.write "<TR>"
  response.write "<TD WIDTH='300' ALIGN='center'><a href='news.asp?action=managearticles'><IMG SRC='news/mm_managearticles.gif' border='0'></A><BR></TD>"
  response.write "</tr></table>"
End If

End Sub

'******* Process LogOff ***********************************************************

Sub LogOff

Session.Abandon
response.redirect "news.asp"

End Sub

'******* Manage Authors *************************************************************

Sub ManageAuthors

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

SQL = "SELECT * FROM Authors ORDER BY AuthorFirstName"
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic

RS.MoveFirst

'-------- Paging ----------------------------------------------

If request.querystring("Page") = "" Then
  Page = 1
  RS.Move First
Else
  Page = Request.QueryString("Page")
  If Page = 1 then
    RS.Move First
  Else
    RS.Move CInt((Page * RecordsPerPage) - RecordsPerPage)
  End If
End If
n = 0
RS.PageSize = RecordsPerPage

'-----------------------------------------------------------------

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_author.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Manage Authors</font><br></td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Tasks: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_author.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=addauthor'>Add An Author</a></font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br><br>"

response.write "<table align='center' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15'><font face='Verdana' size='1' color='black'>&nbsp</font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15'><font face='Verdana' size='1' color='black'>&nbsp</font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15%'><font face='Verdana' size='1' color='black'><b>First Name</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_seperator.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15%'><font face='Verdana' size='1' color='black'><b>Last Name</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_seperator.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15%'><font face='Verdana' size='1' color='black'><b>UserName</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_seperator.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='23%'><font face='Verdana' size='1' color='black'><b>Email</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_seperator.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15%'><font face='Verdana' size='1' color='black'><b>Rights Level</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_seperator.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='23%'><font face='Verdana' size='1' color='black'><b>Categories</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"

UseBackColor = BackColorOne

Do until RS.EOF
  If n = RecordsPerPage then
    exit do
  End If
  
  If RS("AuthorLevel") = 1 then
    RightsType = "Administrator"
  Else
    RightsType = "Publisher"
  End If
  SQLc = "SELECT * FROM AuthorCategoryLink WHERE AuthorID = " & RS("AuthorID")
  Set RSc=dbc.execute(SQLc)
  If NOT RSc.EOF then
    AssignedCategories = ""
    Do While NOT RSc.EOF
      If RSc("CategoryID") = "99999" then
        AssignedCategories = "<img src='news/icon_category.gif' border='0'> <b>ALL</b>"
      Else
        SQLd = "SELECT * FROM Categories WHERE CategoryID = " & RSc("CategoryID")
        Set RSd=dbc.execute(SQLd)
        AssignedCategories = AssignedCategories & "<img src='news/icon_category.gif' border='0'> " & RSd("CategoryName") & "<br>"
      End If
      RSc.MoveNext
    Loop
    AssignedCatLength = len(AssignedCategories)
    AssignedCategories = left(AssignedCategories, (AssignedCatLength -1))
  Else
    AssignedCategories = "None" 
  End If
  
  response.write "<tr>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='15'><font face='Verdana' size='1' color='black'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='15'><font face='Verdana' size='1' color='black'>&nbsp<a href='news.asp?action=editauthor&authorid=" & RS("AuthorID") & "'><img src='news/icon_edit.gif' border='0'></a>&nbsp</font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='15'><font face='Verdana' size='1' color='black'>&nbsp<a href='news.asp?action=deleteauthor&authorid=" & RS("AuthorID") & "'><img src='news/icon_delete.gif' border='0'></a>&nbsp</font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='15%'><font face='Verdana' size='1' color='black'>" & RS("AuthorFirstName") & "</font></td>"
  response.write "<td background='news/table_seperator.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='news/table_seperator.gif' border='0'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='15%'><font face='Verdana' size='1' color='black'>" & RS("AuthorLastName") & "</font></td>"
  response.write "<td background='news/table_seperator.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='news/table_seperator.gif' border='0'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='15%'><font face='Verdana' size='1' color='black'>" & RS("AuthorUserName") & "</font></td>"
  response.write "<td background='news/table_seperator.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='news/table_seperator.gif' border='0'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='23%'><font face='Verdana' size='1' color='black'>" & RS("AuthorEmailAddress") & "</font></td>"
  response.write "<td background='news/table_seperator.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='news/table_seperator.gif' border='0'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='15%'><font face='Verdana' size='1' color='black'>" & RightsType & "</font></td>"
  response.write "<td background='news/table_seperator.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='news/table_seperator.gif' border='0'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='left' width='23%'><font face='Verdana' size='1' color='black'>" & AssignedCategories & "</font></td>"
  response.write "</tr>"
  RS.MoveNext
  If UseBackColor = BackColorOne then
    UseBackColor = BackColorTwo
  Else
    UseBackColor = BackColorOne
  End If
  n=n+1
  
Loop

response.write "</table>"
  
'------- Page Navigation ----------------------------------
response.write "<br>"
response.write "<table width='100%'>"
response.write "<tr>"
response.write "<td align=left><font face='Verdana' size='1'>&nbsp</font>"
response.write "</td>"
response.write "<td width='30%' align=right>"
response.write "<font face='Verdana' size='1'>"

response.write "<table align='center' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='100%'><font face='Verdana' size='1' color='black'>"

If Page <> 1 then
  response.write "<a href=news.asp?action=manageauthors&Page=" & Page - 1 & ">" 
  response.write "<< Prev"
End If
If Page <> 1 then
  response.write "</a>&nbsp"
end If
For intCount = 1 to RS.PageCount
  If IntCount = 1 then
    response.write " | "
  End If
  If cint(intCount) = cint(Page) then
    response.write "<b>" & intCount & "</b> | "
  Else
    response.write "<a href=news.asp?action=manageauthors&Page=" & intCount & ">" & intCount & "</a> | "
  End If
Next

If cint(page) <> cint(RS.PageCount) then
  response.write "<a href=news.asp?action=manageauthors&Page=" & Page + 1 & ">"
  response.write "&nbspNext >>"
End If
If cint(Page) = cint(RS.PageCount) then
  response.write "</a>"
End If

response.write "</font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table>"

response.write "</font></td>"
response.write "</tr>"
response.write "</table>"
'-------------------------------------------------------------

End Sub

'******** Add An Author ***********************************************************

Sub AddAuthor

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_author.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=manageauthors'>Manage Authors</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_author.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Add Author</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Add Author</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

response.write "<form method='POST' action='news.asp?action=addauthorprocess'>"
response.write "<table align='center' width='97%' cellpadding='5' cellspacing='0' border='1' style='border-collapse: collapse' bordercolor='white'>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>First Name:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtFirstName' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Last Name:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLastName' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>User Name:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtUserName' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Password:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtPassword' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Email Address:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtEmailAddress' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Rights Level:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtRightsLevel' value='2' checked>Publisher"
response.write "<input type='radio' name='txtRightsLevel' value='1'>Administrator<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Require Approval Before Publishing:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtAuthorRequireApproval' value='YES'>YES"
response.write "<input type='radio' name='txtAuthorRequireApproval' value='NO' checked>NO<br></font>"
response.write "</td>"
response.write "</tr>"

SQL = "SELECT * FROM Categories ORDER BY CategoryName"
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic

response.write "<tr>"
response.write "<td  vAlign='top' align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Assigned Categories:<br><font color='red'>Hold CTRL to select multiple categories.</font></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<select size='" & RS.RecordCount + 1 & "' name='txtAssignedCategories' multiple>"
response.write "<option value='99999'>ALL</option>"

Do While NOT RS.EOF
  response.write "<option value='" & RS("CategoryID") & "'>" & RS("CategoryName") & "</option>"
  RS.MoveNext
Loop

response.write "</select>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='white'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='white'>"
response.write "<input type='submit' value='Add this Author'><br>"
response.write "</td>"
response.write "</tr>"

response.write "</table>"
response.write "</form>"

End Sub

'******* Add Author Process *******************************************************

Sub AddAuthorProcess

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

Set RS=Server.CreateObject("ADODB.RecordSet")
RS.Open "SELECT * FROM Authors", dbc, adOpenDynamic, adLockPessimistic, adCMDText

RS.AddNew
RS("AuthorFirstName")=request.form("txtFirstName")
RS("AuthorLastName")=request.form("txtLastName")
RS("AuthorUserName")=request.form("txtUserName")
RS("AuthorPassword")=request.form("txtPassword")
RS("AuthorEmailAddress")=request.form("txtEmailAddress")
RS("AuthorRequireApproval")=request.form("txtAuthorRequireApproval")
RS("AuthorLevel")=request.form("txtRightsLevel")
RS.Update

RS.Close
Set RS=Nothing

SQL = "SELECT * FROM Authors"
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic
RS.MoveLast
AuthorID = RS("AuthorID")
RS.Close
Set RS=Nothing

Set RS=Server.CreateObject("ADODB.RecordSet")
RS.Open "SELECT * FROM AuthorCategoryLink", dbc, adOpenDynamic, adLockPessimistic, adCMDText

Dim Arr
Arr = Split(CStr(Request.Form("txtAssignedCategories")),",")
For x = 0 to UBound(Arr)
  RS.AddNew
  RS("AuthorID") = AuthorID
  RS("CategoryID") = Trim(Arr(x))
Next
  RS.Update
  RS.Close
  Set RS=Nothing

response.redirect "news.asp?action=summary&type=addauthorsuccess"

End Sub

'******* Edit Author Screen *******************************************************

Sub EditAuthor

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

SQL = "SELECT * FROM Authors WHERE AuthorID = " & request.querystring("authorid")
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_author.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=manageauthors'>Manage Authors</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_author.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Edit Author</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Edit Author</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

response.write "<form method='POST' action='news.asp?action=editauthorprocess'>"
response.write "<input type='hidden' name='txtAuthorID' value='" & request.querystring("authorid") & "'>"
response.write "<table align='center' width='97%' cellpadding='5' cellspacing='0' border='1' style='border-collapse: collapse' bordercolor='white'>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>First Name:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtFirstName' size='50' value='" & RS("AuthorFirstName") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Last Name:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLastName' size='50' value='" & RS("AuthorLastName") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>User Name:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtUserName' size='50' value='" & RS("AuthorUserName") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Password:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtPassword' size='50' value='" & RS("AuthorPassword") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Email Address:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtEmailAddress' size='50' value='" & RS("AuthorEmailAddress") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Rights Level:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtRightsLevel' value='2' "
If RS("AuthorLevel") = 2 then
  response.write "checked"
End If
response.write ">Publisher"
response.write "<input type='radio' name='txtRightsLevel' value='1' "
If RS("AuthorLevel") = 1 then
  response.write "checked"
End If
response.write ">Administrator<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Require Approval Before Publishing:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtAuthorRequireApproval' value='YES'"
If RS("AuthorRequireApproval") = "YES" then
  response.write " checked"
End If
response.write ">YES"
response.write "<input type='radio' name='txtAuthorRequireApproval' value='NO'"
If RS("AuthorRequireApproval") = "NO" then
  response.write " checked"
End If
response.write ">NO<br></font>"
response.write "</td>"
response.write "</tr>"

SQLc = "SELECT * FROM Categories ORDER BY CategoryName"
Set RSc=Server.CreateObject("adodb.Recordset")
RSc.Open SQLc, dbc, adopenstatic

response.write "<tr>"
response.write "<td  vAlign='top' align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Assigned Categories:<br><font color='red'>Hold CTRL to select multiple categories.</font></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<select size='" & RSc.RecordCount + 1 & "' name='txtAssignedCategories' multiple>"

response.write "<option value='99999' "
SQLd = "SELECT * FROM AuthorCategoryLink WHERE AuthorID = " & RS("AuthorID") & " AND CategoryID = 99999"
Set RSd=Server.CreateObject("adodb.Recordset")
RSd.Open SQLd, dbc, adopenstatic
If NOT RSd.EOF then
  response.write "selected"
End If
RSd.Close
Set RSd = Nothing
response.write ">ALL</option>"

Do While NOT RSc.EOF
  response.write "<option value='" & RSc("CategoryID") & "' "
  SQLd = "SELECT * FROM AuthorCategoryLink WHERE AuthorID = " & RS("AuthorID") & " AND CategoryID = " & RSc("CategoryID")
  Set RSd=Server.CreateObject("adodb.Recordset")
  RSd.Open SQLd, dbc, adopenstatic
  If NOT RSd.EOF then
    response.write "selected"
  End If
  RSd.Close
  Set RSd = Nothing
  response.write ">" & RSc("CategoryName") & "</option>"
  RSc.MoveNext
Loop

response.write "</select>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='white'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='white'>"
response.write "<input type='submit' value='Save These Changes'><br>"
response.write "</td>"
response.write "</tr>"

response.write "</table>"
response.write "</form>"

End Sub

'******* Edit Author Process ******************************************************

Sub EditAuthorProcess

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

SQL="UPDATE Authors Set AuthorFirstName = '"&request.form("txtFirstName")&"', AuthorLastName = '"&request.form("txtLastName")&"', AuthorUserName = '"&request.form("txtUserName")&"', AuthorPassword = '"&request.form("txtPassword")&"', AuthorEmailAddress = '"&request.form("txtEmailAddress")&"', AuthorLevel = '"&request.form("txtRightsLevel")&"', AuthorRequireApproval = '"&request.form("txtAuthorRequireApproval")&"' WHERE [AuthorID] ="&request.form("txtAuthorID")&""
dbc.Execute(SQL)

SQL = "DELETE FROM AuthorCategoryLink WHERE AuthorID IN("& request.form("txtAuthorID") &")"
dbc.Execute(SQL)

Set RS=Server.CreateObject("ADODB.RecordSet")
RS.Open "SELECT * FROM AuthorCategoryLink", dbc, adOpenDynamic, adLockPessimistic, adCMDText

Dim Arr
Arr = Split(CStr(Request.Form("txtAssignedCategories")),",")
For x = 0 to UBound(Arr)
  RS.AddNew
  RS("AuthorID") = request.form("txtAuthorID")
  RS("CategoryID") = Trim(Arr(x))
Next
RS.Update
RS.Close
Set RS=Nothing

response.redirect "news.asp?action=summary&type=editauthorsuccess"

End Sub

'******* Delete Author Screen *****************************************************

Sub DeleteAuthor

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_author.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=manageauthors'>Manage Authors</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_author.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Delete Author</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Delete Author</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

SQL = "SELECT * FROM Authors WHERE AuthorID = " & request.querystring("authorid")
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic

If RS("AuthorID") = 1 then

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>Sorry you cannot delete this Author.<br><br>"

  response.write "<table align='center' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_author.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Administrator</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"

  response.write "<a href='news.asp?action=mainmenu'>Main Menu</a> | <a href='news.asp?action=manageauthors'>Manage Authors</a><br>"
  response.write "</p>"

Else

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>Are you sure you want to delete this Author?<br><br>"

  response.write "<table align='center' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_author.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>" & RS("AuthorFirstName") & " " & RS("AuthorLastName") & "</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"

  response.write "<a href='news.asp?action=deleteauthorprocess&authorid=" & request.querystring("authorid") & "'>YES</a> | <a href='news.asp?action=manageauthors'>NO</a><br>"
  response.write "</p>"
End If

RS.Close
Set RS = Nothing

End Sub 

'******* Delete Author Process ****************************************************

Sub DeleteAuthorProcess

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

SQL = "DELETE FROM AuthorCategoryLink WHERE AuthorID IN("& request.querystring("authorid") &")"
dbc.Execute(SQL)

SQL = "DELETE FROM Authors WHERE AuthorID IN("& request.querystring("authorid") &")"
dbc.Execute(SQL)

SQL = "UPDATE Articles SET ArticleAuthor = 1 WHERE ArticleAuthor = " & request.querystring("authorid")
dbc.Execute(SQL)

response.redirect "news.asp?action=summary&type=deleteauthorsuccess"

End Sub

'******* Draw Manage Categories Screen ********************************************

Sub ManageCategories

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

SQL = "SELECT * FROM Categories ORDER BY CategoryName"
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic

RS.MoveFirst

'-------- Paging ----------------------------------------------

If request.querystring("Page") = "" Then
  Page = 1
  RS.Move First
Else
  Page = Request.QueryString("Page")
  If Page = 1 then
    RS.Move First
  Else
    RS.Move CInt((Page * RecordsPerPage) - RecordsPerPage)
  End If
End If
n = 0
RS.PageSize = RecordsPerPage

'-----------------------------------------------------------------

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_category.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Manage Categories</font><br></td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Tasks: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_category.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=addcategory'>Add A Category</a></font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br><br>"

response.write "<table align='center' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15'><font face='Verdana' size='1' color='black'>&nbsp</font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15'><font face='Verdana' size='1' color='black'>&nbsp</font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15%'><font face='Verdana' size='1' color='black'><b>Category Name</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_seperator.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='25%'><font face='Verdana' size='1' color='black'><b>Category Description</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_seperator.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10%'><font face='Verdana' size='1' color='black'><b>Layout Type</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_seperator.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10%'><font face='Verdana' size='1' color='black'><b>Article Layout</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_seperator.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='30%'><font face='Verdana' size='1' color='black'><b>Assigned Authors</b></font></td>"

response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"

UseBackColor = BackColorOne

Do until RS.EOF
  If n = RecordsPerPage then
    exit do
  End If
  
  SQLc = "SELECT * FROM AuthorCategoryLink WHERE CategoryID = " & RS("CategoryID") & " OR CategoryID = 99999"
  Set RSc=dbc.execute(SQLc)
  If NOT RSc.EOF then
    AssignedAuthors = ""
    Do While NOT RSc.EOF
      SQLd = "SELECT * FROM Authors WHERE AuthorID = " & RSc("AuthorID")
      Set RSd=dbc.execute(SQLd)
      AssignedAuthors = AssignedAuthors & "<img src='news/icon_author.gif' border='0'>" & RSd("AuthorFirstName") & " " & RSd("AuthorLastName") & "<br>"
      RSc.MoveNext
    Loop
    AssignedAuthLength = len(AssignedAuthors)
    AssignedAuthors = left(AssignedAuthors, (AssignedAuthLength -1))
  Else
    AssignedAuthors = "None" 
  End If
  
  response.write "<tr>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='15'><font face='Verdana' size='1' color='black'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='15'><font face='Verdana' size='1' color='black'>&nbsp<a href='news.asp?action=editcategory&categoryid=" & RS("CategoryID") & "'><img src='news/icon_edit.gif' border='0'></a>&nbsp</font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='15'><font face='Verdana' size='1' color='black'>&nbsp<a href='news.asp?action=deletecategory&categoryid=" & RS("CategoryID") & "'><img src='news/icon_delete.gif' border='0'></a>&nbsp</font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='15%'><font face='Verdana' size='1' color='black'>" & RS("CategoryName") & "</font></td>"
  response.write "<td background='news/table_seperator.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='news/table_seperator.gif' border='0'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='left' width='25%'><font face='Verdana' size='1' color='black'>" & RS("CategoryDescription") & "</font></td>"

  response.write "<td background='news/table_seperator.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='news/table_seperator.gif' border='0'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='left' width='10%'><font face='Verdana' size='1' color='black'>" & RS("CategoryLayoutType") & " - "
  If RS("CategoryLayoutType") <> 0 then
    SQLz = "SELECT * FROM LayoutTypes WHERE LTID = " & RS("CategoryLayoutType")
    Set RSz=dbc.execute(SQLz)
    response.write RSz("LTName")
    RSz.Close
    Set RSz=Nothing
  Else
    response.write "Use Config Default"
  End If
  response.write "</font></td>"

  response.write "<td background='news/table_seperator.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='news/table_seperator.gif' border='0'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='left' width='10%'><font face='Verdana' size='1' color='black'>" & RS("CategoryArticleLayout") & " - "
  If RS("CategoryArticleLayout") <> 0 then
    SQLz = "SELECT * FROM ArticleLayouts WHERE ALID = " & RS("CategoryArticleLayout")
    Set RSz=dbc.execute(SQLz)
    response.write RSz("ALName")
    RSz.Close
    Set RSz=Nothing
  Else
    response.write "Use Config Default"
  End If
  response.write "</font></td>"

  response.write "<td background='news/table_seperator.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='news/table_seperator.gif' border='0'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='left' width='30%'><font face='Verdana' size='1' color='black'>" & AssignedAuthors & "</font></td>"
  response.write "</tr>"
  RS.MoveNext
  If UseBackColor = BackColorOne then
    UseBackColor = BackColorTwo
  Else
    UseBackColor = BackColorOne
  End If
  n=n+1
  
Loop

response.write "</table>"
  
'------- Page Navigation ----------------------------------
response.write "<br>"
response.write "<table width='100%'>"
response.write "<tr>"
response.write "<td align=left><font face='Verdana' size='1'>&nbsp</font>"
response.write "</td>"
response.write "<td width='30%' align=right>"
response.write "<font face='Verdana' size='1'>"

response.write "<table align='center' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='100%'><font face='Verdana' size='1' color='black'>"

If Page <> 1 then
  response.write "<a href=news.asp?action=managecategories&Page=" & Page - 1 & ">" 
  response.write "<< Prev"
End If
If Page <> 1 then
  response.write "</a>&nbsp"
end If
For intCount = 1 to RS.PageCount
  If IntCount = 1 then
    response.write " | "
  End If
  If cint(intCount) = cint(Page) then
    response.write "<b>" & intCount & "</b> | "
  Else
    response.write "<a href=news.asp?action=managecategories&Page=" & intCount & ">" & intCount & "</a> | "
  End If
Next

If cint(page) <> cint(RS.PageCount) then
  response.write "<a href=news.asp?action=managecategories&Page=" & Page + 1 & ">"
  response.write "&nbspNext >>"
End If
If cint(Page) = cint(RS.PageCount) then
  response.write "</a>"
End If

response.write "</font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table>"

response.write "</font></td>"
response.write "</tr>"
response.write "</table>"
'-------------------------------------------------------------

End Sub

'******* Add New Category Screen **************************************************

Sub AddCategory

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_category.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managecategories'>Manage Categories</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_category.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Add Category</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Add Category</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

response.write "<form method='POST' action='news.asp?action=addcategoryprocess'>"
response.write "<table align='center' width='97%' cellpadding='5' cellspacing='0' border='1' style='border-collapse: collapse' bordercolor='white'>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Category Name:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtCategoryName' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Category Description:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtCategoryDescription' cols='38' rows='5'></textarea><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Category Layout Type:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<select name='txtLayoutType'>"
response.write "<option value='0'>0 - Use Configuration Default</option>"

SQLz = "SELECT * FROM LayoutTypes ORDER BY LTID"
Set RSz = dbc.execute(SQLz)

Do While NOT RSz.EOF
  response.write "<OPTION VALUE='" & RSz("LTID") & "'>" & RSz("LTID") & " - " & RSz("LTName") & "</OPTION>"
  RSz.MoveNext
Loop
RSz.Close
Set RSz=Nothing

response.write "</select><br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Article Layout Type:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<select name='txtArticleLayout'>"
response.write "<option value='0'>0 - Use Configuration Default</option>"

SQLz = "SELECT * FROM ArticleLayouts ORDER BY ALID"
Set RSz = dbc.execute(SQLz)

Do While NOT RSz.EOF
  response.write "<OPTION VALUE='" & RSz("ALID") & "'>" & RSz("ALID") & " - " & RSz("ALName") & "</OPTION>"
  RSz.MoveNext
Loop
RSz.Close
Set RSz=Nothing

response.write "</select><br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='white'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='white'>"
response.write "<input type='submit' value='Add this Category'><br>"
response.write "</td>"
response.write "</tr>"

response.write "</table>"
response.write "</form>"

End Sub

'******* Add Category Process *****************************************************

Sub AddCategoryProcess

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

Set RS=Server.CreateObject("ADODB.RecordSet")
RS.Open "SELECT * FROM Categories", dbc, adOpenDynamic, adLockPessimistic, adCMDText

RS.AddNew
RS("CategoryName")=request.form("txtCategoryName")
RS("CategoryDescription")=request.form("txtCategoryDescription")
RS("CategoryLayoutType")=request.form("txtLayoutType")
RS("CategoryArticleLayout")=request.form("txtArticleLayout")
RS.Update

RS.Close
Set RS=Nothing

SQL = "SELECT * FROM Categories"
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic
RS.MoveLast
CategoryID = RS("CategoryID")
RS.Close
Set RS=Nothing

'Set RS=Server.CreateObject("ADODB.RecordSet")
'RS.Open "SELECT * FROM AuthorCategoryLink", dbc, adOpenDynamic, adLockPessimistic, adCMDText

'RS.AddNew
'RS("CategoryID") = CategoryID
'RS("AuthorID") = 1
'RS.Update

'RS.Close
'Set RS=Nothing

response.redirect "news.asp?action=summary&type=addcategorysuccess"

End Sub

'******* Edit Category Screen **************************************************

Sub EditCategory

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

SQL = "SELECT * FROM Categories WHERE CategoryID = " & request.querystring("categoryid")
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_category.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managecategories'>Manage Categories</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_category.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Edit Category</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Edit Category</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

response.write "<form method='POST' action='news.asp?action=editcategoryprocess'>"
response.write "<input type='hidden' name='txtCategoryID' value='" & request.querystring("categoryid") & "'>"
response.write "<table align='center' width='97%' cellpadding='5' cellspacing='0' border='1' style='border-collapse: collapse' bordercolor='white'>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Category Name:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtCategoryName' size='50' value='" & RS("CategoryName") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Category Description:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtCategoryDescription' cols='38' rows='5'>" & RS("CategoryDescription") & "</textarea><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Category Layout Type:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<select name='txtLayoutType'>"
response.write "<option value='0'"
If RS("CategoryLayoutType") = 0 then
  response.write " selected"
End If
response.write ">0 - Use Configuration Default</option>"

SQLz = "SELECT * FROM LayoutTypes ORDER BY LTID"
Set RSz = dbc.execute(SQLz)

Do While NOT RSz.EOF
  response.write "<OPTION VALUE='" & RSz("LTID") & "'"
  If RS("CategoryLayoutType") = RSz("LTID") then
    response.write " selected"
  End If
  response.write ">" & RSz("LTID") & " - " & RSz("LTName") & "</OPTION>"
  RSz.MoveNext
Loop
RSz.Close
Set RSz=Nothing

response.write "</select><br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>Category Article Layout:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<select name='txtArticleLayout'>"
response.write "<option value='0'"
If RS("CategoryArticleLayout") = 0 then
  response.write " selected"
End If
response.write ">0 - Use Configuration Default</option>"

SQLz = "SELECT * FROM ArticleLayouts ORDER BY ALID"
Set RSz = dbc.execute(SQLz)

Do While NOT RSz.EOF
  response.write "<OPTION VALUE='" & RSz("ALID") & "'"
  If RS("CategoryArticleLayout") = RSz("ALID") then
    response.write " selected"
  End If
  response.write ">" & RSz("ALID") & " - " & RSz("ALName") & "</OPTION>"
  RSz.MoveNext
Loop
RSz.Close
Set RSz=Nothing

response.write "</select><br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='white'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='white'>"
response.write "<input type='submit' value='Save These Changes'><br>"
response.write "</td>"
response.write "</tr>"

response.write "</table>"
response.write "</form>"

End Sub

'******* Edit Category Process ****************************************************

Sub EditCategoryProcess

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

SQL="UPDATE Categories Set CategoryName = '"&FixString(request.form("txtCategoryName"))&"', CategoryDescription = '"&FixString(request.form("txtCategoryDescription"))&"', CategoryLayoutType = '"&request.form("txtLayoutType")&"', CategoryArticleLayout = '"&request.form("txtArticleLayout")&"' WHERE [CategoryID] ="&request.form("txtCategoryID")&""
dbc.Execute(SQL)

response.redirect "news.asp?action=summary&type=editcategorysuccess"

End Sub

'******* Delete Category Screen *****************************************************

Sub DeleteCategory

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_category.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managecategories'>Manage Categories</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_category.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Delete Category</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Delete Category</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

SQL = "SELECT * FROM Categories WHERE CategoryID = " & request.querystring("categoryid")
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic

SQLb = "SELECT * FROM ArticleCategoryLink WHERE CategoryID = " & request.querystring("categoryid")
Set RSb=dbc.execute(SQLb)

If RSb.EOF then
  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>Are you sure you want to delete this Category?<br><br>"
  response.write "<table align='center' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_category.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>" & RS("CategoryName") & "</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<a href='news.asp?action=deletecategoryprocess&categoryid=" & request.querystring("categoryid") & "'>YES</a> | <a href='news.asp?action=managecategories'>NO</a><br>"
  response.write "</p>"
Else
  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>Sorry you cannot delete this category because it still contains articles.<BR>Remove any articles from this category first.<br><br>"
  response.write "<table align='center' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_category.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>" & RS("CategoryName") & "</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<a href='news.asp?action=managecategories'>OK</a><br>"
  response.write "</p>"
End If
  
RSb.Close
Set RSb=Nothing

RS.Close
Set RS = Nothing

End Sub 

'******* Delete Category Process ****************************************************

Sub DeleteCategoryProcess

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

SQL = "DELETE FROM AuthorCategoryLink WHERE AuthorID IN("& request.querystring("categoryid") &")"
dbc.Execute(SQL)

SQL = "DELETE FROM Categories WHERE CategoryID IN("& request.querystring("categoryid") &")"
dbc.Execute(SQL)

response.redirect "news.asp?action=summary&type=deletecategorysuccess"

End Sub

'******* Manage Articles **********************************************************

Sub ManageArticles

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If request.querystring("filter") <> "" then
  Session("frFilter") = request.querystring("filter")
End If

If Session("frFilter") = "all" or Session("frFilter") = "" then
  SQL = "SELECT * FROM Articles ORDER BY ArticleDate DESC"
  Set RS=Server.CreateObject("adodb.Recordset")
  RS.Open SQL, dbc, adopenstatic
End If
  
If Session("frFilter") = "published" then
  SQL = "SELECT * FROM Articles WHERE ArticleStatus = 'PUBLISHED' ORDER BY ArticleDate DESC"
  Set RS=Server.CreateObject("adodb.Recordset")
  RS.Open SQL, dbc, adopenstatic
End If

If Session("frFilter") = "un-published" then
  SQL = "SELECT * FROM Articles WHERE ArticleStatus = 'UN-PUBLISHED' ORDER BY ArticleDate DESC"
  Set RS=Server.CreateObject("adodb.Recordset")
  RS.Open SQL, dbc, adopenstatic
End If

If Session("frFilter") = "archived" then
  SQL = "SELECT * FROM Articles WHERE ArticleStatus = 'ARCHIVED' ORDER BY ArticleDate DESC"
  Set RS=Server.CreateObject("adodb.Recordset")
  RS.Open SQL, dbc, adopenstatic
End If

If Session("frFilter") = "usersubmitted" then
  SQL = "SELECT * FROM Articles WHERE ArticleStatus = 'USER SUBMITTED' ORDER BY ArticleDate DESC"
  Set RS=Server.CreateObject("adodb.Recordset")
  RS.Open SQL, dbc, adopenstatic
End If

If Session("frFilter") = "waitingapproval" then
  SQL = "SELECT * FROM Articles WHERE ArticleStatus = 'AWAITING APPROVAL' ORDER BY ArticleDate DESC"
  Set RS=Server.CreateObject("adodb.Recordset")
  RS.Open SQL, dbc, adopenstatic
End If

If NOT RS.EOF then
  RS.MoveFirst
End If

'-------- Paging ----------------------------------------------

If request.querystring("Page") = "" Then
  Page = 1
  If NOT RS.EOF then
    RS.MoveFirst
  End If
Else
  Page = Request.QueryString("Page")
  If Page = 1 then
    RS.Move First
  Else
    RS.Move CInt((Page * RecordsPerPage) - RecordsPerPage)
  End If
End If

n = 0
RS.PageSize = RecordsPerPage

'-----------------------------------------------------------------

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Manage Articles</font><br></td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Tasks: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=addarticle'>Add An Article</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=archivearticles'>Archive Articles</a></font><br></td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Filters: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
If Session("frFilter") <> "published" then
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticles&filter=published'>PUBLISHED</a></font><br></td>"
Else
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>PUBLISHED</b></font><br></td>"
End If
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
If Session("frFilter") <> "un-published" then
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticles&filter=un-published'>UN-PUBLISHED</a></font><br></td>"
Else
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>UN-PUBLISHED</b></font><br></td>"
End If
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
If Session("frFilter") <> "waitingapproval" then
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticles&filter=waitingapproval'>AWAITING APPROVAL</a></font><br></td>"
Else
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>AWAITING APPROVAL</b></font><br></td>"
End If
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
If Session("frFilter") <> "archived" then
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticles&filter=archived'>ARCHIVED</a></font><br></td>"
Else
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>ARCHIVED</b></font><br></td>"
End If
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
If Session("frFilter") <> "usersubmitted" then
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticles&filter=usersubmitted'>USER SUBMITTED</a></font><br></td>"
Else
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>USER SUBMITTED</b></font><br></td>"
End If
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
If Session("frFilter") <> "all" then
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticles&filter=all'>ALL</a></font><br></td>"
Else
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>ALL</b></font><br></td>"
End If
response.write "</tr>"
response.write "</table><br>"
response.write "<br><br><BR>"

response.write "<table align='center' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15'><font face='Verdana' size='1' color='black'>&nbsp</font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15'><font face='Verdana' size='1' color='black'>&nbsp</font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='38%'><font face='Verdana' size='1' color='black'><b>Title / Summary</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_seperator.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15%'><font face='Verdana' size='1' color='black'><b>Categories</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_seperator.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15%'><font face='Verdana' size='1' color='black'><b>Author</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_seperator.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10%'><font face='Verdana' size='1' color='black'><b>Status</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_seperator.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='28%'><font face='Verdana' size='1' color='black'><b>Date</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"

UseBackColor = BackColorOne

Do until RS.EOF
  If n = RecordsPerPage then
    exit do
  End If

  SQLd = "SELECT * FROM ArticleCategoryLink WHERE ArticleID = " & RS("ArticleID")
  Set RSd=dbc.execute(SQLd)
  ArticleCategory = ""
  Do While NOT RSd.EOF
    SQLe = "SELECT * FROM Categories WHERE CategoryID = " & RSd("CategoryID")
    Set RSe=dbc.execute(SQLe)
      ArticleCategoryLink = RSe("CategoryName")
    RSe.Close
    Set RSe=Nothing
    ArticleCategory = ArticleCategory & "<IMG SRC='news/icon_category.gif' BORDER='0'> " & ArticleCategoryLink & "<BR>"
    RSd.MoveNext
  Loop
  RSd.Close
  Set RSd=Nothing

  SQLd = "SELECT * FROM Authors WHERE AuthorID = " & RS("ArticleAuthor")
  Set RSd=dbc.execute(SQLd)
  ArticleAuthor = RSd("AuthorFirstName") & " " & RSd("AuthorLastName")
  RSd.Close
  Set RSd=Nothing
  
  response.write "<tr>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='17'><font face='Verdana' size='1' color='black'>&nbsp<a target='_new' href='news.asp?action=detail&article=" & RS("ArticleID") & "'><img src='news/icon_view.gif' border='0'></a>&nbsp</font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='17'><font face='Verdana' size='1' color='black'>&nbsp<a href='news.asp?action=editarticle&articleid=" & RS("ArticleID") & "'><img src='news/icon_edit.gif' border='0'></a>&nbsp</font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='17'><font face='Verdana' size='1' color='black'>&nbsp<a href='news.asp?action=deletearticle&articleid=" & RS("ArticleID") & "'><img src='news/icon_delete.gif' border='0'></a>&nbsp</font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='left' width='38%'><font face='Verdana' size='1' color='black'><b>" & RS("ArticleTitle") & "</b><br>" & RS("ArticleSummary") & "</font></td>"
  response.write "<td background='news/table_seperator.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='news/table_seperator.gif' border='0'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='15%'><font face='Verdana' size='1' color='black'>" & ArticleCategory & "</font></td>"
  response.write "<td background='news/table_seperator.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='news/table_seperator.gif' border='0'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='15%'><font face='Verdana' size='1' color='black'>" & ArticleAuthor & "</font></td>"
  response.write "<td background='news/table_seperator.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='news/table_seperator.gif' border='0'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='10%'><font face='Verdana' size='1' color='black'>" & RS("ArticleStatus") & "</font></td>"
  response.write "<td background='news/table_seperator.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='news/table_seperator.gif' border='0'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='28%'><font face='Verdana' size='1' color='black'>" & FormatDate(RS("ArticleDate"),"FULL") & "</font></td>"
  response.write "</tr>"
  RS.MoveNext
  If UseBackColor = BackColorOne then
    UseBackColor = BackColorTwo
  Else
    UseBackColor = BackColorOne
  End If
  n=n+1
  
Loop

response.write "</table>"
  
'------- Page Navigation ----------------------------------
response.write "<br>"
response.write "<table width='100%'>"
response.write "<tr>"
response.write "<td align=left><font face='Verdana' size='1'>&nbsp</font>"
response.write "</td>"
response.write "<td width='30%' align=right>"
response.write "<font face='Verdana' size='1'>"

response.write "<table align='center' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='100%'><font face='Verdana' size='1' color='black'>"

If Page <> 1 then
  response.write "<a href=news.asp?action=managearticles&Page=" & Page - 1 & "&filter=" & request.querystring("filter") & ">" 
  response.write "<< Prev"
End If
If Page <> 1 then
  response.write "</a>&nbsp"
end If
For intCount = 1 to RS.PageCount
  If IntCount = 1 then
    response.write " | "
  End If
  If cint(intCount) = cint(Page) then
    response.write "<b>" & intCount & "</b> | "
  Else
    response.write "<a href=news.asp?action=managearticles&Page=" & intCount & "&filter=" & request.querystring("filter") & ">" & intCount & "</a> | "
  End If
Next

If cint(page) <> cint(RS.PageCount) AND NOT RS.EOF then
  response.write "<a href=news.asp?action=managearticles&Page=" & Page + 1 & "&filter=" & request.querystring("filter") & ">"
  response.write "&nbspNext >>"
End If
If cint(Page) = cint(RS.PageCount) then
  response.write "</a>"
End If

response.write "</font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table>"

response.write "</font></td>"
response.write "</tr>"
response.write "</table>"
'-------------------------------------------------------------

End Sub

'******* Add An Article ***********************************************************

Sub AddArticle

If Session("frUserName") = "" AND request.querystring("action") <> "submitnews" then
  response.redirect "news.asp?action=login&err=notlogged"
End If


%>
<SCRIPT LANGUAGE="JavaScript">
<!--
function DataValidation()
{
if (document.addarticle.txtArticleTitle.value == "") {

alert("You must enter a TITLE for this article!");
return false;
}
if (document.addarticle.txtArticleCategories.value == "") {

alert("You must select at least one CATEGORY for this article!");
return false;
}

return true;

}

// -->
</SCRIPT>
<%

If request.querystring("action") <> "submitnews" then

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticles'>Manage Articles</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Add Article</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Add Article</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

End If

response.write "<form method='POST' action='news.asp?action=addarticleprocess' name='addarticle' ONSUBMIT='return DataValidation();'>"
response.write "<table align='center' width='97%' cellpadding='5' cellspacing='0' border='1' style='border-collapse: collapse' bordercolor='white'>"

If request.querystring("action") = "submitnews" then
  response.write "<INPUT TYPE='hidden' NAME='txtArticleStatusHidden' VALUE='USER SUBMITTED'>"
End If

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Title:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtArticleTitle' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Summary:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtArticleSummary' COLS='38' ROWS='5'></TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Body:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<font face='Verdana' size='1' color='black'><b>Browser Type:</b> " & BrowserType & "</font>"
If BrowserType = "Microsoft" then
  %>
  <!--#include file="news/editor.asp" -->
  <%
Else
  response.write "<br>"
  response.write "<textarea name='txtArticleBody' COLS='38' ROWS='5'></textarea>"
End If

response.write "<br>"
response.write "</td>"
response.write "</tr>"

If request.querystring("action") <> "submitnews" then

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Multi-Page:</B></FONT><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='checkbox' name='txtArticleMultiPage' VALUE='YES'><font face='Verdana' size='1' color='black'>This is a Multi-Page Article<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Layout:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<SELECT NAME='txtArticleLayout'>"
response.write "<option VALUE='0'>0 - Use Category Default</OPTION>"
SQLz="SELECT * FROM ArticleLayouts ORDER BY ALID"
Set RSz=dbc.execute(SQLz)
Do While NOT RSz.EOF
  response.write "<option VALUE='" & RSz("ALID") & "'>" & RSz("ALID") & " - " & RSz("ALName") & "</OPTION>"
  RSz.MoveNext
Loop
RSz.Close
Set RSz=Nothing
response.write "</SELECT>"
response.write "<br>"
response.write "</td>"
response.write "</tr>"

End If

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Date:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtArticleDate' size='50' value='" & Now() & "'> "
%>
<img src='news/mini_dateselect.gif' name="FromDate" onClick="calpopup('news.asp?action=minical&form=addarticle&element=txtArticleDate', '160', '150')"> 
<%
response.write "<br>"
response.write "</td>"
response.write "</tr>"

If request.querystring("action") <> "submitnews" then

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Author:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<FONT FACE='Verdana' SIZE='2' COLOR='black'>" & Session("frFirstName") & " " & Session("frLastName") & "<br>"
response.write "</td>"
response.write "</tr>"

End If

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Source:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtArticleSource' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Source Link:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtArticleSourceLink' size='50'><br>"
response.write "</td>"
response.write "</tr>"

If request.querystring("action") <> "submitnews" then

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Status:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtArticleStatus' value='PUBLISHED' checked>Published"
response.write "<input type='radio' name='txtArticleStatus' value='UN-PUBLISHED'>Un-Published Draft"
response.write "<input type='radio' name='txtArticleStatus' value='ARCHIVED'>Archived"
response.write "<input type='radio' name='txtArticleStatus' value='USER SUBMITTED'>User Submitted"
response.write "<input type='radio' name='txtArticleStatus' value='AWAITING APPROVAL'>Awaiting Approval<br></font>"
response.write "</td>"
response.write "</tr>"

End If

SQLc = "SELECT * FROM Categories ORDER BY CategoryName"
Set RSc=Server.CreateObject("adodb.Recordset")
RSc.Open SQLc, dbc, adopenstatic

response.write "<tr>"
response.write "<td  vAlign='top' align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Categories:</B><br><font color='red'>Hold CTRL to select multiple categories.</font></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<select size='" & RSc.RecordCount & "' name='txtArticleCategories' multiple>"

If request.querystring("action") <> "submitnews" then
  Do While NOT RSc.EOF
    SQLd = "SELECT * FROM AuthorCategoryLink WHERE AuthorID = " & Session("frAuthorID") & " AND CategoryID = " & RSc("CategoryID") & " OR AuthorID = " & Session("frAuthorID") & " AND CategoryID = 99999"
    Set RSd=Server.CreateObject("adodb.Recordset")
    RSd.Open SQLd, dbc, adopenstatic
    If NOT RSd.EOF then
      response.write "<option value='" & RSc("CategoryID") & "' "
      response.write ">" & RSc("CategoryName") & "</option>"
    End If
    RSd.Close
    Set RSd = Nothing
    RSc.MoveNext
  Loop
Else
  Do While NOT RSc.EOF
    response.write "<option value='" & RSc("CategoryID") & "' "
    response.write ">" & RSc("CategoryName") & "</option>"
    RSc.MoveNext
  Loop
End If

response.write "</select>"
response.write "</td>"
response.write "</tr>"

If request.querystring("action") <> "submitnews" then

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Image:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtArticleImage' size='50'> "
%>
<img src='news/mini_fileupload.gif' name="ArticleImage" onClick="calpopup('news.asp?action=uploadfile&location=addarticle&form=addarticle&element=txtArticleImage', '400', '160')"> 
<%
response.write "<BR>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Start Date:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtArticleStartDate' size='50'> "
%>
<img src='news/mini_dateselect.gif' name="FromDate" onClick="calpopup('news.asp?action=minical&form=addarticle&element=txtArticleStartDate', '160', '150')"> 
<%
response.write "<br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article End Date:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtArticleEndDate' size='50'> "
%>
<img src='news/mini_dateselect.gif' name="FromDate" onClick="calpopup('news.asp?action=minical&form=addarticle&element=txtArticleEndDate', '160', '150')"> 
<%
response.write "<br>"
response.write "</td>"
response.write "</tr>"

End If

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='white'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='white'>"
response.write "<input type='submit' value='Add this Article'><br>"
response.write "</td>"
response.write "</tr>"

response.write "</table>"
response.write "</form>"

If request.querystring("action") = "submitnews" then
  response.write "<BR>"
  Call DrawButtonBar
End If

End Sub

'******* Add Article Process ******************************************************

Sub AddArticleProcess

'If Session("frUserName") = "" then
'  response.redirect "news.asp?action=login&err=notlogged"
'End If

If Session("frRequireApproval") = "YES" then
  ArticleStatus = "AWAITING APPROVAL"
Else
  ArticleStatus = request.form("txtArticleStatus")
End If

If request.form("txtArticleStatusHidden") <> "" then
  ArticleStatus = "USER SUBMITTED"
End If

If request.form("txtArticleStartDate") = "" then
  txtArticleStartDate = FormatDateTime(cDate(request.form("txtArticleDate")),2)
Else
  txtArticleStartDate = cDate(request.form("txtArticleStartDate"))
End If

If request.form("txtArticleEndDate") = "" then
  txtArticleEndDate = cDate("12/31/2010")
Else
  txtArticleEndDate = cDate(request.form("txtArticleEndDate"))
End If

If Session("frAuthorID") = "" then
  Session("frAuthorID") = 1
End If

Set RS=Server.CreateObject("ADODB.RecordSet")
RS.Open "SELECT * FROM Articles", dbc, adOpenDynamic, adLockPessimistic, adCMDText

RS.AddNew
RS("ArticleTitle")=request.form("txtArticleTitle")
RS("ArticleSummary")=request.form("txtArticleSummary")
RS("ArticleBody")=request.form("txtArticleBody")
RS("ArticleDate")=request.form("txtArticleDate")
RS("ArticleAuthor")=Session("frAuthorID")
RS("ArticleSource")=request.form("txtArticleSource")
RS("ArticleSourceLink")=request.form("txtArticleSourceLink")
RS("ArticleStatus")=ArticleStatus
RS("ArticleImage")=request.form("txtArticleImage")
RS("ArticleStartDate")=txtArticleStartDate
RS("ArticleEndDate")=txtArticleEndDate
RS("ArticleMultiPage")=request.form("txtArticleMultiPage")
RS("ArticleLayout")=request.form("txtArticleLayout")
RS.Update

RS.Close
Set RS=Nothing

SQL = "SELECT * FROM Articles ORDER BY ArticleID"
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic
RS.MoveLast
ArticleID = RS("ArticleID")
RS.Close
Set RS=Nothing

Set RS=Server.CreateObject("ADODB.RecordSet")
RS.Open "SELECT * FROM ArticleCategoryLink", dbc, adOpenDynamic, adLockPessimistic, adCMDText

Dim Arr
Arr = Split(CStr(Request.Form("txtArticleCategories")),",")
For x = 0 to UBound(Arr)
  RS.AddNew
  RS("ArticleID") = ArticleID
  RS("CategoryID") = Trim(Arr(x))
Next
  RS.Update
  RS.Close
  Set RS=Nothing'

If request.form("txtArticleStatusHidden") = "" then
  response.redirect "news.asp?action=summary&type=addarticlesuccess"
Else
  response.redirect "news.asp?action=summary&type=submitarticlesuccess"
End If

End Sub

'******* Edit Article Screen ******************************************************

Sub EditArticle

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

SQLc = "SELECT * FROM ArticleCategoryLink WHERE ArticleID = " & request.querystring("articleid")
Set RSc=dbc.execute(SQLc)

Do While NOT RSc.EOF
  SQL = "SELECT * FROM AuthorCategoryLink WHERE AuthorID = " & Session("frAuthorID") & " AND CategoryID = " & RSc("CategoryID") & " OR AuthorID = " & Session("frAuthorID") & " AND CategoryID = 99999"
  Set RS=Server.CreateObject("adodb.Recordset")
  RS.Open SQL, dbc, adopenstatic
  If NOT RS.EOF then
    CanEdit = "YES"
    Exit Do
  End If
  RSc.MoveNext
Loop

RS.Close
Set RS=Nothing
RSc.Close
Set RSc=Nothing

If CanEdit <> "YES" then
  response.redirect "news.asp?action=summary&type=notallowed"
End If

%>
<SCRIPT LANGUAGE="JavaScript">
<!--
function DataValidation()
{
if (document.editarticle.txtArticleTitle.value == "") {

alert("You must enter a TITLE for this article!");
return false;
}
if (document.editarticle.txtArticleCategories.value == "") {

alert("You must select at least one CATEGORY for this article!");
return false;
}

return true;

}

// -->
</SCRIPT>
<%

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticles'>Manage Articles</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Edit Article</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Edit Article</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

SQL = "SELECT * FROM Articles WHERE ArticleID = " & request.querystring("articleid")
Set RS=dbc.execute(SQL)

response.write "<form onSubmit='document.all.txtArticleBody.value=document.all.oDiv.innerHTML' method='POST' action='news.asp?action=editarticleprocess' name='editarticle' ONSUBMIT='return DataValidation();'>"
response.write "<table align='center' width='97%' cellpadding='5' cellspacing='0' border='1' style='border-collapse: collapse' bordercolor='white'>"
response.write "<INPUT TYPE='hidden' NAME='txtArticleID' VALUE='" & request.querystring("articleid") & "'>"
response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Title:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtArticleTitle' size='50' VALUE="%>"<%=RS("ArticleTitle")%>"<%
response.write "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Summary:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtArticleSummary' COLS='38' ROWS='5'>" & RS("ArticleSummary") & "</TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Body:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<font face='Verdana' size='1' color='black'><b>Browser Type:</b> " & BrowserType & "</font>"
If BrowserType = "Microsoft" then
  %>
  <!--#include file="news/editor.asp" -->
  <%
Else
  response.write "<br>"
  response.write "<textarea name='txtArticleBody' COLS='38' ROWS='5'>" & RS("ArticleBody") & "</textarea>"
End If

response.write "<br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Multi-Page Article:</B></FONT><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='checkbox' name='txtArticleMultiPage' VALUE='YES'"
If RS("ArticleMultiPage") = "YES" then
  response.write " checked"
End If
response.write "><font face='Verdana' size='1' color='black'>This is a Multi-Page Article<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Layout:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<SELECT NAME='txtArticleLayoutType'>"
response.write "<option VALUE='0'"
If RS("ArticleLayout") = 0 then
  response.write " selected"
End If
response.write ">0 - Use Category Default</OPTION>"
SQLz="SELECT * FROM ArticleLayouts ORDER BY ALID"
Set RSz=dbc.execute(SQLz)
Do While NOT RSz.EOF
  response.write "<option VALUE='" & RSz("ALID") & "'"
  If RS("ArticleLayout") = RSz("ALID") then
    response.write " selected"
  End If 
  response.write ">" & RSz("ALID") & " - " & RSz("ALName") & "</OPTION>"
  RSz.MoveNext
Loop
RSz.Close
Set RSz=Nothing
response.write "</SELECT>"
response.write "<br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Date:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtArticleDate' size='50' VALUE='" & RS("ArticleDate") & "'> "
%>
<img src='news/mini_dateselect.gif' name="FromDate" onClick="calpopup('news.asp?action=minical&form=editarticle&element=txtArticleDate', '160', '150')"> 
<%
response.write "<br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Author:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<INPUT TYPE='radio' NAME='txtArticleAuthor' VALUE='" & RS("ArticleAuthor") & "' checked>"
SQLa = "SELECT * FROM Authors WHERE AuthorID = " & RS("ArticleAuthor")
Set RSa=dbc.execute(SQLa)
ArticleAuthor = RSa("AuthorFirstName") & " " & RSa("AuthorLastName")
RSa.Close
Set RSa=Nothing
response.write "<FONT FACE='Verdana' SIZE='2' COLOR='black'><B>Previous Author:</B>" & ArticleAuthor & "<BR></FONT>"
response.write "<INPUT TYPE='radio' NAME='txtArticleAuthor' VALUE='" & Session("frAuthorID") & "'>"
response.write "<FONT FACE='Verdana' SIZE='2' COLOR='black'><B>Current Author:</B>" & Session("frFirstName") & " " & Session("frLastName") & " <BR></FONT>"

response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Source:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtArticleSource' size='50' VALUE='" & RS("ArticleSource") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Source Link:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtArticleSourceLink' size='50' VALUE='" & RS("ArticleSourceLink") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Status:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtArticleStatus' value='PUBLISHED'"
If RS("ArticleStatus") = "PUBLISHED" then
  response.write " checked"
End If
response.write ">Published"
response.write "<input type='radio' name='txtArticleStatus' value='UN-PUBLISHED'"
If RS("ArticleStatus") = "UN-PUBLISHED" then
  response.write " checked"
End If
response.write ">Un-Published Draft"
response.write "<input type='radio' name='txtArticleStatus' value='ARCHIVED'"
If RS("ArticleStatus") = "ARCHIVED" then
  response.write " checked"
End If
response.write ">Archived"
response.write "<input type='radio' name='txtArticleStatus' value='USER SUBMITTED'"
If RS("ArticleStatus") = "USER SUBMITTED" then
  response.write " checked"
End If
response.write ">User Submitted"
response.write "<input type='radio' name='txtArticleStatus' value='AWAITING APPROVAL'"
If RS("ArticleStatus") = "AWAITING APPROVAL" then
  response.write " checked"
End If
response.write ">Awaiting Approval<br></font>"
response.write "</td>"
response.write "</tr>"

SQLc = "SELECT * FROM Categories ORDER BY CategoryName"
Set RSc=Server.CreateObject("adodb.Recordset")
RSc.Open SQLc, dbc, adopenstatic

response.write "<tr>"
response.write "<td  vAlign='top' align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Categories:</B><br><font color='red'>Hold CTRL to select multiple categories.</font></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<select size='" & RSc.RecordCount & "' name='txtArticleCategories' multiple>"

Do While NOT RSc.EOF
  SQLd = "SELECT * FROM AuthorCategoryLink WHERE AuthorID = " & Session("frAuthorID") & " AND CategoryID = " & RSc("CategoryID") & " OR AuthorID = " & Session("frAuthorID") & " AND CategoryID = 99999"
  Set RSd=Server.CreateObject("adodb.Recordset")
  RSd.Open SQLd, dbc, adopenstatic
  If NOT RSd.EOF then
    response.write "<option value='" & RSc("CategoryID") & "' "
    SQLf = "SELECT * FROM ArticleCategoryLink WHERE ArticleID = " & RS("ArticleID") & " AND CategoryID = " & RSc("CategoryID")
    Set RSf=Server.CreateObject("adodb.Recordset")
    RSf.Open SQLf, dbc, adopenstatic
    If NOT RSf.EOF then
      response.write " selected"
    End If
    RSf.Close
    Set RSf=Nothing
    response.write ">" & RSc("CategoryName") & "</option>"
  End If
  RSd.Close
  Set RSd = Nothing
  RSc.MoveNext
Loop

response.write "</select>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Image:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtArticleImage' size='50' VALUE='" & RS("ArticleImage") & "'> "
%>
<img src='news/mini_fileupload.gif' name="ArticleImage" onClick="calpopup('news.asp?action=uploadfile&location=editarticle&form=editarticle&element=txtArticleImage', '400', '160')"> 
<%
response.write "<BR>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Start Date:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtArticleStartDate' size='50' VALUE='" & RS("ArticleStartDate") & "'> "
%>
<img src='news/mini_dateselect.gif' name="FromDate" onClick="calpopup('news.asp?action=minical&form=editarticle&element=txtArticleStartDate', '160', '150')"> 
<%
response.write "<br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article End Date:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtArticleEndDate' size='50' VALUE='" & RS("ArticleEndDate") & "'> "
%>
<img src='news/mini_dateselect.gif' name="FromDate" onClick="calpopup('news.asp?action=minical&form=editarticle&element=txtArticleEndDate', '160', '150')"> 
<%
response.write "<br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='white'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='white'>"
response.write "<input type='submit' value='Save These Changes'><br>"
response.write "</td>"
response.write "</tr>"

response.write "</table>"
response.write "</form>"

End Sub

'******* Edit Article Process *****************************************************

Sub EditArticleProcess

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frRequireApproval") = "YES" then
  ArticleStatus = "AWAITING APPROVAL"
Else
  ArticleStatus = request.form("txtArticleStatus")
End If

If request.form("txtArticleStartDate") = "" then
  txtArticleStartDate = FormatDateTime(cDate(request.form("txtArticleDate")),2)
Else
  txtArticleStartDate = cDate(request.form("txtArticleStartDate"))
End If

If request.form("txtArticleEndDate") = "" then
  txtArticleEndDate = cDate("12/31/2010")
Else
  txtArticleEndDate = cDate(request.form("txtArticleEndDate"))
End If


SQL="UPDATE Articles SET ArticleTitle = '"&FixString(request.form("txtArticleTitle"))&"', "
SQL = SQL & "ArticleSummary = '"&FixString(request.form("txtArticleSummary"))&"', "
SQL = SQL & "ArticleBody = '"&FixString(request.form("txtArticleBody"))&"', "
SQL = SQL & "ArticleMultiPage = '"&request.form("txtArticleMultiPage")&"', "
SQL = SQL & "ArticleLayout = '"&request.form("txtArticleLayoutType")&"', "
SQL = SQL & "ArticleDate = '"&request.form("txtArticleDate")&"', "
SQL = SQL & "ArticleStatus = '"&ArticleStatus&"', "
SQL = SQL & "ArticleAuthor = '"&request.form("txtArticleAuthor")&"', "
SQL = SQL & "ArticleSource = '"&FixString(request.form("txtArticleSource"))&"', "
SQL = SQL & "ArticleSourceLink = '"&FixString(request.form("txtArticleSourceLink"))&"', "
SQL = SQL & "ArticleImage = '"&request.form("txtArticleImage")&"' " 
SQL = SQL & ", ArticleStartDate = '"&txtArticleStartDate&"' "
SQL = SQL & ", ArticleEndDate = '"&txtArticleEndDate&"' "
SQL = SQL & "WHERE [ArticleID] ="&request.form("txtArticleID")
response.write SQL
dbc.Execute(SQL)

SQL = "DELETE FROM ArticleCategoryLink WHERE ArticleID IN("& request.form("txtArticleID") &")"

response.write SQL
dbc.Execute(SQL)

Set RS=Server.CreateObject("ADODB.RecordSet")
RS.Open "SELECT * FROM ArticleCategoryLink", dbc, adOpenDynamic, adLockPessimistic, adCMDText

Dim Arr
Arr = Split(CStr(Request.Form("txtArticleCategories")),",")
For x = 0 to UBound(Arr)
  RS.AddNew
  RS("ArticleID") = request.form("txtArticleID")
  RS("CategoryID") = Trim(Arr(x))
Next
RS.Update
RS.Close
Set RS=Nothing

response.redirect "news.asp?action=summary&type=editarticlesuccess"

End Sub

'******* Delete Article Screen ****************************************************

Sub DeleteArticle

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticles'>Manage Articles</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Delete Article</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Delete Article</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

SQL = "SELECT * FROM Articles WHERE ArticleID = " & request.querystring("articleid")
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic

response.write "<p align='center'>"
response.write "<font face='Verdana' size='1' color='black'>Are you sure you want to delete this Article?<br><br>"

response.write "<table width='50%' align='center' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><B>" & RS("ArticleTitle") & "</B><BR>" & RS("ArticleSummary") & "</font><br></td>"
response.write "</tr>"
response.write "</table><br>"

response.write "<a href='news.asp?action=deletearticleprocess&articleid=" & request.querystring("articleid") & "'>YES</a> | <a href='news.asp?action=managearticles'>NO</a><br>"
response.write "</p>"

RS.Close
Set RS = Nothing

End Sub 

'******* Delete Article Process ****************************************************

Sub DeleteArticleProcess

SQL = "DELETE FROM ArticleCategoryLink WHERE ArticleID IN("& request.querystring("articleid") &")"
dbc.Execute(SQL)

SQL = "DELETE FROM Articles WHERE ArticleID IN("& request.querystring("articleid") &")"
dbc.Execute(SQL)

response.redirect "news.asp?action=summary&type=deletearticlesuccess"

End Sub

'******* Manage Layout Types ******************************************************

Sub ManageLayoutTypes

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

SQL = "SELECT * FROM LayoutTypes ORDER BY LTName"
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic

RS.MoveFirst

'-------- Paging ----------------------------------------------

If request.querystring("Page") = "" Then
  Page = 1
  RS.Move First
Else
  Page = Request.QueryString("Page")
  If Page = 1 then
    RS.Move First
  Else
    RS.Move CInt((Page * RecordsPerPage) - RecordsPerPage)
  End If
End If
n = 0
RS.PageSize = RecordsPerPage

'-----------------------------------------------------------------

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_layouttypes.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Manage Layout Types</font><br></td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Tasks: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_layouttypes.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=addlayouttype'>Add An New Layout Type</a></font><br></td>"
response.write "</tr>"

response.write "</table><br>"
response.write "<br><br>"

response.write "<table align='center' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15'><font face='Verdana' size='1' color='black'>&nbsp</font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15'><font face='Verdana' size='1' color='black'>&nbsp</font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='50%'><font face='Verdana' size='1' color='black'><b>Name / Description</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_seperator.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='50%'><font face='Verdana' size='1' color='black'><b>Preview</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"

UseBackColor = BackColorOne

Do until RS.EOF
  If n = RecordsPerPage then
    exit do
  End If

  response.write "<tr>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' VALIGN='top' width='17'><font face='Verdana' size='1' color='black'>&nbsp<a target='_new' href='news.asp?action=previewlayouttype&ltid=" & RS("LTID") & "'><img src='news/icon_view.gif' border='0'></a>&nbsp</font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' VALIGN='top' width='17'><font face='Verdana' size='1' color='black'>&nbsp<a href='news.asp?action=editlayouttype&ltid=" & RS("LTID") & "'><img src='news/icon_edit.gif' border='0'></a>&nbsp</font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' VALIGN='top' width='17'><font face='Verdana' size='1' color='black'>&nbsp<a href='news.asp?action=deletelayouttype&ltid=" & RS("LTID") & "'><img src='news/icon_delete.gif' border='0'></a>&nbsp</font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='left' VALIGN='top' width='50%'><font face='Verdana' size='1' color='black'><b>" & RS("LTName") & "</B><BR>" & RS("LTDescription") & "</font></td>"
  response.write "<td background='news/table_seperator.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='news/table_seperator.gif' border='0'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='50%'><font face='Verdana' size='1' color='black'><IMG SRC='news/articleimages/" & RS("LTPreview") & "' BORDER='0'></font></td>"
  response.write "</tr>"
  RS.MoveNext
  If UseBackColor = BackColorOne then
    UseBackColor = BackColorTwo
  Else
    UseBackColor = BackColorOne
  End If
  n=n+1
  
Loop

response.write "</table>"
  
'------- Page Navigation ----------------------------------
response.write "<br>"
response.write "<table width='100%'>"
response.write "<tr>"
response.write "<td align=left><font face='Verdana' size='1'>&nbsp</font>"
response.write "</td>"
response.write "<td width='30%' align=right>"
response.write "<font face='Verdana' size='1'>"

response.write "<table align='center' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='100%'><font face='Verdana' size='1' color='black'>"

If Page <> 1 then
  response.write "<a href=news.asp?action=managelayouttypes&Page=" & Page - 1 & ">" 
  response.write "<< Prev"
End If
If Page <> 1 then
  response.write "</a>&nbsp"
end If
For intCount = 1 to RS.PageCount
  If IntCount = 1 then
    response.write " | "
  End If
  If cint(intCount) = cint(Page) then
    response.write "<b>" & intCount & "</b> | "
  Else
    response.write "<a href=news.asp?action=managelayouttypes&Page=" & intCount & ">" & intCount & "</a> | "
  End If
Next

If cint(page) <> cint(RS.PageCount) then
  response.write "<a href=news.asp?action=managelayouttypes&Page=" & Page + 1 & ">"
  response.write "&nbspNext >>"
End If
If cint(Page) = cint(RS.PageCount) then
  response.write "</a>"
End If

response.write "</font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table>"

response.write "</font></td>"
response.write "</tr>"
response.write "</table>"
'-------------------------------------------------------------

End Sub

'******* Add Layout Type Screen ***************************************************

Sub AddLayoutType

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_layouttypes.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managelayouttypes'>Manage Layout Types</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_layouttypes.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Add A New Layout Type</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Add A New Layout Type</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

response.write "<form method='POST' name='addlayouttype' action='news.asp?action=addlayouttypeprocess'>"
response.write "<table align='center' width='97%' cellpadding='5' cellspacing='0' border='1' style='border-collapse: collapse' bordercolor='white'>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Layout Type Name:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTName' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Layout Type Description:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTDescription' cols='38' ROWS='5'></TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Number of Articles to Show:</B><BR>This is the total number of articles you want to show on the main and category news screens.</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTNumberToShow' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Number of Days to Show:</B><BR>This is the total number of days to show on the main / category news screens if you are using a grouped by day format.</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTDaysToShow' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Number of Features to Show:</B><BR>Features are the most recent articles... they will have an image next to the on the main / category news listing areas.</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTNumberOfFeatures' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>How many columns should should be used to display Features:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTFeaturesAcross' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>How many columns should should be used to display Regular news items:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTArticlesAcross' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Link To Full Article Text:</B><BR>If you enter something here it will appear under each article summary with a link to the full article:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTLinkToDetailText' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Would you like to display the last updated date:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtLTShowLastUpdate' value='YES' checked>YES"
response.write "<input type='radio' name='txtLTShowLastUpdate' value='NO'>NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>If you do want to show the last updated date what color would you like the background of the cell to be:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTUpdateBGColor' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Would you like to show a category summary on the main page:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtLTShowCategorySection' value='YES' checked>YES"
response.write "<input type='radio' name='txtLTShowCategorySection' value='NO'>NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>If you said YES to the previous item, how many columns should it have:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTCategoriesAcross' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Enter the amount of cell padding that should be between articles:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTArticlePadding' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Would you like to show a information about the author under the title on the main / category pages:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtLTShowMoreInfo' value='YES' checked>YES"
response.write "<input type='radio' name='txtLTShowMoreInfo' value='NO'>NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#DDDDDD'><font face='Verdana' size='1' color='black'>"
response.write "</font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Enter a heading to go above the Feature Articles:</B><BR>If you enter nothing there will be no heading... You can enter HTML Here</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTTopNewsHeading' cols='38' ROWS='5'></TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Enter a heading to go above the Recent Articles:</B><BR>If you enter nothing there will be no heading... You can enter HTML Here</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTRecentNewsHeading' cols='38' ROWS='5'></TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Enter a heading to go above the Category Summary:</B><BR>If you enter nothing there will be no heading... You can enter HTML Here</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTCategoryNewsHeading' cols='38' ROWS='5'></TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#DDDDDD'><font face='Verdana' size='1' color='black'>"
response.write "</font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Custom Page Header:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTHeader' cols='38' ROWS='5'></TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Custom Page Footer:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTFooter' cols='38' ROWS='5'></TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#DDDDDD'><font face='Verdana' size='1' color='black'>"
response.write "</font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Would you like to group your news into day blocks:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtLTGroupByDay' value='YES' checked>YES"
response.write "<input type='radio' name='txtLTGroupByDay' value='NO'>NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Enter an HTML Header for the date block if you are grouping articles by day:</B><BR>The date will be inserted between the Header and Footer.</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTDateBlockHeader' cols='38' ROWS='5'></TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Enter an HTML Footer for the date block if you are grouping articles by day:</B><BR>The date will be inserted between the Header and Footer.</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTDateBlockFooter' cols='38' ROWS='5'></TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#DDDDDD'><font face='Verdana' size='1' color='black'>"
response.write "</font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Would you like to show a headline box on your pages:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtLTShowNormalHLBox' value='YES' checked>YES"
response.write "<input type='radio' name='txtLTShowNormalHLBox' value='NO'>NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Would you like to headline box on the left or right side:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtLTHLLocation' value='LEFT' checked>LEFT"
response.write "<input type='radio' name='txtLTHLLocation' value='RIGHT'>RIGHT<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Enter the HTML Header for your Headline Box:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTHLBoxHeader' cols='38' ROWS='5'></TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Enter the HTML Footer for your Headline Box:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTHLBoxFooter' cols='38' ROWS='5'></TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Layout Type Preview:</B><BR>You can upload a preview image of this layout type for easier reference.</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTPreview' size='50'> "
%>
<img src='news/mini_fileupload.gif' name="ArticleImage" onClick="calpopup('news.asp?action=uploadfile&location=addlayouttype&form=addlayouttype&element=txtLTPreview', '400', '160')"> 
<%
response.write "<BR>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='white'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='white'>"
response.write "<input type='submit' value='Add this Layout Type'><br>"
response.write "</td>"
response.write "</tr>"

response.write "</table>"
response.write "</form>"

End Sub

'******* Add Layout Type Process **************************************************

Sub AddLayoutTypeProcess

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

Set RS=Server.CreateObject("ADODB.RecordSet")
RS.Open "SELECT * FROM LayoutTypes", dbc, adOpenDynamic, adLockPessimistic, adCMDText

RS.AddNew
RS("LTName")=request.form("txtLTName")
RS("LTDescription")=request.form("txtLTDescription")
RS("LTNumberToShow")=request.form("txtLTNumberToShow")
RS("LTNumberOfFeatures")=request.form("txtLTNumberOfFeatures")
RS("LTShowCategorySection")=request.form("txtLTShowCategorySection")
RS("LTShowNormalHLBox")=request.form("txtLTShowNormalHLBox")
RS("LTDateBlockHeader")=request.form("txtLTDateBlockHeader")
RS("LTDateBlockFooter")=request.form("txtLTDateBlockFooter")
RS("LTLinkToDetailText")=request.form("txtLTLinkToDetailText")
RS("LTHLLocation")=request.form("txtLTHLLocation")
RS("LTFeaturesAcross")=request.form("txtLTFeaturesAcross")
RS("LTShowLastUpdate")=request.form("txtLTShowLastUpdate")
RS("LTUpdateBGColor")=request.form("txtLTUpdateBGColor")
RS("LTTopNewsHeading")=request.form("txtLTTopNewsHeading")
RS("LTRecentNewsHeading")=request.form("txtLTRecentNewsHeading")
RS("LTCategoryNewsHeading")=request.form("txtLTCategoryNewsHeading")
RS("LTArticlesAcross")=request.form("txtLTArticlesAcross")
If request.form("txtLTCategoriesAcross") <> "" then
  RS("LTCategoriesAcross")=request.form("txtLTCategoriesAcross")
End If
RS("LTGroupByDay")=request.form("txtLTGroupByDay")
RS("LTDaysToShow")=request.form("txtLTDaysToShow")
RS("LTArticlePadding")=request.form("txtLTArticlePadding")
RS("LTShowMoreInfo")=request.form("txtLTShowMoreInfo")
RS("LTPreview")=request.form("txtLTPreview")
RS("LTHLBoxHeader")=request.form("txtLTHLBoxHeader")
RS("LTHLBoxFooter")=request.form("txtLTHLBoxFooter")
RS("LTHeader")=request.form("txtLTHeader")
RS("LTFooter")=request.form("txtLTFooter")
RS.Update

RS.Close
Set RS=Nothing

response.redirect "news.asp?action=summary&type=addlayouttypesuccess"

End Sub

'******* Edit Layout Type *********************************************************

Sub EditLayoutType

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

SQL = "SELECT * FROM LayoutTypes WHERE LTID = " & request.querystring("ltid")
Set RS=dbc.execute(SQL)

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_layouttypes.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managelayouttypes'>Manage Layout Types</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_layouttypes.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Edit Layout Type</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Edit Layout Type</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

response.write "<form method='POST' name='editlayouttype' action='news.asp?action=editlayouttypeprocess'>"
response.write "<INPUT TYPE='hidden' NAME='txtLTID' VALUE='" & request.querystring("ltid") & "'>"
response.write "<table align='center' width='97%' cellpadding='5' cellspacing='0' border='1' style='border-collapse: collapse' bordercolor='white'>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Layout Type Name:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTName' size='50' VALUE='" & RS("LTName") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Layout Type Description:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTDescription' cols='38' ROWS='5'>" & RS("LTDescription") & "</TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Number of Articles to Show:</B><BR>This is the total number of articles you want to show on the main and category news screens.</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTNumberToShow' size='50' VALUE='" & RS("LTNumberToShow") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Number of Days to Show:</B><BR>This is the total number of days to show on the main / category news screens if you are using a grouped by day format.</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTDaysToShow' size='50' VALUE='" & RS("LTDaysToShow") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Number of Features to Show:</B><BR>Features are the most recent articles... they will have an image next to the on the main / category news listing areas.</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTNumberOfFeatures' size='50' VALUE='" & RS("LTNumberOfFeatures") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>How many columns should should be used to display Features:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTFeaturesAcross' size='50' VALUE='" & RS("LTFeaturesAcross") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>How many columns should should be used to display Regular news items:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTArticlesAcross' size='50' VALUE='" & RS("LTArticlesAcross") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Link To Full Article Text:</B><BR>If you enter something here it will appear under each article summary with a link to the full article:</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTLinkToDetailText' size='50' VALUE='" & RS("LTLinkToDetailText") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Would you like to display the last updated date:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtLTShowLastUpdate' value='YES'"
If RS("LTShowLastUpdate") = "YES" then
  response.write " checked"
End If
response.write ">YES"
response.write "<input type='radio' name='txtLTShowLastUpdate' value='NO'"
If RS("LTShowLastUpdate") = "NO" then
  response.write " checked"
End If
response.write ">NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>If you do want to show the last updated date what color would you like the background of the cell to be:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTUpdateBGColor' size='50' VALUE='" & RS("LTUpdateBGColor") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Would you like to show a category summary on the main page:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtLTShowCategorySection' value='YES'"
If RS("LTShowCategorySection") = "YES" then
  response.write " checked"
End If
response.write ">YES"
response.write "<input type='radio' name='txtLTShowCategorySection' value='NO'"
If RS("LTShowCategorySection") = "NO" then
  response.write " checked"
End If
response.write ">NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>If you said YES to the previous item, how many columns should it have:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTCategoriesAcross' size='50' VALUE='" & RS("LTCategoriesAcross") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Enter the amount of cell padding that should be between articles:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTArticlePadding' size='50' VALUE='" & RS("LTArticlePadding") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Would you like to show a information about the author under the title on the main / category pages:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtLTShowMoreInfo' value='YES'"
If RS("LTShowMoreInfo") = "YES" then
  response.write " checked"
End If
response.write ">YES"
response.write "<input type='radio' name='txtLTShowMoreInfo' value='NO'"
If RS("LTShowMoreInfo") = "NO" then
  response.write " checked"
End If
response.write ">NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#DDDDDD'><font face='Verdana' size='1' color='black'>"
response.write "</font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Enter a heading to go above the Feature Articles:</B><BR>If you enter nothing there will be no heading... You can enter HTML Here</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTTopNewsHeading' cols='38' ROWS='5'>" & RS("LTTopNewsHeading") & "</TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Enter a heading to go above the Recent Articles:</B><BR>If you enter nothing there will be no heading... You can enter HTML Here</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTRecentNewsHeading' cols='38' ROWS='5'>" & RS("LTRecentNewsHeading") & "</TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Enter a heading to go above the Category Summary:</B><BR>If you enter nothing there will be no heading... You can enter HTML Here</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTCategoryNewsHeading' cols='38' ROWS='5'>" & RS("LTCategoryNewsHeading") & "</TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#DDDDDD'><font face='Verdana' size='1' color='black'>"
response.write "</font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Custom Page Header:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTHeader' cols='38' ROWS='5'>" & RS("LTHeader") & "</TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Custom Page Footer:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTFooter' cols='38' ROWS='5'>" & RS("LTFooter") & "</TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#DDDDDD'><font face='Verdana' size='1' color='black'>"
response.write "</font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Would you like to group your news into day blocks:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtLTGroupByDay' value='YES'"
If RS("LTGroupByDay") = "YES" then
  response.write " checked"
End If
response.write ">YES"
response.write "<input type='radio' name='txtLTGroupByDay' value='NO'"
If RS("LTGroupByDay") = "NO" then
  response.write " checked"
End If
response.write ">NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Enter an HTML Header for the date block if you are grouping articles by day:</B><BR>The date will be inserted between the Header and Footer.</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTDateBlockHeader' cols='38' ROWS='5'>" & RS("LTDateBlockHeader") & "</TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Enter an HTML Footer for the date block if you are grouping articles by day:</B><BR>The date will be inserted between the Header and Footer.</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTDateBlockFooter' cols='38' ROWS='5'>" & RS("LTDateBlockFooter") & "</TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#DDDDDD'><font face='Verdana' size='1' color='black'>"
response.write "</font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Would you like to show a headline box on your pages:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtLTShowNormalHLBox' value='YES'"
If RS("LTShowNormalHLBox") = "YES" then
  response.write " checked"
End If
response.write ">YES"
response.write "<input type='radio' name='txtLTShowNormalHLBox' value='NO'"
If RS("LTShowNormalHLBox") = "NO" then
  response.write " checked"
End If
response.write ">NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Would you like to headline box on the left or right side:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtLTHLLocation' value='LEFT'"
If RS("LTHLLocation") = "LEFT" then
  response.write " checked"
End If
response.write ">LEFT"
response.write "<input type='radio' name='txtLTHLLocation' value='RIGHT'"
If RS("LTHLLocation") = "RIGHT" then
  response.write " checked"
End If
response.write ">RIGHT<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Enter the HTML Header for your Headline Box:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTHLBoxHeader' cols='38' ROWS='5'>" & RS("LTHLBoxHeader") & "</TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Enter the HTML Footer for your Headline Box:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtLTHLBoxFooter' cols='38' ROWS='5'>" & RS("LTHLBoxFooter") & "</TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Layout Type Preview:</B><BR>You can upload a preview image of this layout type for easier reference.</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtLTPreview' size='50' VALUE='" & RS("LTPreview") & "'> "
%>
<img src='news/mini_fileupload.gif' name="ArticleImage" onClick="calpopup('news.asp?action=uploadfile&location=editlayouttype&form=editlayouttype&element=txtLTPreview', '400', '160')"> 
<%
response.write "<BR>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='white'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='white'>"
response.write "<input type='submit' value='Save These Changes'><br>"
response.write "</td>"
response.write "</tr>"

response.write "</table>"
response.write "</form>"

End Sub

'******* Edit Layout Type Process *************************************************

Sub EditLayoutTypeProcess

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

SQL="UPDATE LayoutTypes SET LTName = '"&FixString(request.form("txtLTName"))&"', "

SQL = SQL & "LTDescription = '"&FixString(request.form("txtLTDescription"))&"', "
SQL = SQL & "LTNumberToShow = '"&request.form("txtLTNumberToShow")&"', "
SQL = SQL & "LTNumberOfFeatures = '"&request.form("txtLTNumberOfFeatures")&"', "
SQL = SQL & "LTShowCategorySection = '"&request.form("txtLTShowCategorySection")&"', "
SQL = SQL & "LTShowNormalHLBox = '"&request.form("txtLTShowNormalHLBox")&"', "
SQL = SQL & "LTDateBlockHeader = '"&FixString(request.form("txtLTDateBlockHeader"))&"', "
SQL = SQL & "LTDateBlockFooter = '"&FixString(request.form("txtLTDateBlockFooter"))&"', "
SQL = SQL & "LTLinkToDetailText = '"&FixString(request.form("txtLTLinkToDetailText"))&"', "
SQL = SQL & "LTHLLocation = '"&request.form("txtLTHLLocation")&"', "
SQL = SQL & "LTFeaturesAcross = '"&request.form("txtLTFeaturesAcross")&"', "
SQL = SQL & "LTShowLastUpdate = '"&request.form("txtLTShowLastUpdate")&"', "
SQL = SQL & "LTUpdateBGColor = '"&FixString(request.form("txtLTUpdateBGColor"))&"', "
SQL = SQL & "LTTopNewsHeading = '"&FixString(request.form("txtLTTopNewsHeading"))&"', "
SQL = SQL & "LTRecentNewsHeading = '"&FixString(request.form("txtLTRecentNewsHeading"))&"', "
SQL = SQL & "LTCategoryNewsHeading = '"&FixString(request.form("txtLTCategoryNewsHeading"))&"', "
SQL = SQL & "LTArticlesAcross = '"&request.form("txtLTArticlesAcross")&"', "
SQL = SQL & "LTCategoriesAcross = '"&request.form("txtLTCategoriesAcross")&"', "
SQL = SQL & "LTGroupByDay = '"&request.form("txtLTGroupByDay")&"', "
SQL = SQL & "LTDaysToShow = '"&request.form("txtLTDaysToShow")&"', "
SQL = SQL & "LTArticlePadding = '"&request.form("txtLTArticlePadding")&"', "
SQL = SQL & "LTShowMoreInfo = '"&request.form("txtLTShowMoreInfo")&"', "
SQL = SQL & "LTPreview = '"&FixString(request.form("txtLTPreview"))&"', "
SQL = SQL & "LTHLBoxHeader = '"&FixString(request.form("txtLTHLBoxHeader"))&"', "
SQL = SQL & "LTHeader = '"&FixString(request.form("txtLTHeader"))&"', "
SQL = SQL & "LTFooter = '"&FixString(request.form("txtLTFooter"))&"', "
SQL = SQL & "LTHLBoxFooter = '"&FixString(request.form("txtLTHLBoxFooter"))&"' " 
SQL = SQL & "WHERE [LTID] ="&request.form("txtLTID")
dbc.Execute(SQL)

response.redirect "news.asp?action=summary&type=editlayouttypesuccess"

End Sub

'******* Delete Layout Type Screen ************************************************

Sub DeleteLayoutType

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_layouttypes.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managelayouttypes'>Manage Layout Types</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_layouttypes.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Delete Layout Type</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Delete Layout Type</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

SQL = "SELECT * FROM LayoutTypes WHERE LTID = " & request.querystring("ltid")
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic

response.write "<p align='center'>"
response.write "<font face='Verdana' size='1' color='black'><B>Are you sure you want to delete this Layout Type?</B><BR>Note: Doing so will reset any category using this layout type back to the default layout type.<BR>If this is currently your default layout type it will be changed back to the first layout type.<br><br>"

response.write "<table width='50%' align='center' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_layouttypes.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><B>" & RS("LTName") & "</B><BR>" & RS("LTDescription") & "</font><br></td>"
response.write "</tr>"
response.write "</table><br>"

response.write "<a href='news.asp?action=deletelayouttypeprocess&ltid=" & request.querystring("ltid") & "'>YES</a> | <a href='news.asp?action=managelayouttypes'>NO</a><br>"
response.write "</p>"

RS.Close
Set RS = Nothing

End Sub

'******* Delete Layout Type Process ***********************************************

Sub DeleteLayoutTypeProcess

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

Set RS=Server.CreateObject("ADODB.RecordSet")
RS.Open "SELECT * FROM Categories WHERE CategoryLayoutType =  " & request.querystring("ltid"), dbc, adOpenDynamic, adLockPessimistic, adCMDText

Do While NOT RS.EOF
  SQLc="UPDATE Categories SET CategoryLayoutType = 1 WHERE [CategoryID] = " & RS("CategoryID")
  dbc.Execute(SQLc)
  RS.MoveNext
  RSc.Close
  Set RSc=Nothing
Loop

RS.Close
Set RS=Nothing

SQL = "DELETE FROM LayoutTypes WHERE LTID IN("& request.querystring("ltid") &")"
dbc.Execute(SQL)

response.redirect "news.asp?action=summary&type=deletelayouttypesuccess"

End Sub

'******* Edit Configuration Screen ************************************************

Sub EditConfig

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

SQL = "SELECT * FROM Config"
Set RS=dbc.execute(SQL)

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_config.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Edit Configuration</font><br></td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Tasks: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_config.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=createsyndicationhtml'>Syndication HTML</a></font><br></td>"
response.write "</tr>"

response.write "</table><br>"
response.write "<br><BR>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Edit Configuration</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

response.write "<form method='POST' action='news.asp?action=editconfigprocess'>"
response.write "<INPUT TYPE='hidden' NAME='txtConfigID' VALUE='1'>"
response.write "<table align='center' width='97%' cellpadding='5' cellspacing='0' border='1' style='border-collapse: collapse' bordercolor='white'>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Default Layout Type:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<SELECT NAME='txtDefaultLayoutType'>"

SQLa = "SELECT * FROM LayoutTypes"
Set RSa = dbc.execute(SQLa)

Do While NOT RSa.EOF
  response.write "<OPTION VALUE='" & RSa("LTID") & "'"
  If RS("DefaultLayoutType") = RSa("LTID") then
    response.write " selected"
  End If
  response.write ">" & RSa("LTName") & "</OPTION>"
  RSa.MoveNext
Loop
RSa.Close
Set RSa=Nothing

response.write "<br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Default Article Layout:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<SELECT NAME='txtDefaultArticleLayout'>"
SQLz="SELECT * FROM ArticleLayouts ORDER BY ALID"
Set RSz=dbc.execute(SQLz)
Do While NOT RSz.EOF
  response.write "<option VALUE='" & RSz("ALID") & "'"
  If RS("DefaultArticleLayout") = RSz("ALID") then
    response.write " selected"
  End If 
  response.write ">" & RSz("ALID") & " - " & RSz("ALName") & "</OPTION>"
  RSz.MoveNext
Loop
RSz.Close
Set RSz=Nothing
response.write "</SELECT>"
response.write "<br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Default Font Face:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtDefaultFontFace' size='50' VALUE='" & RS("DefaultFontFace") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Default Font Title Size:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtDefaultFontTitleSize' size='50' VALUE='" & RS("DefaultFontTitleSize") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Default Font Body Size:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtDefaultFontBodySize' size='50' VALUE='" & RS("DefaultFontBodySize") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Default Font Color:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtDefaultFontColor' size='50' VALUE='" & RS("DefaultFontColor") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Email Component:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<SELECT NAME='txtEmailComponent'>"
response.write "<OPTION VALUE='CDONTS'"
If RS("EmailComponent") = "CDONTS" then
  response.write " selected"
End If
response.write ">CDONTS</OPTION>"
response.write "<OPTION VALUE='ASPEmail'"
If RS("EmailComponent") = "ASPEmail" then
  response.write " selected"
End If
response.write ">ASPEmail</OPTION>"
response.write "<OPTION VALUE='JMail'"
If RS("EmailComponent") = "JMail" then
  response.write " selected"
End If
response.write ">JMail</OPTION>"
response.write "<OPTION VALUE='ASPMail'"
If RS("EmailComponent") = "ASPMail" then
  response.write " selected"
End If
response.write ">ASPMail</OPTION>"
response.write "</select>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Email The Administrators Email Address:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtAdminEmail' size='50' VALUE='" & RS("AdminEmail") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Email Site Name:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtEmailSiteName' size='50' VALUE='" & RS("EmailSiteName") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Email Site URL:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtEmailSiteURL' size='50' VALUE='" & RS("EmailSiteURL") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Email Host (Required for some mail components):</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtEmailHost' size='50' VALUE='" & RS("EmailHost") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Text to append to Syndication Feed:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtSyndicationText' size='50' VALUE='" & RS("SyndicationText") & "'><br>"
response.write "</td>"
response.write "</tr>"


response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Admin Records Per Page:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtAdminRecordsPerPage' size='50' VALUE='" & RS("AdminRecordsPerPage") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Admin Color Scheme:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtAdminColor' size='50' VALUE='" & RS("AdminColor") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Admin Back Color 1:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtAdminBackColorOne' size='50' VALUE='" & RS("AdminBackColorOne") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Admin Back Color 2:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtAdminBackColorTwo' size='50' VALUE='" & RS("AdminBackColorTwo") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Which links would you like to show at the bottom of the public areas:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<FONT FACE='Verdana' SIZE='1' COLOR='black'>"
response.write "<input type='checkbox' name='txtBBShowHome' VALUE='YES'"
If RS("BBShowHome") = "YES" then
  response.write " checked"
End If
response.write "> Home "
response.write "<input type='checkbox' name='txtBBShowSearch' VALUE='YES'"
If RS("BBShowSearch") = "YES" then
  response.write " checked"
End If
response.write "> Search "
response.write "<input type='checkbox' name='txtBBShowArchives' VALUE='YES'"
If RS("BBShowArchives") = "YES" then
  response.write " checked"
End If
response.write "> Archives "
response.write "<input type='checkbox' name='txtBBShowSubmit' VALUE='YES'"
If RS("BBShowSubmit") = "YES" then
  response.write " checked"
End If
response.write "> Submit News " 
response.write "<input type='checkbox' name='txtBBShowEmailAdmin' VALUE='YES'"
If RS("BBShowEmailAdmin") = "YES" then
  response.write " checked"
End If
response.write "> Email Admin " 
response.write "<input type='checkbox' name='txtBBShowLogin' VALUE='YES'"
If RS("BBShowLogin") = "YES" then
  response.write " checked"
End If
response.write "> Login " 
response.write "<input type='checkbox' name='txtBBShowSyndication' VALUE='YES'"
If RS("BBShowSyndication") = "YES" then
  response.write " checked"
End If
response.write "> Syndication Link "
response.write "</FONT>"
response.write "<BR></td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='white'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='white'>"
response.write "<input type='submit' value='Save These Changes'><br>"
response.write "</td>"
response.write "</tr>"

response.write "</table>"
response.write "</form>"

End Sub

'******* Edit Config Process ******************************************************

Sub EditConfigProcess

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

SQL="UPDATE Config SET DefaultLayoutType = '"&request.form("txtDefaultLayoutType")&"', "

SQL = SQL & "DefaultArticleLayout = '"&request.form("txtDefaultArticleLayout")&"', "
SQL = SQL & "DefaultFontFace = '"&FixString(request.form("txtDefaultFontFace"))&"', "
SQL = SQL & "DefaultFontTitleSize = '"&FixString(request.form("txtDefaultFontTitleSize"))&"', "
SQL = SQL & "DefaultFontBodySize = '"&FixString(request.form("txtDefaultFontBodySize"))&"', "
SQL = SQL & "DefaultFontColor = '"&FixString(request.form("txtDefaultFontColor"))&"', "
SQL = SQL & "EmailComponent = '"&FixString(request.form("txtEmailComponent"))&"', "
SQL = SQL & "EmailSiteName = '"&FixString(request.form("txtEmailSiteName"))&"', "
SQL = SQL & "AdminEmail = '"&FixString(request.form("txtAdminEmail"))&"', "
SQL = SQL & "EmailSiteURL = '"&FixString(request.form("txtEmailSiteURL"))&"', "
SQL = SQL & "EmailHost = '"&FixString(request.form("txtEmailHost"))&"', "
SQL = SQL & "SyndicationText = '"&FixString(request.form("txtSyndicationText"))&"', "
SQL = SQL & "AdminRecordsPerPage = '"&request.form("txtAdminRecordsPerPage")&"', "
SQL = SQL & "AdminColor = '"&FixString(request.form("txtAdminColor"))&"', "
SQL = SQL & "AdminBackColorOne = '"&FixString(request.form("txtAdminBackColorOne"))&"', "
SQL = SQL & "BBShowSearch = '"&request.form("txtBBShowSearch")&"', "
SQL = SQL & "BBShowArchives = '"&request.form("txtBBShowArchives")&"', "
SQL = SQL & "BBShowSubmit = '"&request.form("txtBBShowSubmit")&"', "
SQL = SQL & "BBShowEmailAdmin = '"&request.form("txtBBShowEmailAdmin")&"', "
SQL = SQL & "BBShowLogin = '"&request.form("txtBBShowLogin")&"', "
SQL = SQL & "BBShowHome = '"&request.form("txtBBShowHome")&"', "
SQL = SQL & "BBShowSyndication = '"&request.form("txtBBShowSyndication")&"', "
SQL = SQL & "AdminBackColorTwo = '"&FixString(request.form("txtAdminBackColorTwo"))&"' "
SQL = SQL & " WHERE [ConfigID] ="&request.form("txtConfigID")
dbc.Execute(SQL)

response.redirect "news.asp?action=summary&type=editconfigsuccess"

End Sub

'******* Manage Article Layouts Screen ********************************************

Sub ManageArticleLayouts

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

SQL = "SELECT * FROM ArticleLayouts ORDER BY ALName"
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic

RS.MoveFirst

'-------- Paging ----------------------------------------------

If request.querystring("Page") = "" Then
  Page = 1
  RS.Move First
Else
  Page = Request.QueryString("Page")
  If Page = 1 then
    RS.Move First
  Else
    RS.Move CInt((Page * RecordsPerPage) - RecordsPerPage)
  End If
End If
n = 0
RS.PageSize = RecordsPerPage

'-----------------------------------------------------------------

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_articlelayouts.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Manage Article Layouts</font><br></td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Tasks: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_articlelayouts.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=addarticlelayout'>Add A New Article Layout</a></font><br></td>"
response.write "</tr>"

response.write "</table><br>"
response.write "<br><br>"

response.write "<table align='center' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15'><font face='Verdana' size='1' color='black'>&nbsp</font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='15'><font face='Verdana' size='1' color='black'>&nbsp</font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='50%'><font face='Verdana' size='1' color='black'><b>Name / Description</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_seperator.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='50%'><font face='Verdana' size='1' color='black'><b>Preview</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"

UseBackColor = BackColorOne

Do until RS.EOF
  If n = RecordsPerPage then
    exit do
  End If

  response.write "<tr>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' VALIGN='top' width='17'><font face='Verdana' size='1' color='black'>&nbsp<a target='_new' href='news.asp?action=previewarticlelayout&alid=" & RS("ALID") & "'><img src='news/icon_view.gif' border='0'></a>&nbsp</font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' VALIGN='top' width='17'><font face='Verdana' size='1' color='black'>&nbsp<a href='news.asp?action=editarticlelayout&alid=" & RS("ALID") & "'><img src='news/icon_edit.gif' border='0'></a>&nbsp</font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' VALIGN='top' width='17'><font face='Verdana' size='1' color='black'>&nbsp<a href='news.asp?action=deletearticlelayout&alid=" & RS("ALID") & "'><img src='news/icon_delete.gif' border='0'></a>&nbsp</font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='left' VALIGN='top' width='50%'><font face='Verdana' size='1' color='black'><b>" & RS("ALName") & "</B><BR>" & RS("ALDescription") & "</font></td>"
  response.write "<td background='news/table_seperator.gif' align='center' width='10'><font face='Verdana' size='1' color='black'><img src='news/table_seperator.gif' border='0'></font></td>"
  response.write "<td bgcolor='" & UseBackColor & "' align='center' width='50%'><font face='Verdana' size='1' color='black'><IMG SRC='news/articleimages/" & RS("ALPreview") & "' BORDER='0'></font></td>"
  response.write "</tr>"
  RS.MoveNext
  If UseBackColor = BackColorOne then
    UseBackColor = BackColorTwo
  Else
    UseBackColor = BackColorOne
  End If
  n=n+1
  
Loop

response.write "</table>"
  
'------- Page Navigation ----------------------------------
response.write "<br>"
response.write "<table width='100%'>"
response.write "<tr>"
response.write "<td align=left><font face='Verdana' size='1'>&nbsp</font>"
response.write "</td>"
response.write "<td width='30%' align=right>"
response.write "<font face='Verdana' size='1'>"

response.write "<table align='center' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='100%'><font face='Verdana' size='1' color='black'>"

If Page <> 1 then
  response.write "<a href=news.asp?action=managearticlelayouts&Page=" & Page - 1 & ">" 
  response.write "<< Prev"
End If
If Page <> 1 then
  response.write "</a>&nbsp"
end If
For intCount = 1 to RS.PageCount
  If IntCount = 1 then
    response.write " | "
  End If
  If cint(intCount) = cint(Page) then
    response.write "<b>" & intCount & "</b> | "
  Else
    response.write "<a href=news.asp?action=managearticlelayouts&Page=" & intCount & ">" & intCount & "</a> | "
  End If
Next

If cint(page) <> cint(RS.PageCount) then
  response.write "<a href=news.asp?action=managearticlelayouts&Page=" & Page + 1 & ">"
  response.write "&nbspNext >>"
End If
If cint(Page) = cint(RS.PageCount) then
  response.write "</a>"
End If

response.write "</font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table>"

response.write "</font></td>"
response.write "</tr>"
response.write "</table>"
'-------------------------------------------------------------

End Sub

'******* Add Article Layout Screen ************************************************

Sub AddArticleLayout

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_articlelayouts.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticlelayouts'>Manage Layout Types</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_articlelayouts.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Add A New Article Layout</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Add A New Article Layout</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

response.write "<form method='POST' name='addarticlelayout' action='news.asp?action=addarticlelayoutprocess'>"
response.write "<table align='center' width='97%' cellpadding='5' cellspacing='0' border='1' style='border-collapse: collapse' bordercolor='white'>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Layout Name:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtALName' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Layout Description:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtALDescription' cols='38' ROWS='5'></TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Headline:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowHeadline' value='YES' checked>YES"
response.write "<input type='radio' name='txtALShowHeadline' value='NO'>NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Author:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowAuthor' value='YES' checked>YES"
response.write "<input type='radio' name='txtALShowAuthor' value='NO'>NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Source:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowSource' value='YES' checked>YES"
response.write "<input type='radio' name='txtALShowSource' value='NO'>NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Date / Time:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowDateTime' value='YES' checked>YES"
response.write "<input type='radio' name='txtALShowDateTime' value='NO'>NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Article Image:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowArticleImage' value='YES' checked>YES"
response.write "<input type='radio' name='txtALShowArticleImage' value='NO'>NO<br></font>"
response.write "</td>"
response.write "</tr>"


response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Summary:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowSummary' value='YES' checked>YES"
response.write "<input type='radio' name='txtALShowSummary' value='NO'>NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Summary Font Size:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtALSummaryFontSize' size='50'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Email Link:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowEmailLink' value='YES' checked>YES"
response.write "<input type='radio' name='txtALShowEmailLink' value='NO'>NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Print Button:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowPrintButton' value='YES' checked>YES"
response.write "<input type='radio' name='txtALShowPrintButton' value='NO'>NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Related Articles:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowRelatedArticles' value='YES' checked>YES"
response.write "<input type='radio' name='txtALShowRelatedArticles' value='NO'>NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Related Articles Header:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<TEXTAREA NAME='txtALRAHeader' COLS='38' ROWS='5'></TEXTAREA>"
response.write "<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Line Under Info:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowLine' value='YES' checked>YES"
response.write "<input type='radio' name='txtALShowLine' value='NO'>NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Layout Preview:</B><BR>You can upload a preview image of this article layout for easier reference.</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtALPreview' size='50'> "
%>
<img src='news/mini_fileupload.gif' name="ArticleImage" onClick="calpopup('news.asp?action=uploadfile&location=addarticlelayout&form=addarticlelayout&element=txtALPreview', '400', '160')"> 
<%
response.write "<BR>"
'response.write "<FONT FACE='verdana' SIZE='1'><A target='_new' HREF='news.asp?action=uploadfile&location=addarticlelayout'>Upload An Image</a>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='white'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='white'>"
response.write "<input type='submit' value='Add this Article Layout'><br>"
response.write "</td>"
response.write "</tr>"

response.write "</table>"
response.write "</form>"

End Sub

'******* Add Article Layout Process ***********************************************

Sub AddArticleLayoutProcess

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

Set RS=Server.CreateObject("ADODB.RecordSet")
RS.Open "SELECT * FROM ArticleLayouts", dbc, adOpenDynamic, adLockPessimistic, adCMDText

RS.AddNew
RS("ALName")=request.form("txtALName")
RS("ALDescription")=request.form("txtALDescription")
RS("ALShowHeadline")=request.form("txtALShowHeadline")
RS("ALShowAuthor")=request.form("txtALShowAuthor")
RS("ALShowSource")=request.form("txtALShowSource")
RS("ALShowDateTime")=request.form("txtALShowDateTime")
RS("ALShowSummary")=request.form("txtALShowSummary")
RS("ALSummaryFontSize")=request.form("txtALSummaryFontSize")
RS("ALShowArticleImage")=request.form("txtALShowArticleImage")
RS("ALShowEmailLink")=request.form("txtALShowEmailLink")
RS("ALShowPrintButton")=request.form("txtALShowPrintButton")
RS("ALShowRelatedArticles")=request.form("txtALShowRelatedArticles")
RS("ALShowLine")=request.form("txtALShowLine")
RS("ALPreview")=request.form("txtALPreview")
RS("ALRAHeader")=request.form("txtALRAHeader")
RS.Update

RS.Close
Set RS=Nothing

response.redirect "news.asp?action=summary&type=addarticlelayoutsuccess"

End Sub

'******* Edit Article Layout ******************************************************

Sub EditArticleLayout

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

SQL = "SELECT * FROM ArticleLayouts WHERE ALID = " & request.querystring("alid")
Set RS=dbc.execute(SQL)

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_articlelayouts.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticlelayouts'>Manage Article Layouts</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_articlelayouts.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Edit Article Layout</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Edit Article Layout</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

response.write "<form method='POST' name='editarticlelayout' action='news.asp?action=editarticlelayoutprocess'>"
response.write "<INPUT TYPE='hidden' NAME='txtALID' VALUE='" & request.querystring("alid") & "'>"
response.write "<table align='center' width='97%' cellpadding='5' cellspacing='0' border='1' style='border-collapse: collapse' bordercolor='white'>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Layout Name:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtALName' size='50' VALUE='" & RS("ALName") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Layout Description:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<textarea name='txtALDescription' cols='38' ROWS='5'>" & RS("ALDescription") & "</TEXTAREA><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Headline:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowHeadline' value='YES'"
If RS("ALShowHeadline") = "YES" then
  response.write " checked"
End If
response.write ">YES"
response.write "<input type='radio' name='txtALShowHeadline' value='NO'"
If RS("ALShowHeadline") = "NO" then
  response.write " checked"
End If
response.write ">NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Author:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowAuthor' value='YES'"
If RS("ALShowAuthor") = "YES" then
  response.write " checked"
End If
response.write ">YES"
response.write "<input type='radio' name='txtALShowAuthor' value='NO'"
If RS("ALShowAuthor") = "NO" then
  response.write " checked"
End If
response.write ">NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Source:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowSource' value='YES'"
If RS("ALShowSource") = "YES" then
  response.write " checked"
End If
response.write ">YES"
response.write "<input type='radio' name='txtALShowSource' value='NO'"
If RS("ALShowSource") = "NO" then
  response.write " checked"
End If
response.write ">NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Date / Time:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowDateTime' value='YES'"
If RS("ALShowDateTime") = "YES" then
  response.write " checked"
End If
response.write ">YES"
response.write "<input type='radio' name='txtALShowDateTime' value='NO'"
If RS("ALShowDateTime") = "NO" then
  response.write " checked"
End If
response.write ">NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Article Image:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowArticleImage' value='YES'"
If RS("ALShowArticleImage") = "YES" then
  response.write " checked"
End If
response.write ">YES"
response.write "<input type='radio' name='txtALShowArticleImage' value='NO'"
If RS("ALShowArticleImage") = "NO" then
  response.write " checked"
End If
response.write ">NO<br></font>"
response.write "</td>"
response.write "</tr>"


response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Summary:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowSummary' value='YES'"
If RS("ALShowSummary") = "YES" then
  response.write " checked"
End If
response.write ">YES"
response.write "<input type='radio' name='txtALShowSummary' value='NO'"
If RS("ALShowSummary") = "NO" then
  response.write " checked"
End If
response.write ">NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Summary Font Size:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtALSummaryFontSize' size='50' VALUE='" & RS("ALSummaryFontSize") & "'><br>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Email Link:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowEmailLink' value='YES'"
If RS("ALShowEmailLink") = "YES" then
  response.write " checked" 
End If
response.write ">YES"
response.write "<input type='radio' name='txtALShowEmailLink' value='NO'"
If RS("ALShowEmailLink") = "NO" then
  response.write " checked"
End If
response.write ">NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Print Button:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowPrintButton' value='YES'"
If RS("ALShowPrintButton") = "YES" then
  response.write " checked"
End If
response.write ">YES"
response.write "<input type='radio' name='txtALShowPrintButton' value='NO'"
If RS("ALShowPrintButton") = "NO" then
  response.write " checked"
End If
response.write ">NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Related Articles:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowRelatedArticles' value='YES'"
If RS("ALShowRelatedArticles") = "YES" then
  response.write " checked"
End If
response.write ">YES"
response.write "<input type='radio' name='txtALShowRelatedArticles' value='NO'"
If RS("ALShowRelatedArticles") = "NO" then
  response.write " checked"
End If
response.write ">NO<br></font>"
response.write "</td>"
response.write "</tr>"


response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Related Articles Header:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<TEXTAREA NAME='txtALRAHeader' COLS='38' ROWS='5'>" & RS("ALRAHeader") & "</TEXTAREA>"
response.write "<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Show Line Under Info:</B></font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'><font face='Verdana' size='1' color='black'>"
response.write "<input type='radio' name='txtALShowLine' value='YES'"
If RS("ALShowLine") = "YES" then
  response.write " checked"
End If
response.write ">YES"
response.write "<input type='radio' name='txtALShowLine' value='NO'"
If RS("ALShowLine") = "NO" then
  response.write " checked"
End If
response.write ">NO<br></font>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='#DDDDDD'>"
response.write "<font face='Verdana' size='1' color='black'><B>Article Layout Preview:</B><BR>You can upload a preview image of this article layout for easier reference.</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='#EEEEEE'>"
response.write "<input type='text' name='txtALPreview' size='50' VALUE='" & RS("ALPreview") & "'> "
%>
<img src='news/mini_fileupload.gif' name="ArticleImage" onClick="calpopup('news.asp?action=uploadfile&location=editarticlelayout&form=editarticlelayout&element=txtALPreview', '400', '160')"> 
<%
response.write "<BR>"
response.write "</td>"
response.write "</tr>"

response.write "<tr>"
response.write "<td align='right' width='20%' bgcolor='white'>"
response.write "<font face='Verdana' size='1' color='black'>&nbsp</font><br></td>"
response.write "<td align='left' width='80%' bgcolor='white'>"
response.write "<input type='submit' value='Save These Changes'><br>"
response.write "</td>"
response.write "</tr>"

response.write "</table>"
response.write "</form>"

End Sub

'******* Edit Article Layout Process **********************************************

Sub EditArticleLayoutProcess

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

SQL="UPDATE ArticleLayouts SET ALName = '"&FixString(request.form("txtALName"))&"', "

SQL = SQL & "ALDescription = '"&FixString(request.form("txtALDescription"))&"', "
SQL = SQL & "ALShowHeadline = '"&request.form("txtALShowHeadline")&"', "
SQL = SQL & "ALShowAuthor = '"&request.form("txtALShowAuthor")&"', "
SQL = SQL & "ALShowSource = '"&request.form("txtALShowSource")&"', "
SQL = SQL & "ALShowDateTime = '"&request.form("txtALShowDateTime")&"', "
SQL = SQL & "ALShowSummary = '"&request.form("txtALShowSummary")&"', "
SQL = SQL & "ALSummaryFontSize = '"&FixString(request.form("txtALSummaryFontSize"))&"', "
SQL = SQL & "ALShowArticleImage = '"&request.form("txtALShowArticleImage")&"', "
SQL = SQL & "ALShowEmailLink = '"&request.form("txtALShowEmailLink")&"', "
SQL = SQL & "ALShowPrintButton = '"&request.form("txtALShowPrintButton")&"', "
SQL = SQL & "ALShowRelatedArticles = '"&request.form("txtALShowRelatedArticles")&"', "
SQL = SQL & "ALRAHeader = '"&FixString(request.form("txtALRAHeader"))&"', "
SQL = SQL & "ALShowLine = '"&request.form("txtALShowLine")&"', "
SQL = SQL & "ALPreview = '"&FixString(request.form("txtALPreview"))&"' " 
SQL = SQL & "WHERE [ALID] ="&request.form("txtALID")
dbc.Execute(SQL)

response.redirect "news.asp?action=summary&type=editarticlelayoutsuccess"

End Sub

'******* Delete Article Layout ****************************************************

Sub DeleteArticleLayout

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_articlelayouts.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticlelayouts'>Manage Articles Layouts</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_articlelayouts.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Delete Article Layout</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Delete Article Layout</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

SQL = "SELECT * FROM ArticleLayouts WHERE ALID = " & request.querystring("alid")
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic

response.write "<p align='center'>"
response.write "<font face='Verdana' size='1' color='black'><B>Are you sure you want to delete this Article Layout?</B><BR>Note: Doing so will reset any category using this article layout back to the default article layout.<BR>If this is currently your default article layout it will be changed back to the first article layout.<br><br>"

response.write "<table width='50%' align='center' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_articlelayouts.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><B>" & RS("ALName") & "</B><BR>" & RS("ALDescription") & "</font><br></td>"
response.write "</tr>"
response.write "</table><br>"

response.write "<a href='news.asp?action=deletearticlelayoutprocess&alid=" & request.querystring("alid") & "'>YES</a> | <a href='news.asp?action=managearticlelayouts'>NO</a><br>"
response.write "</p>"

RS.Close
Set RS = Nothing

End Sub

'******* Delete Article Layout Process ********************************************

Sub DeleteArticleLayoutProcess

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

Set RS=Server.CreateObject("ADODB.RecordSet")
RS.Open "SELECT * FROM Categories WHERE CategoryArticleLayout =  " & request.querystring("alid"), dbc, adOpenDynamic, adLockPessimistic, adCMDText

Do While NOT RS.EOF
  SQLc="UPDATE Categories SET CategoryArticleLayout = '1' WHERE [CategoryID] = " & RS("CategoryID")
  dbc.Execute(SQLc)
  RS.MoveNext
  RSc.Close
  Set RSc=Nothing
Loop

RS.Close
Set RS=Nothing

SQL = "DELETE FROM ArticleLayouts WHERE ALID IN("& request.querystring("alid") &")"
dbc.Execute(SQL)

response.redirect "news.asp?action=summary&type=deletearticlelayoutsuccess"

End Sub

'******* Archive Articles Screen **************************************************

Sub ArchiveArticles

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticles'>Manage Articles</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Archive Articles</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Archive Articles</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

response.write "<p align='center'>"
response.write "<font face='Verdana' size='1' color='black'><B>Select a date that should be used to archive the articles... anything older than the date you select will be archived.</B><br><br>"

response.write "<form name='archivearticles' METHOD='post' ACTION='news.asp?action=archivearticlesprocess'>"
response.write "<table width='50%' align='center' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='center'>"
response.write "<input type='text' name='txtArchiveDate' size='15'> "
%>
<img src='news/mini_dateselect.gif' name="ArchiveDate" onClick="calpopup('news.asp?action=minical&form=archivearticles&element=txtArchiveDate', '160', '150')"> 
<%
response.write "<BR><BR><INPUT TYPE='submit' VALUE='Proceed With Archive'>"
response.write "</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "</FORM>"
response.write "<br>"
response.write "</p>"

End Sub

'******* Archive Articles Process *************************************************

Sub ArchiveArticlesProcess

If Session("frUserName") = "" then
  response.redirect "news.asp?action=login&err=notlogged"
End If

If Session("frLevel") <> 1 then
  response.redirect "news.asp?action=mainmenu"
End If

ArchiveDate = CDate(request.form("txtArchiveDate"))

If UseSQLServer <> "YES" then
  SQL = "SELECT * FROM Articles WHERE ArticleDate < #" & ArchiveDate & "#"
Else
  SQL = "SELECT * FROM Articles WHERE ArticleDate < '" & ArchiveDate & "'"
End If
Set RS=Server.CreateObject("adodb.Recordset")
RS.Open SQL, dbc, adopenstatic
NumberArchived = RS.RecordCount
RS.Close
Set RS=Nothing

If UseSQLServer <> "YES" then
  SQL = "UPDATE Articles SET ArticleStatus = 'ARCHIVED' WHERE ArticleDate < #" & ArchiveDate & "#"
Else
  SQL = "UPDATE Articles SET ArticleStatus = 'ARCHIVED' WHERE ArticleDate < '" & ArchiveDate & "'"
End If
Set RS=dbc.execute(SQL)

Call DrawWelcomeBar

response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticles'>Manage Articles</a></font><br></td>"
response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Archive Articles</font><br></td>"
response.write "</tr>"
response.write "</table><br>"
response.write "<br>"

response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Archive Articles</b></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table><br><br>"

response.write "<p align='center'>"
response.write "<font face='Verdana' size='1' color='black'><B>You have successfuly archived <FONT COLOR=blue>" & NumberArchived & "</FONT> articles.</B><br><br>"

response.write "<table width='50%' align='center' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='white' align='center'>"
response.write "</td>"
response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'></font><br></td>"
response.write "</tr>"
response.write "</table><br>"

response.write "<a href='news.asp?action=managearticles'>OK</a><br>"
response.write "</p>"

End Sub

'******* Draw Send Email Screen ***************************************************

Sub EmailToFriend

response.write "<BODY LEFTMARGIN='0' TOPMARGIN='0'>"

response.write "<BODY leftmaring='0' TOPMARGIN='0'>"
response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='silver' align='center' width='100%'><font face='Verdana' size='1' color='black'>Email Article</font></td>"
response.write "</tr>"
response.write "</table><br><br>"

response.write "<p ALIGN='center'>"
response.write "<form METHOD='POST' ACTION='news.asp?action=sendemail&article=" & request.querystring("article") & "'>"
response.write "<FONT FACE='Verdana' SIZE='1' COLOR='black'>"
response.write "Send TO Email Address:<BR>"
response.write "<INPUT TYPE=TEXT NAME='txtSendTo' SIZE='40'><BR>"
response.write "Send FROM Email Address:<BR>"
response.write "<INPUT TYPE=TEXT NAME='txtSendFrom' SIZE='40'><BR>"
response.write "Comments:<BR>"
response.write "<textarea COLS='38' ROWS='5' NAME='txtComments'></TEXTAREA><BR><BR>"
response.write "<INPUT TYPE=SUBMIT VALUE='Send'>"
response.write "</FORM>"
response.write "</P>"

End Sub

'******* Send the Email ***********************************************************

Sub SendEmail

SQL = "SELECT * FROM Articles WHERE ArticleID = " & request.querystring("article")
Set RS=dbc.execute(SQL)

  '------ Fill the Variables --------------------------
  txtSendTo = request.form("txtSendTo")
  txtSendFrom = request.form("txtSendFrom")
  txtComments = request.form("txtComments")
  txtSubject = RS("ArticleTitle")
  txtBody = "<FONT FACE='Verdana' SIZE='1' COLOR='black'>This " & EmailSiteName & "(<A HREF='" & EmailSiteURL & "'>" & EmailSiteURL & "</A>) article has been sent to your from:<BR>"
  txtBody = txtBody & "<B>" & txtSendFrom & "</B><BR><BR>Senders Comments:<BR>" & txtComments & "<BR>"
  txtBody = txtBody & "-------------------------------------------------------------------------<BR>"
  txtBody = txtBody & "</FONT><A HREF='" & EmailSiteURL & "/news.asp?action=detail&article=" & RS("ArticleID") & "'>"
  txtBody = txtBody & "<FONT face='Verdana' size='3'><B>" & RS("ArticleTitle") & "</b></A></FONT><BR><FONT FACE='Verdana' SIZE='1' COLOR='black'>" & RS("ArticleDate") & "</FONT><BR>"
  txtBody = txtBody & RS("ArticleBody")
  '-----------------------------------------------------
  
%>
<SCRIPT LANGUAGE=JAVASCRIPT>
function closewin() { 
  self.close() 
      } 
</SCRIPT>   
<%

  If EmailComponent = "CDONTS" then
    Set sMail = Server.CreateObject("CDONTS.NewMail")
    sMail.BodyFormat = 0
    sMail.MailFormat = 0
    sMail.From = txtSendFrom
    sMail.To = txtSendTo
    sMail.Subject = txtSubject
    sMail.Body = txtBody
    sMail.Send( )  
    response.write "<BODY leftmaring='0' TOPMARGIN='0'>"
    response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
    response.write "<tr>"
    response.write "<td bgcolor='silver' align='center' width='100%'><font face='Verdana' size='1' color='black'>Email Article</font></td>"
    response.write "</tr>"
    response.write "</table><br><br>"
    response.write "<FONT FACE='Verdana' SIZE='2' COLOR='black'><B>The article was successfully sent to:</B> " & txtSendTo
    response.write "<BR><BR><A HREF=''"
    %>
    onclick="closewin(); return false"
    <%
    response.write ">Click HERE to close this window.</A>"
  End If
  
  If EmailComponent = "ASPEmail" then
    Set sMail = Server.CreateObject("Persits.MailSender")
    sMail.Host = EmailHost
    sMail.From = txtSendFrom
    sMail.FromName = txtSendFrom
    sMail.ReplyTo = txtSendFrom
    sMail.AddAddress = txtSendTo     'This needs to be changed to handle multiples!!!
    sMail.Subject = txtSubject
    sMail.Body = txtBody
    sMail.Send
    response.write "<BODY leftmaring='0' TOPMARGIN='0'>"
    response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
    response.write "<tr>"
    response.write "<td bgcolor='silver' align='center' width='100%'><font face='Verdana' size='1' color='black'>Email Article</font></td>"
    response.write "</tr>"
    response.write "</table><br><br>"
    response.write "<FONT FACE='Verdana' SIZE='2' COLOR='black'><B>The article was successfully sent to:</B> " & txtSendTo
    response.write "<BR><BR><A HREF=''"
    %>
    onclick="closewin(); return false"
    <%
    response.write ">Click HERE to close this window.</A>"
  End If
  
  If EmailComponent = "JMail" then
    Set sMail = Server.CreateObject("JMail.Message")
    sMail.Logging = true
    sMail.silent = true
    sMail.From = txtSendFrom
    sMail.FromName = txtSendFrom
    sMail.AddRecipient = txtSendTo     'This needs to be changed to handle multiples!!!
    sMail.Subject = txtSubject
    sMail.Body = txtBody
    sMail.Send(EmailHost)
    response.write "<BODY leftmaring='0' TOPMARGIN='0'>"
    response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
    response.write "<tr>"
    response.write "<td bgcolor='silver' align='center' width='100%'><font face='Verdana' size='1' color='black'>Email Article</font></td>"
    response.write "</tr>"
    response.write "</table><br><br>"
    response.write "<FONT FACE='Verdana' SIZE='2' COLOR='black'><B>The article was successfully sent to:</B> " & txtSendTo
    response.write "<BR><BR><A HREF=''"
    %>
    onclick="closewin(); return false"
    <%
    response.write ">Click HERE to close this window.</A>"
  End If

  If EmailComponent = "ASPMail" then  
    Set sMail = Server.CreateObject("SMTPsvg.Mailer")
    sMail.RemoteHost = EmailHost
    sMail.FromAddress = txtSendFrom
    sMail.FromName = txtSendFrom
    sMail.AddRecipient = txtSendTo     'This needs to be changed to handle multiples!!!
    sMail.Subject = txtSubject
    sMail.BodyText = txtBody
    sMail.SendMail

    response.write "<BODY leftmaring='0' TOPMARGIN='0'>"
    response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
    response.write "<tr>"
    response.write "<td bgcolor='silver' align='center' width='100%'><font face='Verdana' size='1' color='black'>Email Article</font></td>"
    response.write "</tr>"
    response.write "</table><br><br>"
    response.write "<FONT FACE='Verdana' SIZE='2' COLOR='black'><B>The article was successfully sent to:</B> " & txtSendTo
    response.write "<BR><BR><A HREF=''"
    %>
    onclick="closewin(); return false"
    <%
    response.write ">Click HERE to close this window.</A>"
  End If  

End Sub

'******* Draw Button Bar **********************************************************

Sub DrawButtonBar

response.write "<TABLE WIDTH='100%' ALIGN='center' CELLPADDING='0' CELLSPACING='0'><TR>"
response.write "<TD ALIGN='center' WIDTH='100%'><FONT FACE='Verdana' SIZE='1' COLOR='black'>"

If BBShowHome = "YES" then
  response.write "<A HREF='news.asp'>Home</A>"
End If
If BBShowSearch = "YES" then
  response.write "| <A HREF='news.asp?action=searcharticles'>Search</A>"
End If
If BBShowArchives = "YES" then
  response.write "| <A HREF='news.asp?action=archives'>News Archives</A>"
End If
If BBShowSubmit = "YES" then
  response.write "| <A HREF='news.asp?action=submitnews'>Submit News</A>"
End If
If BBShowEmailAdmin = "YES" then
  response.write "| <A HREF='mailto:" & AdminEmail & "'>Email Administrator</A>"
End If
If BBShowLogin = "YES" then
  response.write "| <A HREF='news.asp?action=login'>Login</A>"
End If
If BBShowSyndication = "YES" then
  response.write "| <A HREF='news.asp?action=createsyndicationhtml&type=public'>Get Syndicated Content</A>"
End If
response.write "</TD></TR></TABLE>"

End Sub

'******* Draw Summary Screen ******************************************************

Sub Summary

'If Session("frUserName") = "" then
'  response.redirect "news.asp?action=login&err=notlogged"
'End If

If request.querystring("type") <> "submitarticlesuccess" then
  response.write "<table align='center' width='100%'>"
  response.write "<tr>"
  response.write "<td align='left'>"
  response.write "<img src='news/default_logo.gif' border='0'>"
  response.write "</td>"
  response.write "</tr>"
  response.write "</table>"

  response.write "<table align='center' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Welcome: </b>" & Session("frFirstName") & " " & Session("frLastName") & " | <b>Rights:</b> " & Session("frRights") & " | <a href='news.asp?action=logoff'>Log Off</a></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table>"
End If

If request.querystring("type") = "submitarticlesuccess" then
  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>Thank you for your submission... Your article will be reviewed by our administrators.<br><br>"
  response.write "<a href='news.asp'>Click Here</a><br>"
  response.write "</p>"
End If

If request.querystring("type") = "addauthorsuccess" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_author.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=manageauthors'>Manage Authors</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_author.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Add Author</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Add Author</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>The Author was added successfully.<br><br>"
  response.write "<a href='news.asp?action=addauthor'>Add Another Author</a> | <a href='news.asp?action=manageauthors'>Back To Manage Authors</a> | <a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If 

If request.querystring("type") = "editauthorsuccess" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_author.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=manageauthors'>Manage Authors</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_author.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Edit Author</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Edit Author</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>The Author was edited successfully.<br><br>"
  response.write "<a href='news.asp?action=manageauthors'>Back To Manage Authors</a> | <a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If 

If request.querystring("type") = "deleteauthorsuccess" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_author.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=manageauthors'>Manage Authors</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_author.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Delete Author</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Delete Author</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>The Author was deleted successfully.<br><br>"
  response.write "<a href='news.asp?action=manageauthors'>Back to Manage Authors</a> | <a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If 

If request.querystring("type") = "addcategorysuccess" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_category.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managecategories'>Manage Categories</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_category.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Add Category</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Add Category</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>The Category was added successfully.<br><br>"
  response.write "<a href='news.asp?action=addcategory'>Add Another Category</a> | <a href='news.asp?action=managecategories'>Back To Manage Categories</a> | <a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If

If request.querystring("type") = "editcategorysuccess" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_category.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managecategories'>Manage Categories</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_category.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Edit Categories</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Edit Categories</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>The Category was edited successfully.<br><br>"
  response.write "<a href='news.asp?action=managecategories'>Back To Manage Categories</a> | <a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If

If request.querystring("type") = "deletecategorysuccess" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_category.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managecategories'>Manage Categories</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_category.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Delete Category</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Delete Category</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>The Category was deleted successfully.<br><br>"
  response.write "<a href='news.asp?action=managecategories'>Back to Manage Categories</a> | <a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If 

If request.querystring("type") = "addarticlesuccess" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticles'>Manage Articles</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Add Article</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Add Article</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>The Article was added successfully."
  If Session("frRequireApproval") = "YES" then
    response.write "Your Article will appear on the website after it is approved by an administrator"
  End If
  response.write "<br><br>"
  response.write "<a href='news.asp?action=addarticle'>Add Another Article</a> | <a href='news.asp?action=managearticles'>Back To Manage Articles</a> | <a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If

If request.querystring("type") = "editarticlesuccess" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticles'>Manage Articles</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Edit Article</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Edit Article</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>The Article was modified successfully."
  If Session("frRequireApproval") = "YES" then
    response.write "Your Article will appear on the website after it is approved by an administrator"
  End If  
  response.write "<br><br>"
  response.write "<a href='news.asp?action=managearticles'>Back To Manage Articles</a> | <a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If

If request.querystring("type") = "notallowed" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticles'>Manage Articles</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Edit Article</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Edit Article</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>You don't have access to perform this function.<BR><BR>"
  response.write "<a href='news.asp?action=managearticles'>Back To Manage Articles</a> | <a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If

If request.querystring("type") = "deletearticlesuccess" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticles'>Manage Articles</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_article.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Delete Article</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Delete Article</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>The Article was deleted successfully.<br><br>"
  response.write "<a href='news.asp?action=managearticles'>Back To Manage Articles</a> | <a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If

If request.querystring("type") = "addlayouttypesuccess" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_layouttypes.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managelayouttypes'>Manage Layout Types</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_layouttypes.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Add A New Layout Type</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Add A New Layout Type</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>The Layout Type was added successfully.<br><br>"
  response.write "<a href='news.asp?action=addlayouttype'>Add Another Layout Type</a> | <a href='news.asp?action=managelayouttypes'>Back To Manage Layout Types</a> | <a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If

If request.querystring("type") = "editlayouttypesuccess" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_layouttypes.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managelayouttypes'>Manage Layout Types</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_layouttypes.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Edit Layout Type</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Edit Layout Type</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>The Layout Type was edited successfully.<br><br>"
  response.write "<a href='news.asp?action=managelayouttypes'>Back To Manage Layout Types</a> | <a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If

If request.querystring("type") = "deletelayouttypesuccess" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_layouttypes.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managelayouttypes'>Manage Layout Types</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_layouttypes.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Delete Layout Type</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Delete Layout Type</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>The Layout Type was deleted successfully.<br><br>"
  response.write "<a href='news.asp?action=managelayouttypes'>Back To Manage Layout Types</a> | <a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If

If request.querystring("type") = "editconfigsuccess" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_config.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Edit Configuration</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Edit Configuration</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>The Configuration was edited successfully.<br><br>"
  response.write "<a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If

If request.querystring("type") = "addarticlelayoutsuccess" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_articlelayouts.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticlelayouts'>Manage Article Layouts</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_articlelayouts.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Add A New Article Layout</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Add A New Article Layout</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>The Article Layout was added successfully.<br><br>"
  response.write "<a href='news.asp?action=addarticlelayout'>Add Another Article Layout</a> | <a href='news.asp?action=managearticlelayouts'>Back To Manage Article Layouts</a> | <a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If

If request.querystring("type") = "editarticlelayoutsuccess" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_articlelayouts.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticlelayouts'>Manage Article Layouts</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_articlelayouts.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Edit Article Layout</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Edit Article Layout</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>The Article Layout was updated successfully.<br><br>"
  response.write "<a href='news.asp?action=managearticlelayouts'>Back To Manage Article Layouts</a> | <a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If

If request.querystring("type") = "deletearticlelayoutsuccess" then

  response.write "<table align='left' cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><b>Navigation: </b></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_page.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=mainmenu'>Main Menu</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_articlelayouts.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'><a href='news.asp?action=managearticlelayouts'>Manage Article Layouts</a></font><br></td>"
  response.write "<td bgcolor='white' align='left'><img src='news/icon_articlelayouts.gif' border='0'></td>"
  response.write "<td bgcolor='white' align='left'><font face='Verdana' size='1' color='black'>Delete Article Layout</font><br></td>"
  response.write "</tr>"
  response.write "</table><br>"
  response.write "<br>"

  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Delete Article Layout</b></font></td>"
  response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

  response.write "<p align='center'>"
  response.write "<font face='Verdana' size='1' color='black'>The Article Layout was deleted successfully.<br><br>"
  response.write "<a href='news.asp?action=managearticlelayouts'>Back To Manage Article Layouts</a> | <a href='news.asp?action=mainmenu'>Main Menu</a><br>"
  response.write "</p>"
End If

End Sub

'******* Draw Welcome Bar ********************************************************

Sub DrawWelcomeBar

response.write "<table align='center' width='100%'>"
response.write "<tr>"
response.write "<td align='left'>"
response.write "<img src='news/default_logo.gif' border='0'>"
response.write "</td>"
response.write "</tr>"
response.write "</table>"

response.write "<table align='center' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_left.gif' border='0'></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='left' width='100%'><font face='Verdana' size='1' color='black'><b>Welcome: </b>" & Session("frFirstName") & " " & Session("frLastName") & " | <b>Rights:</b> " & Session("frRights") & " | <a href='news.asp?action=logoff'>Log Off</a></font></td>"
response.write "<td background='" & AdminFolderColor & "header_middle.gif' align='center' width='11'><font face='Verdana' size='1' color='black'><img src='" & AdminFolderColor & "header_right.gif' border='0'></font></td>"
response.write "</tr>"
response.write "</table>"

End Sub

'******* Format Date Function *****************************************************

Function FormatDate(sDate, sFormat)
  Dim NewDate, timeReturnAMPM, timeValue
  timeValue = FormatDateTime(sDate, 3)
  If sFormat = "FULL" then
    NewDate = MonthName(Month(sDate)) & " " & Day(sDate) & ", " & Year(sDate)
    timeReturnAMPM = right(timeValue, 2)
    If Len(timeValue) = 10 then
      timeValue = left(timeValue,4)
      timeValue = timeValue + timeReturnAMPM
    Else
      timeValue = left(timeValue,5)
      timeValue = timeValue + timeReturnAMPM
    End If
    NewDate = NewDate & " " & timeValue
    FormatDate = NewDate & " " & TimeZone
  End If
End Function

'****** Upload A File ******************************************************************

Sub UploadFile

formname = request.querystring("form")
elementname = request.querystring("element")

%>
<SCRIPT LANGUAGE="javascript"> 
function calpopulate(dte) { 
window.opener.<%=formname & "." & elementname%>.value = dte; 
  self.close() 
      } 
</SCRIPT> 

<BODY LEFTMARGIN='0' TOPMARGIN='0'>
<%

response.write "<BODY leftmaring='0' TOPMARGIN='0'>"
response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
response.write "<tr>"
response.write "<td bgcolor='silver' align='center' width='100%'><font face='Verdana' size='1' color='black'>Upload A File</font></td>"
response.write "</tr>"
response.write "</table><br><br>"

response.write "<P ALIGN='center'>"
response.write "<form ENCTYPE='multipart/form-data'  METHOD='post' ACTION='news.asp?action=uploadfileprocess&form=" & formname & "&element=" & elementname & "'>"
response.write "<FONT FACE='verdana' SIZE='1' COLOR='black'><B>Select a file to upload:</b><BR>"
response.write "NOTE: This uploaded will place your files in the following directory:<BR>"
response.write "<FONT COLOR='red' >" & FileDirectory & "</FONT></FONT><BR>"
response.write "<INPUT TYPE=FILE SIZE=22 NAME='FILE1'><BR><BR>"
response.write "<INPUT TYPE='submit' VALUE='Upload File'>"
response.write "</FORM>"
response.write "</P>"

End Sub

'****** Upload File Process ************************************************************

Sub UploadFileProcess

Dim Uploader, File
Set Uploader = New FileUploader

formname = request.querystring("form")
elementname = request.querystring("element")

%>
<SCRIPT LANGUAGE="javascript"> 
function calpopulate(dte) { 
window.opener.<%=formname & "." & elementname%>.value = dte; 
  self.close() 
      } 
</SCRIPT> 

<BODY LEFTMARGIN='0' TOPMARGIN='0'>
<%

  response.write "<BODY leftmaring='0' TOPMARGIN='0'>"
  response.write "<table align='left' width='100%' cellpadding='0' cellspacing='0' border='0' style='border-collapse: collapse' bordercolor='#DDDDDD'>"
  response.write "<tr>"
  response.write "<td bgcolor='silver' align='center' width='100%'><font face='Verdana' size='1' color='black'>Upload A File</font></td>"
  response.write "</tr>"
  response.write "</table><br><br>"

Uploader.Upload()

If Uploader.Files.Count = 0 Then
  Response.Write "No File(s) were uploaded."
Else
  For Each File In Uploader.Files.Items
    File.SaveToDisk FileDirectory
  Next
  response.write "<FONT FACE='Verdana' SIZE='1' COLOR='black'>Your image was uploaded successfully!</FONT><BR>"
  response.write "<A href='' "
  %>
   onClick="calpopulate('<% response.write Session("frFileName") %>')" return false;
  <%
  response.write ">CLICK HERE</A>"
End If

End Sub

'****** Draw A Mini Calendar Selector **************************************************

Sub DrawMiniCalendar(theDate) '---------------------------------- Draw a month calendar

  Dim ThisMonthsFirstDay
  Dim NextMonthsFirstDay
  Dim ThisMonthsLastDay
  Dim LastMonthsLastDay
  Dim StartDate
  Dim Counter
  
  formname = request.querystring("form")
  elementname = request.querystring("element")

  '------- Setup some information about the month -----------------
  ThisMonthsFirstDay = cDate(Month(theDate) & "/1/" & Year(theDate))
  NextMonthsFirstDay = dateAdd("m",1,ThisMonthsFirstDay)
  ThisMonthsLastDay = dateadd("d",-1,NextMonthsFirstDay)
  LastMonthsLastDay = dateadd("d",-1,ThisMonthsFirstDay)
  StartDate = dateadd("d",1-weekday(ThisMonthsFirstDay),ThisMonthsFirstDay)

  '------- Draw the beginning of the calendar ----------------------

%>
<SCRIPT LANGUAGE="javascript"> 
function calpopulate(dte) { 
window.opener.<%=formname & "." & elementname%>.value = dte; 
  self.close() 
      } 
</SCRIPT> 

<BODY LEFTMARGIN='0' TOPMARGIN='0'>
<%

  If Month(theDate) > 1 then
    PrevMonthLink = Month(theDate) - 1
    PrevYearLink = Year(theDate)
    PreviousLink = PrevMonthLink & "/1/" & PrevYearLink
  End If

  If Month(theDate) < 12 then
    NextMonthLink = Month(theDate) + 1
    NextYearLink = Year(theDate)
    NextLink = NextMonthLink & "/1/" & NextYearLink
  End If

  If Month(theDate) = 1 then
    PrevMonthLink = 12
    PrevYearLink = Year(theDate) - 1
    PreviousLink = PrevMonthLink & "/1/" & PrevYearLink
  End If

  If Month(theDate) = 12 then
    NextMonthLink = 1
    NextYearLink = Year(theDate) + 1
    NextLink = NextMonthLink & "/1/" & NextYearLink
  End If

  response.write "<table width='100%' border='0' height='100%' cellpadding='1' cellspacing='1' bgcolor='silver'>" & chr(13)
  response.write "<tr height='1'>" & chr(13)
  response.write "<td valign='top' colspan='7' align='center' bgcolor='black'>" & chr(13)
  response.write "<font face='Verdana' size='1' color='white'><b>" & chr(13)

  response.write "<table cellpadding='0' cellspacing='0' border='0' width='100%'>"
  response.write "<tr>"
  response.write "<td width='20'>"
  response.write "<a href='news.asp?action=minical&form=" & formname & "&element=" & elementname & "&caltype=mini&date=" & PreviousLink & "'>"
  response.write "<img border='0' src='news/mini_leftarrow.gif'></a>"
  response.write "</td>"
  response.write "<td align='center' width='100%' background='news/mini_back.gif'>"
'  response.write "<a href='calendar.asp?caltype=month&month=" & Month(theDate) & "&year=" & Year(theDate) & "'>"
  response.write "<font face='Verdana' size='1' color='black'><b>" & chr(13)
  response.write MonthName(Month(theDate)) & " " & Year(theDate)
'  response.write "</a>"
  response.write "</font>"
  response.write "</td>"
  response.write "<td width='20'>"
  If CalendarType <> "day" AND CalendarType <> "week" AND CalendarType <> "year" then
    response.write "<a href='news.asp?action=minical&form=" & formname & "&element=" & elementname & "&caltype=mini&date=" & NextLink & "'>"
    response.write "<img border='0' src='news/mini_rightarrow.gif'></a>"
  Else
    response.write "<img border='0' src='news/mini_back.gif'></a>"
  End If
  response.write "</td>"
  response.write "</tr>"
  response.write "</table>"

  response.write "</b></font></td>"
  response.write "<tr height='1'>" & chr(13)
  response.write "<td align='center' width='14%'><font face='Verdana' size='1' color='black'><b>S</b></font></td>" & chr(13)
  response.write "<td align='center' width='14%'><font face='Verdana' size='1' color='black'><b>M</b></font></td>" & chr(13)
  response.write "<td align='center' width='14%'><font face='Verdana' size='1' color='black'><b>T</b></font></td>" & chr(13)
  response.write "<td align='center' width='14%'><font face='Verdana' size='1' color='black'><b>W</b></font></td>" & chr(13)
  response.write "<td align='center' width='14%'><font face='Verdana' size='1' color='black'><b>T</b></font></td>" & chr(13)
  response.write "<td align='center' width='14%'><font face='Verdana' size='1' color='black'><b>F</b></font></td>" & chr(13)
  response.write "<td align='center' width='14%'><font face='Verdana' size='1' color='black'><b>S</b></font></td>" & chr(13)
  response.write "</tr>" & chr(13)
  response.write "<tr>" & chr(13)



  '-------- If the first day is not sunday --------------------------
  If weekday(ThisMonthsFirstDay) > 1 then
    For Counter = day(StartDate) to day(LastMonthsLastDay)
      Call DrawOtherMiniDay (Counter, theDate)
    Next
  End if
  
  '-------- Draw normal days after Saturday start a new row ---------
  For Counter = 1 to day(ThisMonthsLastDay)
    Call DrawMiniNormalDay (Counter, theDate)
    If weekday(cDate(Month(theDate) & "/" & Counter & "/" & Year(theDate))) = 7 then
      response.write "</tr>" & chr(13)
      If Counter <> day(ThisMonthsLastDay) then
        response.write "<tr>" & chr(13)
      End If
    End if
  Next
  
  '-------- If last day is not saturday -----------------------------
  If weekday(ThisMonthsLastDay) < 7 then
     For Counter = 1 to 7 - weekday(ThisMonthsLastDay)
       Call DrawOtherMiniDay (Counter, theDate)
     Next
  End if

  '-------- Draw the last row of the calendar -----------------------
  response.write "</tr>" & chr(13)
  response.write "</table>" & chr(13)

End Sub 

Sub DrawMiniNormalDay(DayNumber, theDate) '----------------------------------- Draw a Normal Day

  If Day(Now) = DayNumber and Month(Now) = Month(theDate) and Year(Now) = Year(theDate) then
    MiniCalDayBGColor = "#DDDDDD"
  Else
    MiniCalDayBGColor = "#EEEEEE"
  End If
  
  If weekday(cDate(Month(theDate) & "/" & DayNumber & "/" & Year(theDate))) = 7 or weekday(cDate(Month(theDate) & "/" & DayNumber & "/" & Year(theDate))) = 1 then
    MiniCalDayBGColor = "#DEDEEF"
  End If

  DateToSend = Month(theDate) & "/" & DayNumber & "/" & Year(theDate)
  response.write "<td valign='center' "

  %>
  onMouseover="this.bgColor='#DDDDFF'"
  onMouseout="this.bgColor='#EEEEEE'"
  onClick="calpopulate('<% response.write DateToSend %>')"
  <%

  response.write " width='14%' valign='top' bgcolor='" & MiniCalDayBGColor & "' align='center'>" & chr(13)
  response.write "<font face='Verdana' size='1' color='" & DayFontColor & "'>" & chr(13)
  If CalendarType = "day" then
    response.write "<a href='calendar.asp?caltype=day&date=" & Month(theDate) & "/" & DayNumber & "/" & Year(theDate) & "'>"
    response.write DayNumber
  End If
  If CalendarType = "week" then
    response.write "<a href='calendar.asp?caltype=week&date=" & Month(theDate) & "/" & DayNumber & "/" & Year(theDate) & "'>"
    response.write DayNumber
  End If
  If CalendarType = "year" then
    response.write "<a href='calendar.asp?caltype=day&date=" & Month(theDate) & "/" & DayNumber & "/" & Year(theDate) & "'>"
    response.write DayNumber
  End If
  If CalendarType <> "year" and CalendarType <> "week" and CalendarType <> "day" then
    response.write DayNumber
  End If
  response.write "</a>"
  response.write "</font></td>" & chr(13)

End Sub

Sub DrawOtherMiniDay(DayNumber, theDate) '--------------------------------------- Draw Other Day

  response.write "<td width='14%' valign='top' bgcolor='" & MiniOtherDayBackColor & "' align='center'>" & chr(13)
  response.write "<font face='" & CalendarFontFace & "' size='2' color='white'>" & chr(13)
  response.write "</font></td>" & chr(13)

End Sub

'******* SQL Search Query Builder ************************************************

Function GenerateSQLSearch(strText, strTable, strField )
  Dim selectClause
  Dim fromClause
  Dim whereClause

  selectClause = "SELECT  * "
  fromClause = "FROM " & strTable & " " 
  whereClause = "WHERE "
  
  '-------- Remove Any Words that are 3 letters or less --------------------------
  strTextTEMP = split(strText, " ")
  CountMax = ubound(strTextTEMP)
  For I = 0 to CountMax
    If len(strTextTEMP(I)) > 3 then
      strTextFIXED = strTextFIXED & " " & strTextTEMP(I)
    End If
  Next
  strText = strTextFIXED
  '-------------------------------------------------------------------------------

  whereClause = whereClause & " (" & strField & " LIKE '%" & _ 
  Replace( Trim( strText ), " ", "%' OR " & strField & " LIKE '%") & "%')"
  
  GenerateSQLSearch = selectClause & fromClause & whereClause

End Function

'******* Fix String Function *****************************************************

Function FixString(strSource)
	FixString = Replace(strSource, "'", "''")
End Function

'******* Write out the page footer ***********************************************

Sub DrawFooter

response.write Session("DefaultFooter")

End Sub

%>