Link to home
Start Free TrialLog in
Avatar of erikTsomik
erikTsomikFlag for United States of America

asked on

Database execution error in coldfusion components

I am trying to extends the CF components internal.ulisting that provides with the list of item and also invold worrkflow processing. My extending madule looks exactly the same as the original module , the only different is I added a few stored procedure. Andwhen I ran the components I am getting the error: Database Exception - in C:\Hotbanana\hb50\display.cfc : line 2795
          Error Executing Database Query.

The extended component:
<cfcomponent displayname="courseschedule2" extends="hb50.internal.ulisting">
      <cfset this.DATATYPES = enum("item,category,config")>
      <cfset this.ALIGN = enum("left,right")>
      <cfset this.IMAGE_ALIGN = enum("left,right,inline")>
      <cfset this.COLUMN_LAYOUT = enum("single,double")>
      <cfset this.DISPLAY_TYPES = enum("full,memo,trimmed")>
      <cfset this.DATE_LAYOUT_TYPES = enum("oneline,twolines")>
      <cfset this.MAX_ITEMS = 5>
      <cfset this.PRIVATE_IMAGE = '<img src="images/lock.gif" width="9" height="10" border="0" align="absmiddle">'>
      
      <cffunction name="init" access="public" returntype="any" output="false">
            <cfargument name="companyID" required="true" type="numeric">            
            <cfargument name="webid" required="false" default="0">
            <cfargument name="datatype" required="false" default="0">

            <cfset super.init(companyID, arguments.webID, arguments.datatype)>            
            
            <cfset this.slash = getFileSeparator()>
            
            <!--- create objects --->
            <cfset this.category = createObject("component", "hb50.category").init(companyID)>
            <cfset this.workflow = getObject("hb50.workflow",companyID,true)>
            <cfset this.display = getObject("hb50.display",companyID,true)>
            <cfset this.media = getObject("hb50.media",companyID,true)>
            <cfset this.navigation = getObject("hb50.navigation",companyID,true)>
            
            <!--- configuration data --->
            <cfxml casesensitive="no" variable="this.xmlConfigData">
                  <cfoutput>
                        <data>
                              <!--- <item varname="blnDescription" title="Description" type="#this.TYPES.BOOLEAN#" default="1" required="false"/> --->
                              <item varname="blnAbstract" title="Abstract" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnDate" title="Date" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnImage" title="Image" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnLink" title="Link" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnResource" title="Related Information" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnAddress" title="Address" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnPhone" title="Phone" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnFax" title="Fax" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnEmail" title="Email" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnCategoryListing" title="Category Listing" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnCategoryPageContent" title="Show Page Content" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnCategoryDescription" title="Show Category Description" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnCategorySearch" title="Show Category Search Form" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnCategoryImage" title="Show Category Image" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnCategoryImageWrap" title="Wrap Text" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="intCategoryImageAlign" title="Category Image Alignment" type="#this.TYPES.SELECT#" required="false"/>
                              <item varname="intCategoryImageWidth" title="Category Image width" type="#this.TYPES.NUMBER#" required="false"/>                              
                              <item varname="intCategoryImageHeight" title="Category Image Height" type="#this.TYPES.NUMBER#" required="false"/>
                              <item varname="intCategoryLayoutType" title="Category Layout" type="#this.TYPES.SELECT#" required="false"/>
                              <item varname="blnCategoryPagination" title="Show Pagination" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="intCategoryDisplayItems" title="Items to Display" type="#this.TYPES.NUMBER#" required="false"/>
                              <item varname="blnItemListingPageContent" title="Show Page Content" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnItemListingDescription" title="Show Item Description" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="intItemListingDescriptionType" title="Item Description Type" type="#this.TYPES.SELECT#" required="false"/>
                              <item varname="intItemListingDescriptionLength" title="Item Description Length" type="#this.TYPES.SELECT#" default="300" required="false"/>
                              <item varname="txtItemListingDescriptionAction" title="Call To Action" type="#this.TYPES.TEXT#" default="more..." required="false"/>
                              <item varname="blnItemListingSearch" title="Show Item Search Form" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnItemListingAnchor" title="Show Item Anchor" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnItemListingTitle" title="Show Item Title" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="intItemListingDateLayoutType" title="Date Layout Type" type="#this.TYPES.SELECT#" required="false"/>
                              <item varname="intItemListingLayoutType" title="Item Listing Layout" type="#this.TYPES.SELECT#" required="false"/>
                              <item varname="blnItemListingImage" title="Show Item Image" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnItemListingImageWrap" title="Wrap Text" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="intItemListingImageWidth" title="Image Width" type="#this.TYPES.NUMBER#" required="false"/>
                              <item varname="intItemListingImageHeight" title="Image Height" type="#this.TYPES.NUMBER#" required="false"/>
                              <item varname="intItemListingImageAlign" title="Item Image Alignment" type="#this.TYPES.SELECT#" required="false"/>
                              <item varname="blnItemListingPagination" title="Show Pagination" type="#this.TYPES.BOOLEAN#" required="false"/>                              
                              <item varname="intItemListingDisplayItems" title="Items to Display" type="#this.TYPES.NUMBER#" required="false"/>
                              <item varname="blnItemDetail" title="Item Detail Page" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnItemDetailPageContent" title="Show Page Content" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnItemDetailResource" title="Show Ralated Resources" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="txtItemDetailResourceCaption" title="Related Resource Caption" type="#this.TYPES.TEXT#" required="false"/>
                              <item varname="blnItemDetailImage" title="Show Image" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="intItemDetailImageAlign" title="Item Image Alignment" type="#this.TYPES.SELECT#" required="false"/>
                              <item varname="intItemDetailImageWidth" title="Item Image width" type="#this.TYPES.NUMBER#" required="false"/>
                              <item varname="intItemDetailImageHeight" title="Item Image Height" type="#this.TYPES.NUMBER#" required="false"/>
                              <item varname="blnNotification" title="Send Notification" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="txtNotificationFromEmail" title="From Email" type="#this.TYPES.TEXT#" default="#this.qryCompany.txtEmail#" required="false"/>
                              <item varname="txtNotificationFromName" title="From Name" type="#this.TYPES.TEXT#" required="false"/>
                              <item varname="txtNotificationSubject" title="Notification Subject" type="#this.TYPES.TEXT#" required="false"/>
                              <item varname="txtNotificationMessage" title="Notification Message" type="#this.TYPES.HTML#" required="false"/>
                              <item varname="blnSecurityEnabled" title="Enable" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="intRoleIDs" title="Access Role(s)" type="#this.TYPES.SELECT#" required="false" insert="false" multiple="true"/>
                              <item varname="intWebID" title="Web ID" type="#this.TYPES.SELECT#" required="false"/>
                              <item varname="intCompanyID" title="Company ID" type="#this.TYPES.SELECT#" required="false"/>
                              <item varname="blnDeleted" title="Deleted" type="#this.TYPES.BOOLEAN#" required="false"/>
                        </data>
                  </cfoutput>
            </cfxml>
            
            <cfscript>
                  this.configData = newFormData();
                  this.configData.itemname = "Config";
                  this.configData.itemsname = "Configs";
                  this.configData.tablename = "tblCourseListingSettings";

                  this.configData.datatype = this.DATATYPES.CONFIG;
                              
                  this.configData.navid = this.navid;
                  this.configData.subid = this.subid;
                  this.configData.tabid = this.tabid;
                  
                  this.configData.webid = this.webid;
                  this.configData.link = this.link;
                  this.configData.varID = "intID";

                  this.configData.columns = xmlDataToArray(this.xmlConfigData);
                                    
                  this.configData.tabs[1] = StructNew();
                  this.configData.tabs[1].caption = "Fields";
                  this.configData.tabs[1].columnlist = "blnAbstract,blnDate,blnImage,blnLink,blnResource,blnAddress,blnPhone,blnFax,blnEmail";

                  this.configData.tabs[2] = StructNew();
                  this.configData.tabs[2].caption ="Category Listing";
                  this.configData.tabs[2].columnlist = "blnCategoryListing,blnCategoryPageContent,blnCategoryDescription,blnCategorySearch,blnCategoryImage,blnCategoryImageWrap,blnCategoryImageAlign,intCategoryImageWidth,intCategoryImageHeight,blnCategoryPagination,intCategoryDisplayItems,intCategoryLayoutType";
                                                
                  this.configData.tabs[3] = StructNew();
                  this.configData.tabs[3].caption ="Item Listing";
                  this.configData.tabs[3].columnlist = "blnItemListingPageContent,blnItemListingTitle,intItemListingDateLayoutType,blnItemListingDescription,intItemListingDescriptionType,intItemListingDescriptionLength,txtItemListingDescriptionAction,blnItemListingSearch,blnItemListingAnchor,intItemListingLayoutType,blnItemListingImage,blnItemListingImageWrap,intItemListingImageWidth,intItemListingImageHeight,intItemListingImageAlign,blnItemListingPagination,intItemListingDisplayItems";
                  
                  this.configData.tabs[4] = StructNew();
                  this.configData.tabs[4].caption ="Item Detail";
                  this.configData.tabs[4].columnlist = "blnItemDetail,blnItemDetailPageContent,blnItemDetailResource,txtItemDetailResourceCaption,blnItemDetailImage,intItemDetailImageAlign,intItemDetailImageWidth,intItemDetailImageHeight";
                  
                  this.configData.tabs[5] = StructNew();
                  this.configData.tabs[5].caption ="Notification";
                  this.configData.tabs[5].columnlist = "blnNotification,txtNotificationFromEmail,txtNotificationFromName,txtNotificationSubject";
                  
                  this.configData.tabs[6] = StructNew();
                  this.configData.tabs[6].caption = "Notification Message";
                  this.configData.tabs[6].columnList = "txtNotificationMessage";
                  
                  this.configData.tabs[7] = StructNew();
                  this.configData.tabs[7].caption = "Security";
                  this.configData.tabs[7].columnList = "blnSecurityEnabled,intRoleIDs";
                  
                  this.configData.blnWorkflow = false;
                  this.configData.blnApproval = false;
                  this.configData.blnLock = false;
                  this.configData.blnVersion = false;
                  this.configData.blnDelete = false;
                  this.configData.blnPreview = false;
                  this.configData.blnCategory = false;
                  this.configData.blnScheduling = false;
                  this.configData.blnMeta = false;
                  this.configData.blnResources = false;
                  this.configData.blnOrder = false;
                  this.configData.blnExtraColumns = false;
            </cfscript>            

            <cfset this.workflow.verifyColumns(this.configData)>
            <cfset qryConfig = getConfigQuery()>
            
            <!--- form data --->
            <cfxml casesensitive="no" variable="this.xmlData">
                  <cfoutput>
                        <data>
                              <!--- set required to false and changed type to hidden--->
                              <item varname="txtTitle" title="Title" type="#this.TYPES.HIDDEN#" required="false"/>
                              <item varname="intCategoryID" title="Category" type="#this.TYPES.CATEGORY#" required="true"/>
                              <!--- added field--->
                              <item varname="blnCCSSLink" title="Link to Course Schedule?" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="txtAbstract" title="Abstract" type="#this.TYPES.MEMO#" required="false"/>
                              <cfif qryConfig.blnDate is 1>
                                    <item varname="dtDate" title="Date" type="#this.TYPES.DATE#" required="false"/>
                              </cfif>
                              <cfif qryConfig.blnImage is 1>
                                    <item varname="intImageID" title="Image" type="#this.TYPES.MEDIA#" ext="jpeg,jpg,jpe,gif,png" required="true"/>
                              </cfif>
                              <cfif qryConfig.blnLink is 1>
                                    <item varname="txtLink" title="Link" type="#this.TYPES.TEXT#" required="false"/>
                              </cfif>
                              <cfif qryConfig.blnAddress is 1>
                                    <item varname="txtAddress" title="Address" type="#this.TYPES.TEXT#" required="false"/>
                                    <item varname="txtCity" title="City" type="#this.TYPES.TEXT#" required="false"/>
                                    <item varname="txtProvince" title="Province" type="#this.TYPES.TEXT#" required="false"/>
                                    <item varname="txtCountry" title="Country" type="#this.TYPES.TEXT#" required="false"/>
                                    <item varname="txtPostalCode" title="Postal Code" type="#this.TYPES.TEXT#" required="false"/>
                              </cfif>
                              <cfif qryConfig.blnPhone is 1>
                                    <item varname="txtPhone" title="Phone" type="#this.TYPES.TEXT#" required="false"/>
                                    <item varname="txtTollFree" title="Toll Free" type="#this.TYPES.TEXT#" required="false"/>
                              </cfif>
                              <cfif qryConfig.blnFax is 1>
                                    <item varname="txtFax" title="Fax" type="#this.TYPES.TEXT#" required="false"/>
                              </cfif>
                              <cfif qryConfig.blnEmail is 1>
                                    <item varname="txtEmail" title="Email" type="#this.TYPES.TEXT#" required="false"/>
                              </cfif>
                              <item varname="blnNotification" title="Send Notification" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="blnPrivate" title="Private" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <!--- changed txtdescription required to false--->      
                              <item varname="txtDescription" title="Description" type="#this.TYPES.HTML#" required="false"/>
                        </data>
                  </cfoutput>
            </cfxml>
            
            <cfif isDefined("this.xmlData.data.frontend.xmltext")>
                  <cfset this.frontendDisplay = this.xmlData.data.frontend.xmltext>
            </cfif>
            
            <!--- added stored procedure to pull course numbers, titles for drop-down--->      
            <cfstoredproc datasource='#this.datasource#' procedure='qryCourseNumbers'>
                  <cfprocresult name='qryCourseNumbers'>                  
                  <cfprocparam type='In' cfsqltype='CF_SQL_varCHAR' variable='@AY' value='07-08' null='no'></cfprocparam>
                  <cfswitch expression="#this.companyid#">
                  <cfcase value="2">
                  <cfprocparam type='in' cfsqltype='cf_sql_varchar' variable='@dept' value='PSL' null='no'></cfprocparam>
                  <cfprocparam type='in' cfsqltype='cf_sql_varchar' variable='@dept2' value='PSL' null='no'></cfprocparam>
                  </cfcase>
                  <cfcase value="9">
                  <cfprocparam type='in' cfsqltype='cf_sql_varchar' variable='@dept' value='business' null='no'></cfprocparam>
                  <cfprocparam type='in' cfsqltype='cf_sql_varchar' variable='@dept2' value='undergraduate' null='no'></cfprocparam>
                  </cfcase>
                  <cfcase value="10">
                  <cfprocparam type='in' cfsqltype='cf_sql_varchar' variable='@dept' value='education' null='no'></cfprocparam>
                  <cfprocparam type='in' cfsqltype='cf_sql_varchar' variable='@dept2' value='education' null='no'></cfprocparam>
                  </cfcase>
      
    </cfswitch>
                  </cfstoredproc>      
            
                  
            <cfscript>
                  this.formData = newFormData();
                  this.formData.columns = xmlDataToArray(this.xmlData);
                  this.formData.tablename = "tblCourseListing";
                  this.formData.title = "Course Details";
                  tabCount = 1;
                  
                  x = StructNew();
                  x.title = 'Course Number/Title';
                  x.varname = 'intCourseID';
                  x.required = true;
                  x.type = TYPES.SELECT;
                  x.query = qryCourseNumbers;
                  x.displayVar = "CourseName";
                  x.valueVar = "CourseID";                  
                  x.onChange = "txtTitle.value=intCourseID.options[intCourseID.selectedIndex].text;";
                  ArrayPrepend(this.formData.columns, x);      
                  
                  this.formData.tabs[tabCount] = StructNew();
                  this.formData.tabs[tabCount].caption = "Details";
                  this.formData.tabs[tabCount].columnlist = "txtTitle,intCategoryID,intCourseID,blnCCSSLink";
                  if (qryConfig.blnImage is 1) {
                        this.formData.tabs[tabCount].columnlist = this.formData.tabs[tabCount].columnlist & ',intImageID';
                  }
                  
                  if (qryConfig.blnLink is 1) {
                        this.formData.tabs[tabCount].columnlist = this.formData.tabs[tabCount].columnlist & ',txtLink';
                  }
                  if (qryConfig.blnSecurityEnabled is 1) {
                        this.formData.tabs[tabCount].columnlist = this.formData.tabs[tabCount].columnlist & ',blnPrivate';
                  }
                  
                  
                  
                  
                  
                  
                  if (qryConfig.blnDate is 1) {
                        tabCount = tabcount + 1;
                        this.formData.tabs[tabCount] = StructNew();
                        this.formData.tabs[tabCount].caption = "Date";
                        this.formData.tabs[tabCount].columnlist = 'dtDate';
                  }
                  
                  if (qryConfig.blnAddress is 1 OR qryConfig.blnPhone is 1 OR qryConfig.blnFax is 1 OR qryConfig.blnEmail is 1) {
                        tabCount = tabCount + 1;
                        this.formData.tabs[tabCount] = StructNew();
                        this.formData.tabs[tabCount].caption = "Address";
                        this.formData.tabs[tabCount].columnlist = '';
                  }
                  
                  if (qryConfig.blnAddress is 1) {
                        this.formData.tabs[tabCount].columnlist = ListAppend(this.formData.tabs[tabCount].columnlist,'txtAddress,txtCity,txtProvince,txtCountry,txtPostalCode');
                  }
                  if (qryConfig.blnPhone is 1) {
                        this.formData.tabs[tabCount].columnlist = ListAppend(this.formData.tabs[tabCount].columnlist,'txtPhone,txtTollFree');
                  }
                  if (qryConfig.blnFax is 1) {                        
                        this.formData.tabs[tabCount].columnlist = ListAppend(this.formData.tabs[tabCount].columnlist,'txtFax');
                  }
                  if (qryConfig.blnEmail is 1) {
                        this.formData.tabs[tabCount].columnlist = ListAppend(this.formData.tabs[tabCount].columnlist,'txtEmail');
                  }
                  if (qryConfig.blnAbstract is 1) {
                        tabCount = tabCount + 1;
                        this.formData.tabs[tabCount] = StructNew();
                        this.formData.tabs[tabCount].caption = "Abstract";
                        this.formData.tabs[tabCount].columnlist = "txtAbstract";
                  }
                  
                  tabCount = tabCount + 1;
                  this.formData.tabs[tabCount] = StructNew();
                  this.formData.tabs[tabCount].caption = "Body";
                  this.formData.tabs[tabCount].columnlist = "txtDescription";
                  
                  this.formData.notificationTabIndex = 0;
                  if (qryConfig.blnNotification is 1) {
                        tabCount = tabCount + 1;
                        this.formData.tabs[tabCount] = StructNew();
                        this.formData.tabs[tabCount].caption = "Notification";
                        this.formData.tabs[tabCount].columnlist = "blnNotification";
                        this.formData.notificationTabIndex = tabCount;
                  }

                  this.formData.webid = this.webid;
                  this.formData.datatype = this.DATATYPES.ITEM;
                  this.formData.navid = this.navid;
                  this.formData.subid = this.subid;
                  this.formData.tabid = this.tabid;
                  this.formData.link = this.link;                  
                  this.formData.varID = "intID";

                  this.formData.blnWorkflow = true;
                  this.formData.blnApproval = true;
                  this.formData.blnLock = true;
                  this.formData.blnVersion = true;
                  this.formData.blnDelete = true;
                  this.formData.blnPreview = true;
                  this.formData.blnCategory = true;
                  this.formData.blnScheduling = true;
                  this.formData.blnMeta = true;                  
                  this.formData.blnResources = true;
                  this.formData.blnTranslate = true;
                  this.formData.blnOrder = true;
            </cfscript>

            <!--- category data --->
            <cfxml casesensitive="no" variable="this.xmlCatData">
                  <cfoutput>
                        <data>
                              <item varname="txtTitle" title="Title" type="#this.TYPES.TEXT#" required="true"/>
                              <item varname="intImageID" title="Image" type="#this.TYPES.MEDIA#" required="true" ext="jpeg,jpg,jpe,gif,png"/>
                              <item varname="blnShowCategoryTitle" title="Show Category Title?" type="#this.TYPES.BOOLEAN#" required="false"/>
                              <item varname="txtDescription" title="Description" type="#this.TYPES.HTML#" required="false"/>
                              <item varname="intCategoryID" title="Category" type="#this.TYPES.HIDDEN#" required="false" vartype="int"/>                              
                        </data>
                  </cfoutput>
            </cfxml>
            
            <cfscript>
                  this.catData = newFormData();
                  this.catData.itemname = "Category";
                  this.catData.itemsname = "Categories";
                  this.catData.tablename = "tblCourseListingCategory";

                  this.catData.datatype = this.DATATYPES.CATEGORY;
                              
                  this.catData.navid = this.navid;
                  this.catData.subid = this.subid;
                  this.catData.tabid = this.tabid;
                  
                  this.catData.webid = this.webid;                  
                  this.catData.link = this.link;                  
                  this.catData.varID = "intID";                  

                  this.catData.columns = xmlDataToArray(this.xmlCatData);
                                    
                  this.catData.tabs[1] = StructNew();
                  this.catData.tabs[1].caption = "Title";
                  this.catData.tabs[1].columnlist = "txtTitle,blnShowCategoryTitle,intCategoryID";
                  if (qryConfig.blnCategoryImage is 1) {
                        this.catData.tabs[1].columnlist = this.catData.tabs[1].columnlist & ",intImageID";
                  }
                                    
                  this.catData.tabs[2] = StructNew();
                  this.catData.tabs[2].caption = "Description";
                  this.catData.tabs[2].columnlist = "txtDescription";

                  this.catData.blnWorkflow = true;
                  this.catData.blnApproval = true;
                  this.catData.blnLock = true;
                  this.catData.blnVersion = true;
                  this.catData.blnDelete = true;
                  this.catData.blnPreview = false;
                  this.catData.blnCategory = false;
                  this.catData.blnScheduling = false;                  
                  this.catData.blnMeta = true;                  
                  this.catData.blnResources = false;
                  this.catData.blnOrder = true;                  
            </cfscript>
            
            <!--- notification list data --->
            <cfxml casesensitive="no" variable="this.xmlListData">
                  <cfoutput>
                        <data>
                              <item varname="intItemID" title="" type="#this.TYPES.SELECT#" required="false"/>
                              <item varname="intListID" title="" type="#this.TYPES.SELECT#" required="false"/>
                              <item varname="intCompanyID" title="" type="#this.TYPES.SELECT#" required="false"/>
                        </data>
                  </cfoutput>
            </cfxml>
            
            <cfscript>
                  this.listData = newFormData();
                  this.listData.tablename = "tblCourseListingLists";
                  this.listData.blnExtraColumns = false;

                  this.listData.columns = xmlDataToArray(this.xmlListData);
            </cfscript>
            
            <!--- role data --->
            <cfxml casesensitive="no" variable="this.xmlRoleData">
                  <cfoutput>
                        <data>
                              <item varname="intWebID" title="" type="#this.TYPES.SELECT#" required="false"/>
                              <item varname="intCompanyID" title="" type="#this.TYPES.SELECT#" required="false"/>
                              <item varname="intRoleID" title="" type="#this.TYPES.SELECT#" required="false"/>
                        </data>
                  </cfoutput>
            </cfxml>
            
            <cfscript>
                  this.roleData = newFormData();                  
                  this.roleData.tablename = "tblCourseListingRole";
                  this.roleData.blnExtraColumns = false;
                  this.roleData.columns = xmlDataToArray(this.xmlRoleData);
            </cfscript>
            
            <cfreturn this />
      </cffunction>

      <!--- returns query of all data -- containing at least some minimal set of columns --->
      <cffunction name="getQuery" access="private" returntype="query">
            <cfif (this.datatype is this.DATATYPES.CATEGORY)>
                  <cfreturn this.workflow.getQuery(this.catData) />
            <cfelse>
                  <cfreturn this.workflow.getQuery(this.formData) />
            </cfif>
      </cffunction>

      <!--- return list of ulisting categories --->
      <cffunction name="getCategoryQuery" access="private" returntype="query">
            <cfset var qryCategory = ''>
            
            <cfquery name="qryCategory" datasource="#this.datasource#" cachedwithin="#this.queryCache#">
                  SELECT       NAV.intID, NAV.intOrder, ULCAT.blnShowCategoryTitle,
                  ULCAT.txtTitle, ULCAT.intCategoryID, ULCAT.blnLive, ULCAT.txtDescription, ULCAT.intImageID, ULCAT.intItemID
                  FROM       tblNavigation AS NAV
                  LEFT JOIN #this.catData.tablename# AS ULCAT
                        ON      ULCAT.intCategoryID = NAV.intID AND ULCAT.blnLive = 1
                  WHERE       NAV.intParentID = #this.webid#
                  AND       NAV.blnCategory = 1
                  AND       ULCAT.blnLive = 1
                  AND       NAV.blnDeleted = 0
                  <cfif isDefined('ckeywords')>
                        AND (ULCAT.txtTitle LIKE N'%#ckeywords#%' OR ULCAT.txtDescription LIKE N'%#ckeywords#%')
                  </cfif>
                  ORDER BY NAV.intOrder
            </cfquery>

            <cfreturn qryCategory />            
      </cffunction>
      
      <cffunction name="getItemQuery" access="public" returntype="query" output="false">
            <cfargument name="qryConfig" type="query" required="false">
            <cfargument name="blnLive" type="boolean" default="false" required="no">
            <cfset var qryItem = ''>
            
            <cfquery name="qryItem" datasource="#this.datasource#" cachedwithin="#this.queryCache#">
                  SELECT      
                        <cfif this.formData.blnCategory>
                           isnull(isnull(tblItem.intCategoryID, #this.formData.tablename#.intCategoryID), 0) AS intCategoryID,
                        </cfif>
                        #this.formData.tablename#.*, tblItem.intID, tblItem.intOrder as intItemOrder
                        FROM tblItem
                        INNER JOIN #this.formData.tablename#
                              ON      tblItem.intID = #this.formData.tablename#.intItemID      
                        <cfif arguments.blnLive>
                              AND #this.formData.tablename#.blnLive = 1
                        </cfif>
                        LEFT JOIN tblItemLock ON tblItem.intID = tblItemLock.intItemID
                                                                  AND tblItemLock.intID IN (SELECT TOP 1 intID FROM tblItemLock WHERE intItemID = tblItem.intID)
                        LEFT JOIN tblNavigation ON tblItem.intWebID = tblNavigation.intID
                        WHERE tblItem.intDataType = #val(this.formData.datatype)#
                        AND tblNavigation.intCompanyID = #this.companyID#
                        AND tblItem.blnDeleted = 0
                        AND tblItem.intWebID = #this.formData.webid#
                        <cfif arguments.blnLive is true AND this.formData.blnScheduling>
                              AND (#this.formData.tablename#.dtStart IS NULL OR #this.formData.tablename#.dtStart <= #getODBCNow()#)
                              AND (#this.formData.tablename#.dtEnd IS NULL OR #this.formData.tablename#.dtEnd >= #getODBCNow()#)
                        </cfif>
                        <cfif isDefined("URL.c") and Val(URL.c)>
                              AND #this.formData.tablename#.intCategoryID = #URL.c#
                        </cfif>
                        <cfif isDefined("ikeywords") and Len(Trim(ikeywords))>
                              AND (#this.formData.tablename#.txtTitle LIKE N'%#ikeywords#%' OR #this.formData.tablename#.txtDescription LIKE '%#ikeywords#%'
                                          <cfif qryConfig.blnAbstract is 1>OR #this.formData.tablename#.txtAbstract LIKE '%##ikeywords##%'</cfif>
                                          <cfif qryConfig.blnAddress is 1>
                                                OR #this.formData.tablename#.txtAddress LIKE N'%#ikeywords#%' OR #this.formData.tablename#.txtCity LIKE '%#ikeywords#%'
                                                OR #this.formData.tablename#.txtProvince LIKE N'%#ikeywords#%' OR #this.formData.tablename#.txtProvince LIKE '%#ikeywords#%'
                                                OR #this.formData.tablename#.txtCountry LIKE N'%#ikeywords#%' OR #this.formData.tablename#.txtCountry LIKE '%#ikeywords#%'
                                                OR #this.formData.tablename#.txtPostalCode LIKE N'%#ikeywords#%' OR #this.formData.tablename#.txtPostalCode LIKE '%#ikeywords#%'
                                          </cfif>
                                          <cfif qryConfig.blnLink is 1>
                                                OR #this.formData.tablename#.txtLink LIKE N'%#ikeywords#%'
                                          </cfif>)      
                        </cfif>
                         ORDER BY
                        <cfif qryConfig.blnDate is 1>
                              #this.formData.tablename#.dtDate DESC,
                        </cfif>
                        <cfif this.formData.blnOrder>
                              tblItem.intOrder
                        <cfelse>
                              #this.formData.tablename#.#this.formData.sortcolumn# #this.formData.sortdirection#
                        </cfif>
            </cfquery>
            <cfreturn qryItem />
      </cffunction>
      <!--- /getItemQuery --->
      
      <!--- returns ulisting config settings --->
      <cffunction name="getConfigQuery" access="public" returntype="query">
            <cfset var qryConfig = ''>
            <cfquery name="qryConfig" datasource="#this.datasource#" maxrows="1" cachedwithin="#this.queryCache#">
                  SELECT       TOP 1 *
                  FROM       #this.configData.tablename#
                  WHERE       blnDeleted = 0 AND intCompanyID = #this.companyID# AND intWebID = #this.webid#
            </cfquery>
            
            <cfreturn qryConfig />
      </cffunction>
      
      
      <!--- returns ulisting roles used for accessing private items --->
      <cffunction name="getRoleQuery" access="private" returntype="query">
            <cfset var qryRoles = ''>
            
            <cfquery name="qryRoles" datasource="#this.datasource#">
                  SELECT       intWebID, intCompanyID, intRoleID
                  FROM       #this.roleData.tablename#
                  WHERE       intWebID = <cfqueryparam value="#this.webID#" cfsqltype="cf_sql_integer">
                  AND       intCompanyID = <cfqueryparam value="#this.CompanyID#" cfsqltype="cf_sql_integer">
            </cfquery>
            
            <cfreturn qryRoles />
      </cffunction>
      
      <!--- returns ulisting roles as a comma-delimited list --->
      <cffunction name="getListRoles" access="private" returntype="string" output="false">
            <cfset var qryRoles = getRoleQuery()>
            <cfset var listRoles = ValueList(qryRoles.intRoleID)>
            
            <cfreturn listRoles />
      </cffunction>
      
      
      <!--- returns the URL of the login page for extranet --->
      <cffunction name="getLoginURL" access="private" returntype="string" output="false">
            <cfset var loginURL = ''>
            
            <cfquery name="qryLoginPage" datasource="#this.datasource#">
                  SELECT       TOP 1 tblNavigation.intID
                  FROM       tblNavigation LEFT JOIN tblPlugin ON tblNavigation.intPluginID = tblPlugin.intID
                  WHERE       tblPlugin.txtType = <cfqueryparam value='extranet login' cfsqltype="cf_sql_varchar">
                  AND       tblNavigation.blnDeleted = <cfqueryparam value="0" cfsqltype="cf_sql_tinyint">
                  AND       tblNavigation.blnActive = <cfqueryparam value="1" cfsqltype="cf_sql_tinyint">
                  AND       intCompanyID = <cfqueryparam value="#this.CompanyID#" cfsqltype="cf_sql_integer">
            </cfquery>      
            
            <cfif qryLoginPage.recordCount GT 0>
                  <cfset loginURL = this.qryCompany.txtWeb & "/" & this.navigation.getDirectory(qryLoginPage.intID) & "index.cfm">
            </cfif>
            
            <cfreturn loginURL />
      </cffunction>
      
      
      <!--- returns list of text columns to be searched --->
      <cffunction name="getSearchColumns" access="public" returntype="string">
            <cfset var i = 0>
            <cfset var list = "">
            
            <cfloop from="1" to="#ArrayLen(this.formData.columns)#" index="i">
                  <cfif ListFindNoCase("#TYPES.TEXT#,#TYPES.HTML#", this.formData.columns[i].type)>
                        <cfset list = ListAppend(list, this.formData.columns[i].varname)>
                  </cfif>
            </cfloop>

            <cfif this.formData.blnMeta>
                  <cfset list = ListAppend(list, "txtMetaKeywords")>
                  <cfset list = ListAppend(list, "txtMetaDescription")>
            </cfif>

            <cfreturn list>
      </cffunction>

      <!--- returns list of text columns to be searched --->
      <cffunction name="getCategorySearchColumns" access="public" returntype="string">
            <cfset var i = 0>
            <cfset var list = "">
            
            <cfloop from="1" to="#ArrayLen(this.catData.columns)#" index="i">
                  <cfif ListFindNoCase("#TYPES.TEXT#,#TYPES.HTML#", this.catData.columns[i].type)>
                        <cfset list = ListAppend(list, this.catData.columns[i].varname)>
                  </cfif>
            </cfloop>

            <cfif this.catData.blnMeta>
                  <cfset list = ListAppend(list, "txtMetaKeywords")>
                  <cfset list = ListAppend(list, "txtMetaDescription")>
            </cfif>

            <cfreturn list>
      </cffunction>
      
      <!--- checks whether the logged in user has access to the ulisting private items --->
      <cffunction name="privateAccess" access="private" returntype="boolean">
            <cfif NOT isDefined("SESSION.loggedIn") OR SESSION.loggedIn is false>
                  <cfreturn false>      
            </cfif>
            
            <!--- if they don't belong to a role, they won't have access --->
            <cfif not ListLen(SESSION.rolelist)>
                  <cfreturn false>
            </cfif>

            <!--- otherwise, check getListRoles() to see if one of their roles is allowed --->
            <cfset listRoles = getListRoles()>
            
            <cfif not ListLen(listRoles)>
                  <cfreturn false>
            </cfif>
            
            <cfloop list="#listRoles#" delimiters="," index="i">
                  <cfset temp = ListFind(SESSION.rolelist,i)>
                  <cfif temp neq 0>
                        <cfbreak>
                  </cfif>
            </cfloop>
            
            <cfif temp neq 0>
                  <cfreturn true>
            <cfelse>
                  <cfreturn false>
            </cfif>
      </cffunction>
      
      <!--- returns a public interface for this listing tool --->
      <cffunction name="getFrontEnd" access="public" returntype="struct">
            <!--- <cfset var qryAll = getPublicQuery()> --->
            <cfset var qryConfig = getConfigQuery()>
            <cfset var qryAll = getItemQuery(qryConfig, true)>
            <cfset var output = StructNew()>
            
            <!--- get the URL of the login page for extranet --->
            <cfset this.loginURL = getLoginURL()>
            
            <!--- start row for paging --->
            <cfparam name="URL.sr" default="1">
            <cfif URL.sr LTE 0>
                  <cfset URL.sr = 1>
            </cfif>

            <!--- listing --->
            <cfset output.title = "">
            <cfset output.body = "">
            <cfset output.meta = StructNew()>
            <cfset output.meta.keywords = ''>
            <cfset output.meta.description = ''>
            
            <!--- assume that we only use login.cfc and not loginview.cfc --->
            <cfif isDefined("URL.logout")>
                  <!--- save the SESSION navid of the current page --->
                  <cfif StructKeyExists(SESSION, "navid")>
                        <cfset tmpNavID = SESSION.navid>
                  </cfif>
                  <!--- flush the session --->
                  <cfset StructClear(SESSION)>
                  <!--- reset some SESSION variables --->
                  <cfset SESSION.loggedIn = false>
                  <cfif Val(tmpNavID)>
                        <cfset SESSION.navid = tmpNavID>
                  </cfif>
            </cfif>      
            
            <!--- need to check if loggedin extranet user belongs to role(s) specified
                  to access the private ulisting items This has been replace with a lock and redirect for item detail page --->
            <cfif qryConfig.blnSecurityEnabled IS 1 and (qryConfig.blnItemListingDescription or qryConfig.blnItemListingAnchor)>
                  <cfif not privateAccess()>
                        <cfset qryAll = SelectFrom(qryAll,"blnPrivate", 0)>
                  </cfif>
            </cfif>
                  
                  
            <!--- output item details --->                        
            <cfif isDefined("URL.i")>
                  <cfif qryConfig.blnItemDetailPageContent is 0>
                        <cfset output.blnHideContent = true>
                  </cfif>
                  <cfset qryItem = SelectFrom(qryAll, "intItemID", Val(URL.i))>
                  <cfset output.title = qryItem.txtTitle>
                  <cfset output.body = getItemDetail(qryConfig, qryItem)>
                  <cfreturn output />
            </cfif>
            
            <!--- if item anchors are set --->
            <cfif qryConfig.blnItemListingAnchor is 1>
                  <cfif qryConfig.blnItemListingPageContent is 0>
                        <cfset output.blnHideContent = true>
                  </cfif>
                  <cfset output.body = getAnchoredListing(qryConfig, qryAll)>
                  <cfreturn output />
            </cfif>                        
            
            <cfif isDefined("FORM.c") AND Val(FORM.c)>
                  <cfset URL.c = FORM.c>
            </cfif>
            
            <!--- output item listing of the category --->
            <cfif qryConfig.blnCategoryListing is 0 OR isDefined("URL.c")>
                  <cfif qryConfig.blnItemListingPageContent is 0>
                        <cfset output.blnHideContent = true>
                  </cfif>
                  <!--- <cfset qryItems = SelectFrom(qryAll, "intCategoryID", Val(URL.c))> --->
                  <cfset output.body = getItemListing(qryConfig, qryAll)>
                  <cfreturn output />
            </cfif>
            
            <cfif qryConfig.blnCategoryPageContent is 0>
                  <cfset output.blnHideContent = true>
            </cfif>
            
            <!--- output category listing --->                  
            <cfset output.body = getCategoryListing(qryConfig, qryAll)>
            
            <cfreturn output />
      </cffunction>

      <!--- return listing of all categories --->
      <cffunction name="getCategoryListing" access="private" returntype="string" output="false">
            <cfargument name="qryConfig" type="query" required="true">
            <cfargument name="qryAll" type="query" required="true">

            <cfset var qryDistinctCats = ''>
            <cfset var qryCategories = ''>
            <cfset var qryAllCategories = getCategoryQuery()>
            <cfset var listingOutput = ''>
            <cfset var thepagination = ''>                        
            
            <cfif isDefined("URL.c")>
                  <cfset qryCategories = qryAllCategories>
            <cfelse>
                  <cfquery name="qryDistinctCats" dbtype="query">
                        SELECT DISTINCT intCategoryID
                        FROM       qryAll
                  </cfquery>

                  <cfquery name="qryCategories" dbtype="query">
                        SELECT       qryAllCategories.*
                        FROM       qryAllCategories, qryDistinctCats
                        WHERE       qryAllCategories.intCategoryID = qryDistinctCats.intCategoryID
                        ORDER BY qryAllCategories.intOrder
                  </cfquery>
            </cfif>
            
            <cfsavecontent variable="listingOutput">
                  <!--- output search form is category search is enabled --->
                  <cfif qryConfig.blnCategorySearch is 1>
                        <cfoutput>
                        <form name="hbsrchmod" id="hbsrchmod" method="post" action="#SCRIPT_NAME#">
                              <input type="text" name="ckeywords" id="hbsrchkey" <cfif isDefined('ckeywords')>value="#ckeywords#"</cfif>/>
                              <input type="submit" name="hbsrchbtn" id="hbsrchbtn" value="Search" />
                        </form>
                        </cfoutput>                                                
                  </cfif>
                  
                  <!--- total number of categories --->
                  <cfset recordsToDisplay = qryCategories.recordCount>      
                  
                  <cfif recordsToDisplay is 0>
                        <p>There are no categories to display.</p>
                  <cfelse>                        
           
                        <!--- if paging enabled --->
                        <cfif qryConfig.blnCategoryPagination is 1>
                              <cfset recordsToDisplay = Val(qryConfig.intCategoryDisplayItems)>
                              <cfif qryConfig.intCategoryLayoutType is this.COLUMN_LAYOUT.DOUBLE>
                                    <cfset recordsToDisplay = recordsToDisplay * 2>
                              </cfif>
                              <cfset thepagination = this.display.getPaginationDisplay(qryCategories.recordCount, recordsToDisplay, URL.sr, '')>
                        </cfif>
                                          
                        <cfif Len(Trim(thepagination))><cfoutput>#thepagination#</cfoutput></cfif>
                        <div id="hbcatmod">
                              <cfif qryConfig.intCategoryLayoutType is this.COLUMN_LAYOUT.DOUBLE> <!--- double columns --->                                                                              
                                    <cfset count = 1>                                    
                                    <cfoutput query="qryCategories" startrow="#URL.sr#" maxrows="#recordsToDisplay#">
                                          <cfif count mod 2 is 1>
                                          <div class="hbcatrow">
                                                <div class="hbcatcollft">
                                          <cfelse>
                                                <div class="hbcatcolrht">
                                          </cfif>
                                                <cfif qryConfig.blnCategoryImage is 1 and Val(intImageID)> <!--- with image --->
                                                      <cfif qryConfig.intCategoryImageAlign is this.IMAGE_ALIGN.INLINE> <!--- image inline --->
                                                            <img src="#this.workflow.setSSLPrefix(this.media.getURL(intImageID,Val(qryConfig.intCategoryImageWidth),Val(qryConfig.intCategoryImageHeight)),this.webid)#" class="hbcatinl" border="0"/>
                                                            <h5><a href="#SCRIPT_NAME#?c=#intCategoryID#">#txtTitle#</a></h5>
                                                      <cfelse> <!--- image left or right --->
                                                            <h5><a href="#SCRIPT_NAME#?c=#intCategoryID#">#txtTitle#</a></h5>
                                                            <img src="#this.workflow.setSSLPrefix(this.media.getURL(intImageID,Val(qryConfig.intCategoryImageWidth),Val(qryConfig.intCategoryImageHeight)),this.webid)#" <cfif qryConfig.intCategoryImageAlign EQ this.IMAGE_ALIGN.LEFT>class="hbcatlft"<cfelse>class="hbcatrht"</cfif> border="0" />
                                                      </cfif>
                                                <cfelse> <!--- without image --->
                                                      <h5><a href="#SCRIPT_NAME#?c=#intCategoryID#">#txtTitle#</a></h5>
                                                </cfif>                                                                              
                                                <cfif qryConfig.blnCategoryDescription is 1>
                                                      <!--- convertTokens() --->
                                                      #this.workflow.convertTokens(txtDescription,false,this.webid)#
                                                </cfif>
                                                </div>
                                          <cfif count mod 2 is 0>
                                                <div class="clr">&nbsp;</div>
                                          </div>
                                          </cfif>
                                          <cfset count = count + 1>
                                    </cfoutput>
                                    <cfif count mod 2 is 0>
                                          <div class="clr">&nbsp;</div>
                                    </div>
                                    </cfif>                                    
                              <cfelse> <!--- one column --->
                                    <cfif qryConfig.blnCategoryImage is 1>
                                          <cfif qryConfig.intCategoryImageAlign is this.IMAGE_ALIGN.LEFT or qryConfig.intCategoryImageAlign is this.IMAGE_ALIGN.RIGHT>
                                                <cfif qryConfig.blnCategoryImageWrap is 1 >
                                                      <cfoutput query="qryCategories" startrow="#URL.sr#" maxrows="#recordsToDisplay#">
                                                            <h5><a href="#SCRIPT_NAME#?c=#intCategoryID#">#txtTitle#</a></h5>
                                                            <cfif intImageID gt 0><a href="#SCRIPT_NAME#?c=#intCategoryID#"><img src="#this.media.getURL(intImageID,Val(qryConfig.intCategoryImageWidth),Val(qryConfig.intCategoryImageHeight))#" <cfif qryConfig.intCategoryImageAlign is this.IMAGE_ALIGN.LEFT>class="hbcatlft"<cfelse>class="hbcatrht"</cfif> border="0" /></a></cfif>
                                                            <cfif qryConfig.blnCategoryDescription is 1>#this.workflow.convertTokens(txtDescription)#</cfif>
                                                            <div class="clr">&nbsp;</div>
                                                      </cfoutput>
                                                <cfelse>      
                                                      <cfset roundedWidth = roundImageWidth(Val(qryConfig.intCategoryImageWidth))>                                          
                                                      <cfoutput query="qryCategories" startrow="#URL.sr#" maxrows="#recordsToDisplay#">
                                                            <cfif qryConfig.intCategoryImageAlign is this.IMAGE_ALIGN.LEFT>
                                                            <div class="hbcatlft#roundedWidth#"><cfif intImageID GT 0><img src="#this.media.getURL(intImageID,Val(qryConfig.intCategoryImageWidth),Val(qryConfig.intCategoryImageHeight))#" border="0"/></cfif></div>
                                                            <div class="hbcatrht#roundedWidth#">
                                                            <cfelse>
                                                            <div class="hbcatrht#roundedWidth#"><cfif intImageID GT 0><img src="#this.media.getURL(intImageID,Val(qryConfig.intCategoryImageWidth),Val(qryConfig.intCategoryImageHeight))#"  border="0"/></cfif></div>
                                                            <div class="hbcatlft#roundedWidth#">      
                                                            </cfif>
                                                            <h5><a href="#SCRIPT_NAME#?c=#intCategoryID#">#txtTitle#</a></h5>
                                                            <cfif qryConfig.blnCategoryDescription is 1>#this.workflow.convertTokens(txtDescription)#</cfif>
                                                            </div>
                                                            <div class="clr">&nbsp;</div>
                                                      </cfoutput>                                          
                                                </cfif>                                          
                                          <cfelse> <!--- this.IMAGE_ALIGN.INLINE --->
                                                <cfoutput query="qryCategories" startrow="#URL.sr#" maxrows="#recordsToDisplay#">
                                                      <cfif intImageID GT 0><img src="#this.workflow.setSSLPrefix(this.media.getURL(intImageID,Val(qryConfig.intCategoryImageWidth),Val(qryConfig.intCategoryImageHeight)),this.webid)#"  border="0"  /></cfif>
                                                      <h5><a href="#SCRIPT_NAME#?c=#intCategoryID#">#txtTitle#</a></h5>
                                                      <cfif qryConfig.blnCategoryDescription is 1>#this.workflow.convertTokens(txtDescription)#</cfif>
                                                      <div class="clr">&nbsp;</div>
                                                </cfoutput>
                                          </cfif>
                                    <cfelse>
                                          <cfoutput query="qryCategories" startrow="#URL.sr#" maxrows="#recordsToDisplay#">
                                                <h5><a href="#SCRIPT_NAME#?c=#intCategoryID#">#txtTitle#</a></h5>
                                                <cfif qryConfig.blnCategoryDescription is 1>#this.workflow.convertTokens(txtDescription)#</cfif>
                                                <div class="clr">&nbsp;</div>
                                          </cfoutput>
                                    </cfif>
                              </cfif> <!--- column layout --->                                                                  
                        </div>
                        <cfif Len(Trim(thepagination))><cfoutput>#thepagination#</cfoutput></cfif>                  
                  </cfif>
            </cfsavecontent>
            
            <cfreturn listingOutput>
      </cffunction>
      <!--- /getCategoryListing --->
      
      
      <!--- return listing of all items under the category --->
      <cffunction name="getItemListing" access="private" returntype="string" output="false">
            <cfargument name="qryConfig" type="query" required="true">
            <cfargument name="qryAll" type="query" required="true">
                              
            <cfscript>
                  var listingOutput = '';
                  var thepagination = '';
                  var infoList = '';
                  var addressLine1 = '';
                  var addressLine2 = '';
                  var roundedWidth = 0;
                  var count = 0;
                  var qryItems = #arguments.qryAll#;
                  var txtURL = '';
                  var txtItemLink = '';
                  var loginLink = this.loginURL;
            </cfscript>
            
            <cfif isDefined("URL.c") and Val(URL.c)>
                  <cfset qryItems = SelectFrom(qryAll,'intCategoryID',URL.c)>
            </cfif>      
                  
            <cfsavecontent variable="listingOutput">
                  <!--- <cfif qryConfig.blnSecurityEnabled is 1 AND Len(Trim(rids)) AND NOT ( isDefined("SESSION.loggedIn_#this.webid#") AND SESSION['loggedIn_#this.webid#'] ) AND Len(Trim(loginLink))> --->
                    <cfif qryConfig.blnSecurityEnabled IS 1 AND (qryConfig.blnItemListingAnchor or qryConfig.blnItemListingDescription) IS 1 AND NOT ( isDefined("SESSION.loggedIn") AND SESSION['loggedIn'] ) AND Len(Trim(loginLink))><!--- loggedIn_#this.webid# --->
                        <cfset loginLink = loginLink & '?wid=#this.webid#'>
                        <cfif isDefined("URL.c")>
                              <cfset loginLink = loginLink & '&cid=#URL.c#'>
                        </cfif>
                        <cfoutput><p><a href="#loginLink#">Login</a> to view secured items</p></cfoutput>
                  </cfif>
                  
                  
                  <!--- output the search form if item listing search is enabled --->
                  <cfif qryConfig.blnItemListingSearch is 1>
                        <cfset qryCategories = getCategoryQuery()>
                        <cfoutput>                              
                        <form name="frmSearch" id="hbsrchmod" method="post" action="#SCRIPT_NAME#">
                              <input type="text" name="ikeywords" id="hbsrchkey" <cfif isDefined('ikeywords')>value="#ikeywords#"</cfif> />
                              <select name="c" id="hbsrchsel">
                                    <option value="0">All</option>
                                    <cfloop query="qryCategories">
                                          <option value="#qryCategories.intCategoryID#" <cfif isDefined("URL.c") AND qryCategories.intCategoryID is URL.c>selected</cfif>>#qryCategories.txtTitle#</option>
                                    </cfloop>      
                              </select>
                              <input type="submit" name="hbsrchbtn" id="hbsrchbtn" value="Search" />
                        </form>
                        </cfoutput>      
                  </cfif>
                  
                  <!--- total number of items --->
                  <cfset recordsToDisplay = qryItems.recordCount>            
                  
                  <cfif recordsToDisplay is 0>
                        <p>There are no items to display.</p>
                  <cfelse>                        
                        <!--- if paging is enabled --->
                        <cfif qryConfig.blnItemListingPagination is 1>
                              <cfset recordsToDisplay = Val(qryConfig.intItemListingDisplayItems)>
                              <cfif qryConfig.intItemListingLayoutType is this.COLUMN_LAYOUT.DOUBLE>
                                    <cfset recordsToDisplay = recordsToDisplay * 2>
                              </cfif>
                              <cfset thepagination = this.display.getPaginationDisplay(qryItems.recordCount, recordsToDisplay, URL.sr, '')>
                        </cfif>
                        
                        <cfset callAction = 'more...'>
                        <cfif Len(Trim(qryConfig.txtItemListingDescriptionAction))>
                              <cfset callAction = qryConfig.txtItemListingDescriptionAction>
                        </cfif>                        
                                          
                        <cfif Len(Trim(thepagination))><cfoutput>#thepagination#</cfoutput></cfif>
                              
                        <div id="hblistmod">                  
                              <cfif qryConfig.intItemListingLayoutType is this.COLUMN_LAYOUT.DOUBLE> <!--- double columns --->
                                    <cfset count = 1>
                                    
                                    <cfoutput query="qryItems" startrow="#URL.sr#" maxrows="#recordsToDisplay#">                                    
                                          <cfif count MOD 2 is 1>
                                          <div class="hblistrow">
                                                <div class="hblistcollft">
                                          <cfelse>
                                                <div class="hblistcolrht">
                                          </cfif>
                                                      <cfset txtTarget = ''>
                                                      <cfif qryConfig.blnItemDetail is 1>                                                                  
                                                            <cfset txtURL = "#SCRIPT_NAME#?i=#intItemID#">
                                                      <cfelseif qryConfig.blnLink is 1 AND Len(Trim(txtLink))>
                                                            <cfif REFindNoCase("http[s]://",txtLink)>
                                                                  <cfset txtURL = txtLink>
                                                            <cfelse>
                                                                  <cfset txtURL = "http://#txtLink#">
                                                            </cfif>
                                                            <cfset txtTarget = 'target="_blank"'>
                                                      <cfelse>
                                                            <cfset txtURL = ''>
                                                      </cfif>
                                                      <cfif qryConfig.blnImage is 1 AND qryConfig.blnItemListingImage is 1 AND qryConfig.intItemListingImageAlign is this.IMAGE_ALIGN.INLINE AND Val(intImageID)>
                                                             <cfif Len(Trim(txtURL))>
                                                                  <a href="#txtURL#" #txtTarget#><img src="#this.media.getURL(intImageID,Val(qryConfig.intItemListingImageWidth),Val(qryConfig.intItemListingImageHeight))#" border="0" class="hblistinl" /></a>
                                                            <cfelse>
                                                                  <img src="#this.workflow.setSSLPrefix(this.media.getURL(intImageID,Val(qryConfig.intItemListingImageWidth),Val(qryConfig.intItemListingImageHeight)),this.webid)#" border="0" class="hblistinl" />                                                                  
                                                            </cfif>                                                       
                                                       </cfif>                                                       
                                                      <cfif qryConfig.blnItemListingTitle is 1>
                                                            <cfif Len(Trim(txtURL))>
                                                                  <h5><a href="#txtURL#" #txtTarget#>#txtTitle#</a><cfif blnPrivate> #this.PRIVATE_IMAGE#</cfif></h5>
                                                            <cfelse>
                                                                  <h5>#txtTitle#<cfif blnPrivate> #this.PRIVATE_IMAGE#</cfif></h5>
                                                            </cfif>
                                                      </cfif>
                                                      <cfset infoList = ''>                                                                                                
                                                      <cfif qryConfig.blnDate is 1 AND isDate(dtDate)><cfset infoList = infoList & '<li>#DateFormat(dtDate, 'mmmm dd, yyyy')#</li>'></cfif>
                                                      <cfif qryConfig.blnAddress is 1>
                                                            <cfset addressLine1 = ''>
                                                            <cfset addressLine2 = ''>
                                                            <cfset addressLine1 = addressLine1 & '#txtAddress#'>
                                                            <cfif Len(Trim(txtCity))><cfset addressLine2 = addressLine2 & '#txtCity#,'></cfif>
                                                            <cfif Len(Trim(txtProvince))><cfset addressLine2 = addressLine2 & ' #txtProvince#,'></cfif>
                                                            <cfif Len(Trim(txtPostalCode))><cfset addressLine2 = addressLine2 & ' #txtPostalCode#'></cfif>
                                                            <cfset addressLine2 = addressLine2 & ' #txtCountry#'>
                                                            <cfif Len(Trim(addressLine1))><cfset infoList = infoList & '<li>#addressLine1#</li>'></cfif>
                                                            <cfif Len(Trim(addressLine2))><cfset infoList = infoList & '<li>#addressLine2#</li>'></cfif>
                                                      </cfif>
                                                      <cfif qryConfig.blnPhone is 1 AND Len(Trim(txtPhone))><cfset infoList = infoList & '<li>Phone: #txtPhone#</li>'></cfif>
                                                      <cfif qryConfig.blnFax is 1 AND Len(Trim(txtFax))><cfset infoList = infoList & '<li>Fax: #txtFax#</li>'></cfif>
                                                      <cfif qryConfig.blnPhone is 1 AND Len(Trim(txtTollFree))><cfset infoList = infoList & '<li>Toll-Free: #txtTollFree#</li>'></cfif>
                                                      <cfif qryConfig.blnEmail is 1 AND Len(Trim(txtEmail))><cfset infoList = infoList & '<li>Email: <a href="mailto:#txtEmail#">#txtEmail#</a></li>'></cfif>
                                                      <cfif qryConfig.blnLink is 1 AND Len(Trim(txtLink))>
                                                            <cfif REFindNoCase("http[s]://",txtLink)>
                                                                  <cfset txtItemLink = txtLink>
                                                            <cfelse>
                                                                  <cfset txtItemLink = "http://#txtLink#">
                                                            </cfif>
                                                            <cfset infoList = infoList & '<li><a href="#txtItemLink#" target="_blank">#txtLink#</a></li>'>
                                                      </cfif>
                                                      <cfif Len(Trim(infoList))>
                                                            <ul>
                                                                  #infoList#                                                      
                                                            </ul>
                                                      <cfelse>
                                                            <br />
                                                      </cfif>
                                                      <cfif qryConfig.blnImage is 1 AND qryConfig.blnItemListingImage is 1 AND qryConfig.intItemListingImageAlign NEQ this.IMAGE_ALIGN.INLINE AND Val(intImageID)>                                                            
                                                            <cfif Len(Trim(txtURL))>
                                                                  <a href="#txtURL#" #txtTarget#><img src="#this.media.getURL(intImageID,Val(qryConfig.intItemListingImageWidth),Val(qryConfig.intItemListingImageHeight))#" border="0" <cfif qryConfig.intItemListingImageAlign is this.IMAGE_ALIGN.LEFT>class="hblistlft"<cfelse>class="hblistrht"</cfif>/></a>
                                                            <cfelse>
                                                                  <img src="#this.workflow.setSSLPrefix(this.media.getURL(intImageID,Val(qryConfig.intItemListingImageWidth),Val(qryConfig.intItemListingImageHeight)),this.webid)#" border="0" <cfif qryConfig.intItemListingImageAlign EQ this.IMAGE_ALIGN.LEFT>class="hblistlft"<cfelse>class="hblistrht"</cfif>/>                                                            
                                                            </cfif>
                                                      </cfif>      
                                                      <cfif qryConfig.blnItemListingDescription is 1>
                                                            <cfif qryConfig.intItemListingDescriptionType is this.DISPLAY_TYPES.MEMO>
                                                                  #txtAbstract#
                                                            <cfelseif qryConfig.intItemListingDescriptionType is this.DISPLAY_TYPES.TRIMMED AND Val(qryConfig.intItemListingDescriptionLength)>      
                                                                  <!--- Thomas Auguest 29 2006: More... option doesn't work for two column item listing. START --->
                                                                  <!--- <cfif Len(Trim(txtURL))>
                                                                        #this.display.memoFormat(txtDescription, qryConfig.intItemListingDescriptionLength, ' [ <a href="#txtURL#">#callAction#</a> ]')#
                                                                  <cfelse>
                                                                        #this.display.memoFormat(txtDescription, qryConfig.intItemListingDescriptionLength, '')#
                                                                  </cfif> --->
                                                                  #this.display.memoFormat(txtDescription, qryConfig.intItemListingDescriptionLength, ' [ <a href="#SCRIPT_NAME#?i=#intItemID#">#callAction#</a> ]')#
                                                                  <!--- Thomas Auguest 29 2006: More... option doesn't work for two column item listing. END--->
                                                            <cfelse> <!--- full --->
                                                                  <!--- convertTokens() --->
                                                                  #this.workflow.convertTokens(txtDescription,false,this.webid)#
                                                            </cfif>                                                      
                                                      </cfif>
                                                </div>                                                
                                          <cfif count MOD 2 is 0>            
                                                <div class="clr">&nbsp;</div>                                                
                                          </div>
                                          </cfif>
                                          <cfset count = count + 1>                                          
                                    </cfoutput>
                                    <cfif count MOD 2 is 0>
                                          <div class="clr">&nbsp;</div>
                                    </div>
                                    </cfif>      
                              <cfelse> <!--- single column --->
                                    <cfif qryConfig.blnDate is 1 AND qryConfig.intItemListingDateLayoutType is this.DATE_LAYOUT_TYPES.ONELINE>
                                                                              
                                          <cfoutput query="qryItems" startrow="#URL.sr#" maxrows="#recordsToDisplay#">
                                                <div class="hblistlft"><cfif isDate(dtDate)><strong><a href="#SCRIPT_NAME#?i=#intItemID#">#DateFormat(dtDate,'mmm dd, yyyy')#</a></strong></cfif></div>
                                                <div class="hblistrht75">
                                                      <cfif qryConfig.blnItemListingTitle is 1><strong><a href="#SCRIPT_NAME#?i=#intItemID#">#txtTitle#</a></strong></cfif>
                                                      <cfif qryConfig.blnItemListingDescription is 1>
                                                            <cfif qryConfig.intItemListingDescriptionType is this.DISPLAY_TYPES.MEMO>
                                                                  #txtAbstract#
                                                            <cfelseif qryConfig.intItemListingDescriptionType is this.DISPLAY_TYPES.TRIMMED AND Val(qryConfig.intItemListingDescriptionLength)>      
                                                                  #this.display.memoFormat(txtDescription, qryConfig.intItemListingDescriptionLength, ' [ <a href="#SCRIPT_NAME#?i=#intItemID#">#callAction#</a> ]')#
                                                            <cfelse> <!--- full --->
                                                                  <!--- convertTokens() --->
                                                                  #this.workflow.convertTokens(txtDescription,false,this.webid)#
                                                            </cfif>                                                      
                                                      </cfif>
                                                </div>
                                          </cfoutput>
                                    <cfelse> <!--- no date or date layout is two line --->
                                          <cfset roundedWidth = roundImageWidth(Val(qryConfig.intItemListingImageWidth))>                                          
                                          <cfoutput query="qryItems" startrow="#URL.sr#" maxrows="#recordsToDisplay#">
                                                <cfset txtTarget = ''>                                          
                                                <cfif qryConfig.blnItemDetail is 1>
                                                      <cfset txtURL = '#SCRIPT_NAME#?i=#intItemID#'>
                                                <cfelseif qryConfig.blnLink is 1 AND Len(Trim(txtLink))>
                                                      <cfif REFindNoCase("http[s]://",txtLink)>
                                                            <cfset txtURL = txtLink>
                                                      <cfelse>
                                                            <cfset txtURL = "http://#txtLink#">
                                                      </cfif>
                                                      <cfset txtTarget = 'target="_blank"'>
                                                <cfelse>
                                                      <cfset txtURL = ''>      
                                                </cfif>
                                                <cfif qryConfig.blnImage is 1 AND qryConfig.blnItemListingImage is 1 AND Val(intImageID)>                                                      
                                                      <cfif qryConfig.blnItemListingImageWrap is 1 OR qryConfig.intItemListingImageAlign is this.IMAGE_ALIGN.INLINE AND Val(intImageID)> <!--- image wrap --->
                                                            <cfif qryConfig.intItemListingImageAlign is this.IMAGE_ALIGN.RIGHT> <!--- image right --->
                                                                  
                                                                  <cfif Len(Trim(txtURL))>                                                                        
                                                                        <a href="#txtURL#" #txtTarget#><img src="#this.media.getURL(intImageID,Val(qryConfig.intItemListingImageWidth),Val(qryConfig.intItemListingImageHeight))#" border="0" class="hblistrht"/></a>
                                                                  <cfelse>
                                                                        <img src="#this.workflow.setSSLPrefix(this.media.getURL(intImageID,Val(qryConfig.intItemListingImageWidth),Val(qryConfig.intItemListingImageHeight)),this.webid)#" border="0" class="hblistrht"/>
                                                                  </cfif>                                                                  
                                                            <cfelse> <!--- image left or inline --->      
                                                                  <cfif Len(Trim(txtURL))>
                                                                        <a href="#txtURL#" #txtTarget#><img src="#this.media.getURL(intImageID,Val(qryConfig.intItemListingImageWidth),Val(qryConfig.intItemListingImageHeight))#" border="0" <cfif qryConfig.intItemListingImageAlign is this.IMAGE_ALIGN.LEFT>class="hblistlft"<cfelse>class="hblistinl"</cfif> /></a>
                                                                  <cfelse>
                                                                        <img src="#this.workflow.setSSLPrefix(this.media.getURL(intImageID,Val(qryConfig.intItemListingImageWidth),Val(qryConfig.intItemListingImageHeight)),this.webid)#" border="0" <cfif qryConfig.intItemListingImageAlign EQ this.IMAGE_ALIGN.LEFT>class="hblistlft"<cfelse>class="hblistinl"</cfif> />                                                                        
                                                                  </cfif>
                                                            </cfif>
                                                      <cfelse> <!--- image no wrap --->                                                                                                                        
                                                            <cfif Len(Trim(txtURL))>
                                                                  <div <cfif qryConfig.intItemListingImageAlign is this.IMAGE_ALIGN.LEFT>class="hblistlft"<cfelse>class="hblistrht"</cfif>><a href="#txtURL#"><img src="#this.media.getURL(intImageID,Val(qryConfig.intItemListingImageWidth),Val(qryConfig.intItemListingImageHeight))#" border="0"/></a></div>
                                                                  <div <cfif qryConfig.intItemListingImageAlign is this.IMAGE_ALIGN.LEFT>class="hblistrht#roundedWidth#"<cfelse>class="hblistlft#roundedWidth#"</cfif>>
                                                            <cfelse>
                                                                  <div <cfif qryConfig.intItemListingImageAlign is this.IMAGE_ALIGN.LEFT>class="hblistlft"<cfelse>class="hblistrht"</cfif>><img src="#this.media.getURL(intImageID,Val(qryConfig.intItemListingImageWidth),Val(qryConfig.intItemListingImageHeight))#" border="0"/></div>
                                                                  <div <cfif qryConfig.intItemListingImageAlign is this.IMAGE_ALIGN.LEFT>class="hblistrht#roundedWidth#"<cfelse>class="hblistlft#roundedWidth#"</cfif>>
                                                            </cfif>
                                                      </cfif>                                                                                                                                                                  
                                                </cfif>
                                                <cfif qryConfig.blnItemListingTitle is 1>
                                                      <cfif Len(Trim(txtURL))>
                                                            <h5><a href="#txtURL#" #txtTarget#>#txtTitle#</a><cfif blnPrivate> #this.PRIVATE_IMAGE#</cfif></h5>
                                                      <cfelse>
                                                            <h5>#txtTitle#<cfif blnPrivate> #this.PRIVATE_IMAGE#</cfif></h5>
                                                      </cfif>                                                      
                                                </cfif>
                                                <cfset infoList = ''>                                                                                                
                                                <cfif qryConfig.blnDate is 1 AND isDate(dtDate)><cfset infoList = infoList & '<li>#DateFormat(dtDate, 'mmmm dd, yyyy')#</li>'></cfif>
                                                <cfif qryConfig.blnAddress is 1>
                                                      <cfset addressLine1 = ''>
                                                      <cfset addressLine2 = ''>
                                                      <cfset addressLine1 = addressLine1 & '#txtAddress#'>
                                                      <cfif Len(Trim(txtCity))><cfset addressLine2 = addressLine2 & '#txtCity#,'></cfif>
                                                      <cfif Len(Trim(txtProvince))><cfset addressLine2 = addressLine2 & ' #txtProvince#,'></cfif>
                                                      <cfif Len(Trim(txtPostalCode))><cfset addressLine2 = addressLine2 & ' #txtPostalCode#'></cfif>
                                                      <cfset addressLine2 = addressLine2 & ' #txtCountry#'>
                                                      <cfif Len(Trim(addressLine1))><cfset infoList = infoList & '<li>#addressLine1#</li>'></cfif>
                                                      <cfif Len(Trim(addressLine2))><cfset infoList = infoList & '<li>#addressLine2#</li>'></cfif>
                                                </cfif>
                                                <cfif qryConfig.blnPhone is 1 AND Len(Trim(txtPhone))><cfset infoList = infoList & '<li>Phone: #txtPhone#</li>'></cfif>
                                                <cfif qryConfig.blnFax is 1 AND Len(Trim(txtFax))><cfset infoList = infoList & '<li>Fax: #txtFax#</li>'></cfif>
                                                <cfif qryConfig.blnPhone is 1 AND Len(Trim(txtTollFree))><cfset infoList = infoList & '<li>Toll-Free: #txtTollFree#</li>'></cfif>
                                                <cfif qryConfig.blnEmail is 1 AND Len(Trim(txtEmail))><cfset infoList = infoList & '<li>Email: <a href="mailto:#txtEmail#">#txtEmail#</a></li>'></cfif>
                                                <cfif qryConfig.blnLink is 1 AND Len(Trim(txtLink))>
                                                      <cfif REFindNoCase("http[s]://",txtLink)>
                                                            <cfset txtItemLink = txtLink>
                                                      <cfelse>
                                                            <cfset txtItemLink = "http://#txtLink#">
                                                      </cfif>
                                                      <cfset infoList = infoList & '<li><a href="#txtItemLink#" target="_blank">#txtLink#</a></li>'>
                                                </cfif>
                                                <cfif Len(Trim(infoList))>
                                                      <ul>
                                                            #infoList#                                                      
                                                      </ul>
                                                </cfif>
                                                
                                                <cfif qryConfig.blnItemListingDescription is 1>
                                                      <cfif qryConfig.intItemListingDescriptionType is this.DISPLAY_TYPES.MEMO>
                                                            #txtAbstract#
                                                      <cfelseif qryConfig.intItemListingDescriptionType is this.DISPLAY_TYPES.TRIMMED AND Val(qryConfig.intItemListingDescriptionLength)>      
                                                            #this.display.memoFormat(txtDescription, qryConfig.intItemListingDescriptionLength, ' [ <a href="#SCRIPT_NAME#?i=#intItemID#">#callAction#</a> ]')#
                                                      <cfelse> <!--- full --->
                                                            <!--- convertTokens() --->
                                                            #this.workflow.convertTokens(txtDescription,false,this.webid)#
                                                      </cfif>                                                      
                                                </cfif>
                                                <div class="clr">&nbsp;</div>
                                                <cfif qryConfig.blnImage is 1 AND qryConfig.blnItemListingImage is 1 AND qryConfig.blnItemListingImageWrap is 0 AND Val(intImageID)>
                                                </div>
                                                </cfif>                                    
                                          </cfoutput>                                          
                                    </cfif>
                              </cfif>                              
                        </div>
                        <cfif Len(Trim(thepagination))><cfoutput>#thepagination#</cfoutput></cfif>                        
                  </cfif>
            </cfsavecontent>
            
            <cfreturn listingOutput />
      </cffunction>
      <!--- /getItemListing --->
      
      <!--- return listing of all items with anchors --->
      <cffunction name="getAnchoredListing" access="private" returntype="string" output="false">
            <cfargument name="qryConfig" type="query" required="true">
            <cfargument name="qryAll" type="query" required="true">
            
            <cfscript>
                  var listingOutput = '';
                  var infoList = '';
                  var addressLine1 = '';
                  var addressLine2 = '';
                  var roundedWidth = 0;
                  var count = 0;
                  var txtURL = '';
                  var txtTarget = '';
                  var txtItemLink = '';
                  var loginLink = this.loginURL;
                  
                  var qryAllCategories = getCategoryQuery();
                  var qryItems = #arguments.qryAll#;
            </cfscript>
            
            <cfsavecontent variable="listingOutput">
                  <cfset nItemCount = qryItems.recordCount>
                  
                  <cfif nItemCount is 0>
                        <p>There are no items to display.</p>
                  <cfelse>
                        <!--- re-order the items by intCategoryID --->
                        <cfquery name="qryAll" dbtype="query">
                              SELECT      *
                              FROM      qryAll
                              ORDER BY intCategoryID
                        </cfquery>
                        
                        <!--- Provide Login link if items are secure --->
                        <cfif Arguments.qryConfig.blnSecurityEnabled IS 1 AND (qryConfig.blnItemListingAnchor or qryConfig.blnItemListingDescription) IS 1 AND NOT ( isDefined("SESSION.loggedIn") AND SESSION['loggedIn'] ) AND Len(Trim(loginLink))><!--- loggedIn_#this.webid# --->
                              <cfset loginLink = loginLink & '?wid=#this.webid#'>
                              <cfif isDefined("URL.c")>
                                    <cfset loginLink = loginLink & '&cid=#URL.c#'>
                              </cfif>
                              <cfoutput><p><a href="#loginLink#">Login</a> to view secured items</p></cfoutput>
                        </cfif>
                        <div id="anchorlisting">
                        <a name="item0"></a>
                        <cfloop query="qryAllCategories">
                              <cfset qryItems = SelectFrom(qryAll,'intCategoryID',qryAllCategories.intID)>
                              <cfoutput>
                              <cfif qryAllCategories.blnShowCategoryTitle eq "1">
                              <h2>#qryAllCategories.txtTitle#</h2>
                              </cfif>
                              <cfif qryConfig.blnCategoryDescription eq "1">
                              <p>#qryAllCategories.txtDescription#</p>
                              </cfif>
                              
                              <ul>
                              </cfoutput>
                              <cfoutput query="qryItems">
                                    <!--- Donny: missing url parameter
                                    <li><strong><a href="#SCRIPT_NAME###item#currentRow#">#txtTitle#</a></strong></li> --->
                                    <li><strong><a href="#SCRIPT_NAME#<cfif Len(Trim(QUERY_STRING))>?#QUERY_STRING#</cfif>##item#count + currentRow#">#qryItems.txtTitle#</a></strong></li>
                              </cfoutput>
                              </ul>
                              <cfset count = count + qryItems.recordCount>
                        </cfloop>
                        <div class="clr">&nbsp;</div>
                        <cfset count = 0>
                        <cfloop query="qryAllCategories">
                              <cfset qryItems = SelectFrom(qryAll,'intCategoryID',qryAllCategories.intID)>
                              <ul id="dottedtop">
                              <cfoutput query="qryItems">
                                    <cfset roundedWidth = roundImageWidth(Val(qryConfig.intItemListingImageWidth))>
                                    <li>
                                          <h5><a name="item#count + currentRow#"></a>#txtTitle#<cfif blnPrivate> #this.PRIVATE_IMAGE#</cfif></h5>
                                          <!--- <strong>#qryAllCategories.txtTitle#</strong><br /> --->
                                          <div id="hblistmod">
                                          <cfif qryConfig.blnImage is 1 AND qryConfig.blnItemListingImage is 1>
                                                <cfif qryConfig.blnItemListingImageWrap is 1 OR qryConfig.intItemListingImageAlign is this.IMAGE_ALIGN.INLINE AND Val(intImageID)> <!--- image wrap --->
                                                      <cfif qryConfig.intItemListingImageAlign is this.IMAGE_ALIGN.RIGHT> <!--- image right --->
                                                            <img src="#this.workflow.setSSLPrefix(this.media.getURL(intImageID,Val(qryConfig.intItemListingImageWidth),Val(qryConfig.intItemListingImageHeight)),this.webid)#" border="0" class="hblistrht"/>
                                                      <cfelse> <!--- image left or inline --->      
                                                            <img src="#this.workflow.setSSLPrefix(this.media.getURL(intImageID,Val(qryConfig.intItemListingImageWidth),Val(qryConfig.intItemListingImageHeight)),this.webid)#" border="0" <cfif qryConfig.intItemListingImageAlign EQ this.IMAGE_ALIGN.LEFT>class="hblistlft"<cfelse>class="hblistinl"</cfif> />
                                                      </cfif>
                                                <cfelseif Val(intImageID)> <!--- image no wrap --->                                                            
                                                      <div <cfif qryConfig.intItemListingImageAlign is this.IMAGE_ALIGN.LEFT>class="hblistlft"<cfelse>class="hblistrht"</cfif>><img src="#this.media.getURL(intImageID,Val(qryConfig.intItemListingImageWidth),Val(qryConfig.intItemListingImageHeight))#" border="0"/></div>
                                                      <div <cfif qryConfig.intItemListingImageAlign is this.IMAGE_ALIGN.LEFT>class="hblistrht#roundedWidth#"<cfelse>class="hblistlft#roundedWidth#"</cfif>>
                                                </cfif>
                                          </cfif>
                                          <cfset infoList = ''>                                                                                                
                                          <cfif qryConfig.blnDate is 1 AND isDate(dtDate)><cfset infoList = infoList & '<li>#DateFormat(dtDate, 'mmmm dd, yyyy')#</li>'></cfif>
                                          <cfif qryConfig.blnAddress is 1>
                                                <cfset addressLine1 = ''>
                                                <cfset addressLine2 = ''>
                                                <cfset addressLine1 = addressLine1 & '#txtAddress#'>
                                                <cfif Len(Trim(txtCity))><cfset addressLine2 = addressLine2 & '#txtCity#,'></cfif>
                                                <cfif Len(Trim(txtProvince))><cfset addressLine2 = addressLine2 & ' #txtProvince#,'></cfif>
                                                <cfif Len(Trim(txtPostalCode))><cfset addressLine2 = addressLine2 & ' #txtPostalCode#'></cfif>
                                                <cfset addressLine2 = addressLine2 & ' #txtCountry#'>
                                                <cfif Len(Trim(addressLine1))><cfset infoList = infoList & '<li>#addressLine1#</li>'></cfif>
                                                <cfif Len(Trim(addressLine2))><cfset infoList = infoList & '<li>#addressLine2#</li>'></cfif>
                                          </cfif>
                                          <cfif qryConfig.blnPhone is 1 AND Len(Trim(txtPhone))><cfset infoList = infoList & '<li>Phone: #txtPhone#</li>'></cfif>
                                          <cfif qryConfig.blnFax is 1 AND Len(Trim(txtFax))><cfset infoList = infoList & '<li>Fax: #txtFax#</li>'></cfif>
                                          <cfif qryConfig.blnPhone is 1 AND Len(Trim(txtTollFree))><cfset infoList = infoList & '<li>Toll-Free: #txtTollFree#</li>'></cfif>
                                          <cfif qryConfig.blnEmail is 1 AND Len(Trim(txtEmail))><cfset infoList = infoList & '<li>Email: <a href="mailto:#txtEmail#">#txtEmail#</a></li>'></cfif>
                                          <cfif qryConfig.blnLink is 1 AND Len(Trim(txtLink))>
                                                <cfif REFindNoCase("http[s]://",txtLink)>
                                                      <cfset txtItemLink = txtLink>
                                                <cfelse>
                                                      <cfset txtItemLink = "http://#txtLink#">
                                                </cfif>
                                                <cfset infoList = infoList & '<li><a href="#txtItemLink#" target="_blank">#txtLink#</a></li>'>
                                          </cfif>
                                          <cfif Len(Trim(infoList))>
                                                <ul>
                                                      #infoList#                                                      
                                                </ul>
                                          </cfif>
                                          <!--- convertTokens() --->
                                          #this.workflow.convertTokens(txtDescription,false,this.webid)#
                                          <!--- Donny: missing url parameter
                                          <p><a href="#SCRIPT_NAME###item0">Back to top</a></p> --->
                                          
                                          <cfstoredproc procedure="getCourseDesc" datasource="#this.datasource#">
                              <cfprocresult name="getCourseDesc">
                              <cfprocparam cfsqltype="cf_sql_varchar" type="in" value="07-08">
                              <cfprocparam cfsqltype="cf_sql_integer" type="in" value="#qryItems.intcourseid#">
                              </cfstoredproc>
                              
                              <cfstoredproc procedure="getPreqList" datasource="#this.datasource#">
                              <cfprocresult name="getPreqList">
                              <cfprocparam cfsqltype="cf_sql_integer" type="in" value="#qryItems.intcourseid#">
                              </cfstoredproc>
                              
                              
                                    <cfif getcoursedesc.coursedescription neq ""><p>#getcoursedesc.coursedescription# </p></cfif>
                                    <cfif getcoursedesc.catalognotes neq ""><p>#getcoursedesc.catalognotes#</p></cfif>
                              
                              
                              <cfif getPreqList.recordcount neq 0>
                              <p><em>Prerequisite(s):</em>
                              <cfloop query="getPreqList">
                                    <cfif #preq_flag# eq "C">
                                          #left(CourseNumber,3)#.#right(CourseNumber,3)# #CourseTitle#<cfif #Currentrow# lt #Recordcount#>,<cfelse>.</cfif>
                                    <cfelse>
                                          &nbsp;#lstPrerequisitesID#&nbsp;
                                    </cfif>            
                              </cfloop></p>
                              </cfif>
                              
                                    <cfif qryItems.blnCCSSLink eq "1">
                               <p><img src="/images/CCSSicon.gif" title="See When This Course is Offered" alt="See When This Course is Offered" border="0"> <a href="/courseschedule/index.cfm?action=search&coursenumberlookup=#getcoursedesc.coursenumber###courselist" target="_blank">See when this course is offered (opens a new browser window)</a></p>
                              </cfif>
                                          
                                          <p><a href="#SCRIPT_NAME#<cfif Len(Trim(QUERY_STRING))>?#QUERY_STRING#</cfif>##item0">Back to top</a></p>
                                          <div class="clr">&nbsp;</div>
                                          <cfif qryConfig.blnImage is 1 AND qryConfig.blnItemListingImage is 1 AND qryConfig.blnItemListingImageWrap is 0>
                                                </div>
                                          </cfif>
                                          </div>
                                    </li>
                              </cfoutput>
                              </ul>
                              <cfset count = count + qryItems.recordCount>
                        </cfloop>
                        </div>
                  </cfif>
            </cfsavecontent>
            
            <cfreturn listingOutput />
      </cffunction>
      <!--- /getAnchoredListing --->      
      <!--- output the details of specified item in the front end --->
      <cffunction name="getItemDetail" access="private" returntype="string" output="false">
            <cfargument name="qryConfig" type="query" required="true">
            <cfargument name="qryItem" type="query" required="true">            

            <cfset var detailOutput = ''>
            <cfset var txtItemLink = ''>
            <!--- Login redirect to login page --->
            <cfset var loginLink = this.loginURL>
            
            <cfif qryConfig.blnSecurityEnabled is 1 AND qryItem.recordCount AND qryItem.blnPrivate is 1>
                  <cfif NOT (isDefined("SESSION.loggedIn") AND SESSION['loggedIn']) AND Len(Trim(loginLink))>
                  
                        <cfset loginLink = loginLink & '?wid=#this.webid#'>
                        <cfif isDefined("URL.c")>
                              <cfset loginLink = loginLink & '&cid=#URL.c#'>
                        </cfif>
                        <cfset loginLink = loginLink & '&iid=#qryItem.intItemID#'>
                        <cflocation url="#loginLink#" addtoken="no">
                  </cfif>                  
            </cfif>
            
            <cfsavecontent variable="detailOutput">
                  <cfif qryItem.recordCount is 0>
                        <p>The item is not found.</p>
                  <cfelse>
                        <div id="hbdetmod">
                              <cfoutput query="qryItem" maxrows="1">
                                    <!--- <h5>#txtTitle#<cfif blnPrivate> #this.PRIVATE_IMAGE#</cfif></h5> --->
                                    <cfif blnPrivate> #this.PRIVATE_IMAGE#</cfif>
                                    <cfset infoList = ''>                                                                                                
                                    <cfif qryConfig.blnDate is 1 AND isDate(dtDate)><cfset infoList = infoList & '<li>#DateFormat(dtDate, 'mmmm dd, yyyy')#</li>'></cfif>
                                    <cfif qryConfig.blnAddress is 1>
                                          <cfset addressLine = ''>
                                          <cfset addressLine = addressLine & '#txtAddress#'>
                                          <cfif Len(Trim(txtCity))><cfset addressLine = addressLine & ' #txtCity#,'></cfif>
                                          <cfif Len(Trim(txtProvince))><cfset addressLine = addressLine & ' #txtProvince#,'></cfif>
                                          <cfif Len(Trim(txtPostalCode))><cfset addressLine = addressLine & ' #txtPostalCode#'></cfif>
                                          <cfset addressLine = addressLine & ' #txtCountry#'>
                                          <cfif Len(Trim(addressLine))><cfset infoList = infoList & '<li>#addressLine#</li>'></cfif>
                                    </cfif>
                                    <cfif qryConfig.blnPhone is 1 AND Len(Trim(txtPhone))><cfset infoList = infoList & '<li>Phone: #txtPhone#</li>'></cfif>
                                    <cfif qryConfig.blnFax is 1 AND Len(Trim(txtFax))><cfset infoList = infoList & '<li>Fax: #txtFax#</li>'></cfif>
                                    <cfif qryConfig.blnPhone is 1 AND Len(Trim(txtTollFree))><cfset infoList = infoList & '<li>Toll-Free: #txtTollFree#</li>'></cfif>
                                    <cfif qryConfig.blnEmail is 1 AND Len(Trim(txtEmail))><cfset infoList = infoList & '<li>Email: <a href="mailto:#txtEmail#">#txtEmail#</a></li>'></cfif>
                                    <cfif qryConfig.blnLink is 1 AND Len(Trim(txtLink))>
                                          <cfif REFindNoCase("http[s]://",txtLink)>
                                                <cfset txtItemLink = txtLink>
                                          <cfelse>
                                                <cfset txtItemLink = "http://#txtLink#">
                                          </cfif>
                                          <cfset infoList = infoList & '<li><a href="#txtItemLink#" target="_blank">#txtLink#</a></li>'>
                                    </cfif>
                                    <cfif Len(Trim(infoList))>
                                          <ul>
                                                #infoList#                                                      
                                          </ul>
                                    </cfif>
                                    <cfif qryConfig.blnImage is 1 AND qryConfig.blnItemDetailImage is 1 AND Val(intImageID)><img src="#this.media.getURL(intImageID,Val(qryConfig.intItemDetailImageWidth),Val(qryConfig.intItemDetailImageHeight))#"  border="0" <cfif qryConfig.intItemDetailImageAlign is this.IMAGE_ALIGN.LEFT>class="hbdetlft"<cfelseif qryConfig.intItemDetailImageAlign is this.IMAGE_ALIGN.RIGHT>class="hbdetrht"<cfelse>class="hbdetinl"</cfif> /></cfif>
                                    <!--- convertTokens() --->
                                    <p>#this.workflow.convertTokens(txtDescription,false,this.webid)#</p>                              
                                    <cfif qryConfig.blnResource is 1>
                                          <cfset addlResources = this.media.getAdditionalResources(Val(intResourceID))>                                           
                                          <cfif ArrayLen(addlResources)>
                                          <br/>
                                          <strong>#qryConfig.txtItemDetailResourceCaption#:</strong><br />
                                          <ul>
                                                <cfloop from="1" to="#ArrayLen(addlResources)#" index="i">
                                                      <li><a href="#addlResources[i].link#" <cfif addlResources[i].blnNewWindow>target="_blank"</cfif>><img src="images/#addlResources[i].icon#" width="18" height="18" border="0" alt=""></a> <a href="#addlResources[i].link#" target="_blank">#addlResources[i].title#</a><cfif val(addlResources[i].filesize)> [#round(addlResources[i].filesize / 1024)# kb]</cfif> </li>
                                                </cfloop>
                                          </ul>
                                          </cfif>
                                    </cfif>      
                              </cfoutput>
                        </div>
                  </cfif>
            </cfsavecontent>
            
            <cfreturn detailOutput />
      </cffunction>
      <!--- /getItemDetail --->
      
      <cffunction name="roundImageWidth" access="private" returntype="numeric" output="false">
            <cfargument name="width" type="numeric" required="true">
            <cfset var w75 = 75>
            <cfset var w150 = 150>
            <cfset var w225 = 225>
            <cfset var w300 = 300>
            
            <cfif width lte w75>
                  <cfreturn w75 />
            <cfelseif width lte w150>
                  <cfreturn w150 />
            <cfelseif width lte w225>
                  <cfreturn w225 />
            <cfelse>
                  <cfreturn w300 />
            </cfif>            
      </cffunction>

      <!--- Hot Banana Console tabs --->
      <cffunction name="getTabs" access="public" returntype="any">
            <cfxml variable="xmlNav">
                  <cfoutput>
                        <item>
                              <item caption="#XMLFormat(translate(this.formData.itemsname))#" id="#this.DATATYPES.ITEM#"/>
                              <cfif this.formData.blnCategory>
                                    <item caption="#XMLFormat(translate('Categories'))#" id="#this.DATATYPES.CATEGORY#"/>
                              </cfif>
                              <item caption="#XMLFormat(translate('Config'))#" id="#this.DATATYPES.CONFIG#"/>
                        </item>
                  </cfoutput>
            </cfxml>
            
            <cfreturn xmlNav />
      </cffunction>

      <!--- returns hotbanana back end interface --->
      <cffunction name="getBackEnd" access="public" returntype="string">
            <cfset this.workflow.verifyColumns(this.catData)>
            <cfset this.workflow.verifyColumns(this.formData)>
            <cfset this.workflow.verifyColumns(this.listData)>
            <cfset this.workflow.verifyColumns(this.roleData)>
                  
            <cfif (this.datatype is this.DATATYPES.CATEGORY)>
                  <cfreturn getCategoryBackEnd()>
            <cfelseif (this.datatype is this.DATATYPES.ITEM)>
                  <cfreturn getItemBackEnd()>
            <cfelse>
                  <cfreturn getConfigBackEnd()>
            </cfif>
      </cffunction>

      <!--- returns hotbanana back end of the categories tab --->
      <cffunction name="getCategoryBackEnd" access="private" returntype="string">      
            <cfparam name="txtTitle" default="">
            
            <cfquery name="qryNavCategoryOrder" datasource="#this.datasource#">
                  UPDATE       tblNavigation
                  SET            tblNavigation.intOrder =
                        (SELECT tblItem.intOrder
                         FROM       tblItem
                         LEFT JOIN tblCourseListingCategory
                         ON       tblItem.intID = tblCourseListingCategory.intItemID
                         AND       tblCourseListingCategory.blnLive = 1
                         WHERE       intDatatype = #this.DATATYPES.CATEGORY#
                         AND       intWebID = #this.webid#
                         AND       tblNavigation.intID = tblCourseListingCategory.intCategoryID)
                  WHERE       intParentID = #this.webid#
                  AND       blnCategory = 1
                  AND       blnDeleted = 0
            </cfquery>

            <cfif isDefined("FORM.button")>
                  <!--- <cfif (NOT isDefined("FORM.intCategoryID"))>
                        <cfset qryCategory = selectFrom(this.workflow.getQuery(this.catData), "intItemID", FORM.id)>
                        <cfset FORM.intCategoryID = qryCategory.intCategoryID>
                  </cfif> --->

                  <cfif FORM.button is translate("Delete")>
                        <!--- <cfset FORM.intCategoryID = val(FORM.intCategoryID)> --->
                        <cfset this.category.deleteCategory(val(FORM.intCategoryID))>
                        <cfset this.display.setActionMsg(this.workflow.processForm(this.catData))>
                  <cfelseif FORM.button is translate("Restore")>
                        <cfset this.category.restoreCategory(val(FORM.intCategoryID))>
                        <cfset this.display.setActionMsg(this.workflow.processForm(this.catData))>
                  <cfelse>
                        <cfif (isDefined("FORM.intCategoryID") AND FORM.intCategoryID gt 0)>
                              <!---  we need to see if the category was approved before we set the actual category title --->
                              <cfset this.display.setActionMsg(this.workflow.processForm(this.catData))>
                              <cfset qryCategory = selectFrom(this.workflow.getQuery(this.catData), "intItemID", FORM.id)>
                              <cfif (NOT isDefined("qryCategory.blnApproved")) or (qryCategory.blnApproved is 1)>
                                    <cfset this.category.updateCategory(FORM.intCategoryID,qryCategory.txtTitle)>
                              </cfif>
                        <cfelse>
                              <cfset FORM.intCategoryID = this.category.addCategory(this.webid,txtTitle)>
                              <cfset this.display.setActionMsg(this.workflow.processForm(this.catData))>
                        </cfif>
                  </cfif>
            </cfif>

            <!--- <cfset this.formData.query = this.workflow.getQuery(this.formData)> --->

            <cfset qryRecords = this.workflow.getQuery(this.catData)>
            <!--- <cfset qryRecords = getCategoryQuery()> --->            

            <!--- <cfset qryPublic = this.workflow.getPublicQuery(this.formData)> --->
            <cfset qryPublic = getItemQuery(qryConfig,false)>
            <cfset extraColumn = ArrayNew(1)>

            <!--- Donny's note: caculate no. of item for each category --->
            <cfoutput query="qryRecords">
                  <cfquery name="qryItemCount" dbtype="query">
                        SELECT DISTINCT intItemID
                        FROM       qryPublic
                        WHERE       intCategoryID = #Val(qryRecords.intCategoryID)#
                  </cfquery>
                  <cfset count = qryItemCount.recordcount>
                  <cfset ArrayAppend(extraColumn, count)>
                  <cfset this.category.setActive(qryRecords.intCategoryID, (count GT 0))>
            </cfoutput>
            
            <cfset QueryAddColumn(qryRecords, "numRecords", extraColumn)>
            <cfset this.catData.query = qryRecords>

            <cfif (isDefined("mode") and mode is "edit")>
                  <!--- disable delete if there are associated items to this category --->
                  <cfif isDefined("id") and Val(id)>
                        <cfset extraValue = selectFrom(qryRecords, "intItemID", id).numRecords>
                        <cfif (extraValue gt 0)>
                              <cfset this.catData.blnDelete = false>
                        </cfif>
                  </cfif>
                  <cfreturn this.display.getAddEdit(this.catData)>
            </cfif>

            <cfreturn this.display.getListing(this.catData,"txtTitle","Category","numRecords","Items",this.link)>
      </cffunction>
      <!--- /getCategoryBackEnd --->

      <!--- executes scheduled task --->
      <cffunction name="runTask" access="public" output="false">
            <cfargument name="itemid" type="numeric" required="true">
            <cfargument name="itemuid" type="string" required="true">
            <cfargument name="listIds" type="string" required="true">
                        
            <cffile action="delete" file="#this.qryCompany.txtPath##this.slash#tasks#this.slash#UListingNotification_#arguments.itemuid#.cfm">
            <cfschedule action="delete" task="#this.datasource#_#this.companyID#_UListingNotification_#arguments.itemuid#">            
            
            <cfset sendNotification(itemid,listIds)>
      </cffunction>
      
      <!--- schedule a task that will send the communication out --->      
      <cffunction name="scheduleTask" access="private" output="false">            
            <cfargument name="itemid" type="numeric" required="true">
            <cfset var startDateTime = ''>
            <cfset var listIds = ''>
            
            <cfquery name="qryItem" datasource="#this.datasource#" maxrows="1">
                  SELECT       TOP 1 intID, intUID, dtStart, dtEnd, blnLive
                  FROM       #this.formData.tablename#
                  WHERE       intID = <cfqueryparam value="#itemid#" cfsqltype="cf_sql_integer">
            </cfquery>      
            
            <cfquery name="qryNotificationLists" datasource="#this.datasource#" maxrows="1">
                  SELECT       TOP 1 intListID
                  FROM       #this.listData.tablename#
                  WHERE       intItemID = <cfqueryparam value="#itemID#" cfsqltype="cf_sql_integer">
                  AND            intCompanyID = <cfqueryparam value="#this.companyID#" cfsqltype="cf_sql_integer">
            </cfquery>
                                    
            <cfif qryItem.recordCount is 0 OR Val(qryItem.blnLive) is 0 OR qryNotificationLists.recordCount is 0>
                  <cfreturn "Schedule failed">
            </cfif>      
            <cfset startDateTime = qryItem.dtStart>
            <cfset listIds = ValueList(qryNotificationLists.intListID)>
            <cfif NOT isDate(startDateTime) OR DateDiff("n", startDateTime, now()) GTE 0>                  
                  <cfset sendNotification(itemid,listIds)>
                  <cfreturn "Task run">                  
            </cfif>
      
            <cfset itemuid = qryItem.intUID>
                                    
            <cfset taskcfm = '<cfset createObject("component","hb50.internal.ulisting").init(#this.CompanyID#,#this.webid#,0).runTask(#itemid#,"#itemuid#","#listIds#")>'>            
            
            <cfif not DirectoryExists('#this.qryCompany.txtPath##this.slash#tasks')>
                  <cfdirectory action="create" directory="#this.qryCompany.txtPath##this.slash#tasks" mode="775">
            </cfif>
            <cffile action="write" file="#this.qryCompany.txtPath##this.slash#tasks#this.slash#UListingNotification_#itemuid#.cfm" output="#taskcfm#" mode="775">
            <cfschedule action="update" task="#this.datasource#_#this.companyID#_UListingNotification_#itemuid#" operation="httprequest"
                              startDate="#DateFormat(startDateTime, 'mm/dd/yyyy')#" startTime="#TimeFormat(startDateTime, 'hh:mm tt')#" interval="Once"
                              url="#this.qryCompany.txtWeb#/tasks/UListingNotification_#itemuid#.cfm?requestTimeout=10000">
                        
            <cfreturn "Task scheduling OK">
      </cffunction>
      
      <cffunction name="sendNotification" access="private" returntype="any" output="false">
            <cfargument name="itemID" type="numeric" required="true">
            <cfargument name="listIds" type="string" required="true">
            
            <cfset var contactManager = getObject("hb50.plugins.generic.contactmanager",this.companyID,true)>
            <cfset var qryRecipients = contactManager.getRecipientsInLists(listIds)>
            <cfset var htmlBody = ''>
            <cfset var emailFooter = getEmailFooter()>
            <cfset var fromEmail = this.qryCompany.txtEmail>
            <cfset var toEmail = ''>
            <cfset var subject = "Update Notification">
            <cfset var qryItem = ''>
            <cfset var pageTitle = ''>
            <cfset var pageURL = ''>
            
            <cfif Len(Trim(listIds)) is 0>
                  <cfreturn 0 />
            </cfif>
                  
            <cfif qryRecipients.recordCount is 0>
                  <cfreturn 0 />
            </cfif>
                  
            <cfquery name="qryItem" datasource="#this.datasource#" maxrows="1">
                  SELECT      TOP 1 intItemID
                  FROM      #this.formData.tablename#
                  WHERE      intID = <cfqueryparam value="#val(arguments.itemID)#" cfsqltype="cf_sql_integer">
            </cfquery>
                  
            <cfset qryConfig = getConfigQuery()>
            
            <cfif Len(Trim(qryConfig.txtNotificationSubject))>
                  <cfset subject = qryConfig.txtNotificationSubject>
            </cfif>
            <cfif Len(Trim(qryConfig.txtNotificationFromEmail))>
                  <cfset fromEmail = qryConfig.txtNotificationFromEmail>
                  <cfif Len(Trim(qryConfig.txtNotificationFromName))>
                        <cfset fromEmail = '"#qryConfig.txtNotificationFromName#" <#fromEmail#>'>
                  </cfif>
            </cfif>            
                                    
            <cfset pageTitle = this.navigation.getCaption(this.webID)>
            <cfset pageURL = '#this.navigation.getURL(this.webID)#?i=#qryItem.intItemID#'>
            
            <cfsavecontent variable="htmlBody">
                  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
                  <html>
                  <head>
                  <title><cfoutput>#this.qryCompany.txtTitle# -  #subject#</cfoutput></title>
                  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
                  <style>
                        body {font:12px arial;}
                        a {color:#000000;}                              
                  </style>
                  <cfoutput>
                  <title>#subject#</title>
                  <script src="SpryAssets/SpryCollapsiblePanel.js" type="text/javascript"></script>
                  <link href="SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css">
                  </head>
                        
                  <body>
                  <div id="CollapsiblePanel2" class="CollapsiblePanel">
                    <div class="CollapsiblePanelTab" tabindex="0">Tab</div>
                    <div class="CollapsiblePanelContent">Content</div>
                </div>
                        <div id="CollapsiblePanel1" class="CollapsiblePanel">
                          <div class="CollapsiblePanelTab" tabindex="0">Tab</div>
                          <div class="CollapsiblePanelContent">Content</div>
                </div>                              
            #this.workflow.convertTokens(qryConfig.txtNotificationMessage)#<br/>
                        <a href="#pageURL#" target="_blank">#pageURL#</a><br/>
                        <p>#emailFooter#</p>
                      <script type="text/javascript">
<!--
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1");
var CollapsiblePanel2 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel2");
//-->
</script>
                  </body>
                  </html>
                  </cfoutput>
            </cfsavecontent>
                        
            <cfset communication = getObject("hb50.communication",this.companyID,true)>
                        
            <cfif Len(Trim(fromEmail))>                  
                  <cfloop query="qryRecipients">                        
                        <cfset toEmail = qryRecipients.txtEmail>
                        <cfif Len(Trim(toEmail))>
                              <cftry>
                              <cfset communication.sendTextHTML(toEmail,fromEmail,subject, htmlBody, "")>
                              <cfcatch></cfcatch>
                              </cftry>
                        </cfif>
                  </cfloop>                  
            </cfif>                        
      </cffunction>
      
      <cffunction name="getEmailFooter" access="private" returntype="string">
            <cfset emailFooter = '#this.qryCompany.txtTitle#<br/>Phone: #this.qryCompany.txtTelephone#<br/>Email: #this.qryCompany.txtEmail#'>
            <cftry>                              
                  <cfquery name="qryDisplaySettings" datasource="#this.datasource#" maxrows="1" cachedwithin="#this.queryCache#">
                        SELECT       TOP 1 intCompanyID, txtEmailFooter
                        FROM       tblDisplaySettings
                        WHERE       intCompanyID = #this.companyID#
                  </cfquery>
                  <cfset emailFooter = this.workflow.convertTokens(qryDisplaySettings.txtEmailFooter)>                              
                  <cfcatch></cfcatch>
            </cftry>
            
            <cfreturn emailFooter />
      </cffunction>
      
      
      <!--- returns hotbanana back end of the items tab --->
      <cffunction name="getItemBackEnd" access="private" returntype="string">
            <!--- <cfsetting showdebugoutput="yes"> --->            
            <cfset this.display.setActionMsg(this.workflow.processForm(this.formData))>            
            
            <cfif isDefined("FORM.intListIds") AND Len(Trim(FORM.intListIds))>
                  <cfquery name="qryItem" datasource="#this.datasource#" maxrows="1">                              
                        SELECT       TOP 1 intID, intUID, blnLive
                        FROM       #this.formData.tablename#
                        WHERE       intItemID = <cfqueryparam value="#Val(FORM.id)#" cfsqltype="cf_sql_integer">
                        ORDER BY dtAdded DESC
                  </cfquery>

                  <!--- notification list data --->
                  <cfif qryItem.recordCount AND isDefined("FORM.intListIds") AND Len(Trim(FORM.intListIds))>
                        <cfloop list="#FORM.intListIds#" index="idx">
                              <cfquery name="qryAddList" datasource="#this.datasource#">
                                    INSERT INTO #this.listData.tablename#
                                          (intItemID,intListID,intCompanyID)
                                    VALUES (
                                          <cfqueryparam value="#qryItem.intID#" cfsqltype="cf_sql_integer">,
                                          <cfqueryparam value="#idx#" cfsqltype="cf_sql_integer">,
                                          <cfqueryparam value="#this.companyID#" cfsqltype="cf_sql_integer">)
                              </cfquery>
                        </cfloop>
                  </cfif>
                  
                  <cfif FORM.button is Translate("Check in")>
                        <cfif isDefined("FORM.blnNotification")  AND Val(qryItem.blnLive)>                                    
                              <cfset scheduleTask(Val(qryItem.intID))>
                        </cfif>                              
                  <cfelse>                                                            
                        <cfif fileexists("#this.qryCompany.txtPath##this.slash#tasks#this.slash#UListingNotification_#qryItem.intUID#.cfm")>
                              <cffile action="delete" file="#this.qryCompany.txtPath##this.slash#tasks#this.slash#UListingNotification_#qryItem.intUID#.cfm">
                              <cfschedule action="delete" task="#this.datasource#_#this.companyID#_UListingNotification_#qryItem.intUID#">
                        </cfif>
                  </cfif>                        
            </cfif>
            
            <cfif isDefined("FORM.button") AND FORM.button is Translate("Approve") AND isDefined("FORM.id") AND Val(FORM.id)>
                  <cftrace text="U Listing: Approved items"/>
                  <cfquery name="qryApprovedItem" datasource="#this.datasource#" maxrows="1">
                        SELECT       TOP 1 blnNotification, intID, intUID
                        FROM       #this.formData.tablename#
                        WHERE       intItemID = <cfqueryparam value="#Val(FORM.id)#" cfsqltype="cf_sql_integer">
                        AND            blnLive = <cfqueryparam value="1" cfsqltype="cf_sql_bit">
                        ORDER BY dtAdded DESC
                  </cfquery>
                  <cfif qryApprovedItem.recordCount AND qryApprovedItem.blnNotification is 1>
                        <cfquery name="qryNotificationLists" datasource="#this.datasource#" maxrows="1">
                              SELECT       TOP 1 intListID
                              FROM       #this.listData.tablename#
                              WHERE       intItemID = <cfqueryparam value="#qryApprovedItem.intID#" cfsqltype="cf_sql_integer">
                              AND            intCompanyID = <cfqueryparam value="#this.companyID#" cfsqltype="cf_sql_integer">  
                        </cfquery>
                        <cfif qryNotificationLists.recordCount>
                              <cftrace text="U Listing: schedule notification task for approved item"/>
                              <cfset scheduleTask(qryApprovedItem.intID)>
                        <cfelse>                        
                              <cfif fileexists("#this.qryCompany.txtPath##this.slash#tasks#this.slash#UListingNotification_#qryApprovedItem.intUID#.cfm")>
                                    <cftrace text="U Listing: remove scheduled task for approved item"/>
                                    <cffile action="delete" file="#this.qryCompany.txtPath##this.slash#tasks#this.slash#UListingNotification_#qryApprovedItem.intUID#.cfm">
                                    <cfschedule action="delete" task="#this.datasource#_#this.companyID#_UListingNotification_#qryApprovedItem.intUID#">
                              </cfif>
                        </cfif>
                  </cfif>
            </cfif>
            
            <cfset this.formData.query = getQuery()>

            <!--- check if category should be active after every save --->
            <cfif isDefined("FORM.intCategoryID") AND Val(FORM.intCategoryID)>
                  <!--- <cfset qryRecords = this.workflow.getQuery(this.catData)> --->
                  <!--- <cfset qryPublic = this.workflow.getPublicQuery(this.formData)> --->
                  <cfset qryRecords = getCategoryQuery()>
                  <cfset qryPublic = getItemQuery(qryConfig,true)>
                  <cfoutput query="qryRecords">
                        <cfquery name="qryItemCount" dbtype="query">
                              SELECT DISTINCT intItemID
                              FROM       qryPublic
                              WHERE       intCategoryID = #Val(qryRecords.intCategoryID)#
                        </cfquery>
                        <cfset count = qryItemCount.recordcount>
                        <cfset this.category.setActive(qryRecords.intCategoryID, (count GT 0))>
                  </cfoutput>
            </cfif>
            
            <cfif isDefined("URL.id") AND Val(URL.id)>
                  <cfset FORM.id = URL.id>
            </cfif>
            
            <cfif (isSet("mode", "edit"))>
                  <cfif this.formData.notificationTabIndex GT 0>
                        <cfset this.contactManager = getObject("hb50.plugins.generic.contactmanager",this.companyID,true)>
                        <cftry>
                              <cfset qryLists = this.contactManager.getListQuery()>
                        <cfcatch><cfset qryLists = QueryNew("intID,txtTitle")></cfcatch>
                        </cftry>
                        
                        <cfset listingLists = "">
                        <cfif isDefined("FORM.id") and Val(FORM.id)>
                              <!--- version stuff --->
                              <cfquery name="qryVersion" datasource="#this.datasource#">
                                    SELECT       UL.intID, UL.blnNotification, UL.intItemID, UL.blnLive<!--- , tblItem.blnDeleted, tblItem.blnApproved --->
                                    FROM       #this.formData.tablename# AS UL
                                    LEFT JOIN tblItem ON tblItem.intID = UL.intItemID
                                    WHERE       UL.intItemID = <cfqueryparam value="#Val(FORM.id)#" cfsqltype="cf_sql_integer">
                                    ORDER BY UL.blnLive DESC, UL.dtAdded DESC
                              </cfquery>
                              <cfparam name="FORM.intVersionID" default="#qryVersion.intID#">
                              <!--- <cfquery name="qryVersion" dbtype="query">
                                    SELECT       *
                                    FROM       qryVersion
                                    ORDER BY blnLive DESC, dtAdded DESC
                              </cfquery> --->
                                                
                              <cfset qryListingItem = selectFrom(qryVersion, this.formData.varID, val(FORM.intVersionID))>
                              <cfquery name="qryListingLists" datasource="#this.datasource#">
                                    SELECT       intListID
                                    FROM       #this.listData.tablename#
                                    WHERE       intItemID = <cfqueryparam value="#Val(qryListingItem.intID)#" cfsqltype="cf_sql_integer">
                                    AND       intCompanyID = <cfqueryparam value="#this.companyID#" cfsqltype="cf_sql_integer">
                              </cfquery>
                              <cfset listingLists = ValueList(qryListingLists.intListID)>
                        </cfif>
                                                            
                        <cfsavecontent variable="notificationTab">
                              <cfoutput>
                              <script language="JavaScript" type="text/javascript">
                              function jsAddContactList() {
                                    if (document.frmAddEdit.intListIds.selectedIndex != 0) {
                                          return false;
                                    }
                                    jsPopup('addContactList','callback=jsUpdateListSelect');
                                    return false;                                    
                              }
                              function jsUpdateListSelect(listID, listTitle) {
                                    var size = document.frmAddEdit.intListIds.options.length;
                                    document.frmAddEdit.intListIds.options[size] = new Option(listTitle, listID);
                                    document.frmAddEdit.intListIds.selectedIndex = size;
                              }
                                                            
                              function jsViewRecipients() {
                                    if (document.frmAddEdit.intListIds.selectedIndex <= 0) {
                                          alert("Please select a list.");
                                          return;
                                    }
                                    var form = document.frmAddEdit;
                                    var tempAction = form.action;
                                    window.open('', 'recipientsWindow', 'height=450,width=350,innerHeight=200,innerWidth=250,location=no,menubar=no,resizable=yes,titlebar=yes,toolbar=no,scrollbars=yes');
                                    form.action = '#this.qryCompany.txtHBWeb#/popup/viewRecipientsInLists.cfm';
                                    form.target = 'recipientsWindow';
                                    form.submit();
                                    form.action = tempAction;
                                    form.target = '';
                              }
                              
                              function jsExtraValidate() {
                                    if (document.frmAddEdit.blnNotification.checked) {
                                          if (!confirm('Notification will be sent, continue?')) {
                                                return false;
                                          }                                          
                                    }
                                    return true;
                              }
                              var submitted = false;
                              function jsPreSubmit() {                                          
                                    var valid = jsValidate() && jsExtraValidate();
                                    if (valid) {
                                          if (submitted) return false;
                                          submitted = true;
                                          document.body.onbeforeunload = null;
                                    }
                                    return valid;
                              }
                              document.frmAddEdit.onsubmit = jsPreSubmit;
                              </script>      
                              <div id="blnNotification"></div>                        
                              <div style="padding:10px;">
                                    <fieldset>
                                    <legend><input type="checkbox" name="blnNotification" <cfif isDefined("qryListingItem") AND qryListingItem.blnNotification is 1>checked</cfif>> Send Notification </legend>
                                    <table cellpadding="5">
                                          <tr>
                                                <td class="formCaption">List: <br />
                                                      <select name="intListIds" class="formTextBox" style="width:235px;height:150px;" multiple="true" onchange="jsAddContactList();">
                                                            <option value="-1">Add a new list</option>
                                                            <cfloop query="qryLists">
                                                                  <option value="#qryLists.intID#" <cfif ListFind(listingLists,qryLists.intID)>selected</cfif>>#qryLists.txtTitle#</option>
                                                            </cfloop>
                                                      </select><br />
                                                      <input type="button" onclick="jsViewRecipients();" class="buttons" value="View Recipients" style="width:110px;">                                                      
                                                </td>
                                          </tr>
                                    </table>
                                    </fieldset>
                              </div>
                              </cfoutput>
                        </cfsavecontent>      
                        <cfset this.formData.tabs[this.formData.notificationTabIndex].body = notificationTab>
                  </cfif>
                  
                  <cfreturn this.display.getAddEdit(this.formData) />
            </cfif>
            
            <!--- if nothing else has been returned, return the generic listing --->
            <cfreturn this.display.getListing(this.formData,"txtTitle","Item","dtAdded","Saved",this.link) />
      </cffunction>
      <!--- /getItemBackEnd --->

      <!--- returns hotbanana back end of the config tab --->
      <cffunction name="getConfigBackEnd" access="private" returntype="string">
            <cfif isDefined("FORM.button")>
                  <cfset FORM.intWebID = this.webid>
                  <cfset FORM.intCompanyID = this.companyID>
                              
                  <!--- let workflow take care of the button actions --->
                  <cfset this.display.setActionMsg(this.workflow.processForm(this.configData))>
                  
                  <!--- role stuff --->
                  <!--- <cfset qryOldRoles = getRoleQuery()>
                  <cfset oldRoles = ValueList(qryOldRoles.intRoleID)> --->
                  <cfset oldRoles = getListRoles()>
                  <cfset newRoles = ''>
                  <cfif isDefined("FORM.intRoleIDs") AND Len(Trim(FORM.intRoleIDs))>
                        <cfset newRoles = Trim(FORM.intRoleIDs)>
                        
                        <cfloop list="#newRoles#" index="roleID">
                              <cfset listIndex = ListFind(oldRoles,roleID)>
                              <cftrace text="newRoles = #newRoles# listIndex = #listIndex#"/>
                              
                              <!--- if new role in in old list --->
                              <cfif listIndex GT 0>
                                    <!--- remove the role from the old list --->
                                    <cfset oldRoles = ListDeleteAt(oldRoles,listIndex)>
                              <cfelse>
                                    <cftrace text="insert role"/>
                                    <cfquery name="qryAddRole" datasource="#this.datasource#">
                                          INSERT INTO #this.roleData.tablename#
                                                (intWebID, intCompanyID, intRoleID)
                                          VALUES (
                                                <cfqueryparam value="#this.webID#" cfsqltype="cf_sql_integer">,
                                                <cfqueryparam value="#this.companyID#" cfsqltype="cf_sql_integer">,
                                                <cfqueryparam value="#roleID#" cfsqltype="cf_sql_integer">)                                                
                                    </cfquery>
                              </cfif>
                        </cfloop>
                        <!--- delete an unmatched old roles from the db --->
                        <cfif Len(Trim(oldRoles))>
                              <cfquery name="qryDeleteRoles" datasource="#this.datasource#">
                                    DELETE FROM
                                          #this.roleData.tablename#
                                    WHERE       intWebID = <cfqueryparam value="#this.webID#" cfsqltype="cf_sql_integer">
                                    AND       intCompanyID= <cfqueryparam value="#this.companyID#" cfsqltype="cf_sql_integer">
                                    AND       intRoleID IN (<cfqueryparam value="#oldRoles#" list="true" cfsqltype="cf_sql_integer">)
                              </cfquery>
                        </cfif>
                  </cfif>
                              
                  <cfobjectcache action="clear" />
                  <cfcache action="flush">
            </cfif>
            
            <cfset this.workflow.verifyColumns(this.configData)>
            <cfset qryConfig = getConfigQuery()>
            <cfset this.configData.query = qryConfig>
            
            <cfsavecontent variable="tabTwo">
                  <script language="JavaScript" type="text/javascript">
                        function jsPositiveNumber(theItem,msg,tab) {
                              if (!theItem.value) {
                                    jsTabSwitch(tab);
                                    alert(msg);
                                    return false;
                              }
                              if (isNaN(theItem.value) || Number(theItem.value) <= 0) {
                                    jsTabSwitch(tab);
                                    alert(msg);
                                    return false;
                              }
                              return true;
                        }
                        function jsExtraValidate() {                              
                              var form = document.frmAddEdit;                              
                              if (!form.blnImage.checked && (form.blnItemListingImage.checked || form.blnItemDetailImage.checked)) {
                                    form.blnItemListingImage.checked = false;
                                    form.blnItemDetailImage.checked = false;
                              }
                              if (form.blnCategoryListing.checked) {                                    
                                    if (form.blnCategoryPagination.checked && !jsPositiveNumber(form.intCategoryDisplayItems,'Number of items to diplay is not valid.',2)) {
                                          return false;
                                    }                                    
                                    if (form.blnCategoryImage.checked && 
                                                (!jsPositiveNumber(form.intCategoryImageWidth,'Image Width is not valid.',2) || !jsPositiveNumber(form.intCategoryImageHeight,'Image Height is not valid.',2) ) ) {
                                          return false;
                                    }
                              }
                              if (form.blnItemListingDescription.checked && !jsPositiveNumber(form.intItemListingDescriptionLength,'Description length is not valid.',3)) {
                                    return false;
                              }
                              if (form.blnItemListingPagination.checked && !jsPositiveNumber(form.intItemListingDisplayItems,'Number of items to display is not valid.',3)) {
                                    return false;
                              }
                              if (form.blnItemListingImage.checked && 
                                    (!jsPositiveNumber(form.intItemListingImageWidth,'Image width is not valid.',3) || !jsPositiveNumber(form.intItemListingImageHeight, 'Image height is not valid.',3) ) ) {
                                    return false;
                              }
                              if (form.blnItemDetailResource.checked && !form.txtItemDetailResourceCaption.value) {
                                    jsTabSwitch(4);
                                    alert('Related information caption is required.');
                                    return false;
                              }
                              if (form.blnItemDetailImage.checked && 
                                           (!jsPositiveNumber(form.intItemDetailImageWidth, 'Image width is not valid.', 4) || !jsPositiveNumber(form.intItemDetailImageHeight, 'Image height is not valid.',4)) ) {
                                    return false;
                              }
                              if (form.blnNotification.checked) {
                                    if (!form.txtNotificationFromEmail.value) {
                                          jsTabSwitch(5);
                                          alert('From Email is required.');
                                          return false;
                                    }
                                    if (!form.txtNotificationSubject.value) {
                                          jsTabSwitch(5);
                                          alert('Notification Subject is required.');
                                          return false;
                                    }
                              }
                              return true;
                        }
                        
                        var submitted = false;
                        function jsPreSubmit() {                                          
                              var valid = jsExtraValidate();
                              if (valid) {
                                    if (submitted) return false;
                                    submitted = true;
                                    document.body.onbeforeunload = null;
                              }
                              return valid;
                        }
                        document.frmAddEdit.onsubmit = jsPreSubmit;
                  </script>
                  
                  <cfoutput>
                        <div id="blnCategoryListing"></div>
                        <div id="blnCategoryPageContent"></div>
                        <div id="blnCategoryDescription"></div>
                        <div id="blnCategorySearch"></div>
                        <div id="blnCategoryPagination"></div>
                        <div id="blnCategoryPagination"></div>
                        <div id="blnCategoryImage"></div>
                        <div id="intCategoryDisplayItems"></div>                  
                        <div id="intCategoryImageWidth"></div>
                        <div id="intCategoryImageHeight"></div>
                        <div id="intCategoryImageAlign"></div>
                        <div id="blnCategoryImageWrap"></div>
                        <div id="intCategoryLayoutType"></div>
                        
                        <div style="padding:10px;" class="formCaption">
                              <fieldset>
                                    <legend><input type="checkBox" name="blnCategoryListing" <cfif qryConfig.blnCategoryListing is 1>checked</cfif>> Category Listing &nbsp; </legend>
                                    <table width="100%" cellspacing="0" cellpadding="7" border="0">
                                          <tr>
                                                <td class="formCaption">
                                                      &nbsp;<input type="checkbox" name="blnCategoryPageContent" <cfif qryConfig.blnCategoryPageContent is 1>checked</cfif>> Show Page Content &nbsp;&nbsp;&nbsp;
                                                      <input type="checkbox" name="blnCategoryDescription" <cfif qryConfig.blnCategoryDescription is 1>checked</cfif>> Show Description &nbsp;&nbsp;&nbsp;                                                
                                                      <input type="checkbox" name="blnCategorySearch" <cfif qryConfig.blnCategorySearch is 1>checked</cfif>> Search Form
                                                </td>
                                          </tr>
                                          <tr>
                                                <td>
                                                      <fieldset>
                                                            <legend><input type="checkbox" name="blnCategoryPagination" <cfif qryConfig.blnCategoryPagination is 1>checked</cfif>> Pagination</legend>
                                                            <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                                                  <tr>
                                                                        <td class="formCaption"><input type="text" name="intCategoryDisplayItems" <cfif qryConfig.recordCount is 0>value="#this.MAX_ITEMS#"<cfelse>value="#qryConfig.intCategoryDisplayItems#"</cfif> class="formTextBox" style="width:70px;"> items to display</td>
                                                                  </tr>
                                                            </table>                                          
                                                      </fieldset>
                                                </td>                                                
                                          </tr>
                                          <tr>
                                                <td>
                                                      <fieldset>
                                                            <legend><input type="checkbox" name="blnCategoryImage" <cfif qryConfig.blnCategoryImage is 1>checked</cfif>> Category Image</legend>
                                                            <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                                                  <tr>
                                                                        <td class="formCaption">
                                                                              Width: <input type="text" name="intCategoryImageWidth" <cfif qryConfig.recordCount is 0>value="100"<cfelse>value="#qryConfig.intCategoryImageWidth#"</cfif> style="width:70px;" class="formTextBox"> &nbsp;&nbsp;&nbsp;
                                                                              Height: <input type="text" name="intCategoryImageHeight" <cfif qryConfig.recordCount is 0>value="100"<cfelse>value="#qryConfig.intCategoryImageHeight#"</cfif> style="width:70px;" class="formTextBox">
                                                                        </td>
                                                                        <td class="formCaption">
                                                                              <input type="checkbox" name="blnCategoryImageWrap" <cfif qryConfig.blnCategoryImageWrap is 1>checked</cfif>> Wrap Text
                                                                        </td>
                                                                  </tr>
                                                                  <tr>
                                                                        <td class="formCaption" colspan="2">
                                                                              Align: <input type="radio" name="intCategoryImageAlign" value="#this.IMAGE_ALIGN.LEFT#" <cfif qryConfig.intCategoryImageAlign is this.IMAGE_ALIGN.LEFT>checked</cfif>> Left
                                                                              &nbsp; <input type="radio" name="intCategoryImageAlign" value="#this.IMAGE_ALIGN.RIGHT#" <cfif qryConfig.intCategoryImageAlign is this.IMAGE_ALIGN.RIGHT OR qryConfig.recordCount is 0>checked</cfif>> Right
                                                                              &nbsp; <input type="radio" name="intCategoryImageAlign" value="#this.IMAGE_ALIGN.INLINE#" <cfif qryConfig.intCategoryImageAlign is this.IMAGE_ALIGN.INLINE>checked</cfif>> Inline                                                                        
                                                                        </td>
                                                                  </tr>
                                                            </table>
                                                      </fieldset>
                                                </td>
                                          </tr>
                                          <tr>
                                                <td>
                                                      <fieldset>
                                                            <legend>Layout</legend>
                                                            <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                                                  <tr>
                                                                        <td class="formCaption">
                                                                              <input type="radio" name="intCategoryLayoutType" value="#this.COLUMN_LAYOUT.SINGLE#" <cfif qryConfig.intCategoryLayoutType is this.COLUMN_LAYOUT.SINGLE OR qryConfig.recordCount is 0>checked</cfif>> Single Column
                                                                              &nbsp;&nbsp;&nbsp; <input type="radio" name="intCategoryLayoutType" value="#this.COLUMN_LAYOUT.DOUBLE#" <cfif qryConfig.intCategoryLayoutType is this.COLUMN_LAYOUT.DOUBLE>checked</cfif>> Double Column
                                                                        </td>
                                                                  </tr>
                                                            </table>
                                                      </fieldset>
                                                </td>
                                          </tr>
                                    </table>
                              </fieldset>
                        </div>
                  </cfoutput>      
            </cfsavecontent>
            <cfset this.configData.tabs[2].body = tabTwo>
            
            <cfsavecontent variable="tabThree">
                  <cfoutput>
                  <div id="blnItemListingPageContent"></div>
                  <div id="blnItemListingTitle"></div>
                  <div id="intItemListingDateLayoutType"></div>
                  <div id="blnItemListingDescription"></div>
                  <div id="intItemListingDescriptionType"></div>
                  <div id="intItemListingDescriptionLength"></div>
                  <div id="blnItemListingSearch"></div>
                  <div id="blnItemListingAnchor"></div>
                  <div id="blnItemListingImage"></div>
                  <div id="intItemListingImageAlign"></div>
                  <div id="intItemListingLayoutType"></div>
                  <div id="blnItemListingImageWrap"></div>
                  <div id="intItemListingImageWidth"></div>
                  <div id="intItemListingImageHeight"></div>
                  <div id="blnItemListingPagination"></div>
                  <div id="intItemListingDisplayItems"></div>
                  <div id="txtItemListingDescriptionAction"></div>
                  
                  <div style="padding:10px;" class="formCaption">
                        <fieldset>
                              <table width="100%" cellspacing="0" cellpadding="7" border="0">
                                    <tr>
                                          <td class="formCaption">
                                                &nbsp;<input type="checkbox" name="blnItemListingPageContent" <cfif qryConfig.blnItemListingPageContent is 1>checked</cfif>> Show Page Content &nbsp;&nbsp;&nbsp;
                                                <input type="checkbox" name="blnItemListingSearch" <cfif qryConfig.blnItemListingSearch is 1>checked</cfif>> Search Form &nbsp;&nbsp;&nbsp;
                                                <input type="checkbox" name="blnItemListingAnchor" <cfif qryConfig.blnItemListingAnchor is 1>checked</cfif>> Item Anchor &nbsp;&nbsp;&nbsp;
                                                <input type="checkbox" name="blnItemListingTitle" <cfif qryConfig.recordCount is 0 OR qryConfig.blnItemListingTitle is 1>checked</cfif>> Show Title
                                          </td>
                                    </tr>
                                    <tr>
                                          <td>
                                                <fieldset>
                                                      <legend>Date Layout</legend>
                                                      <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                                            <tr>
                                                                  <td class="formCaption">
                                                                        <input type="radio" name="intItemListingDateLayoutType" value="#this.DATE_LAYOUT_TYPES.TWOLINES#" <cfif qryConfig.intItemListingDateLayoutType is this.DATE_LAYOUT_TYPES.TWOLINES OR qryConfig.recordCount is 0>checked</cfif>> Title Date on different lines &nbsp;&nbsp;&nbsp;
                                                                        <input type="radio" name="intItemListingDateLayoutType" value="#this.DATE_LAYOUT_TYPES.ONELINE#" <cfif qryConfig.intItemListingDateLayoutType is this.DATE_LAYOUT_TYPES.ONELINE>checked</cfif>> Date - Title on one line                                                                         
                                                                  </td>
                                                            </tr>
                                                      </table>
                                                </fieldset>
                                          </td>
                                    </tr>
                                    <tr>
                                          <td>
                                                <fieldset>
                                                      <legend><input type="checkbox" name="blnItemListingDescription" <cfif qryConfig.blnItemListingDescription is 1>checked</cfif>> Description</legend>
                                                      <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                                            <tr>
                                                                  <td class="formCaption">Display: </td>
                                                                  <td class="formCaption" colspan="3">
                                                                        <input type="radio" name="intItemListingDescriptionType" value="#this.DISPLAY_TYPES.FULL#" <cfif qryConfig.intItemListingDescriptionType is this.DISPLAY_TYPES.FULL>checked</cfif>> Full
                                                                  </td>
                                                            </tr>
                                                            <tr>
                                                                  <td class="formCaption">&nbsp;</td>
                                                                  <td class="formCaption" colspan="3">                                                                  
                                                                        <input type="radio" name="intItemListingDescriptionType" value="#this.DISPLAY_TYPES.MEMO#" <cfif qryConfig.intItemListingDescriptionType is this.DISPLAY_TYPES.MEMO>checked</cfif>> Abstract
                                                                  </td>
                                                            </tr>
                                                                  <td>&nbsp;</td>                                                                        
                                                                  <td class="formCaption">
                                                                        <input type="radio" name="intItemListingDescriptionType" value="#this.DISPLAY_TYPES.TRIMMED#" <cfif qryConfig.intItemListingDescriptionType is this.DISPLAY_TYPES.TRIMMED OR qryConfig.recordCount is 0>checked</cfif>> Trimmed
                                                                  </td>
                                                                  <td class="formCaption">
                                                                        Length: <input type="text" name="intItemListingDescriptionLength" <cfif qryConfig.recordCount is 0>value="250"<cfelse>value="#qryConfig.intItemListingDescriptionLength#"</cfif> class="formTextBox" style="width:70px;">
                                                                  </td>
                                                                  <td class="formCaption">
                                                                        Action: <input type="text" name="txtItemListingDescriptionAction" <cfif qryConfig.recordCount is 0>value="more..."<cfelse>value="#qryConfig.txtItemListingDescriptionAction#"</cfif> class="formTextBox" style="width:150px;">
                                                                  </td>
                                                            </tr>
                                                      </table>                                          
                                                </fieldset>
                                          </td>                                                
                                    </tr>
                                    <tr>
                                          <td>
                                                <fieldset>
                                                      <legend><input type="checkbox" name="blnItemListingPagination" <cfif qryConfig.blnItemListingPagination is 1>checked</cfif>> Pagination</legend>
                                                      <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                                            <tr>
                                                                  <td class="formCaption"><input type="text" name="intItemListingDisplayItems" <cfif qryConfig.recordCount is 0>value="#this.MAX_ITEMS#"<cfelse>value="#qryConfig.intItemListingDisplayItems#"</cfif> class="formTextBox" style="width:70px;"> items to display</td>
                                                            </tr>
                                                      </table>                                          
                                                </fieldset>
                                          </td>                                                
                                    </tr>
                                    <tr>
                                          <td>
                                                <fieldset>
                                                      <legend><input type="checkbox" name="blnItemListingImage" <cfif qryConfig.blnItemListingImage is 1>checked</cfif>> Item Image</legend>
                                                      <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                                            <tr>
                                                                  <td class="formCaption">
                                                                        Width: <input type="text" name="intItemListingImageWidth" <cfif qryConfig.recordCount is 0>value="100"<cfelse>value="#qryConfig.intItemListingImageWidth#"</cfif> style="width:70px;" class="formTextBox"> &nbsp;&nbsp;&nbsp;
                                                                        Height: <input type="text" name="intItemListingImageHeight" <cfif qryConfig.recordCount is 0>value="100"<cfelse>value="#qryConfig.intItemListingImageHeight#"</cfif> style="width:70px;" class="formTextBox">
                                                                  </td>
                                                                  <td class="formCaption">
                                                                        <input type="checkbox" name="blnItemListingImageWrap" <cfif qryConfig.blnItemListingImageWrap is 1>checked</cfif>> Wrap Text
                                                                  </td>
                                                            </tr>
                                                            <tr>
                                                                  <td class="formCaption" colspan="2">
                                                                        Align <input type="radio" name="intItemListingImageAlign" value="#this.IMAGE_ALIGN.LEFT#" <cfif qryConfig.intItemListingImageAlign is this.IMAGE_ALIGN.LEFT>checked</cfif>> Left
                                                                        &nbsp; <input type="radio" name="intItemListingImageAlign" value="#this.IMAGE_ALIGN.RIGHT#" <cfif qryConfig.intItemListingImageAlign is this.IMAGE_ALIGN.RIGHT OR qryConfig.recordCount is 0>checked</cfif>> Right
                                                                        &nbsp; <input type="radio" name="intItemListingImageAlign" value="#this.IMAGE_ALIGN.INLINE#" <cfif qryConfig.intItemListingImageAlign is this.IMAGE_ALIGN.INLINE>checked</cfif>> Inline
                                                                  </td>
                                                            </tr>
                                                      </table>
                                                </fieldset>
                                          </td>
                                    </tr>
                                    <tr>
                                          <td>
                                                <fieldset>
                                                      <legend>Layout</legend>
                                                      <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                                            <tr>
                                                                  <td class="formCaption">
                                                                        <input type="radio" name="intItemListingLayoutType" value="#this.COLUMN_LAYOUT.SINGLE#" <cfif qryConfig.intItemListingLayoutType is this.COLUMN_LAYOUT.SINGLE OR qryConfig.recordCount is 0>checked</cfif>> Single Column
                                                                        &nbsp;&nbsp;&nbsp; <input type="radio" name="intItemListingLayoutType" value="#this.COLUMN_LAYOUT.DOUBLE#" <cfif qryConfig.intItemListingLayoutType is this.COLUMN_LAYOUT.DOUBLE>checked</cfif>> Double Column
                                                                  </td>
                                                            </tr>
                                                      </table>
                                                </fieldset>
                                          </td>
                                    </tr>
                              </table>
                        </fieldset>
                  </div>                  
                  </cfoutput>      
            </cfsavecontent>
            <cfset this.configData.tabs[3].body = tabThree>
            
            <cfsavecontent variable="tabFour">
                  <cfoutput>
                        <div id="blnItemDetail"></div>
                        <div id="blnItemDetailPageContent"></div>
                        <div id="blnItemDetailResource"></div>
                        <div id="txtItemDetailResourceCaption"></div>
                        <div id="blnItemDetailImage"></div>
                        <div id="intItemDetailImageWidth"></div>
                        <div id="intItemDetailImageHeight"></div>
                        <div id="intItemDetailImageAlign"></div>
                        
                        <div style="padding:10px;" class="formCaption">
                              <fieldset>
                                    <legend><input type="checkBox" name="blnItemDetail" <cfif qryConfig.blnItemDetail is 1>checked</cfif>> Item Detail Page</legend>
                                    <table width="100%" cellspacing="0" cellpadding="7" border="0">
                                          <tr>
                                                <td class="formCaption">
                                                      &nbsp;<input type="checkbox" name="blnItemDetailPageContent" <cfif qryConfig.blnItemDetailPageContent is 1>checked</cfif>> Show Page Content                                                
                                                </td>
                                          </tr>
                                          <tr>
                                                <td>
                                                      <fieldset>
                                                            <legend><input type="checkbox" name="blnItemDetailResource" <cfif qryConfig.blnItemDetailResource is 1>checked</cfif>> Related Information</legend>
                                                            <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                                                  <tr>
                                                                        <td class="formCaption">Caption: <input type="text" name="txtItemDetailResourceCaption" <cfif qryConfig.recordCount is 0>value="Related Information"<cfelse>value="#qryConfig.txtItemDetailResourceCaption#"</cfif> class="formTextBox" style="width:235px;"></td>
                                                                  </tr>
                                                            </table>                                          
                                                      </fieldset>
                                                </td>                                                
                                          </tr>
                                          <tr>
                                                <td>
                                                      <fieldset>
                                                            <legend><input type="checkbox" name="blnItemDetailImage" <cfif qryConfig.blnItemDetailImage is 1>checked</cfif>> Item Image</legend>
                                                            <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                                                  <tr>
                                                                        <td class="formCaption">
                                                                              Width: <input type="text" name="intItemDetailImageWidth" <cfif qryConfig.recordCount is 0>value="100"<cfelse>value="#qryConfig.intItemDetailImageWidth#"</cfif> style="width:70px;" class="formTextBox"> &nbsp;&nbsp;&nbsp;
                                                                              Height: <input type="text" name="intItemDetailImageHeight" <cfif qryConfig.recordCount is 0>value="100"<cfelse>value="#qryConfig.intItemDetailImageHeight#"</cfif> style="width:70px;" class="formTextBox">
                                                                        </td>
                                                                        <td class="formCaption">
                                                                              Align &nbsp;&nbsp;&nbsp; <input type="radio" name="intItemDetailImageAlign" value="#this.IMAGE_ALIGN.LEFT#" <cfif qryConfig.intItemDetailImageAlign is this.IMAGE_ALIGN.LEFT>checked</cfif>> Left
                                                                              &nbsp;&nbsp;&nbsp; <input type="radio" name="intItemDetailImageAlign" value="#this.IMAGE_ALIGN.RIGHT#" <cfif qryConfig.intItemDetailImageAlign is this.IMAGE_ALIGN.RIGHT OR qryConfig.recordCount is 0>checked</cfif>> Right
                                                                              &nbsp;&nbsp;&nbsp; <input type="radio" name="intItemDetailImageAlign" value="#this.IMAGE_ALIGN.INLINE#" <cfif qryConfig.intItemDetailImageAlign is this.IMAGE_ALIGN.INLINE>checked</cfif>> Inline
                                                                        </td>
                                                                  </tr>
                                                            </table>
                                                      </fieldset>
                                                </td>
                                          </tr>
                                          <tr>
                                                <td>&nbsp;</td>
                                          </tr>
                                    </table>
                              </fieldset>
                        </div>                  
                  </cfoutput>      
            </cfsavecontent>
            <cfset this.configData.tabs[4].body = tabFour>
            
            <cfsavecontent variable="tabFive">
                  <cfoutput>
                        <div id="blnNotification"></div>
                        <div style="padding:10px;" class="formCaption">
                              <fieldset>
                                    <legend><input type="checkBox" name="blnNotification" <cfif qryConfig.blnNotification is 1>checked</cfif>> Send Notification</legend>
                                    <table width="100%" cellspacing="0" cellpadding="7" border="0">
                                          <tr>
                                                <td class="formCaption">From Email: <span class="txtRequired">*</span><br />
                                                      <input type="text" name="txtNotificationFromEmail" value="#qryConfig.txtNotificationFromEmail#" style="width:225px;">
                                                </td>
                                                <td class="formCaption">From Name:<br />
                                                      <input type="text" name="txtNotificationFromName" value="#qryConfig.txtNotificationFromName#" style="width:225px;">
                                                </td>
                                          </tr>
                                          <tr>
                                                <td class="formCaption">Notification Subject: <span class="txtRequired">*</span><br />
                                                      <input type="text" name="txtNotificationSubject" value="#qryConfig.txtNotificationSubject#" style="width:225px;">
                                                </td>
                                                <td>&nbsp;</td>
                                          </tr>
                                    </table>
                              </fieldset>
                        </div>      
                  </cfoutput>            
            </cfsavecontent>
            <cfset this.configData.tabs[5].body = tabFive>
            
            <!--- extranet role stuff --->
            <cfset this.extranet = getObject("hb50.extranet", this.companyID,true)>
            <cfset qryRoles = this.extranet.getRoleQuery()>
            
            <cfset selectedRoles = getListRoles()>
            
            <cfsavecontent variable="tabSeven">
                  <cfoutput>
                  <div id="blnSecurityEnabled"></div>
                  <div style="padding:10px;" class="formCaption">
                        <fieldset>
                              <legend><input type="checkBox" name="blnSecurityEnabled" <cfif qryConfig.blnSecurityEnabled is 1>checked</cfif>> Enable</legend>
                              <table width="100%" cellspacing="0" cellpadding="7" border="0">
                                    <tr>
                                          <td class="formCaption">Access Role(s):<br />
                                                <select name="intRoleIDs" style="width:235px;height:120px;" multiple="true" class="formTextBox">
                                                      <cfloop query="qryRoles">
                                                            <option value="#qryRoles.intRoleID#" <cfif ListFind(selectedRoles, qryRoles.intRoleID)>selected</cfif>>#qryRoles.txtTitle#</option>
                                                      </cfloop>
                                                </select>
                                          </td>
                                    </tr>
                              </table>
                        </fieldset>
                  </div>      
                  </cfoutput>
            </cfsavecontent>
            <cfset this.configData.tabs[7].body = tabSeven>
                        
            <cfif qryConfig.recordCount>
                  <cfset URL.id = qryConfig.intID>
            </cfif>
            <cfsavecontent variable="jsHack">
                  <script>
                  document.getElementById('innerTab1').style.overflow ='auto';
                  document.getElementById('innerTab2').style.overflow ='auto';
                  document.getElementById('innerTab3').style.overflow ='auto';
                  document.getElementById('innerTab4').style.overflow ='auto';
                  </script>
            </cfsavecontent>
            
            <cfreturn this.display.getAddEdit(this.configData) & jsHack>
      </cffunction>
      <!--- /getConfigBackEnd --->
            
      <cffunction name="install" access="public" returntype="struct">
            <cfset var returnStruct = StructNew()>
            
            <cfif isDefined("this.formData")>
                  <cfset this.workflow.verifyColumns(this.formData)>
                  <cfif StructKeyExists(this.formData, 'tablename')>
                        <cfset returnStruct.itemTable = this.formData.tablename>
                  </cfif>
            </cfif>

            <cfif isDefined("this.catData")>
                  <cfset this.workflow.verifyColumns(this.catData)>
                  <cfif StructKeyExists(this.catData, 'tablename')>
                        <cfset returnStruct.categoryTable = this.catData.tablename>
                  </cfif>
            </cfif>
                        
            <cfset this.workflow.verifyColumns(this.configData)>
            <cfset this.workflow.verifyColumns(this.listData)>
            <cfset this.workflow.verifyColumns(this.roleData)>
            
            <cfreturn returnStruct>
      </cffunction>

      <!--- Donny: needed by "hb50\popups\rte\insertlink.cfc" --->
      <cffunction name="getPublicQuery" access="public" returntype="query">      
            <cfif (this.datatype is this.DATATYPES.CATEGORY)>
                  <cfreturn this.workflow.getPublicQuery(this.catData) />
            <cfelse>
                  <cfreturn this.workflow.getPublicQuery(this.formData) />
            </cfif>
      </cffunction>
      
      <!--- returns the formatting of a single item in html, for the public side (or preview).
              scope can be any struct containing all the variables (form, query, etc.)
       --->      
      <cffunction name="getItemDisplay" access="public" returntype="string">
            <cfargument name="scope" required="true" type="any">
            
            <cfset var qryConfig = getConfigQuery()>
            
            <cfsavecontent variable="output">
                  <cfoutput>
                        <div id="hbdetmod">
                        <h5>#scope.txtTitle#<cfif scope.blnPrivate> #this.PRIVATE_IMAGE#</cfif></h5>
                              <cfset infoList = ''>                                                                                                
                              <cfif qryConfig.blnDate is 1 AND isDefined("scope.dtDate") AND isDate(scope.dtDate)><cfset infoList = infoList & '<li>#DateFormat(scope.dtDate, 'mmmm dd, yyyy')#</li>'></cfif>
                              <cfif qryConfig.blnAddress is 1>
                                    <cfset addressLine = ''>
                                    <cfif  isDefined("scope.txtAddress")><cfset addressLine = addressLine & '#scope.txtAddress#'></cfif>
                                    <cfif isDefined("scope.txtCity") AND Len(Trim(scope.txtCity))><cfset addressLine = addressLine & ' #scope.txtCity#,'></cfif>
                                    <cfif isDefined("scope.txtProvince") AND Len(Trim(scope.txtProvince))><cfset addressLine = addressLine & ' #scope.txtProvince#,'></cfif>
                                    <cfif isDefined("scope.txtPostalCode") AND Len(Trim(scope.txtPostalCode))><cfset addressLine = addressLine & ' #scope.txtPostalCode#'></cfif>
                                    <cfif isDefined("scope.txtCountry")><cfset addressLine = addressLine & ' #scope.txtCountry#'></cfif>
                                    <cfif Len(Trim(addressLine))><cfset infoList = infoList & '<li>#addressLine#</li>'></cfif>
                              </cfif>
                              <cfif qryConfig.blnPhone is 1 and isDefined("scope.txtPhone") AND Len(Trim(scope.txtPhone))><cfset infoList = infoList & '<li>Phone: #scope.txtPhone#</li>'></cfif>
                              <cfif qryConfig.blnFax is 1 and isDefined("scope.txtFax") AND Len(Trim(scope.txtFax))><cfset infoList = infoList & '<li>Fax: #scope.txtFax#</li>'></cfif>
                              <cfif qryConfig.blnPhone is 1 and isDefined("scope.txtTollFree") AND Len(Trim(scope.txtTollFree))><cfset infoList = infoList & '<li>Toll-Free: #scope.txtTollFree#</li>'></cfif>
                              <cfif qryConfig.blnEmail is 1 and isDefined("scope.txtEmail") AND Len(Trim(scope.txtEmail))><cfset infoList = infoList & '<li>Email: <a href="mailto:#scope.txtEmail#">#scope.txtEmail#</a></li>'></cfif>
                              <cfif qryConfig.blnLink is 1 and isDefined("scope.txtLink") AND Len(Trim(scope.txtLink))>
                                    <cfif REFindNoCase("http[s]://",scope.txtLink)>
                                          <cfset txtItemLink = scope.txtLink>
                                    <cfelse>
                                          <cfset txtItemLink = "http://#scope.txtLink#">
                                    </cfif>
                                    <cfset infoList = infoList & '<li><a href="#txtItemLink#" target="_blank">#scope.txtLink#</a></li>'>
                              </cfif>
                              <cfif Len(Trim(infoList))>
                                    <ul>
                                          #infoList#                                                      
                                    </ul>
                              </cfif>
                              <cfif qryConfig.blnImage is 1 and qryConfig.blnItemDetailImage is 1 and Val(scope.intImageID)><img src="#this.media.getURL(scope.intImageID,Val(qryConfig.intCategoryImageWidth),Val(qryConfig.intCategoryImageHeight))#"  border="0" <cfif qryConfig.intItemDetailImageAlign is this.IMAGE_ALIGN.LEFT>class="hbdetlft"<cfelseif qryConfig.intItemDetailImageAlign is this.IMAGE_ALIGN.RIGHT>class="hbdetrht"<cfelse>class="hbdetinl"</cfif> /></cfif>
                        <p>#this.workflow.convertTokens(scope.txtDescription,false,this.webid)#</p>                              
                              <!---  <!--- not support yet --->
                              <cfif qryConfig.blnResource is 1>
                                    <cfset addlResources = this.media.getPreviewAdditionalResources(scope.resources))>                                           
                                    <cfif ArrayLen(addlResources)>
                                    <br/>
                                    <strong>#qryConfig.txtItemDetailResourceCaption#:</strong><br />
                                    <ul>
                                          <cfloop from="1" to="#ArrayLen(addlResources)#" index="i">
                                                <li><a href="#addlResources[i].link#" <cfif addlResources[i].blnNewWindow>target="_blank"</cfif>><img src="images/#addlResources[i].icon#" width="18" height="18" border="0" alt=""></a> <a href="#addlResources[i].link#" target="_blank">#addlResources[i].title#</a><cfif val(addlResources[i].filesize)> [#round(addlResources[i].filesize / 1024)# kb]</cfif> </li>
                                          </cfloop>
                                    </ul>
                                    </cfif>
                              </cfif>
                              --->
                        </div>
                  </cfoutput>
            </cfsavecontent>

            <cfreturn output />
      </cffunction>


      <!--- adds a category to this tool, returns the new ID --->
      <cffunction name="addCategory" access="public" returntype="numeric">
            <cfargument name="txtTitle" required="true" type="string">

            <cfset FORM.intCategoryID = this.category.addCategory(this.webid,txtTitle)>
            <!--- back up form --->
            <cfset formCopy = duplicate(FORM)>
            <cfset FORM.txtTitle = FORM.intCategoryID_add_title>
            <cfset FORM.txtDescription = "">
            <cfset FORM.txtMetaDescription = "">
            <cfset FORM.txtMetaKeywords = "">
            <cfset StructDelete(FORM, "id")>
            <cfset this.workflow.doAction(SESSION.userid, this.workflow.ADD, "Added", this.catData)>
            <!--- restore form --->
            <cfset StructClear(FORM)>
            <cfset StructAppend(FORM, formCopy)>
            
            <cfreturn FORM.intCategoryID>
      </cffunction>
</cfcomponent>


the display.cfc componet

<!--- $HBVersion:5.5h3$ --->
<!--- Copyright 1999 ?2007 Hot Banana Software, Inc.
For additional information visit www.hotbanana.com 
Hot Banana is a trademark owned by J.L. Halsey --->

<cfcomponent displayname="display" extends="hb50.object">
      <cffunction name="init" access="public" returntype="any" output="false">
            <cfargument name="companyID" required="true" type="numeric">

            <cfscript>
                  super.init(arguments.companyID);
      
                  this.workflow = getObject("hb50.workflow", arguments.companyID, true);
                  this.actionmsg = '';
                  this.treenavrefresh = false;
      
                  return this;
            </cfscript>
      </cffunction>

      <!--- Returns a formatted listing of data --->
      <cffunction name="getListing" access="public" returntype="string" output="false">
            <cfargument name="formData" type="struct" required="true" />
            <!--- the column name that will be printed out and hyperlinked (ie, txtTitle) --->
            <cfargument name="printColumn" type="string" required="true" />
            <!--- the title of the column that will be printed out and hyperlinked (ie, 'Title') --->
            <cfargument name="printTitle" type="string" required="true" />
            <!--- the extra column name that will be printed out (usually the Sort By column) --->
            <cfargument name="extraColumn" type="string" required="true" />
            <!--- the title of the extra column that will be printed out (ie, 'Category') --->
            <cfargument name="extraTitle" type="string" required="true" />
            <!--- the link to the edit page (ie, page.cfm?tool=12&tab=options) --->
            <cfargument name="linkURL" type="string" required="true" />
            <!--- the column containing the link: overrides linkURL if provided --->
            <cfargument name="linkColumn" type="string" required="false" />
            <!--- the target of the link, in case we want it to open somewhere else for some reason --->
            <cfargument name="linkTarget" type="string" required="false" />
            <!--- should the listing go ahead and search through the results (set to false if they get filtered before this function) --->
            <cfargument name="blnSearchListing" type="boolean" required="false" default="true" />
            
            <cfscript>
                  var i = 1;
                  var searchURL = '';
                  var qryRecords = QueryNew('');
                  var idColumn = formData.varID;
                  var output = '';
                  var buttons = '';
                  var recordID = 0;
                  var title = '';
                  var noHtmlTitle = '';
                  var extraValue = '';
                  var link = '';
                  var capSize = 60;
                  var text = '';
                  
                  if (formData.blnWorkflow)
                        idColumn = "intItemID";
            </cfscript>
            
            <cfparam name="URL.order" default="intOrder">
            <cfparam name="URL.sortorder" default="asc">
            <cfparam name="URL.catid" default="0">
            <cfparam name="URL.statusid" default="0">
            <cfparam name="URL.keywords" default="">
            <cfparam name="URL.pagination" default="#Val(SESSION.pagination)#" type="numeric">
            <cfparam name="URL.SR" default="1">
            
            <cfif isDefined("FORM.keywords")>
                  <cfif isDefined("FORM.catid")>
                        <cfset URL.catid = FORM.catid>
                  </cfif>
                  <cfif isDefined("FORM.statusid")>
                        <cfset URL.statusid = FORM.statusid>
                  </cfif>
                  <cfset URL.keywords = FORM.keywords>
            </cfif>
            <cfset searchURL = "&catid=#catid#&statusid=#statusid#&keywords=#keywords#">

            <cfif not isQuery(formData.query)>
                  <cfset formData.query = this.workflow.getQuery(formData)>
            </cfif>
            <cfset qryRecords = formData.query>
            
            <cfset qryRecords = sortListing(qryRecords, printColumn, extraColumn)>
            <cfif arguments.blnSearchListing>
                  <cfset qryRecords = searchListing(qryRecords, keywords, catID, statusID, printColumn)>
            </cfif>

            <cfif isDefined("FORM.pagenumber")>
                  <cfset URL.SR = 1 + ((Val(FORM.pagenumber) - 1) * URL.pagination)>
            </cfif>
            <cfset URL.SR = max(min(URL.SR,qryRecords.recordcount - (qryRecords.recordcount mod URL.pagination) + 1), 1)>

            <cfsavecontent variable="output">
                  <cfoutput>
                        #getStatus()#
                        
                        <div id="pagination" style="position:absolute; left:396px; top:294px; width:82px; height:15px; z-index:20" class="bevelEmbossStatus">
                              <div id="paginationText" style="position:absolute; left:3px; top:1px; width:67px; height:11px; z-index:20; overflow: hidden;"><nobr>#translate("Items/Page")# #pagination#</nobr></div>
                              <div id="paginationSelect" style="position:absolute; left:64px; top:-2px; width:15px; height:15px; z-index:20"><a href="##" onclick="P7_autoLayers(4,'paginationList'); document.frmPagination.pagination.focus();"><img src="images/btn_status_arrow.gif" width="15" height="15" border="0"></a></div>
                              <div id="paginationList" style="position:absolute; left:-1px; top:-99px; width:141px; height:102px; z-index:20; visibility: hidden;">
                              <form name="frmPagination" method="post" action="">
                                    <select class="selectSmall" style="width:82;" name="pagination" size="7" onchange="window.location = '#arguments.linkURL#&sortorder=#sortorder#&order=#order##searchURL#&pagination=' + this.options[this.selectedIndex].value;" onblur="P7_autoLayers(4,'');">
                                          <option value="5"<cfif URL.pagination is 5> selected</cfif>>5</option>
                                          <option value="10"<cfif URL.pagination is 10> selected</cfif>>10</option>
                                          <option value="25"<cfif URL.pagination is 25> selected</cfif>>25</option>
                                          <option value="50"<cfif URL.pagination is 50> selected</cfif>>50</option>
                                          <option value="100"<cfif URL.pagination is 100> selected</cfif>>100</option>
                                          <option value="250"<cfif URL.pagination is 250> selected</cfif>>250</option>
                                          <option value="500"<cfif URL.pagination is 500> selected</cfif>>500</option>
                                    </select>
                              </form></div>
                        </div>
                        <div id="total" style="position:absolute; left:481px; top:294px; width:62px; height:15px; z-index:5" class="bevelEmbossStatus">
                              <div id="totalText" align="right" style="position:absolute; left:3px; top:1px; width:55px; height:11px; z-index:5">#translate("Total")#:#qryRecords.recordcount#</div>
                        </div>
      
                        <cfsavecontent variable="buttons">
                              <form action="#arguments.linkURL#" method="post">
                                    <input type="hidden" name="id" id="edit_id" value="">
                                    <input type="hidden" name="mode" value="edit">
                                    <cfloop from="1" to="#ArrayLen(formData.listbuttons)#" index="i">
                                          <cfif not StructKeyExists(formData.listbuttons[i], "width")>
                                                <cfset formData.listbuttons[i].width = 100>
                                          </cfif>
                                          <input name="addbutton" type="submit" class="buttons" value="#translate(formData.listbuttons[i].title)#" style="width: #formData.listbuttons[i].width#px"
                                                <cfif StructKeyExists(formData.listbuttons[i], "onClick")>
                                                      onClick="#formData.listbuttons[i].onClick#"
                                                </cfif>
                                          />
                                    </cfloop>
                                    <cfif formData.blnAdd>
                                          <input name="addbutton" type="submit" class="buttons" value="#translate("Add #formData.itemname#")#"
                                           onClick="this.form.id.value = '';"/>
                                    </cfif>
                                    <cfif formData.blnEdit>
                                          <input name="addbutton" type="submit" class="buttons" value="#translate("Edit #formData.itemname#")#"
                                           onClick="if (this.form.id.value == '') { alert('#translate("Please click on an item to edit.")#'); return false; }"/>
                                    </cfif>
                                    <cfif formData.blnOrder>
                                          <script language="JavaScript">
                                                function jsCustomOrder () {
                                                      window.open('popup/order.cfm?webid=#formData.webid#&datatype=#formData.datatype#', '', 'scrollbars=no,width=300,height=265,resizable=yes');
                                                      return false;
                                                }
                                          </script>
                                          <input name="order" type="submit" class="buttons" value="#translate("Order Items")#" onClick='return jsCustomOrder();'/>
                                    </cfif>
                              </form>
                        </cfsavecontent>
                        #getButtonLayer(buttons)#
      
                        #getSearchBar(formData, arguments.linkURL)#
      
                        <div id="header" style="position:absolute; visibility:visible; left:1px; top:1px; width:540px; height:20px; z-index:2;">
                              <table style="background-color:##EEEEEE" border="0" cellspacing="1" cellpadding="0">
                              <tr>
                                  <td width="20" height="21" class="toolHeader">
                                        <img src="images/shim.gif" width="20" height="1" border="0">
                                          </td>
                                <td width="363" class="toolHeader">
                                                <cfif arguments.linkURL is "">
                                                      #translate(arguments.printTitle)#
                                                <cfelse>
                                                      <a href="#arguments.linkURL#<cfif arguments.linkURL contains "?">&<cfelse>?</cfif>pagination=#URL.pagination#&order=title#searchURL#&sortorder=<cfif URL.order is "title" and URL.sortorder is "asc">desc<cfelse>asc</cfif>">#translate(printTitle)#</a>
                                                      <cfif URL.order is "title">
                                                            <cfif URL.sortorder is "asc">
                                                                  <img src="images/btn_move_up.gif" width="9" height="9" border="0" align="absmiddle">
                                                            <cfelse>
                                                                  <img src="images/btn_move_down.gif" width="9" height="9" border="0" align="absmiddle">
                                                            </cfif>
                                                      </cfif>
                                                </cfif>
                                                <cfif qryRecords.recordcount gt URL.pagination>
                                                      <div id="Layer1" style="position:absolute; left:222px; top:1px; width:157px; height:15px; z-index:4; font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: ##666666;">
                                                            <form action="#Left(arguments.linkURL, Find('?', arguments.linkURL) - 1)#?#Right(arguments.linkURL, Len(arguments.linkURL) - Find('?', arguments.linkURL))#&pagination=#URL.pagination#&sortorder=#sortorder#&order=#order##searchURL#" method="post">
                                                                  <div align="right">
                                                                        <cfif SR gt 1>
                                                                              <a href="#Left(arguments.linkURL, Find('?', arguments.linkURL) - 1)#?#Right(arguments.linkURL, Len(arguments.linkURL) - Find('?', arguments.linkURL))#&pagination=#URL.pagination#&sortorder=#sortorder#&order=#order##searchURL#&SR=#SR - URL.pagination#"><img src="images/btn_back.gif" width="11" height="11" border="0"></a>
                                                                        </cfif>
                                                                        PAGE
                                                                          <input name="pagenumber" type="text" style="height:18px; width:32px; font-family: Arial, Helvetica, sans-serif; font-size: 10px;" value="#Ceiling(SR / URL.pagination)#" size="3" onEnter='this.form.submit();'/>
                                                                        OF #Ceiling(qryRecords.recordCount / URL.pagination)#
                                                                        <cfif SR lte qryRecords.recordcount - URL.pagination>
                                                                              <a href="#Left(arguments.linkURL, Find('?', arguments.linkURL) - 1)#?#Right(arguments.linkURL, Len(arguments.linkURL) - Find('?', arguments.linkURL))#&pagination=#URL.pagination#&sortorder=#sortorder#&order=#order##searchURL#&SR=#SR + URL.pagination#"><img src="images/btn_next.gif" width="11" height="11" border="0"></a>
                                                                        </cfif>
                                                                  </div>
                                                            </form>
                                                      </div>
                                                </cfif>
                                          </td>
                                        <td width="120" class="toolHeader">
                                                <cfif arguments.linkURL is "">#translate(arguments.extraTitle)#<cfelse><a href="#arguments.linkURL#<cfif arguments.linkURL contains "?">&<cfelse>?</cfif>pagination=#URL.pagination#&order=date#searchURL#&sortorder=<cfif url.order is "date" and url.sortorder is "asc">desc<cfelse>asc</cfif>">#translate(extraTitle)#</a> <cfif URL.order is "date"><cfif URL.sortorder is "asc"><img src="images/btn_move_up.gif" width="9" height="9" border="0" align="absmiddle"><cfelse><img src="images/btn_move_down.gif" width="9" height="9" border="0" align="absmiddle"></cfif></cfif></cfif>
                                          </td>
                                </tr>
                              </table>
                        </div>
                  </cfoutput>
                  
                  <script>
                        function setEditID(id) {
                              var lastID = document.getElementById('edit_id').value;
                              var lastRow = document.getElementById('row1_' + lastID + '');
                              if (lastRow)
                                    lastRow.style.background = '#FFFFFF';
                              var lastRow = document.getElementById('row2_' + lastID + '');
                              if (lastRow)
                                    lastRow.style.background = '#FFFFFF';
                              var lastRow = document.getElementById('row3_' + lastID + '');
                              if (lastRow)
                                    lastRow.style.background = '#FFFFFF';
                                    
                              document.getElementById('edit_id').value = id;
                              document.getElementById('row1_' + id + '').style.background = '#EEEEEE';
                              document.getElementById('row2_' + id + '').style.background = '#EEEEEE';
                              document.getElementById('row3_' + id + '').style.background = '#EEEEEE';
                        }
                  </script>
                                                      
                  <div id="listing" style="position:absolute; visibility:visible; left:1px; top:1px; width:540px; height:261px; z-index:1; overflow:scroll;">
                        <table style="background-color:#EEEEEE" border="0" cellspacing="1" cellpadding="0">
                              <tr>
                                    <td width="20" height="21" class="toolHeader"><img src="images/shim.gif" width="20" height="1" border="0"></td>
                                     <td width="363" class="toolHeader">&nbsp;</td>
                                     <td width="120" class="toolHeader">&nbsp;</td>
                               </tr>
                              <cfoutput query="qryRecords" startrow="#SR#" maxrows="#URL.pagination#">
                                    <cfset recordID = qryRecords[idColumn]>
                                    <cfset title = qryRecords[arguments.printColumn]>
                                    <cfif Len(arguments.extraColumn)>
                                          <cfset extraValue = qryRecords[arguments.extraColumn]>
                                    <cfelse>
                                          <cfset extraValue = "">
                                    </cfif>
                                     <cfif isDefined("arguments.linkColumn") and Len(arguments.linkColumn)>
                                          <cfset link = qryRecords[arguments.linkColumn]>
                                    <cfelse>
                                          <cfsavecontent variable="link">#arguments.linkURL#<cfif arguments.linkURL contains "?">&<cfelse>?</cfif>mode=edit&id=#recordID#&listparam=#URLEncodedFormat("order=#order#&sortorder=#sortorder#&sr=#sr#&pagination=#url.pagination##searchURL#")#</cfsavecontent>
                                    </cfif>
                                    <cfset noHtmlTitle = ReReplace(title, "<[^>]+>", "", "ALL")>
                                    <cfif Len(noHtmlTitle) gt capSize>
                                          <cfset title = Left(title, 60 + Len(title) - Len(noHtmlTitle)) & "...">
                                    </cfif>

                                    <cfsavecontent variable="text"><a href="#link#" <cfif isDefined("arguments.linkTarget") and Len(arguments.linkTarget)>target="#arguments.linkTarget#"</cfif>><cfif not Len(Trim(title))>no title</cfif>#title#</a></cfsavecontent>

                                    <cfif isDate(extraValue)>
                                          <cftry>
                                                <cfset extraValue = '#LSDateFormat(extraValue, "mmm d, yyyy")# #LSTimeFormat(extraValue, "h:mmtt")#' />
                                                <cfcatch></cfcatch>
                                          </cftry>
                                    </cfif>

                                    <tr>
                                           <td height="21" class="toolList" id="row1_#recordID#" onclick="javascript:setEditID('#recordID#');">#getIcon(qryRecords, currentrow)#</td>
                                           <td class="toolList" id="row2_#recordID#" onclick="javascript:setEditID('#recordID#');">#text#<cfif isDefined("qryRecords.blnFeatured") and qryRecords.blnFeatured is 1> <img src="images/butFeature.gif" width="16" height="16" border="0" alt="#translate("Featured")#" align="bottom"></cfif></td>
                                           <td class="toolList" id="row3_#recordID#" onclick="javascript:setEditID('#recordID#');">#extraValue#</td>
                                    </tr>
                              </cfoutput>
                              <cfif not qryRecords.recordcount>
                                    <cfoutput>
                                    <tr>
                                           <td height="20" bgcolor="##FFFFFF" align="center" valign="center" style="cursor:none;">&nbsp;</td>
                                           <td bgcolor="##FFFFFF" class="formCaption" style="padding:5px;">#translate("There are no records.")#</td>
                                           <td bgcolor="##FFFFFF">&nbsp;</td>
                                    </tr>
                                    </cfoutput>
                              </cfif>
                     </table>
                  </div>
            </cfsavecontent>

            <cfreturn output />
      </cffunction>

      <cffunction name="getSearchBar" access="public" returntype="string" output="false">
            <cfargument name="formData" type="struct" required="true" />
            <cfargument name="linkURL" type="string" required="true" />
            
            <cfset var searchbar = '' />
            <cfset var category  = '' />
            <cfset var qryCategory = '' />
            
            <cfsavecontent variable="searchbar">
                  <cfoutput>
                        <form action="#arguments.linkURL#<cfif arguments.linkURL contains "?">&<cfelse>?</cfif>pagination=#URL.pagination#" method="post">
                              <input type="text" id="searchKeywords" name="keywords" class="searchBox" value="#HTMLEditFormat(URL.keywords)#" style="width: <cfif formData.blnCategory and formData.blnStatus>220<cfelseif formData.blnCategory or formData.blnStatus>349<cfelse>478</cfif>px;"/>
                              <cfif formData.blnStatus>
                                    <select name="statusID" class="searchSelect" onChange='this.form.submit();'>
                                          <option value="0" selected>#translate("Status")# ...</option>
                                          <option value="#this.workflow.STATUS.ACTIVE#" <cfif URL.statusID is this.workflow.STATUS.ACTIVE>selected</cfif>>#translate("Active")#</option>
                                    <cfif formData.blnScheduling>
                                          <option value="#this.workflow.STATUS.PENDING#" <cfif URL.statusID is this.workflow.STATUS.PENDING>selected</cfif>>#translate("Pending")#</option>
                                          <option value="#this.workflow.STATUS.EXPIRED#" <cfif URL.statusID is this.workflow.STATUS.EXPIRED>selected</cfif>>#translate("Expired")#</option>
                                    </cfif>
                                    <cfif formData.blnLock>
                                          <option value="#this.workflow.STATUS.LOCK#" <cfif URL.statusID is this.workflow.STATUS.LOCK>selected</cfif>>#translate("Locked")#</option>
                                    </cfif>
                                    <cfif formData.blnApproval>
                                           <option value="#this.workflow.STATUS.UNAPPROVED#" <cfif URL.statusID is this.workflow.STATUS.UNAPPROVED>selected</cfif>>#translate("Unapproved")#</option>
                                    </cfif>
                                    <cfif formData.blnRestore and formData.blnDelete and SESSION.blnRestore>
                                          <option value="#this.workflow.STATUS.DELETED#" <cfif URL.statusID is this.workflow.STATUS.DELETED>selected</cfif>>#translate("Deleted")#</option>
                                    </cfif>
                                    </select>
                              </cfif>
                              <cfif formData.blnCategory>
                                    <cfparam name="URL.catID" default="0">
                                    <cfset category = createObject("component", "hb50.category").init(this.CompanyID)>
                                    <cfset qryCategory = category.getCategories(formData.webid)>
                                    <select name="catID" class="searchSelect" onChange='this.form.submit();'>
                                          <cfif StructKeyExists(formData, 'categoryname')>
                                                <option value="0" selected>#formData.categoryname# ...</option>
                                          <cfelse>
                                                <option value="0" selected>#translate("Category")# ...</option>
                                          </cfif>
                                          <cfloop query="qryCategory">
                                                <option value="#qryCategory.intID#"<cfif URL.catID is qryCategory.intID> selected</cfif>>#qryCategory["txtTitle"][currentRow]#</option>
                                          </cfloop>
                                    </select>
                              </cfif>
                              <input type="submit" name="Submit" value="#translate("SEARCH")#" class="buttons" style="width:60px"/>
                        </form>
                  </cfoutput>
            </cfsavecontent>
            
            <cfreturn getToolbarLayer(searchbar)>
      </cffunction>

      <!--- sorts records based on url parameters, originating from getListing() --->
      <cffunction name="sortListing" access="public" returntype="query" output="false">
            <cfargument name="qryRecords" type="query" required="true">
            <cfargument name="printColumn" type="string" required="true">
            <cfargument name="extraColumn" type="string" required="true">

            <cfif isDefined("URL.order")>
                  <cfif URL.order is "title">
                        <cfquery name="qryRecords" dbtype="query">
                              SELECT      *, UPPER(#arguments.printColumn#) AS sortPrintColumn
                              FROM       qryRecords
                              ORDER BY sortPrintColumn <cfif isDefined("URL.sortorder") and URL.sortorder is "desc">DESC</cfif>
                        </cfquery>
                  <cfelseif URL.order is "date">
                        <cfquery name="qryRecords" dbtype="query">
                              SELECT       *
                              FROM       qryRecords
                              ORDER BY #arguments.extraColumn# <cfif isDefined("URL.sortorder") and URL.sortorder is "desc">DESC</cfif>
                        </cfquery>
                  </cfif>
            </cfif>

            <cfreturn qryRecords />
      </cffunction>

      <!--- search records based on url parameters, originating from getListing() --->
      <cffunction name="searchListing" access="public" returntype="query" output="false">
            <cfargument name="qryRecords" type="query" required="true">
            <cfargument name="keywords" type="string" required="true">
            <cfargument name="catID" type="numeric" required="true">
            <cfargument name="statusID" type="numeric" required="true">
            <cfargument name="printColumn" type="string" required="true">

            <cfset var qryNewRecords = ''>

            <cfquery name="qryNewRecords" dbtype="query">
                  SELECT       *
                  FROM       qryRecords
                  WHERE       1 = 1
                  <cfif catID and ListFindNoCase(qryRecords.columnlist, "intCategoryID")>
                        AND      intCategoryID = #arguments.catID#
                  </cfif>
                  <cfif ListFindNoCase(qryRecords.columnlist, "intStatusID")>
                        <cfif Val(statusID)>
                              AND intStatusID = #Val(arguments.statusID)#
                        <cfelse>
                              AND intStatusID != #this.workflow.STATUS.DELETED#
                        </cfif>
                  </cfif>
                  <cfif ListLen(keywords, " ")>
                        AND (1 = 2
                              <cfloop list="#arguments.keywords#" delimiters=" " index="i">
                                    OR LOWER(#arguments.printColumn#) LIKE '%#LCase(i)#%'
                              </cfloop>
                        )
                  </cfif>
            </cfquery>

            <cfreturn qryNewRecords />
      </cffunction>

      <!--- returns the status icon of the item for the listing form --->
      <cffunction name="getIcon" access="public" returntype="string" output="false">
            <cfargument name="qryRecords" type="query" required="true" />
            
            <cfscript>
                  var status = -1;
                  var lockmsg = '';
                  var qryLockUsers = '';
                  var image = '';
            </cfscript>
            
            <cfif ListFindNoCase(qryRecords.columnlist, "intStatusID")>
                  <cfset status = qryRecords.intStatusID>
                  
                  <cfif status is this.workflow.STATUS.ACTIVE>
                        <cfreturn '<img src="images/btn_active.gif" width="16" height="18" border="0" alt="#translate("Active")#" title="#translate("Active")#">'>
                  <cfelseif status is this.workflow.STATUS.INACTIVE>
                        <cfreturn '<img src="images/btn_unactive.gif" width="16" height="18" border="0" alt="#translate("Inactive")#" title="#translate("Inactive")#">'>
                  <cfelseif status is this.workflow.STATUS.DELETED>
                        <cfreturn '<img src="images/btn_deleted.gif" width="16" height="18" border="0" alt="#translate("Deleted")#" title="#translate("Deleted")#">'>
                  <cfelseif status is this.workflow.STATUS.UNAPPROVED>
                        <cfreturn '<img src="images/btn_approval.gif" width="16" height="18" border="0" alt="#translate("Waiting For Approval")#" title="#translate("Waiting For Approval")#">'>
                  <cfelseif status is this.workflow.STATUS.UNTRANSLATED>
                        <cfreturn '<img src="images/btn_translate.gif" width="16" height="18" border="0" alt="#translate("Waiting For Translation")#" title="#translate("Waiting For Translation")#">'>
                  <cfelseif status is this.workflow.STATUS.UNSHARED>
                        <cfreturn '<img src="images/btn_notshared.gif" width="16" height="18" border="0" alt="#translate("Not Shared")#" title="#translate("Not Shared")#">'>
                  <cfelseif status is this.workflow.STATUS.CLONED>
                        <cfreturn '<img src="images/btn_cloned.gif" width="16" height="18" border="0" alt="#translate("Cloned")#" title="#translate("Cloned")#">'>      
                  <cfelseif status is this.workflow.STATUS.LOCK>
                        <!--- if it's locked, we want to find out the administrator's name who locked it --->
                        <cfset qryLockUsers = this.workflow.getLockUsers(qryRecords.intItemID)>
                        
                        <cfif selectFrom(qryLockUsers, "intUserID", SESSION.userid).recordcount>
                              <cfreturn '<img src="images/btn_extranet.gif" width="16" height="18" border="0" alt="#translate("Locked")#" title="#translate("Locked")#">'>
                        </cfif>
                        <cfif qryLockUsers.recordcount is 1>
                              <cfif not isDefined("this.access")>
                                    <cfset this.access = createObject("component", "hb50.access").init(this.CompanyID)>
                              </cfif>
                              <!--- in case the user doesnt exist, or something goes wrong, we'll do this try & catch --->
                              <cftry>
                                    <cfset lockmsg = translate("Locked by") & " " & this.access.getUserData(qryLockUsers.intUserID).realname>
                                    <cfcatch></cfcatch>
                              </cftry>
                        <cfelse>
                              <cfset lockmsg = translate('Locked and waiting for approval')>
                        </cfif>

                        <cfset image = '<img src="images/btn_lock.gif" width="16" height="18" border="0" alt="#lockmsg#" title="#lockmsg#">'>
                        
                        <cfreturn image />
                  <cfelseif status is this.workflow.STATUS.PENDING>
                        <cfif StructKeyExists(qryRecords, 'dtStart')>
                              <cfreturn '<img src="images/btn_pending.gif" width="16" height="18" border="0" alt="#translate("Pending until")# #DateFormat(qryRecords.dtStart, "mmmm d, yyyy")# at #TimeFormat(qryRecords.dtStart, "h:mm tt")#" title="#translate("Pending until")# #DateFormat(qryRecords.dtStart, "mmmm d, yyyy")# at #TimeFormat(qryRecords.dtStart, "h:mm tt")#">'>
                        <cfelse>
                              <cfreturn '<img src="images/btn_pending.gif" width="16" height="18" border="0" alt="#translate("Pending")#" title="#translate("Pending")#">'>
                        </cfif>
                  <cfelseif status is this.workflow.STATUS.EXPIRED>
                        <cfif StructKeyExists(qryRecords, 'dtEnd')>
                              <cfreturn '<img src="images/btn_expired.gif" width="16" height="18" border="0" alt="#translate("Expired on")# #DateFormat(qryRecords.dtEnd, "mmmm d, yyyy")# at #TimeFormat(qryRecords.dtEnd, "h:mm tt")#" title="#translate("Expired on")# #DateFormat(qryRecords.dtEnd, "mmmm d, yyyy")# at #TimeFormat(qryRecords.dtEnd, "h:mm tt")#">'>
                        <cfelse>
                              <cfreturn '<img src="images/btn_expired.gif" width="16" height="18" border="0" alt="#translate("Expired")#" title="#translate("Expired")#">'>
                        </cfif>
                  <cfelse>
                        <cfreturn '&nbsp;' />
                  </cfif>
            
            <!--- Jason: hack to display the link validation status icon (DAM) --->      
            <cfelseif ListFindNoCase(qryRecords.columnlist, "blnValidateLink")>
                  <cfif Val(qryRecords.blnValidateLink)>
                        <cfreturn '<img src="images/ico_pass.gif" border="0" align="absmiddle" alt="#translate("Valid Link")#" title="#translate("Valid Link")#">' />
                  <cfelse>
                        <cfreturn '<img src="images/ico_alert.gif" border="0" align="absmiddle" alt="#translate("Invalid Link")#" title="#translate("Invalid Link")#">' />      
                  </cfif>
            </cfif>

            <cfreturn "&nbsp;" />
      </cffunction>

      <!--- wraps buttonCode in the layer that buttons need to go in.
              you can only use it once or other buttons will just overlap in the same spot.
      --->
      <cffunction name="getButtonLayer" access="public" returntype="string" output="false">
            <cfargument name="buttonCode" type="string" required="true">

            <cfsavecontent variable="output">
                  <div id="Buttons" style="position:absolute; left:-1px; top:269px; width:544px; height:22px; z-index:16" align="right">
                        <cfoutput>#buttonCode#</cfoutput>
                  </div>
            </cfsavecontent>
            
            <cfreturn output />
      </cffunction>

      <!--- wraps toolbarCode in the layer that the toolbar needs to go in.
              only use this once per template
      --->
      <cffunction name="getToolbarLayer" access="public" returntype="string" output="false">
            <cfargument name="toolbarCode" type="string" required="true">

            <cfsavecontent variable="output">
                  <div id="Search" style="position:absolute; left:-1px; top:-45px; width:543px; height:200px; z-index:-1;">
                        <cfoutput>#toolbarCode#</cfoutput>
                  </div>
            </cfsavecontent>
            
            <cfreturn output />
      </cffunction>

      <!--- wraps code in the inner layer. only use this once per template --->
      <cffunction name="getInnerLayer" access="public" returntype="string" output="false">
            <cfargument name="code" type="string" required="true">
            <cfargument name="name" type="string" required="false" default="innerLayer">
            <cfargument name="scrolling" type="boolean" required="false" default="false">
            <cfargument name="auto" type="boolean" required="false" default="false">

            <cfsavecontent variable="output">
                  <div id="<cfoutput>#name#</cfoutput>" style="overflow:<cfif scrolling><cfif auto>auto<cfelse>scroll</cfif><cfelse>none</cfif>; position:absolute; left:0px; top:0px; width:543px; height:263px;">
                        <cfoutput>#code#</cfoutput>
                  </div>
            </cfsavecontent>
            
            <cfreturn output />
      </cffunction>

      <!--- Returns 'content' formatted with the minimal formatting needed for a 'box', ie., for add/edit --->
      <cffunction name="getBox" access="public" returntype="string" output="false">
            <cfargument name="title" type="string" required="true">
            <cfargument name="body" type="string" required="true">

            <cfreturn body />
      </cffunction>

      <!--- Returns the pagination structure --->
      <cffunction name="getPagination" access="public" returntype="struct" output="false">
            <cfargument name="Records" type="numeric" required="true">
            <cfargument name="RecordsToDisplay" type="numeric" required="true">
            <cfargument name="SR" type="numeric" required="false" default="1">

            <cfscript>
                  var output = StructNew();
                  var prefix = 2;
                  var numShow = 5;
                  var curPage = 0;

                  SR = Min(Max(1, arguments.SR), arguments.Records);
                  curPage = Ceiling(SR / arguments.RecordsToDisplay);                  
                  
                  output.SR = SR;
                  output.Records = arguments.Records;
                  output.RecordsToDisplay = arguments.RecordsToDisplay;
                  output.prev = 0;
                  output.next = 0;
                  
                  output.numPages = Ceiling(arguments.Records / arguments.RecordsToDisplay);
                  output.startPage = Max(1, min(output.numPages - numShow + 1, curPage - prefix));
                  output.endPage = Min(output.startPage + numShow - 1, output.numPages);
                  output.lastPage = (output.numPages - 1) * arguments.RecordsToDisplay + 1;

                  if (SR gte arguments.RecordsToDisplay)
                        output.prev = SR - arguments.RecordsToDisplay;

                  if ((SR + arguments.RecordsToDisplay) lte arguments.Records)
                        output.next = SR + arguments.RecordsToDisplay;

                  return output;
            </cfscript>
      </cffunction>

      <!--- does a standard pagination, for public use when we don't implement a custom one --->
      <cffunction name="getPaginationDisplay" access="public" returntype="string" output="false">
            <cfargument name="Records" type="numeric" required="true" />
            <cfargument name="RecordsToDisplay" type="numeric" required="true" />
            <cfargument name="SR" type="numeric" required="false" default="1" />
            
            <cfscript>
                  var pag = StructNew();
                  var page = '';
                  var num = 0;
                  var startrow = 0;
            </cfscript>
            
            <cfif arguments.Records lte arguments.RecordsToDisplay or arguments.RecordsToDisplay gt arguments.Records>
                  <cfreturn '' />
            </cfif>

            <cfset pag = getPagination(arguments.Records, arguments.RecordsToDisplay, arguments.SR)>
            <cfset page = getCurrentURL()>
            
            <!--- Added by Daniel --->
            <cfif Find("?", page) lte 0>
                  <cfset page = page & "?">
            <cfelse>
                  <cfset page = page & "&">
            </cfif>

            <cfsavecontent variable="output">
                  <cfoutput>
                        <div id="hbpagestop">
                              <ul>
                                    <li><a <cfif arguments.SR gt 1>href="#page#SR=#pag.prev#"<cfelse>disabled</cfif> title="Previous Page" class="prev"><em>&lsaquo;&lsaquo;</em>Previous</a></li>
                                    <cfloop from="#pag.startPage#" to="#pag.endPage#" index="num">
                                          <cfset startrow = (num-1) * arguments.RecordsToDisplay + 1>
                                          <cfif startrow is arguments.SR>
                                                <li>#num#</li>
                                          <cfelse>
                                                <li><a href="#page#SR=#startrow#" title="Page #num#">#num#</a></li>
                                          </cfif>
                                    </cfloop>
                                    <li><a <cfif pag.next>href="#page#SR=#pag.next#"<cfelse>disabled</cfif> title="Next Page" class="next">Next<em>&rsaquo;&rsaquo;</em></a></li>
                              </ul>
                              <p>#SR#-#Min(arguments.SR + arguments.RecordsToDisplay - 1, arguments.Records)# of #arguments.Records#</p>
                        </div>
                  </cfoutput>
            </cfsavecontent>

            <cfreturn output />
      </cffunction>

      <!--- returns a form broken into a number of tabs --->
      <cffunction name="getFormTabs" access="public" returntype="string" output="false">
            <cfargument name="formData" type="any" required="true">
            <cfargument name="qryData" type="query" required="false">
            
            <cfscript>
                  var tabs = Duplicate(formdata.tabs);
                  var htmltabs = '';
                  var x = '';
                  var y = '';
                  var size = 0;
                  var maxTabs = 6;
                  var i = '';
                  var tabstyle = '';
                  var listMode = '';
                  
                  if (isDefined("formdata.maxTabs") and Val(formdata.maxTabs))
                        maxTabs = formdata.maxTabs;
            </cfscript>

            <cfif ArrayLen(tabs) is 0>
                  <cfset htmltabs = ArrayNew(1)>
                  <cfset x = StructNew()>
                  <cfset x.caption = formData.title>
                  <cfset x.columnlist = "">
                  
                  <cfloop from="1" to="#ArrayLen(formData.columns)#" index="key">
                        <cfif ListFind("#TYPES.HTML#,#TYPES.LIST#", formData.columns[key].type)>
                              <cfset y = StructNew()>
                              <cfset y.caption = formData.columns[key].title>
                              <cfset y.columnlist = formData.columns[key].varname>
                              <cfset ArrayAppend(htmltabs, y)>
                        <cfelse>
                              <cfset x.columnlist = ListAppend(x.columnlist, formData.columns[key].varname)>
                        </cfif>
                  </cfloop>
                  
                  <cfif ListLen(x.columnlist)>
                        <cfset ArrayAppend(tabs, x)>
                  </cfif>
                  <cfif ArrayLen(htmltabs)>
                        <cfloop from="1" to="#ArrayLen(htmltabs)#" index="i">
                              <cfset ArrayAppend(tabs, htmltabs[i])>
                        </cfloop>
                  </cfif>
            </cfif>
            
            <cfscript>
                  //content containers
                  if (formData.blnContainers) {
                        x = StructNew();
                        x.caption = "Content Containers";
                        x.columnlist = "containers";
                        ArrayAppend(tabs, x);
                  }
                  
                  //tagging
                  if (formData.blnTagging) {
                        x = StructNew();
                        x.caption = "Tagging";
                        x.columnlist = "tagging";
                        x.scroll = true;
                        x.auto = true;
                        ArrayAppend(tabs, x);
                  }
            </cfscript>
            
            <cfif formData.blnMeta>
                  <cfsavecontent variable="editForm">
                        <div class="txtMetaType"><input type="text" name="txtMetaType" class="formTextbox" style="width: 50px; border: 1;" disabled="true"></div>
                        <div class="txtMetaName"><input type="text" name="txtMetaName" class="formTextbox" style="width: 130px; border: 1;" disabled="true"></div>
                        <div class="txtMetaValue"><input type="text" name="txtMetaValue" class="formTextbox" style="width: 347px; border: 1;" disabled="true"></div>
                  </cfsavecontent>
                  <cfsavecontent variable="httpHeader">
                        <table class="tableOutline" border="0" cellspacing="1" cellpadding="0">
                                <tr>
                                     <td width="150" height="21" class="toolHeader">HTTP-Equiv</td>
                                     <td width="377" class="toolHeader">Content</td>
                                </tr>
                        </table>
                  </cfsavecontent>
                  <cfsavecontent variable="nameHeader">
                        <table class="tableOutline" border="0" cellspacing="1" cellpadding="0">
                                <tr>
                                     <td width="50" height="21" class="toolHeader">Type</td>
                                     <td width="130" height="21" class="toolHeader">Name</td>
                                     <td width="347" class="toolHeader">Content</td>
                                </tr>
                        </table>
                  </cfsavecontent>
                  
                  <cfscript>
                        listMode = '<div class="txtMetaType">,</div>#CHR(13)##CHR(10)#<div class="txtMetaName">,</div>#CHR(13)##CHR(10)#<div class="txtMetaValue">,</div>';
                                          
                        x = StructNew();
                        x.varname = "txtNameValues";
                        x.title = "Advanced Meta";
                        x.type = TYPES.LIST;
                        x.collist = 'txtMetaType,txtMetaName,txtMetaValue';
                        
                        x.headerText = nameHeader;
                        x.editHTML = editForm;
                        x.listHTML = listMode;
                        x.required = false;
                        x.display = false;
                        ArrayAppend(formData.columns, x);
      
                        x = StructNew();
                        x.caption = "Basic Meta";
                        x.columnlist = "txtMeta";
                        ArrayAppend(tabs, x);
      
                        x = StructNew();
                        x.caption = "Advance Meta";
                        x.columnlist = "txtNameValues";
                        ArrayAppend(tabs, x);
                  </cfscript>
            </cfif>
            
            <cfscript>
                  //additional resources
                  if (formData.blnResources) {
                        x = StructNew();
                        x.caption = "Related Info";
                        x.columnlist = "resources";
                        ArrayAppend(tabs, x);
                  }
                  //scheduling
                  if (formData.blnScheduling) {
                        x = StructNew();
                        x.caption = "Schedule";
                        x.columnlist = "dtStart,dtEnd";
                        ArrayAppend(tabs, x);
                  }
            </cfscript>
            
            <cfsavecontent variable="output">
                  <cfoutput>
                        <cfset size = ArrayLen(tabs)>
                        <cfif size gt maxTabs>
                              <cfset size = maxTabs>
                        </cfif>
                        
                        <cfloop from="1" to="#size#" index="i">
                              <cfoutput>
                                    <div id="edit#i#" style="position:absolute; left:5px; top:-15px; width:525px; height:15px; z-index:3;">
                                          <table border="0" cellspacing="0" cellpadding="0" align="right" class="tabSmall">
                                                <tr>
                                                <cfloop from="1" to="#size#" index="j">
                                                      <cfif i is j>
                                                            <cfset tabstyle = "Y">
                                                      <cfelse>
                                                            <cfset tabstyle = "N">
                                                      </cfif>
                                                      <td class="tabsml#tabstyle#l"><img src="images/shim.gif" width="11" height="15"></td>
                                                      <td class="tabsml#tabstyle#c"><a onclick="jsTabSwitch(#j#);">#translate(tabs[j].caption)#</a></td>
                                                      <td class="tabsml#tabstyle#r"><img src="images/shim.gif" width="11" height="15"></td>
                                                </cfloop>
                                                <cfif size LT ArrayLen(tabs)>
                                                      <td><img src="images/shim.gif" width="11" height="15"></td>
                                                      <td valign="top"><a onclick="jsTabSwitch(#size + 1#);"><img src="images/btn_next.gif" title="more"></a></td>
                                                      <td><img src="images/shim.gif" width="6" height="15"></td>
                                                </cfif>
                                                </tr>
                                          </table>
                                    </div>
                              </cfoutput>
                      </cfloop>
            
                        <cfset size = size + 1>
                        <cfloop from="#size#" to="#Arraylen(tabs)#" index="i">
                              <cfoutput>
                                    <div id="edit#i#" style="position:absolute; left:5px; top:-15px; width:525px; height:15px; z-index:3;">
                                          <table border="0" cellspacing="0" cellpadding="0" align="right" class="tabSmall">
                                                <tr>
                                                    <td><img src="images/shim.gif" width="6" height="15"></td>
                                                      <td valign="top"><a onclick="jsTabSwitch(#size - 1#);"><img src="images/btn_back.gif" title="more"></a></td>
                                                      <td><img src="images/shim.gif" width="11" height="15"></td>
                                                <cfloop from="#size#" to="#ArrayLen(tabs)#" index="j">
                                                      <cfif i is j>
                                                            <cfset tabstyle = "Y">
                                                      <cfelse>
                                                            <cfset tabstyle = "N">
                                                      </cfif>
                                                      <td class="tabsml#tabstyle#l"><img src="images/shim.gif" width="11" height="15"></td>
                                                      <td class="tabsml#tabstyle#c"><a onclick="jsTabSwitch(#j#);">#translate(tabs[j].caption)#</a></td>
                                                      <td class="tabsml#tabstyle#r"><img src="images/shim.gif" width="11" height="15"></td>
                                                </cfloop>
                                                </tr>
                                          </table>
                                    </div>
                              </cfoutput>
                      </cfloop>
                        
                        <!--- put these in reverse order so that the first tab ends up on top
                                I don't know why this works, but it fixed a problem where I couldn't put the focus into a text input.
                        --->
                        <cfloop to="1" from="#ArrayLen(tabs)#" step="-1" index="k">
                              <cfif not StructKeyExists(tabs[k], "body")>
                                    <cfinvoke method="getForm" returnvariable="formhtml">
                                          <cfinvokeargument name="formData" value="#formData#">
                                          <cfif isDefined("qryData")>
                                                <cfinvokeargument name="qryData" value="#qryData#">
                                          </cfif>
                                          <cfinvokeargument name="columnNames" value="#tabs[k].columnlist#">
                                    </cfinvoke>
                                    <cfset tabs[k].body = formhtml>
                              </cfif>
                              #getInnerLayer(tabs[k].body, "innerTab#k#", (StructKeyExists(tabs[k], "scroll") and tabs[k].scroll), (StructKeyExists(tabs[k], "auto") and tabs[k].auto))#
                        </cfloop>
            
                        <script language="JavaScript">
                              var tabList = new Array();
                              <cfloop from="1" to="#ArrayLen(tabs)#" index="i">
                                    tabList[#i#] = '#tabs[i].caption#';
                              </cfloop>
                              
                              function jsTabSwitch(tab) {
                                    document.body.onbeforeunload = null;
                                    P7_autoLayers(4,'edit' + tab,'edit','innerTab' + tab);
                                    <cfloop from="1" to="#ArrayLen(tabs)#" index="j">
                                          if (tab == #j#) {
                                                <cfloop list="#tabs[j].columnlist#" index="varname">
                                                      if (document.getElementById('#varname#') != undefined) {
                                                            document.getElementById('#varname#').style.display = 'block';
                                                      }
                                                </cfloop>
                                                <cfloop from="1" to="#ArrayLen(formData.columns)#" index="key">
                                                      <cfset i = formData.columns[key]>
            
                                                      <cfif ListFindNoCase(tabs[j].columnlist, i.varname) and i.type is this.TYPES.HTML>
                                                            turnEditOn_#i.varname# ()
                                                      </cfif>
            
                                                      <cfif not ListFindNoCase(tabs[j].columnlist, i.varname)>
                                                            if (document.getElementById('#i.varname#') != undefined) {
                                                                  document.getElementById('#i.varname#').style.display = 'none';
                                                            }
                                                      </cfif>
                                                </cfloop>
                                          }
                                    </cfloop>
                                    
                                    switch(tabList[tab].toLowerCase()) {
                                          case 'overview':
                                                document.getElementById('settingsOverviewChanged').value = 1;
                                                break;
                                          case 'extranet':
                                                document.getElementById('settingsExtranetChanged').value = 1;
                                                break;
                                          case 'sharing':
                                                document.getElementById('settingsSharingChanged').value = 1;
                                                break;
                                          case 'workflow':
                                                document.getElementById('settingsWorkflowChanged').value = 1;
                                                break;
                                          case 'conversion':
                                                document.getElementById('settingsConversionChanged').value = 1;
                                                break;
                                          case 'campaign':
                                                document.getElementById('settingsCampaignChanged').value = 1;
                                                break;
                                          case 'blog':
                                                document.getElementById('settingsBlogChanged').value = 1;
                                                break;
                                          case 'webtrends&reg;':
                                                document.getElementById('settingsWTODChanged').value = 1;
                                                break;
                                          case 'google sitemaps':
                                                document.getElementById('settingsGoogleSitemapChanged').value = 1;
                                                break;
                                    }
                              }
                              <!--- this fixes some bug where you can't put in focus --->
                              <cfloop from="#ArrayLen(tabs)#" to="1" index="j" step="-1">
                                    P7_autoLayers(4,'edit#j#','edit','innerTab#j#');
                              </cfloop>
                              jsTabSwitch(1);
                        </script>
                  </cfoutput>
            </cfsavecontent>

            <cfreturn output />
      </cffunction>

      <!--- returns the add/edit form fields, based on data in formData, and filled in with values from qryData --->
      <cffunction name="getForm" access="public" returntype="string" output="false">
            <cfargument name="formData" type="any" required="true">
            <cfargument name="qryData" type="query" required="false">
            <cfargument name="columnNames" type="string" required="false">
            
            <cfscript>
                  var media = '';
                  var output = '';
                  var blnInherit = false;
                  var contentcontainer = '';
                  var tagMgr = '';
                  var value = '';
                  var i = '';
                  var count = 1;
                  var key = '';
            </cfscript>

            <!--- if columnNames is "resources", then this form is the additional resources form --->
            <cfif isDefined("columnNames") and columnNames is "resources">
                  <cfset media = createObject("component", "hb50.media").init(this.CompanyID)>
                  <cfsavecontent variable="output">
                        <img src="images/shim.gif" height="13" width="1" alt="">
                        <div align="center">
                              <cfoutput>
                                    <cfif isDefined("qryData.intResourceID")>
                                          #media.getAdditionalResourcesForm("resources", qryData.intResourceID)#
                                    <cfelse>
                                          #media.getAdditionalResourcesForm("resources")#
                                    </cfif>
                              </cfoutput>
                        </div>
                  </cfsavecontent>
                  
                  <cfreturn output />
            </cfif>

            <!--- Donny: Basic Meta Tag version
            if columnNames is "txtMeta", then this form is the meta data --->
            <cfif isDefined("columnNames") and columnNames is "txtMeta">
                  <cfsavecontent variable="output">
                        <cfoutput>
                              <!--- retrieve keywords and description, will be copies from formData.query to formData.metaquery --->
                              <cfstoredproc datasource="#this.datasource#" procedure="getContentMeta" debug="yes">
                                    <cfprocparam cfsqltype="cf_sql_integer" value="#formData.webid#" type="in">
                                    <cfprocresult name="qryMeta">
                              </cfstoredproc>
      
                              <cfif not(isDefined("URL.id") and Val(URL.id) and isDefined("FORM.intVersionID") and Val(FORM.intVersionID))>
                                    <!--- Donny: for global metatag in Admin. > Website Control > Meta Data --->
                                    <cfquery name="qryData" datasource="#this.datasource#" cachedwithin="#this.queryCache#">
                                          SELECT       txtMetaKeywords, txtMetaDescription
                                          FROM       tblCompany
                                          WHERE       intCompanyID = #Val(this.companyID)#
                                    </cfquery>
                              </cfif>
      
                              <cfset blnInherit = ((not isDefined("qryData.txtMetaKeywords")) or (not isDefined("qryData.txtMetaDescription")) or (qryData.txtMetaKeywords is "" and qryData.txtMetaDescription is ""))>
      
                              <script>
                                    function jsMetaDisable(form, checked) {
                                          form.txtMetaKeywords.disabled = !checked;
                                          form.txtMetaDescription.disabled = !checked;
                                          
                                          if (checked){
                                                form.btnDelete_txtNameValues.style.visibility = "";
                                                form.btnMetaTag_txtNameValues.style.visibility = "";
                                          } else {
                                                form.btnDelete_txtNameValues.style.visibility = "hidden";
                                                form.btnMetaTag_txtNameValues.style.visibility = "hidden";
                                          }
                                    }
      
                                    <cfif (not blnInherit)>
                                          document.frmAddEdit.btnDelete_txtNameValues.style.visibility = ""
                                          document.frmAddEdit.btnMetaTag_txtNameValues.style.visibility = ""
                                    </cfif>
                                    
                                    onclick="jsMetaDisable(this.form, this.checked);"
                              </script>
                              <div class="default" style="padding: 17px; display: none;" id="txtMeta">
                                    <!--- todo :: 952 :: KJ :: 7 dec 2006 :: Change "Meta Data" [text] to "Metadata" [text] --->
                                    <input name="blnInherit" type="checkbox" <cfif not blnInherit> checked</cfif> onclick="jsMetaDisable(this.form, this.checked);"> #translate("Use Custom Metadata")#<br /><br />
                                    #this.language.translate("Enter any extra words you would like associated with this item.")#<br />
                                    #this.language.translate("These words will help this item show up in more search results.")#<br />
                                    <br />
                                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                          <tr>
                                                <td width="50%">
                                                      <font class="formCaption">#translate("Keywords")#:</font><br />
                                                      <textarea style="width: 240px; height: 130px;" class="formTextarea" name="txtMetaKeywords"<cfif blnInherit> disabled</cfif>><cfif blnInherit>#qryMeta.txtMetaKeywords#<cfelseif isDefined("qryData.txtMetaKeywords")>#qryData.txtMetaKeywords#</cfif></textarea>
                                                </td>
                                                <td width="50%">
                                                      <font class="formCaption">#translate("Description")#:</font><br />
                                                      <textarea style="width: 240px; height: 130px;" class="formTextarea" name="txtMetaDescription"<cfif blnInherit> disabled</cfif>><cfif blnInherit>#qryMeta.txtMetaDescription#<cfelseif isDefined("qryData.txtMetaDescription")>#qryData.txtMetaDescription#</cfif></textarea>
                                                </td>
                                          </tr>
                                    </table>
                              </div>
                        </cfoutput>
                  </cfsavecontent>
                  
                  <cfreturn output />
            </cfif>
            
            <!--- content containers petite tab --->
            <cfif isDefined("columnNames") and columnNames is "containers">
                  <cfset contentcontainer = createObject("component", "hb50.contentcontainers").init(this.CompanyID) />
                  <cfsavecontent variable="output">
                        <cfoutput>
                              <cfif isDefined('URL.id') and Val(URL.id)>
                                    #contentcontainer.getContentContainerForm("containers", Val(URL.id))#
                              <cfelse>
                                    #contentcontainer.getContentContainerForm("containers")#
                              </cfif>
                        </cfoutput>
                  </cfsavecontent>
                  
                  <cfreturn output />
            </cfif>
            
            <!--- tagging petite tab --->
            <cfif isDefined("columnNames") and columnNames is "tagging">
                  <!--- Jason: should we cache this tagging object?! --->
                  <cfset tagMgr = getObject("hb50.internal.CTagManager", this.CompanyID, true)>
                  <cfsavecontent variable="output">
                        <cfoutput>
                              <cfif isDefined('URL.id') and Val(URL.id)>
                                    #tagMgr.getTaggingForm("tagging", Val(URL.id))#
                              <cfelse>
                                    #tagMgr.getTaggingForm("tagging")#
                              </cfif>
                        </cfoutput>
                  </cfsavecontent>
                  
                  <cfreturn output />
            </cfif>
            
            <!--- if columnNames is "dtSchedule", then this form is the scheduling --->
            <cfif isDefined("columnNames") and columnNames is "dtStart,dtEnd">
                  <cfsavecontent variable="output">
                        <cfoutput>
                              <script type="text/javascript" src="js/swfobject.js"></script>
                              <!--- this div is set display:block; so that the flash will show up in opera (one time only). weird bug. --->
                              <div id="dtStart" style="display: block;" class="padding17">
                                    <cfif isDefined("qryData.dtStart") and isDate(qryData.dtStart)>
                                          <cfset value = qryData.dtStart>
                                    <cfelse>
                                          <cfset value = now()>
                                    </cfif>
                                    <input type="hidden" id="dtStart_hidden" name="dtStart_hidden" value="#DateFormat(value, "mmm-dd-yy")#">
                                    <fieldset class="formFieldset">
                                          <legend>
                                                <input name="dtStart_chk" type="checkbox" <cfif isDefined("qryData.dtStart") and qryData.dtStart neq "">checked</cfif>> #translate("Start Date and Time")#
                                          </legend>
                                          <table width="100%" border="0" cellspacing="12" class="formCaption">
                                                <tr>
                                                      <td width="210" >
                                                            <div id="flash_swf_start">
                                                            </div>
                                                            <script type="text/javascript">
                                                                  //not needed unless you want to reference the flash movie object later
                                                                  //var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
                                                                  
                                                                  // Handle all the the FSCommand messages in a Flash movie. Uncomment
                                                                  function dtStartflash_DoFSCommand(command, args)
                                                                  {
                                                                        //the line below is left as a guide in case you want to reference
                                                                        //the movie object
                                                                    //var weekviewObj = InternetExplorer ? weekview : document.dt;
                                                                    
                                                                    //alert(args);
                                                                    document.getElementById('dtStart_hidden').value = args;
                                                                  }
                                                                  // Hook for Internet Explorer
                                                                  if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
                                                                          navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1)
                                                                  {
                                                                        document.write('<SCRIPT LANGUAGE=VBScript\> \n');
                                                                        document.write('on error resume next \n');
                                                                        document.write('Sub dtStartflash_FSCommand(ByVal command, ByVal args)\n');
                                                                        document.write('  call dtStartflash_DoFSCommand(command, args)\n');
                                                                        document.write('end sub\n');
                                                                        document.write('</SCRIPT\> \n');
                                                                  }      
                                                               var so = new SWFObject("flash/weekview.swf", "dtStartflash", "200", "31", "7", "##336699");
                                                               so.addVariable("day","#Day(value)#");
                                                               so.addVariable("month","#Month(value)#");
                                                               so.addVariable("year","#Year(value)#");
                                                               so.write("flash_swf_start");
                                                            </script>
                                                      </td>
                                                      <td valign="top" align="left">
                                                            <input type="text" class="formTextbox" name="dtStart_time" id="dtStart_time" value="#TimeFormat(value, "h:MM tt")#" style="width: 50px;" maxlength="8">
                                                      </td>
                                                </tr>
                                          </table>
                                    </fieldset>      
                              </div>
                              <div id="dtEnd" style="display: block;" class="padding17">      
                                    <cfif isDefined("qryData.dtEnd") and isDate(qryData.dtEnd)>
                                          <cfset value = qryData.dtEnd>
                                    <cfelse>
                                          <cfset value = now()>
                                    </cfif>
                                    <input type="hidden" id="dtEnd_hidden" name="dtEnd_hidden" value="#DateFormat(value, "mmm-dd-yy")#">
                                    <fieldset class="formFieldset">
                                          <legend>
                                                <input type="checkbox" name="dtEnd_chk" <cfif isDefined("qryData.dtEnd") and qryData.dtEnd neq "">checked</cfif>> #translate("End Date and Time")#
                                          </legend>
                                          <table width="100%" border="0" cellspacing="12" class="formCaption">
                                                <tr>
                                                      <td width="210">
                                                            <div id="flash_swf_end">
                                                            </div>
                                                            <script type="text/javascript">                                                                  
                                                                  //not needed unless you want to reference the flash movie object later
                                                                  //var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
                                                                  
                                                                  // Handle all the the FSCommand messages in a Flash movie
                                                                  function dtEndflash_DoFSCommand(command, args)
                                                                  {
                                                                        //the line below is left as a guide in case you want to reference
                                                                        //the movie object
                                                                    //var weekviewObj = InternetExplorer ? weekview : document.weekview;
                                                                    
                                                                    //alert(args);
                                                                    document.getElementById('dtEnd_hidden').value = args;
                                                                  }
                                                                  // Hook for Internet Explorer
                                                                  if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
                                                                          navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1)
                                                                  {
                                                                        document.write('<SCRIPT LANGUAGE=VBScript\> \n');
                                                                        document.write('on error resume next \n');
                                                                        document.write('Sub dtEndflash_FSCommand(ByVal command, ByVal args)\n');
                                                                        document.write('  call dtEndflash_DoFSCommand(command, args)\n');
                                                                        document.write('end sub\n');
                                                                        document.write('</SCRIPT\> \n');
                                                                  }
                                                               var so = new SWFObject("flash/weekview.swf", "dtEndflash", "200", "31", "7", "##336699");
                                                               so.addVariable("day","#Day(value)#");
                                                               so.addVariable("month","#Month(value)#");
                                                               so.addVariable("year","#Year(value)#");
                                                               so.write("flash_swf_end");
                                                            </script>
                                                      </td>
                                                      <td valign="top" align="left">
                                                            <input type="text" class="formTextbox" name="dtEnd_time" id="dtEnd_time" value="#TimeFormat(value, "h:MM tt")#" style="width: 50px;" maxlength="8">
                                                      </td>
                                                </tr>
                                          </table>
                                    </fieldset>
                              </div>
                        </cfoutput>
                  </cfsavecontent>
                  
                  <cfreturn output />
            </cfif>

            <cfsavecontent variable="output">
                  <cfoutput>
                        <!--- First, display all the types that fit within a half row --->
                        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="formCaption">
                        <cfloop from="1" to="#ArrayLen(formData.columns)#" index="key">
                              <cfset i = formData.columns[key]>
                              
                              <cfif (not isDefined("columnNames")) or ListFindNoCase(columnNames, i.varname)>
                                    <!--- display all the non-html first (and assume HTML only shows up at end) --->
                                    <cfif not ListFind("#TYPES.HTML#,#TYPES.LIST#", i.type)>
                                            <cfif count mod 2 is 1>
                                                <tr>
                                            </cfif>
                                          <td width="50%" valign="<cfif i.type is TYPES.BOOLEAN>bottom<cfelse>top</cfif>">
                                                <cfif isDefined("qryData")>
                                                      #getFormItemDisplay(formData, i, qryData)#
                                                <cfelse>
                                                      #getFormItemDisplay(formData, i)#
                                                </cfif>
                                          </td>
                                            <cfif count mod 2 is 0>
                                                </tr>
                                            </cfif>
                                            <cfset count = count + 1>
                                      </cfif>
                                 </cfif>
                        </cfloop>
                        <cfif count mod 2 is 0>
                              <td>&nbsp;</td></tr>
                        </cfif>
            
                        <!--- display the types that require a full tab --->
                        <cfloop from="1" to="#ArrayLen(formData.columns)#" index="key">
                              <cfset i = formData.columns[key]>
                              <cfif (not isDefined("columnNames")) or ListFindNoCase(columnNames, i.varname)>
                                    <cfif ListFind("#TYPES.HTML#,#TYPES.LIST#", i.type)>
                                          <!--- display only html --->
                                          <tr>
                                                <td colspan="2" valign="top">
                                                <cfif isDefined("qryData")>
                                                      #getFormItemDisplay(formData, i, qryData)#
                                                <cfelse>
                                                      #getFormItemDisplay(formData, i)#
                                                </cfif>
                                                </td>
                                          </tr>
                                    </cfif>
                              </cfif>
                        </cfloop>
                        </table>
            
                        <!--- if there is a TYPE type, this javascript needs to come after all the form elements --->
                        <cfloop from="1" to="#ArrayLen(formData.columns)#" index="key">
                              <cfset i = formData.columns[key]>
                              <cfif i.type is TYPES.TYPE and ((not isDefined("columnNames")) or ListFindNoCase(columnNames, i.varname))>
                                    <script language="JavaScript">
                                          function hideAllForm() {
                                                <cfloop from="1" to="#ArrayLen(formData.columns)#" index="key">
                                                      <cfset k = formData.columns[key]>
                                                      <cfif k.type neq TYPES.TYPE>
                                                            document.getElementById('#k.varname#').style.display = 'none';
                                                      </cfif>
                                                </cfloop>
                                          }
                                          function changeType() {
                                                var type = document.getElementById('#i.varname#_select').selectedIndex;
                                                hideAllForm();
                                                <cfloop from="1" to="#ArrayLen(i.options)#" index="k">
                                                      if (type == #i.options[k].value#) {
                                                            <cfloop list="#i.options[k].fields#" index="varname">
                                                                  document.getElementById('#varname#').style.display = 'block';
                                                            </cfloop>
                                                      }
                                                </cfloop>
                                          }
                                          changeType();
                                    </script>
                                    <cfbreak>
                              </cfif>
                        </cfloop>
                  </cfoutput>
            </cfsavecontent>

            <cfreturn output />
      </cffunction>

      <cffunction name="getVersionForm" access="public" returntype="string" hint="Returns Version select box" output="false">
            <cfargument name="qryVersion" required="true" type="query">
            <cfargument name="intVersionID" required="true" type="numeric">
            <cfargument name="link" required="true" type="string">
            <cfargument name="formName" required="false" default="frmVersion">
            
            <cfscript>
                  var options = '';
                  var currentVersion = translate("Active Version");
                  var output = '';
            </cfscript>
                        
            <cfsavecontent variable="options">
                  <cfoutput query="qryVersion">
                        <cfif qryVersion.blnLive is 0 and arguments.intVersionID is qryVersion.intID>
                              <cfset currentVersion = "#DateFormat(qryVersion.dtAdded, "mmm dd yyyy")# #TimeFormat(qryVersion.dtAdded, "h:MMtt")#">
                        </cfif>
                        <option value="#qryVersion.intID#" <cfif arguments.intVersionID is qryVersion.intID>selected</cfif>><cfif qryVersion.blnLive is 1>#translate("Active Version")#<cfelse>#DateFormat(qryVersion.dtAdded, "mmm dd yyyy")# #TimeFormat(qryVersion.dtAdded, "h:MMtt")#</cfif></option>
                  </cfoutput>
            </cfsavecontent>
            <cfsavecontent variable="output">
                  <cfoutput>
                        <div id="versions" style="position:absolute; left:396px; top:294px; width:147px; height:15px; z-index:50" class="bevelEmbossStatus">
                              <div id="versionText" style="position:absolute; left:3px; top:1px; width:120px; height:11px; z-index:7">#currentVersion#</div>
                              <div id="versionsSelect" style="position:absolute; left:130px; top:-2px; width:15px; height:15px; z-index:6"><a onmouseover="this.style.cursor = 'pointer'; this.style.cursor = 'hand'; document.body.onbeforeunload = null;" onmouseout="if (window.jsSaveWarning) jsSaveWarning();" onclick="document.getElementById('versionList').style.visibility = 'visible'; document.getElementById('intVersionID').style.visibility = 'visible'; document.getElementById('intVersionID').focus();"><img src="images/btn_status_arrow.gif" width="15" height="15" border="0"></a></div>
                              <div id="versionList" style="position:absolute; left:-1px; top:-99px; width:141px; height:102px; z-index:6; visibility: hidden;">
                                    <form name="#arguments.formName#" action="#arguments.link#&versionid=value" method="post">
                                          <select class="selectSmall" style="width:147; visibility: hidden;" id="intVersionID" name="intVersionID" size="7" onChange='this.blur(); this.form.submit();' onblur="document.getElementById('versionList').style.visibility = 'hidden'; this.style.visibility = 'hidden';">
                                                #options#
                                          </select>
                                    </form>
                              </div>
                        </div>
                  </cfoutput>
            </cfsavecontent>
            
            <cfreturn output />
      </cffunction>

      <cffunction name="getLanguageForm" access="public" returntype="string" hint="Returns Version select box" output="false">
            <cfargument name="formName" required="false" default="frmLanguage">

            <cfif not (isDefined("id") and Val(id))>
                  <cfreturn "">
            </cfif>

            <!--- do the options, and also figure out which option we want to be displayed by default --->
            <cfquery name="qryTranslations" datasource="#this.datasource#" cachedwithin="#this.queryCache#">
                  SELECT       IT.intItemID, IT.intTranslateID, C.txtTitle
                  FROM       tblItemTranslate IT
                  LEFT JOIN tblItem I
                  ON             IT.intTranslateID = I.intID
                  LEFT JOIN tblNavigation N
                  ON             I.intWebID = N.intID
                  LEFT JOIN tblCompany C
                  ON             N.intCompanyID = C.intID
                  WHERE       IT.intItemID = #Val(id)#
                  OR            IT.intItemID IN
                                    (SELECT tblItemTranslate.intItemID
                                     FROM       tblItemTranslate
                                     WHERE       intTranslateID = #Val(id)#)
            </cfquery>

            <cfif not qryTranslations.recordCount>
                  <cfreturn "" />
            </cfif>

            <cfset currentVersion = translate("Original")>
            <cfset selectedIndex = 0>
            <cfsavecontent variable="options">
                  <cfoutput><option value="#qryTranslations.intItemID#">#translate("Original")#</option></cfoutput>
                  <cfoutput query="qryTranslations">
                        <option value="#intTranslateID#" <cfif intTranslateID is id>selected</cfif>>#txtTitle#</option>
                        <cfif intTranslateID is id>
                              <cfset currentVersion = txtTitle>
                              <cfset selectedIndex = currentrow>
                        </cfif>
                  </cfoutput>
            </cfsavecontent>

            <cfsavecontent variable="output">
                  <cfoutput>
                        <script>
                              function jsLaunchTranslation (itemID) {
                                    //window.open('popup.cfm?p=languageview&i=' + itemID + '', '', 'help=no,resizable=yes,scroll=no,status=no,modal=yes');
                                    showModelessDialog('popup.cfm?p=languageview&i=' + itemID + '', '', 'help=no;resizable=yes;scroll=no;status=no;center=yes');
                              }
                        </script>
                        <div id="languages" style="position:absolute; left:249px; top:294px; width:147px; height:15px; z-index:8" class="bevelEmbossStatus">
                              <div id="languageText" style="position:absolute; left:3px; top:1px; width:120px; height:11px; z-index:7">#currentVersion#</div>
                              <div id="languagesSelect" style="position:absolute; left:130px; top:-2px; width:15px; height:15px; z-index:6"><a onmouseover="this.style.cursor = 'pointer'; this.style.cursor = 'hand'; document.body.onbeforeunload = null;" onmouseout="if (window.jsSaveWarning) jsSaveWarning();" onclick="document.getElementById('languageList').style.visibility = 'visible'; document.getElementById('intLanguageID').focus();"><img src="images/btn_status_arrow.gif" width="15" height="15" border="0"></a></div>
                              <div id="languageList" style="position:absolute; left:-1px; top:-99px; width:141px; height:102px; z-index:6; visibility: hidden;">
                                    <select class="selectSmall" style="width:147;" id="intLanguageID" name="i" size="7" onclick='this.blur(); if (this.selectedIndex != #selectedIndex#) jsLaunchTranslation(this.value); this.selectedIndex = #selectedIndex#' onblur="document.getElementById('languageList').style.visibility = 'hidden';">
                                          #options#
                                    </select>
                              </div>
                        </div>
                  </cfoutput>
            </cfsavecontent>
            
            <cfreturn output />
      </cffunction>

      <!--- sets the treenav refresh status to true --->
      <cffunction name="refreshTreeNav" access="public" output="false">
            <cfargument name="newSubID" required="false" type="numeric">

            <cfif isDefined("arguments.newSubID")>
                  <cfset this.treenavsubid = arguments.newSubID>
            </cfif>
            <cfset this.treenavrefresh = true>
      </cffunction>

      <!--- sets the action message to be used by getStatus() --->
      <cffunction name="setActionMsg" access="public" output="false">
            <cfargument name="actionmsg" required="true" type="string">
            <cfargument name="blnTranslate" required="false" type="boolean" default="true">

            <cfif arguments.blnTranslate>
                  <cfset this.actionmsg = translate(arguments.actionmsg)>
            <cfelse>
                  <cfset this.actionmsg = arguments.actionmsg>
            </cfif>
      </cffunction>

      <!--- refresh the treenav --->
      <cffunction name="getStatus" access="public" output="false">
            <cfset var status = '' />
            <cfparam name="this.treenavsubid" default="0">
            
            <cfset status = '<div id="status" style="position:absolute; left:0px; top:294px; width:393px; height:15px; z-index:5" class="bevelEmbossStatus"><img src="images/shim.gif" width="3" height="13" align="absmiddle"><font color="##CC0000">#this.actionmsg#</font></div><div id="fakepagination" style="position:absolute; left:396px; top:294px; width:82px; height:15px; z-index:0" class="bevelEmbossStatus"></div><div id="faketotal" style="position:absolute; left:481px; top:294px; width:62px; height:15px; z-index:0" class="bevelEmbossStatus"></div>'>
            <!--- if there is an action msg, refresh the treenav --->
            <cfif this.treenavrefresh>
                  <cfset status = status & '<script>resetSideNav(#this.treenavsubid#);</script>'>
            </cfif>
            
            <cfreturn status />
      </cffunction>

      <cffunction name="getStyles" access="public" output="false">
            <cfargument name="blnInclElement" required="false" type="boolean" default="false" />
            
            <cfset var styles = '' />
            
            <cfsavecontent variable="styles">
                  <cfoutput>
                        <cfif arguments.blnInclElement>
                              <style type="text/css" id="cssCustomStyles">
                        </cfif>
                        <!--
                              #getStyleRules()#
                        -->
                        <cfif arguments.blnInclElement>
                              </style>
                        </cfif>
                  </cfoutput>
            </cfsavecontent>
            
            <cfreturn styles />
      </cffunction>

      <cffunction name="getStyleRules" access="public" output="false">
            <cfquery name="qryStyles" datasource="#this.datasource#" cachedwithin="#this.queryCache#">
                  SELECT       *
                  FROM       tblStyles
                  WHERE       intCompanyID = #this.CompanyID#
                  AND       blnDeleted = 0
            </cfquery>
            
            <cfsavecontent variable="rules">
                  <cfoutput>
                        <cfloop query="qryStyles">
                              .customStyle#intID# { font-size: #intSize##txtSizePtPx#; font-family: #txtFont#; color: <cfif ListLen(txtColor,'1234567890abcdefABCDEF') is 0>##</cfif>#txtColor#; font-style: <cfif blnItalics is 1>italic<cfelse>normal</cfif>; font-weight: <cfif blnBold is 1>bold<cfelse>normal</cfif>; }
                              <cfif Len(txtLinkColor)>
                                    .customStyle#intID# a:link { color: <cfif ListLen(txtLinkColor,'1234567890abcdefABCDEF') is 0>##</cfif>#txtLinkColor# !important; }
                                    .customStyle#intID# a:hover { color: <cfif ListLen(txtLinkColor,'1234567890abcdefABCDEF') is 0>##</cfif>#txtLinkColor# !important; }
                                    .customStyle#intID# a:active { color: <cfif ListLen(txtLinkColor,'1234567890abcdefABCDEF') is 0>##</cfif>#txtLinkColor# !important; }
                              </cfif>
                              <cfif Len(txtVisitedLinkColor)>
                                    .customStyle#intID# a:visited { color: <cfif ListLen(txtVisitedLinkColor,'1234567890abcdefABCDEF') is 0>##</cfif>#txtVisitedLinkColor# !important; }
                              </cfif>
                        </cfloop>
                        table { font-size: 1.0em; }
                        .tableNoBorder { font-size: 1.0em; border: 0; }
      
                        table.tableSingleBorder { border: 1px solid ##000000; }
                        table.tableSingleBorder td { border: 1px solid ##000000; }
      
                        table.tableDoubleBorder { border: 2px solid ##000000; }
                        table.tableDoubleBorder td { border: 2px solid ##000000; }
      
                        .clickToEnlarge { font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: ##000000; font-style: normal; font-weight: normal; }
                  </cfoutput>
            </cfsavecontent>
            
            <cfreturn rules />
      </cffunction>

      <!--- returns add/edit form for a particular item --->
      <cffunction name="getAddEdit" access="public" returntype="string" output="false">
            <cfargument name="formData" type="any" required="true">

            <cfif not isQuery(formData.query)>
                  <cfset formData.query = this.workflow.getQuery(formData)>
            </cfif>

            <cfif formData.blnMeta>
                  <!--- Donny: retrieve and populate advance meta data --->
                  <cfif isDefined("FORM.id") and Val(FORM.id)>
                        <cfset URL.id = FORM.id>
                  </cfif>
                  <cfif isDefined("URL.id") and Val(URL.id)>
                        <cfif not isDefined("FORM.intVersionID") or Val(FORM.intVersionID) is 0>
                              <!--- retrieve the MetaID if not passed in lookup --->
                              <cfquery name="qryCurrentMetaID" datasource="#this.datasource#" cachedwithin="#this.queryCache#">
                                    SELECT       TOP 1 intID
                                    FROM       #formData.tablename#
                                    WHERE       intItemID = #URL.id#
                                    <!--- see if we are grabbing the live version --->
                                    <cfif isDefined("formData.query.blnlive") and Val(formData.query.blnlive) is 1>
                                          <!--- live --->
                                          AND blnLive = 1
                                    </cfif>
                                    <!--- added by Jason --->
                                    <!--- see if VersionID is appended to the URL --->
                                    <cfif isDefined("URL.versionid") and Val(URL.versionid)>
                                          AND intID = #URL.versionid#
                                    </cfif>
                                    <!--- end added by Jason --->
                                    ORDER BY dtAdded DESC;
                              </cfquery>
                              <cfset FORM.intVersionID = Val(qryCurrentMetaID.intID)>
                        </cfif>
                  </cfif>
                  
                  <cfscript>
                        // retrieve the other metatags (other than keywords and description)
                        this.htmlhead = createObject('component',"hb50.util.htmlhead");
                        this.htmlhead.init(this.CompanyId,true,0,0);
                        txtNameValues = "";
                        txtHTTPValues = "";
                        if (isDefined("URL.id") and isDefined("FORM.intVersionID")) {
                              metaTags = this.htmlhead.getMetaTags(Val(URL.id), FORM.intVersionID);
                              // format the metatag needed in "formData" variable
                              for (i=1; i lte ArrayLen(metaTags); i=i+1) {
                                    if (StructKeyExists(metatags[i], "name")) {
                                          txtNameValues = txtNameValues & 'Normal,' & metatags[i].name & ',' & metatags[i].content & chr(13) & chr(10);
                                    } else if (StructKeyExists(metatags[i], "httpequiv")) {
                                          txtNameValues = txtNameValues & 'HTTP-Eq,' & metatags[i].httpequiv & ',' & metatags[i].content & chr(13) & chr(10);
                                    }
                              }
                        }
                  </cfscript>

                  <cfscript>
                        metaFormData.query = QueryNew('intID,txtNameValues,txtHTTPValues');
                        QueryAddRow(metaFormData.query);
                        QuerySetCell(metaFormData.query, "intID", "1");
                        QuerySetCell(metaFormData.query, "txtNameValues", txtNameValues);
                        QuerySetCell(metaFormData.query, "txtHTTPValues", txtHTTPValues);
                        // save to "formData"
                        formData.metaQuery = metaFormData.query;
                  </cfscript>
            </cfif>

            <cfsavecontent variable="body">
                  <cfoutput>
                        #getStyles(true)#
                        #getStatus()#
                        <cfif formData.blnMeta>
                              <style type="text/css">
                              <!--
                                    .txtMetaName, .txtMetaValue, .txtMetaType {
                                          font-family: Arial, Helvetica, sans-serif;
                                          font-size: 11px;
                                          color: ##666666;
                                          padding: 5px;
                                          font-weight: normal;
                                          background-color: ##FFFFFF;
                                          cursor: hand;
                                          float: left;
                                          overflow: hidden;
                                          border-left: 1px solid ##999999;
                                    }
                                    .txtMetaType { width: 54px; }
                                    .txtMetaName { width: 135px; }
                                    .txtMetaValue { width: 330px; }
                              -->
                              </style>
                        </cfif>
                        <cfif formData.blnPreview>
                              <script language='JavaScript'>
                                    function previewItem(form) {
                                          var tempAction = form.action;
                                          if (window.jsValidate && !jsValidate())
                                                return false;
      
                                          var previewWindow = window.open('', 'previewWindow', 'height=700,width=800,innerHeight=700,innerWidth=800,location=no,menubar=no,resizable=yes,titlebar=yes,toolbar=no,scrollbars=yes');
                                          form.action = '#this.qryCompany.txtWeb#/preview.cfm?navid=#formData.navid#&subid=#formData.subid#&tabid=#formData.tabid#<cfif isDefined("URL.id") and Val(URL.id)>&citemID=#URL.id#</cfif>';
                                          form.target = 'previewWindow';
      
                                          // put in hidden Preview Mode variable
                                          var hiddenItem = document.createElement('input');
                                          hiddenItem.type = 'hidden';
                                          hiddenItem.id = 'hot_banana_preview_mode';
                                          hiddenItem.name = 'hot_banana_preview_mode';
                                          hiddenItem.value = 1;
                                          form.appendChild(hiddenItem);
      
                                          form.submit();
                                          previewWindow.focus();
                                          form.action = tempAction;
                                          form.target = '';
      
                                          // should remove hidden Preview Mode variable
                                          try{
                                                form.removeChild(hiddenItem);
                                          } catch(e) {
                                                hiddenItem.removeNode();
                                          }
      
                                          return false;
                                    }
                                    
                                    function previewWorkflow(form,blnModified) {
                                          var tempAction = form.action;
                                          if (window.jsValidate && !jsValidate()) return false;
      
                                          var previewWindow = window.open('', 'previewWindow', 'height=700,width=800,innerHeight=700,innerWidth=800,location=no,menubar=no,resizable=yes,titlebar=yes,toolbar=no,scrollbars=yes');
                                          form.action = '#this.qryCompany.txtWeb#/preview.cfm?navid=#formData.navid#&subid=#formData.subid#&tabid=#formData.tabid#<cfif isDefined("URL.id") and Val(URL.id)>&citemID=#URL.id#</cfif>';
                                          form.target = 'previewWindow';
      
                                          // put in hidden Preview Mode variable
                                          var hiddenItem = document.createElement('input');
                                          hiddenItem.type = 'hidden';
                                          hiddenItem.id = 'hot_banana_preview_mode';
                                          hiddenItem.name = 'hot_banana_preview_mode';
                                          hiddenItem.value = 1;
                                          form.appendChild(hiddenItem);
                                          
                                          // put in hidden preview mod/current variable
                                          if(blnModified == false)
                                          {
                                                var hiddenItem = document.createElement('input');
                                                hiddenItem.type = 'hidden';
                                                hiddenItem.id = 'hot_banana_preview_current';
                                                hiddenItem.name = 'hot_banana_preview_current';
                                                hiddenItem.value = 1;
                                                form.appendChild(hiddenItem);
                                          }
      
                                          form.submit();
                                          previewWindow.focus();
                                          form.action = tempAction;
                                          form.target = '';
      
                                          // should remove hidden Preview Mode variable
                                          try{
                                                form.removeChild(hiddenItem);
                                          } catch(e) {
                                                hiddenItem.removeNode();
                                          }
      
                                          return false;
                                    }
      
                                    function analyzeItem(form) {
                                          var tempAction = form.action;
                                          if (window.jsValidate && !jsValidate()) return false;
      
                                          var analyzeWindow = window.open('', 'analyzeWindow', 'height=700,width=800,innerHeight=700,innerWidth=800,location=no,menubar=no,resizable=yes,titlebar=yes,toolbar=no,scrollbars=yes');
                                          form.action = '#this.qryCompany.txtWeb#/analytics.cfm?navid=#formData.navid#&subid=#formData.subid#&tabid=#formData.tabid#<cfif isDefined("URL.id") and Val(URL.id)>&I=#URL.id#&citemID=#URL.id#</cfif>';
                                          form.target = 'analyzeWindow';
      
                                          // put in hidden Preview Mode variable
                                          var hiddenItem = document.createElement('input');
                                          hiddenItem.type = 'hidden';
                                          hiddenItem.id = 'hot_banana_preview_mode';
                                          hiddenItem.name = 'hot_banana_preview_mode';
                                          hiddenItem.value = 1;
                                          form.appendChild(hiddenItem);
      
                                          form.submit();
                                          analyzeWindow.focus();
                                          form.action = tempAction;
                                          form.target = '';
      
                                          // should remove hidden Preview Mode variable
                                          try{
                                                form.removeChild(hiddenItem);
                                          } catch(e) {
                                                hiddenItem.removeNode();
                                          }
      
                                          return false;
                                    }
                              </script>
                        </cfif>
      
                        <cfif isDefined("addbutton") and isDefined("FORM.ID") and Val(FORM.ID)>
                              <cftrace text="Setting URL.ID"/>
                              <cfset URL.ID = Val(FORM.ID)>
                        </cfif>
                        <!--- <cfsetting showdebugoutput="yes"> --->
      
                        <cfif isDefined("URL.ID") and Val(URL.ID)> <!--- editing / viewing --->
                              <cfif formData.blnApproval and this.workflow.canApprove(Val(URL.id), SESSION.userid)>
                                    #getApproveForm(formData, URL.ID)#
                              <cfelseif formData.blnLock and this.workflow.isLocked(Val(URL.ID), SESSION.userid)>
                                    <cfquery name="qryItemLock" datasource="#this.datasource#" cachedwithin="#this.queryCache#">
                                          SELECT      blnApproval, intUserID, dtAdded
                                          FROM       tblItemLock
                                          WHERE       intItemID = #Val(URL.ID)#
                                    </cfquery>
      
                                    <cfif not isDefined("this.access")>
                                          <cfset this.access = createObject("component", "hb50.access").init(this.CompanyID)>
                                    </cfif>
                                    <cfif qryItemLock.blnApproval>
                                          #translate("This item is awaiting approval from")#:
                                          <blockquote>
                                                <cfloop query="qryItemLock">
                                                      <cftry>
                                                            #this.access.getUserData(intUserID).realname#<br>
                                                            <cfcatch></cfcatch>
                                                      </cftry>
                                                </cfloop>
                                          </blockquote>
                                    <cfelse>
                                          #translate("This item was locked by")# #this.access.getUserData(qryItemLock.intUserID).realname# #DateFormat(qryItemLock.dtAdded, "mmmm d, yyyy")#.
                                    </cfif>
                                    <form action="#formData.link#" method="post"><input type="submit" value="#translate("Go Back")#" class="buttons"></form>
      
                              <cfelse>
                                    <cfif isDefined("URL.versionID")>
                                          #getEditForm(formData, URL.ID, URL.versionID)#
                                    <cfelse>
                                          #getEditForm(formData, URL.ID)#
                                    </cfif>
                              </cfif>
                        <cfelse> <!--- adding --->
                              #getAddForm(formData)#
                        </cfif>
                  </cfoutput>
            </cfsavecontent>

            <cfreturn body />
      </cffunction>

      <cffunction name="getAddForm" access="public" returntype="string" hint="Returns Default Add Form" output="false">
            <cfargument name="formData" type="any" required="true">
            <cfargument name="formName" required="false" default="frmAddEdit">
            <cfargument name="jsValidate" required="false" default="jsValidate">

            <cfsavecontent variable="output">
                  <cfoutput>
                        #getJSValidate(formData)#
      
                        <script language="JavaScript">
                              var submitted = false;
                              <!--- Notification --->
                              function jsConfirmNotification() {
                                    if (confirm('Send Update Notification to Subscribers?')) {
                                          document.#formName#.HB_sendNotification.value = 1;
                                    }
                                    return true;
                              }
      
                              function jsCarefulSubmit() {
                                    var valid = #jsValidate#();
      
                                    if (valid) {
                                          if (submitted) return false;
                                          document.body.onbeforeunload = null;
                                          submitted = true;
                                    }
      
                                    return valid;
                              }
                        </script>
      
                        <table border="0" cellpadding="0" cellspacing="0">
                              <form name="#formName#" action="#formData.link#<cfif isDefined("URL.listparam")>&#URLDecode(URL.listparam)#</cfif>" method="post" enctype="multipart/form-data" onSubmit="return jsCarefulSubmit();" <cfif isDefined("formData.target")>target="#formData.target#"</cfif>>
                                    <tr>
                                          <td>
                                                #getFormTabs(formData)#
                        
                                                <cfsavecontent variable="buttons">
                                                      <cfif ArrayLen(formData.addbuttons)>
                                                            <cfset addbuttons = formData.addbuttons>
                                                      <cfelse>
                                                            <cfset addbuttons = getAddButtons(formData)>
                                                      </cfif>
                                                      <!--- notification --->
                                                      <input type="hidden" name="HB_sendNotification" value="0">
                                                      <cfloop from="1" to="#ArrayLen(addbuttons)#" index="i">
                                                            <input <cfif StructKeyExists(addbuttons[i], "name")>name="#addbuttons[i].name#"<cfelse>name="button"</cfif> type="submit" class="buttons" value="#translate(addbuttons[i].title)#"
                                                                  <cfif StructKeyExists(addbuttons[i], "width")>style="width: #addbuttons[i].width#px"</cfif>
                                                                  <cfif StructKeyExists(addbuttons[i], "onClick")>onClick="#addbuttons[i].onClick#"
                                                                  <cfelseif addbuttons[i].title is "Check In" and isDefined("this.qryCompany.blnNotification") and Val(this.qryCompany.blnNotification) and isDefined("formData.blnNotification") and formData.blnNotification>
                                                                  <cftry>
                                                                        <cfset notifier = getObject("hb50.plugins.generic.notifier",this.companyID,true)>
                                                                        <cfif notifier.getNotifierListsByWebID(Val(formData.webid)).recordCount>
                                                                              onClick="return jsConfirmNotification();"
                                                                        </cfif>
                                                                        <cfcatch></cfcatch>
                                                                  </cftry>
                                                                  </cfif>
                                                                  <cfif StructKeyExists(addbuttons[i], "disabled")>disabled="#addbuttons[i].disabled#"</cfif>
                                                            >
                                                      </cfloop>
                                                </cfsavecontent>
                                                #getButtonLayer(buttons)#
                                          </td>
                                    </tr>
                              </form>
                        </table>
                  </cfoutput>
            </cfsavecontent>
            
            <cfreturn output />
      </cffunction>

      <cffunction name="getAddButtons" returntype="array" access="private" output="false">
            <cfargument name="formData" type="struct" required="true">
            <cfset var addbuttons = ArrayNew(1)>
            <cfset var notifier = ''>

            <cfif formData.blnPreview>
                  <cfset x = StructNew()>
                  <cfset x.title = "Keyword Analysis">
                  <cfset x.width = 130>
                  <cfset x.onclick = "return analyzeItem(this.form);">
                  <cfset ArrayAppend(addbuttons, x)>
                  <cfset x = StructNew()>
                  <cfset x.title = "Preview">
                  <cfset x.onclick = "return previewItem(this.form);">
                  <cfset ArrayAppend(addbuttons, x)>
            </cfif>

            <cfif formData.blnLock>
                  <cfset x = StructNew()>
                  <cfset x.title = "Save">
                  <cfset ArrayAppend(addbuttons, x)>

                  <cfset x = StructNew()>
                  <cfset x.title = "Check In">
                  <!--- notification --->
                  <cfif isDefined("this.qryCompany.blnNotification") and Val(this.qryCompany.blnNotification) and isDefined("formData.blnNotification") and formData.blnNotification>
                        <cftry>
                              <cfset notifier = getObject("hb50.plugins.generic.notifier",this.companyID,true)>
                              <cfif notifier.getNotifierListsByWebID(Val(formData.webid)).recordCount>
                                    <cfset x.onClick = "return jsConfirmNotification();">
                              </cfif>
                        <cfcatch></cfcatch>
                        </cftry>
                  </cfif>
                  <cfset ArrayAppend(addbuttons, x)>
            <cfelse>
                  <cfset x = StructNew()>
                  <cfset x.title = "Add">
                  <cfset ArrayAppend(addbuttons, x)>
            </cfif>

            <cfreturn addButtons />
      </cffunction>

      <cffunction name="getEditForm" access="public" returntype="string" hint="Returns Default Edit Form" output="false">
            <cfargument name="formData" type="any" required="true">
            <cfargument name="ID" required="true" type="any">
            <cfargument name="versionID" required="false" type="any">
            <cfargument name="formName" required="false" default="frmAddEdit">
            <cfargument name="jsValidate" required="false" default="jsValidate">
            
            <cfscript>
                  var qryUnorderedVersion = QueryNew('');
                  var qryVersion = QueryNew('');
                  var versionLink = '';
                  var qryCurrent = QueryNew('');
                  var editbuttons = ArrayNew(1);
                  var buttons = '';
            </cfscript>

            <cfif formData.blnVersion>
                  <!--- version stuff --->                  
                  <cfquery name="qryUnorderedVersion" datasource="#this.datasource#">
                        SELECT       #formData.tablename#.*, tblItem.blnDeleted
                        FROM       #formData.tablename#
                        LEFT JOIN tblItem
                        ON             tblItem.intID = #formData.tablename#.intItemID
                        WHERE       #formData.tablename#.intItemID = #arguments.ID#
                        ORDER BY dtAdded DESC
                  </cfquery>
                  
                  <cfif qryUnorderedVersion.recordCount gt 0>
                        <cfif isDefined("arguments.versionID")>
                              <cfparam name="FORM.intVersionID" default="#arguments.versionID#">
                        <cfelse>
                              <cfset "FORM.intVersionID" = qryUnorderedVersion.intID>
                        </cfif>

                        <cfquery name="qryVersion" dbtype="query">
                              SELECT      *
                              FROM       qryUnorderedVersion
                              ORDER BY blnLive DESC, dtAdded DESC
                        </cfquery>

                        <cfif formData.blnVersion and FORM.intVersionID neq qryUnorderedVersion.intID>
                              <!--- Donny: grabbing the wrong version?! --->
                              <cfset qryCurrent = selectFrom(qryVersion, formData.varID, FORM.intVersionID)>
                              <!--- <cfset qryCurrent = selectFrom(qryVersion, formData.varID, qryUnorderedVersion.intID)> --->
                        <cfelseif isDefined("formData.query") and isQuery(formData.query)>
                              <!--- if we select from qryVersion we loose additional columns in formData.query --->
                              <cfset qryCurrent = selectFrom(formData.query, formData.varID, FORM.intVersionID)>
                        <cfelse>
                              <cfset qryCurrent = selectFrom(qryVersion, formData.varID, FORM.intVersionID)>
                        </cfif>

                         <cfset versionLink = "#formData.link#&mode=edit&ID=#arguments.ID#">
                  <cfelse>
                        <cfset qryCurrent = selectFrom(formData.query, "intItemID", arguments.ID)>
                  </cfif>
            <cfelseif formData.blnWorkflow>
                  <cfset qryCurrent = selectFrom(formData.query, "intItemID", arguments.ID)>
            <cfelse>
                  <cfset qryCurrent = selectFrom(formData.query, formData.varID, arguments.ID)>
            </cfif>
            
            <cfsavecontent variable="output">
                  <cfoutput>
                        #getJSValidate(formData)#
      
                        <script language="JavaScript">
                              var submitted = false;
                              //notification
                              function jsConfirmNotification(addNote) {
                                    if (confirm('Send Update Notification to Subscribers when page goes live?')) {
                                          document.#formName#.HB_sendNotification.value = 1;
                                    }
                                    
                                    if(addNote == true)                              
                                          jsApproveNote();
                                    return true;
                              }
                              
                              function jsApproveNote()
                              {
                                    if (window.showModalDialog)
                                    {
                                          // modal window
                                          window.showModalDialog('popup/edit_reason_modal.cfm', window, 'resizable: no; help: no; status: no; scroll: no; ');
                                          return true;
                                    }
                                    //else
                                    //{
                                          // pop-up window
                                          //window.open('popup/edit_reason.cfm', '', 'scrollbars=no,width=280,height=150');
                                          //return true;
                                    //}
                              }
                              
                              function jsCarefulSubmit() {
                                    var valid = #jsValidate#();
      
                                    if (valid) {
                                          if (submitted) return false;
                                          
                                          document.body.onbeforeunload = null;
                                          submitted = true;
                                    }
      
                                    return valid;
                              }
                        </script>
      
                        <table border="0" cellpadding="0" cellspacing="0">
                              <form name="#formName#" action="#formData.link#<cfif isDefined("URL.listparam")>&#URLDecode(URL.listparam)#</cfif>" method="post" enctype="multipart/form-data" onSubmit="return jsCarefulSubmit();" <cfif isDefined("formData.target")>target="#formData.target#"</cfif>>
                                    <input type="hidden" name="ID" value="#arguments.ID#">
                                    <tr>
                                          <td>
                                                #getFormTabs(formData, qryCurrent)#
                  
                                                <cfsavecontent variable="buttons">
                                                      <cfset editbuttons = getEditButtons(formData, qryCurrent)>
                                                      
                                                      <!--- notification --->
                                                      <input type="hidden" name="HB_sendNotification" value="0">
                                                      <input type="hidden" name="txtEditReason" id="txtEditReason" value="">
                                                      <cfloop from="1" to="#ArrayLen(editbuttons)#" index="i">
                                                            <input <cfif StructKeyExists(editbuttons[i], "name")>name="#editbuttons[i].name#"<cfelse>name="button"</cfif> type="submit" class="buttons" id="#editbuttons[i].title#_btn" value="#translate(editbuttons[i].title)#"
                                                            <cfif StructKeyExists(editbuttons[i], "width")>style="width: #editbuttons[i].width#px"</cfif>
                                                            <cfif StructKeyExists(editbuttons[i], "onClick")>onClick="#editbuttons[i].onClick#"
            
                                                            <cfelseif editbuttons[i].title is "Check In" AND isDefined("this.qryCompany.blnNotification") AND Val(this.qryCompany.blnNotification) AND isDefined("formData.blnNotification") AND formData.blnNotification>
                                                                  <cftry>
                                                                        <cfset notifier = getObject("hb50.plugins.generic.notifier",this.companyID,true)>
                                                                        <cfif notifier.getNotifierListsByWebID(Val(formData.webid)).recordCount>
                                                                              <cfif getAddNote(formData) is true>
                                                                                    onClick="return jsConfirmNotification(true);"
                                                                              <cfelse>
                                                                                    onClick="return jsConfirmNotification(false);"
                                                                              </cfif>
                                                                        </cfif>
                                                                  <cfcatch></cfcatch>
                                                                  </cftry>
                                                            </cfif>
                                                            <cfif editbuttons[i].title is "Check In">
                                                                  <cfif getAddNote(formData) is true>
                                                                        onClick="return jsApproveNote();"
                                                                  </cfif>
                                                            </cfif>
                                                            <cfif StructKeyExists(editbuttons[i], "disabled")>disabled="#editbuttons[i].disabled#"</cfif>
                                                            >
                                                      </cfloop>
                                                </cfsavecontent>
                                                #getButtonLayer(buttons)#
                                          </td>
                                    </tr>
                              </form>
                        </table>
                        <cfif formData.blnVersion and isDefined("FORM.intVersionID") and Len(versionLink)>
                              #getVersionForm(qryVersion, Val(FORM.intVersionID), versionLink)#
                        </cfif>
                        
                        <cfif formData.blnWorkflow and formData.blnTranslate>
                              #getLanguageForm()#
                        </cfif>
                  </cfoutput>
            </cfsavecontent>

            <cfreturn output />
      </cffunction>
      
      <!--- this function determines if we should display the edit note popup --->
      <cffunction name="getAddNote" returntype="boolean" access="private">
            <cfargument name="formData" type="any" required="true">

            <!--- if this is a super user or at the last level of the approval,
                    do not popup an edit box --->
            <cfif SESSION.superuser>
                  <cfreturn false />
            </cfif>

            <!--- get this user's moderator level --->
            <cfquery name="qryCurrentMod" datasource="#this.datasource#">
                  SELECT       intLevel
                  FROM       tblModerator
                  JOIN       tblUserGroup
                  ON             tblUserGroup.intGroupID = tblModerator.intModeratorID
                  JOIN       tblUser
                  ON             tblUserGroup.intUserID = tblUser.intID
                  WHERE       tblUser.intID = <cfqueryparam value="#SESSION.userid#" cfsqltype="cf_sql_integer">
                  AND       tblModerator.intNavID = <cfqueryparam value="#formData.webid#" cfsqltype="cf_sql_integer">
            </cfquery>

            <!--- get the highest moderator level for this page --->
            <cfquery name="qryTopMod" datasource="#this.datasource#">
                  SELECT       intLevel
                  FROM       tblModerator
                  WHERE       intNavID = <cfqueryparam value="#formData.webid#" cfsqltype="cf_sql_integer">
                  ORDER BY intLevel DESC
            </cfquery>

            <!--- if we are the big cahoona, then do not display popup --->
            <cfif qryCurrentMod.recordCount and qryTopMod.recordCount>
                  <cfif qryCurrentMod.intLevel is qryTopMod.intLevel>
                        <cfreturn false />
                  </cfif>
            <cfelseif NOT qryTopMod.recordCount>
                  <!--- workflow does not exist for this page so do not add note --->
                  <cfreturn false />
            </cfif>
            
            <cfreturn true />
      </cffunction>

      <cffunction name="getEditButtons" returntype="array" access="private" output="false">
            <cfargument name="formData" type="struct" required="true">
            <cfargument name="qryCurrent" type="query" required="true">

            <cfscript>
                  var editbuttons = ArrayNew(1);
                  var notifier = '';
                  var x = '';
                  var idx = 1;
                  var length = ArrayLen(formData.editbuttons);
                  
                  //use user-defined edit buttons
                  if (not isDefined('formData.appendEditbuttons') and length) {
                        editbuttons = formData.editbuttons;
                        return editbuttons;
                  }
            
                  if (isDefined("qryCurrent.blnDeleted") and qryCurrent.blnDeleted is 1) {
                        if (formData.blnRestore) {
                              x = StructNew();
                              x.title = "Restore";
                              ArrayAppend(editbuttons, x);
                        }
                        
                        x = StructNew();
                        x.title = "Go Back";
                        ArrayAppend(editbuttons, x);
                  }
                  else {
                        if (formData.blnDelete) {
                              x = StructNew();
                              x.title = "Delete";
                              x.onclick = "jsValidationRequired = false; return confirm('#JSStringFormat(translate("Are you sure you want to delete this item?"))#');";
                              ArrayAppend(editbuttons, x);
                        }
                        if (formData.blnPreview) {
                              x = StructNew();
                              x.title = "Keyword Analysis";
                              x.width = 130;
                              x.onclick = "return analyzeItem(this.form);";
                              ArrayAppend(editbuttons, x);
                              x = StructNew();
                              x.title = "Preview";
                              x.onclick = "return previewItem(this.form);";
                              ArrayAppend(editbuttons, x);
                        }
                        x = StructNew();
                        x.title = "Save";
                        ArrayAppend(editbuttons, x);
                        
                        if (formData.blnLock) {
                              x = StructNew();
                              x.title = "Check In";
                              
                              //notification
                              if (isDefined("this.qryCompany.blnNotification") and Val(this.qryCompany.blnNotification) and isDefined("formData.blnNotification") and formData.blnNotification) {
                                    try {
                                          notifier = getObject("hb50.plugins.generic.notifier", this.companyID, true);
                                          if (notifier.getNotifierListsByWebID(Val(formData.webid)).recordCount) {
                                                if (getAddNote(formData) is true)
                                                      x.onClick = "return jsConfirmNotification(true);";
                                                else
                                                      x.onClick = "return jsConfirmNotification(false);";
                                          }
                                          else {
                                                if (getAddNote(formData) is true)
                                                      x.onClick = "return jsApproveNote();";
                                          }
                                    }
                                    catch (Any excpt) {}
                              }
                              ArrayAppend(editbuttons, x);
                        }
                  }
                  
                  //append user-defined editbuttons
                  if (isDefined('formData.appendEditbuttons') and formData.appendEditbuttons is true and length) {
                        for (idx = 1; idx lte length; idx = idx + 1)
                              ArrayAppend(editbuttons, formData.editbuttons[idx]);
                  }

                  return editbuttons;
            </cfscript>
      </cffunction>

      <cffunction name="getApproveForm" access="public" returntype="string" hint="Returns Default Approve Form" output="false">
            <cfargument name="formData" type="any" required="true">
            <cfargument name="ID" required="true" type="numeric">
            <cfargument name="formName" required="false" default="frmAddEdit">
            <cfargument name="jsValidate" required="false" default="jsValidate">

            <cfset var i = 0>
            <cfset var oldMetaTags = ''>
            <cfset var newMetaTags = ''>

            <cfquery name="qryOld" datasource="#this.datasource#" maxrows="1">
                  SELECT      TOP 1 *
                  FROM       #formData.tablename#
                  WHERE       intItemID = #ID#
                  AND       blnLive = 1
                  ORDER BY dtAdded DESC
            </cfquery>
            <cfquery name="qryNew" datasource="#this.datasource#" maxrows="1">
                  SELECT       TOP 1 *
                  FROM       #formData.tablename#
                  WHERE       intItemID = #ID#
                  AND       blnLive = 0
                  ORDER BY dtAdded DESC
            </cfquery>

            <cfparam name="leftBody" default="">
            <cfparam name="rightBody" default="">
            
            <cfsavecontent variable="buttons">
                  <cfoutput>
                        <script language="JavaScript">
                              function jsDecline () {
                                    if (window.showModalDialog) {
                                          // modal window
                                          window.showModalDialog('popup/decline_reason_modal.cfm', window, 'resizable: no; help: no; status: no; scroll: no; ');
                                          return true;
                                    } else {
                                          // pop-up window
                                          window.open('popup/decline_reason.cfm', '', 'scrollbars=no,width=280,height=150');
                                          return false;
                                    }
                              }
                        </script>
                        
                        <input name="button" type="submit" <cfif NOT qryOld.recordCount>disabled</cfif> value="#translate("Preview Current")#" class="buttons" onclick="return previewWorkflow(this.form,false)">
                        <input name="button" type="submit" value="#translate("Preview Modified")#" class="buttons" onclick="return previewWorkflow(this.form,true)">
                        <input name="button" type="submit" value="#translate("Approve")#" class="buttons">
                        <input name="button" type="submit" value="#translate("Decline")#" class="buttons" onclick="return jsDecline();">
                        <input name="button" type="submit" value="#translate("Edit")#" class="buttons">
                        <input type="hidden" name="txtDeclineReason" id="txtDeclineReason" value="">
                        <!--- this is here because we need to somehow submit the form with button=Decline without 'clicking' Decline --->
                        <input type="hidden" name="button" id="fakeButton" value="" disabled>
                  </cfoutput>
            </cfsavecontent>

            <cfset numChanged = 0>
            <cfsavecontent variable="body">
                  <cfoutput>
                        <!--- in case no content is added yet --->
                        <cfif NOT qryOld.recordCount AND qryNew.recordCount>
                              <cfloop from="1" to="#ArrayLen(formData.columns)#" index="key">
                                          <cfset column = formData.columns[key]>
                                                <cfif column.varname EQ 'txtBody'>
                                                      <cfset rightBody = HTMLEditFormat(getItemView(formData, column, qryNew[column.varname][1]))>
                                                </cfif>
                                    </cfloop>
                        </cfif>
                        <cfif qryOld.recordCount>
                              <table width="523" border="0" cellpadding="5" cellspacing="0" align="center">
                                    <tr>
                                          <td height="21" style="border-left: 1px solid ##999999;"><img src="images/shim.gif" width="1" height="21"></td>
                                          <td style="border-left: 1px solid ##999999; border-right: 1px solid ##999999;"><img src="images/shim.gif" width="1" height="21"></td>
                                    </tr>
                                    <cfset numChanged = 0>
                                    <cfloop from="1" to="#ArrayLen(formData.columns)#" index="key">
                                          <cfset column = formData.columns[key]>
                                          <cfif (not isDefined("column.display") or column.display neq "false")
                                                  and column.type neq TYPES.HIDDEN and (not isDefined("column.insert") or column.insert)
                                                  and qryOld[column.varname][1] neq qryNew[column.varname][1]>
                                                <cfset numChanged = numChanged + 1>
                                                <cfset compare = diff(getItemView(formData, column, qryOld[column.varname][1]), getItemView(formData, column, qryNew[column.varname][1]))>
                                                <tr><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999;">
                                                      <span class="formCaption">#column.title#:</span><br>
                                                      #compare.str1#
                                                <cfif column.varname EQ 'txtBody'>
                                                      <cfset leftBody = HTMLEditFormat(getItemView(formData, column, qryOld[column.varname][1]))>
                                                </cfif>
                                          </td><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999; border-right: 1px solid ##999999;">
                                                <span class="formCaption">#column.title#:</span><br>
                                                #compare.str2#
                                                <cfif column.varname EQ 'txtBody'>
                                                      <cfset rightBody = HTMLEditFormat(getItemView(formData, column, qryNew[column.varname][1]))>
                                                </cfif>
                                                </td></tr>
                                          </cfif>
                                    </cfloop>
                                    <!--- if using tblResource, we can assume that we also want to compare the file uploaded to this resource.
                                            comparing based on the table name is a Very Bad Thing to do, but I can't figure out another way to make
                                            the exception to pull this off, except making a custom approval form in resources.cfc, which i don't want to do.
                                    --->
                                    <cfif formData.tablename is "tblResource">
                                          <cfset media = createObject("component", "hb50.media").init(this.CompanyID)>
                                          <cfset oldView = "">
                                          <cfif Val(qryOld.intMediaID)>
                                                <cfset oldFile = media.getURL(qryOld.intMediaID)>
                                                <cfset oldView = '<a href="#oldFile#" target="_blank">#GetFileFromPath(oldFile)#</a>'>
                                          </cfif>
                                          <cfset newView = "">
                                          <cfif Val(qryNew.intMediaID)>
                                                <cfset newFile = media.getURL(qryNew.intMediaID)>
                                                <cfset newView = '<a href="#newFile#" target="_blank">#GetFileFromPath(newFile)#</a>'>
                                          </cfif>
                                          <cfif oldView neq newView>
                                                <cfset numChanged = numChanged + 1>
                                                <tr><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999;">
                                                      <span class="formCaption">File:</span><br>
                                                      <span style="background-color: ##FFFF00;">#oldView#</span>
                                                </td><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999; border-right: 1px solid ##999999;">
                                                      <span class="formCaption">File:</span><br>
                                                      <span style="background-color: ##FFFF00;">#newView#</span>
                                                </td></tr>
                                          </cfif>
                                    </cfif>
                                    
                                    <!--- additional resources --->
                                    <cfif formData.blnResources>
                                          <cfset media = createObject("component", "hb50.media").init(this.CompanyID)>
                                          
                                          <cfset oldView = "">
                                          <cfif Val(qryOld.intResourceID)>
                                                <cfset oldResources = media.getAdditionalResources(qryOld.intResourceID)>
                                                <cfloop from="1" to="#ArrayLen(oldResources)#" index="i">
                                                      <cfset oldView = oldView & '#oldResources[i].title#<br>(<a href="#oldResources[i].link#" target="_blank">#GetFileFromPath(oldResources[i].link)#</a>)<br><br>'>
                                                </cfloop>
                                          </cfif>
                                          
                                          <cfset newView = "">
                                          <cfif Val(qryNew.intResourceID)>
                                                <cfset newResources = media.getAdditionalResources(qryNew.intResourceID)>
                                                <cfloop from="1" to="#ArrayLen(newResources)#" index="i">
                                                      <cfset newView = newView & '#newResources[i].title#<br>(<a href="#newResources[i].link#" target="_blank">#GetFileFromPath(newResources[i].link)#</a>)<br><br>'>
                                                </cfloop>
                                          </cfif>
                                          
                                          <cfif oldView neq newView>
                                                <cfset numChanged = numChanged + 1>
                                                <cfset compare = diff(oldView, newView)>
                                                <tr>
                                                      <td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999;">
                                                            <span class="formCaption">Additional Resources:</span><br>
                                                            #compare.str1#
                                                      </td>
                                                      <td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999; border-right: 1px solid ##999999;">
                                                            <span class="formCaption">Additional Resources:</span><br>
                                                            #compare.str2#
                                                      </td>
                                                </tr>
                                          </cfif>
                                    </cfif>
                                    
                                    <!--- meta data --->
                                    <cfif formData.blnMeta>      
                                          <cfif qryOld.txtMetaKeywords neq qryNew.txtMetaKeywords>
                                                <cfset numChanged = numChanged + 1>
                                                <cfset oldView = qryOld.txtMetaKeywords>
                                                <cfset newView = qryNew.txtMetaKeywords>
                                                <cfset compare = diff(oldView,newView)>
                                                <tr><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999;">
                                                      <span class="formCaption">Meta Keywords:</span><br>
                                                      #compare.str1#
                                                </td><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999; border-right: 1px solid ##999999;">
                                                      <span class="formCaption">Meta Keywords:</span><br>
                                                      #compare.str2#
                                                </td></tr>
                                          </cfif>
                                          <cfif qryOld.txtMetaDescription neq qryNew.txtMetaDescription>
                                                <cfset numChanged = numChanged + 1>
                                                <cfset oldView = qryOld.txtMetaDescription>
                                                <cfset newView = qryNew.txtMetaDescription>
                                                <cfset compare = diff(oldView,newView)>
                                                <tr><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999;">
                                                      <span class="formCaption">Meta Description:</span><br>
                                                      #compare.str1#
                                                </td><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999; border-right: 1px solid ##999999;">
                                                      <span class="formCaption">Meta Description:</span><br>
                                                      #compare.str2#
                                                </td></tr>
                                          </cfif>
      
                                          <cfset this.htmlHead = createObject('component',"hb50.util.htmlhead").init(this.companyId,true,0,0)>
                                          <cfset oldMetaTags = this.htmlhead.getMetaTags(ID,qryOld.intID)>
                                          <cfset newMetaTags = this.htmlHead.getMetaTags(ID,qryNew.intID)>
                                          <cfif ArrayLen(oldMetaTags) OR ArrayLen(newMetaTags)>
                                                <cfif ArrayLen(oldMetaTags) GTE ArrayLen(newMetaTags)>
                                                      <cfloop from="1" to="#ArrayLen(oldMetaTags)#" index="idx">
                                                            <cfif StructKeyExists(oldMetaTags[idx], 'name')>
                                                                  <cfset tagName = oldMetaTags[idx].name>
                                                                  <cfset newTagContent = getMetaTagContent(newMetaTags, 'name', tagName)>
                                                            <cfelse>
                                                                  <cfset tagName = oldMetaTags[idx].httpequiv>
                                                                  <cfset newTagContent = getMetaTagContent(newMetaTags, 'httpequiv', tagName)>
                                                            </cfif>
                                                            <cfset oldTagContent = oldMetaTags[idx].content>
      
                                                            <cfif oldTagContent NEQ newTagContent>
                                                                  <cfset numChanged = numChanged + 1>
                                                                  <cfset compare = diff(oldTagContent, newTagContent)>
                                                                  <tr><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999;">
                                                                        <span class="formCaption">#tagName#:</span><br>
                                                                        #compare.str1#
                                                                  </td><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999; border-right: 1px solid ##999999;">
                                                                        <span class="formCaption">#tagName#:</span><br>
                                                                        #compare.str2#
                                                                  </td></tr>
                                                            </cfif>
                                                      </cfloop>
                                                      <cfloop from="1" to="#ArrayLen(newMetaTags)#" index="idx">
                                                            <cfif StructKeyExists(newMetaTags[idx], 'name')>
                                                                  <cfset tagName = newMetaTags[idx].name>
                                                            <cfelse>
                                                                  <cfset tagName = newMetaTags[idx].httpequiv>
                                                            </cfif>
                                                            <cfset newTagContent = newMetaTags[idx].content>
                                                            <cfset numChanged = numChanged + 1>
                                                            <cfset compare = diff('', newTagContent)>
                                                            <tr><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999;">
                                                                  <span class="formCaption">#tagName#:</span><br>
                                                                  #compare.str1#
                                                            </td><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999; border-right: 1px solid ##999999;">
                                                                  <span class="formCaption">#tagName#:</span><br>
                                                                  #compare.str2#
                                                            </td></tr>
                                                      </cfloop>
                                                <cfelse>
                                                      <cfloop from="1" to="#ArrayLen(newMetaTags)#" index="idx">
                                                            <cfif StructKeyExists(newMetaTags[idx], 'name')>
                                                                  <cfset tagName = newMetaTags[idx].name>
                                                                  <cfset oldTagContent = getMetaTagContent(oldMetaTags, 'name', tagName)>
                                                            <cfelse>
                                                                  <cfset tagName = newMetaTags[idx].httpequiv>
                                                                  <cfset oldTagContent = getMetaTagContent(oldMetaTags, 'httpequiv', tagName)>
                                                            </cfif>
                                                            <cfset newTagContent = newMetaTags[idx].content>
      
                                                            <cfif oldTagContent NEQ newTagContent>
                                                                  <cfset numChanged = numChanged + 1>
                                                                  <cfset compare = diff(oldTagContent, newTagContent)>
                                                                  <tr><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999;">
                                                                        <span class="formCaption">#tagName#:</span><br>
                                                                        #compare.str1#
                                                                  </td><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999; border-right: 1px solid ##999999;">
                                                                        <span class="formCaption">#tagName#:</span><br>
                                                                        #compare.str2#
                                                                  </td></tr>
                                                            </cfif>
                                                      </cfloop>
                                                      <cfloop from="1" to="#ArrayLen(oldMetaTags)#" index="idx">
                                                            <cfif StructKeyExists(oldMetaTags[idx], 'name')>
                                                                  <cfset tagName = oldMetaTags[idx].name>
                                                            <cfelse>
                                                                  <cfset tagName = oldMetaTags[idx].httpequiv>
                                                            </cfif>
                                                            <cfset oldTagContent = oldMetaTags[idx].content>
                                                            <cfset numChanged = numChanged + 1>
                                                            <cfset compare = diff(oldTagContent, '')>
                                                            <tr><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999;">
                                                                  <span class="formCaption">#tagName#:</span><br>
                                                                  #compare.str1#
                                                            </td><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999; border-right: 1px solid ##999999;">
                                                                  <span class="formCaption">#tagName#:</span><br>
                                                                  #compare.str2#
                                                            </td></tr>
                                                      </cfloop>
                                                </cfif>
                                          </cfif>
                                    </cfif>
                              
                                    <!--- scheduling --->
                                    <cfif formData.blnScheduling>
                                          <cfscript>
                                                x = StructNew();
                                                x.varname = "dtStart";
                                                x.title = "The date/time this data is scheduled to start";
                                                x.type = TYPES.DATE;
                                                x.required = true;
                                                startColumn = x;
      
                                                x = StructNew();
                                                x.varname = "dtEnd";
                                                x.title = "The date/time this data is scheduled to end";
                                                x.type = TYPES.DATE;
                                                x.required = true;
                                                endColumn = x;
                                          </cfscript>
                                          <cfif qryOld.dtStart neq qryNew.dtStart>
                                                <cfset numChanged = numChanged + 1>
                                                <cfset compare = diff(getItemView(formData, startColumn, qryOld.dtStart), getItemView(formData, startColumn, qryNew.dtStart))>
                                                <tr><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999;">
                                                      <span class="formCaption">Start Date:</span><br>
                                                      #compare.str1#
                                                </td><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999; border-right: 1px solid ##999999;">
                                                      <span class="formCaption">Start Date:</span><br>
                                                      #compare.str2#
                                                </td></tr>
                                          </cfif>
                                          <cfif qryOld.dtEnd neq qryNew.dtEnd>
                                                <cfset numChanged = numChanged + 1>
                                                <cfset compare = diff(getItemView(formData, endColumn, qryOld.dtEnd), getItemView(formData, endColumn, qryNew.dtEnd))>
                                                <tr><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999;">
                                                      <span class="formCaption">End Date:</span><br>
                                                      #compare.str1#
                                                </td><td width="50%" valign="top" class="default" style="border-left: 1px solid ##999999; border-right: 1px solid ##999999;">
                                                      <span class="formCaption">End Date:</span><br>
                                                      #compare.str2#
                                                </td></tr>
                                          </cfif>
                                    </cfif>
                                    <tr><td style="border-bottom: 1px solid ##999999; border-left: 1px solid ##999999;" height="1"><img src="images/shim.gif" height="1" width="1"></td><td style="border-bottom: 1px solid ##999999; border-left: 1px solid ##999999; border-right: 1px solid ##999999;" height="1"><img src="images/shim.gif" height="1" width="1"></td></tr>
                              </table>
      
                        <cfelse> <!--- approving a newly added item --->
                              <cfset numChanged = 1>
                              <table width="523" border="0" cellpadding="5" cellspacing="0" align="center">
                                    <tr>
                                          <td class="default">
                                                <cfloop from="1" to="#ArrayLen(formData.columns)#" index="key">
                                                      <cfset column = formData.columns[key]>
                                                      <cfif (not isDefined("column.display") or column.display neq "false") and column.type neq TYPES.HIDDEN and isDefined("qryNew.#column.varname#")>
                                                            <span class="formCaption">#column.title#:</span><br>
                                                            #getItemView(formdata, column, qryNew[column.varname][1])#<br><br>
                                                      </cfif>
                                                </cfloop>
                                          
                                                <!--- if using tblResource, we can assume that we also want to compare the file uploaded to this resource.
                                                        comparing based on the table name is a Very Bad Thing to do, but I can't figure out another way to make
                                                        the exception to pull this off, except making a custom approval form in resources.cfc, which i don't want to do.
                                                --->
                                                <cfif formData.tablename is "tblResource">
                                                      <cfset media = createObject("component", "hb50.media").init(this.CompanyID)>
                                                      <cfset newView = "">
                                                      <cfif Val(qryNew.intMediaID)>
                                                            <cfset newFile = media.getURL(qryNew.intMediaID)>
                                                            <cfset newView = '<a href="#newFile#" target="_blank">#GetFileFromPath(newFile)#</a>'>
                                                      </cfif>
                                                      <span class="formCaption">File:</span><br>
                                                            #newView#<br><br>
                                                </cfif>
                                          </td>
                                    </tr>
                              </table>
                        </cfif>
                  </cfoutput>
            </cfsavecontent>
            
            <cfif numChanged is 0>
                  <cfset body = "There were no changes.">
            </cfif>

            <cfsavecontent variable="output">
                  <cfoutput>
                        <table border="0" cellspacing="0" cellpadding="0" align="center">
                              <form name="#formName#" action="#formData.link#<cfif isDefined("URL.listparam")>&#URLDecode(url.listparam)#</cfif>" method="post" enctype="multipart/form-data" <cfif isDefined("formData.target")>target="#formData.target#"</cfif>>
                                    <input type="hidden" name="ID" value="#ID#">
                                    <input type="hidden" name="txtCurrentBody" id="txtCurrentBody" value="#leftBody#">
                                    <input type="hidden" name="txtBody" id="txtBody" value="#rightBody#">
                                    <tr>
                                          <td class="default">
                                          <cfif qryOld.recordcount and numChanged>
                                                <div id="header" style="position:absolute; visibility:visible; left:2px; top:0px; width:523px; height:20px; z-index:2; background-color:##ffffff;">
                                                      <table width="525" border="0" cellspacing="0" cellpadding="0">
                                                            <tr>
                                                                  <td bgcolor="##FFFFFF"><img src="images/shim.gif" width="1" height="1"></td>
                                                            </tr>
                                                      </table>
                                                      <table class="tableOutline" width="523" border="0" cellspacing="1" cellpadding="0" bgcolor="##FFFFFF">
                                                             <tr>
                                                                   <td height="21" width="50%" class="toolHeader">#translate("Current")#</td>
                                                                   <td height="21" width="50%" class="toolHeader">#translate("Modified")#</td>
                                                             </tr>
                                                      </table>
                                                </div>
                                          </cfif>
                  
                                          #getInnerLayer(body, "approval", true)#
                                          #getButtonLayer(buttons)#
                  
                                          <cfif formData.blnWorkflow and formData.blnTranslate>
                                                #getLanguageForm()#
                                          </cfif>
                                          </td>
                                    </tr>
                              </form>
                        </table>
                  </cfoutput>
            </cfsavecontent>

            <cfreturn output />
      </cffunction>

      <cffunction name="getMetaTagContent" access="private" returntype="string" output="false">
            <cfargument name="tagArray" type="array" required="true">
            <cfargument name="type" type="string" required="true">
            <cfargument name="tag" type="string" required="true">

            <cfset var tagContent = ''>
            <cfset var theTag = ''>
            <cfset var aIndex = 0>

            <cfloop from="1" to="#ArrayLen(tagArray)#" index="aIndex">
                  <cfset theTag = tagArray[aIndex]>
                  <cfif StructKeyExists(theTag,type) and theTag[type] is tag>
                        <cfset tagContent = theTag.content>
                        <cfset ArrayDeleteAt(tagArray, aIndex)>
                        <cfreturn tagContent />
                  </cfif>
            </cfloop>
            
            <cfreturn tagContent />
      </cffunction>

      <!--- return the current url with form parameters encoded into the url --->
      <cffunction name="getCurrentURL" returntype="string">
            <cfset var page = CGI.SCRIPT_NAME />
            <cfset var sep = "?" />
            <cfset key = '' />
            
            <cfif Len(CGI.QUERY_STRING) or StructCount(FORM)>
                  <cfloop collection="#FORM#" item="key">
                        <cfif key neq "FIELDNAMES">
                              <cfset page = "#page##sep##key#=#URLEncodedFormat(FORM[key])#" />
                              <cfset sep = "&" />
                        </cfif>
                  </cfloop>
                  <cfif Len(CGI.QUERY_STRING)>
                        <cfset page = "#page##sep##ReReplaceNoCase(CGI.QUERY_STRING, '[&]?SR=[0-9]+', '')#" />
                  </cfif>
            </cfif>

            <cfreturn page />
      </cffunction>

      <!--- given two strings, returns a struct with the two strings, with changes highlighted in yellow --->
      <cffunction name="diff" returntype="any" output="false">
            <cfargument name="str1" type="string">
            <cfargument name="str2" type="string">

            <cfset var output = StructNew()>
            <cfset var start = 0> <!--- how many characters match at the start --->
            <cfset var end = 0>   <!--- how many characters match at the end --->
            <cfset var a = 0>
            <cfset var string1 = Trim(arguments.str1)>
            <cfset var string2 = Trim(arguments.str2)>            
            <cfset output.str1 = "">
            <cfset output.str2 = "">

            <cfif Compare(str1, str2) is 0>
                  <cfset output.str1 = str1>
                  <cfset output.str2 = str2>
                  
                  <cfreturn output />
            </cfif>

            <!--- find the number of characters at the start of the strings that are equal (start) --->
            <cfloop from="1" to="#min(Len(string1), len(string2))#" index="a">
                  <cfif asc(mid(string1, a, 1)) is asc(mid(string2, a, 1))>
                        <cfset start = start + 1>
                  <cfelse>
                        <cfbreak>
                  </cfif>
            </cfloop>

            <!--- the number of characters after the matched chunk at the start --->
            <cfset lastLength = min(len(string1), len(string2)) - start>

            <!--- count the number of characters that are equal at the end of the strings --->
            <cfloop from="1" to="#min(lastLength, min(len(string1), len(string2)))#" index="a">
                  <cfif asc(mid(string1, len(string1) - a + 1, 1)) is asc(mid(string2, len(string2) - a + 1, 1))>
                        <cfset end = end + 1>
                  <cfelse>
                        <cfbreak>
                  </cfif>
            </cfloop>

            <!--- use starting matching chunk --->
            <cfif start gt 0>
                  <cfset output.str1 = left(string1, start)>
                  <cfset output.str2 = left(string1, start)>
            </cfif>

            <!--- append highlighted differing part (if necessary) --->
            <cfset highlight1 = max(0,len(string1) - start - end)>
            <cfif highlight1 gt 0>
                  <cfset output.str1 = output.str1 & '<span style="background-color: ##FFFF00;">' & mid(string1, start + 1, highlight1) & '</span>'>
            </cfif>
            <cfset highlight2 = max(0,len(string2) - start - end)>
            <cfif highlight2 gt 0>
                  <cfset output.str2 = output.str2 & '<span style="background-color: ##FFFF00;">' & mid(string2, start + 1, highlight2) & '</span>'>
            </cfif>

            <!--- append similar chunk on end --->
            <cfif end gt 0>
                  <cfset output.str1 = output.str1 & right(string1, end)>
                  <cfset output.str2 = output.str2 & right(string2, end)>
            </cfif>

            <cfreturn output />
      </cffunction>

      <cffunction name="getJSValidate" access="public" returntype="string" hint="Returns jsValidate cases." output="false">
            <cfargument name="formData" required="true">
            <cfargument name="formName" required="false" default="frmAddEdit">
            <cfargument name="functionName" required="false" default="jsValidate">

            <cfset isRequired = translate('is required')>
            <cfsavecontent variable="output">
                  <cfoutput>
                        <script language="JavaScript">
                              var jsValidationRequired = true;
                              function #functionName#() {
                                    // when they click delete, set jsValidationRequired to false and it won't validate the page.
                                    if (!jsValidationRequired) return true;
      
                                    <cfloop from="1" to="#ArrayLen(formData.columns)#" index="key">
                                          <cfset i = formData.columns[key]>
                                          <cfif isDefined("i.required") and i.required>
                                                <cfif i.type is TYPES.MEDIA and SESSION.blnAddResource>
                                                       if (document.#formName#.#i.varname# != undefined && !document.#formName#.#i.varname#.disabled) {
                                                             if (document.getElementById('#i.varname#_pickold').style.display == 'none') {
                                                                  if (!(document.#formName#.#i.varname#_upload.value &&
                                                                     document.#formName#.#i.varname#_add_title.value &&
                                                                    document.#formName#.#i.varname#_category.value)) {
                                                                                alert('#translate("A Category, Title and File are required for")# #i.title#');
                                                                              return false;
                                                                  }
                                                            } else {
                                                                  if (!document.#formName#.#i.varname#.value) {
                                                                        alert("#translate(i.title)# #isRequired#.");
                                                                        mydiv = document.getElementById('#i.varname#');
                                                                        if (document.#formName#.#i.varname#.focus && mydiv.style.display == 'block') document.#formName#.#i.varname#.focus();
                                                                        return false;
                                                                  }
                                                            }
                                                      }
                                                <cfelse>
                                                      <cfif i.type is TYPES.CATEGORY>
                                                             if (document.#formName#.#i.varname# != undefined && !document.#formName#.#i.varname#.disabled
                                                                   && !(document.#formName#.#i.varname#.value || document.#formName#.#i.varname#_add_title.value)) {
                                                      <cfelse>
                                                             <!--- Donny (20060623): document.#formName#.#i.varname#.disabled can be undefined for disabled field --->
                                                             if (document.#formName#.#i.varname# != undefined && document.#formName#.#i.varname#.disabled == false && !document.#formName#.#i.varname#.value) {
                                                      </cfif>
                                                                  alert("#translate(i.title)# #isRequired#.");
                                                                  <cfif i.type is TYPES.HTML and SESSION.richText>
                                                                        htmldiv = document.getElementById('DIV#i.varname#');
                                                                        if (htmldiv.focus && htmldiv.style.display == 'block') htmldiv.focus();
                                                                  <cfelse>
                                                                        mydiv = document.getElementById('#i.varname#');
                                                                        try {
                                                                              document.#formName#.#i.varname#.focus();
                                                                        } catch (e) {}
                                                                  </cfif>
                                                                  return false;
                                                             }
                                                </cfif>
                                          </cfif>
                                    </cfloop>
      
                                    return true;
                              }
                        </script>
                  </cfoutput>
            </cfsavecontent>

            <cfreturn output />
      </cffunction>

      <cffunction name="getXMLSelect" access="public" returntype="string" hint="Returns a select generated using an XML document" output="false">
            <cfargument name="xmlDoc" type="any" required="true">
            <cfargument name="varname" type="string" required="true">
            <cfargument name="selList" type="any" required="false" default="0">
            <cfargument name="pruneAt" type="string" required="false" default=""> <!--- used to avoid cycles --->

            <cfsavecontent variable="output">
                  <cfoutput>
                        <select name="#varname#">
                              <option value="#xmldoc.item.xmlattributes.id#" <cfif ListFind(selList, xmldoc.item.xmlattributes.id)>selected</cfif>>#xmldoc.item.xmlattributes.caption#</option>
                              #getXMLSelectRecursive(xmldoc.item, varname, selList, pruneAt)#
                        </select>
                  </cfoutput>
            </cfsavecontent>
            
            <cfreturn output />
      </cffunction>

      <cffunction name="getXMLSelectRecursive" access="public" returntype="string" hint="Returns options recursively generated using an XML document" output="false">
            <cfargument name="xmlDoc" type="any" required="true">
            <cfargument name="varname" type="string" required="true">
            <cfargument name="selList" type="any" required="true">
            <cfargument name="pruneAt" type="string" required="true">
            <cfargument name="indent" type="numeric" required="false" default="0">
            <cfargument name="showCategory" type="boolean" required="false" default="true">

            <cfsavecontent variable="output">
                  <cfoutput>
                        <cfloop from="1" to="#ArrayLen(xmlDoc.xmlchildren)#" index="i">
                              <cfset item = xmlDoc.xmlchildren[i]>                        
                              <cfif not ListFindNoCase(pruneAt, item.xmlattributes.id) and (not isDefined('item.xmlattributes.blnCategory') or not item.xmlattributes.blnCategory or showCategory)>
                                    <option value="#item.xmlattributes.id#" <cfif ListFind(selList, item.xmlattributes.id)>selected</cfif>>#RepeatString("&nbsp;", indent*3)##item.xmlattributes.caption#</option>
                                    #getXMLSelectRecursive(item, varname, selList, pruneAt, indent + 1, showCategory)#
                              </cfif>
                        </cfloop>
                  </cfoutput>
            </cfsavecontent>
            
            <cfreturn output />
      </cffunction>
      
      <!--- todo :: 931 :: KJ :: 7 dec 2006 :: Global Meta Data set up to emulate Workflow :: copy of getXMLSelectRecursive(), this new funtion is modifed return a list of ids --->
      <cffunction name="getXMLSelectRecursive2" access="public" returntype="string" hint="Returns options recursively generated using an XML document" output="false">
            <cfargument name="xmlDoc" type="any" required="true">
            <cfargument name="varname" type="string" required="true">
            <cfargument name="selList" type="any" required="true">
            <cfargument name="pruneAt" type="string" required="true">
            <cfargument name="indent" type="numeric" required="false" default="0">
            <cfargument name="showCategory" type="boolean" required="false" default="true">

            <cfsavecontent variable="output">
                        <cfloop from="1" to="#ArrayLen(xmlDoc.xmlchildren)#" index="i">
                              <cfset item = xmlDoc.xmlchildren[i]>                        
                              <cfif not ListFindNoCase(pruneAt, item.xmlattributes.id) and (not isDefined('item.xmlattributes.blnCategory') or not item.xmlattributes.blnCategory or showCategory)>
                                    <cfoutput>,#item.xmlattributes.id#</cfoutput>
                                    <cfset tempList = "#getXMLSelectRecursive2(item, varname, selList, pruneAt, indent + 1, showCategory)#">
                                    <cfif len(trim(tempList)) GT 0>
                                          <cfoutput>,#trim(tempList)#</cfoutput>
                                    </cfif>
                              </cfif>
                        </cfloop>
            </cfsavecontent>
            
            <cfreturn output />
      </cffunction>

      <cffunction name="memoFormat" access="public" returntype="string" output="false">
            <cfargument name="input" type="string" required="true">
            <cfargument name="length" type="numeric" required="true">
            <cfargument name="dots" type="string" required="false" default="...">

            <cfset var text = REReplace(arguments.input, "<[^>]*>"," ","all")>
            <cfif Len(text) gt arguments.length>
                  <cfset text = Left(text, length)>
                  <cfset lastSpace = Len(text) - ReFind("\s[^\s]", reverse(text))>
                  <cfset text = Left(text, lastSpace) & dots>
            </cfif>
            
            <cfreturn text />
      </cffunction>

      <cffunction name="getItemView" access="public" returntype="string" output="false">
            <cfargument name="formData" type="any" required="true">
            <cfargument name="i" type="struct" required="true">
            <cfargument name="data" type="string" required="true">

            <cfset width = 225>

            <cfsavecontent variable="output">
                  <cfoutput>
                        <cfif ListFind("#TYPES.TEXT#,#TYPES.HTML#,#TYPES.MEMO#,#TYPES.NUMBER#,#TYPES.COLOUR#", i.type)>
                              #this.workflow.convertTokens(data)#
                        <cfelseif i.type is TYPES.DATE>
                              <!--- date always has a default of now (due to the flash movie) --->
                              <cfif isDate(data)>
                                    #DateFormat(data, "mmm-dd-yy")#
                              </cfif>
                        <cfelseif ListFind("#TYPES.BOOLEAN#,#TYPES.FEATURED#", i.type)>
                              <cfif data is 1>#translate("Yes")#<cfelse>#translate("No")#</cfif>
                        <cfelseif i.type is TYPES.MEDIA>
                              <cfset media = createObject("component", "hb50.media").init(this.CompanyID)>
                              #media.getMediaDisplay(Val(data))#
                        <cfelseif i.type is TYPES.SELECT>
                              <cfif isDefined("i.multiple") and i.multiple and isDefined("id")>
                                    <cfquery name="qryData" datasource="#this.datasource#" cachedwithin="#this.queryCache#">
                                          SELECT       #i.relationValue#
                                          FROM       #i.relationTable#
                                          WHERE       #i.relationIndex# = #id#
                                    </cfquery>
                              </cfif>
                              <cfif isDefined("i.xml")>
                                    <cfset findXML = searchXMLByID(i.xml, val(data))>
                                    <cfif (not isSimpleValue(findXML)) and StructKeyExists(findXML.xmlattributes, "caption")>
                                          #findXML[1].xmlattributes.caption#
                                    </cfif>
                              <cfelseif isDefined("i.query")>
                                    <cfquery name="qryGetList" datasource="#this.datasource#" cachedwithin="#this.queryCache#">
                                          #PreserveSingleQuotes(i.query)#
                                    </cfquery>
                                    <cfset qryData = selectFrom(qryGetList, i.valueVar, data)>
                                    #qryData[i.displayVar][1]#
                              </cfif>
                        <cfelseif i.type is TYPES.CATEGORY>
                              <cfset category = createObject("component", "hb50.category").init(this.CompanyID)>
                              #selectFrom(category.getCategories(formData.webid), "intID", data).txtTitle#
                        </cfif>
                  </cfoutput>
            </cfsavecontent>

            <cfreturn output />
      </cffunction>

      <cffunction name="getFormItemDisplay" access="public" returntype="string" output="false">
            <cfargument name="formData" type="any" required="true" />
            <cfargument name="i" type="struct" required="true" />
            <cfargument name="qryData" type="query" required="false" />
            <cfargument name="itemWidth" type="numeric" required="false" default="225" />
            
            <cfscript>
                  var lastCat = 0;
                  var count = 0;
                  var width = arguments.itemWidth;
                  var value = '';
                  
                  //padding settings
                  var paddingLeft = 20;
                  var paddingTop = 12;
                  if (StructKeyExists(arguments.formData, 'paddingL'))
                        paddingLeft = Val(formData.paddingL);
                  if (StructKeyExists(arguments.formData, 'paddingT'))
                        paddingTop = Val(formData.paddingT);

                  if (isDefined("qryData") and qryData.recordCount and StructKeyExists(qryData, i.varname))
                        value = qryData[i.varname][1];
                  else if (isDefined("#i.varname#"))            //lets check form vars, just in case
                        value = evaluate("#i.varname#");
                  else if (StructKeyExists(i, "default"))
                        value = i.default;
            </cfscript>

            <cfsavecontent variable="output">
                  <cfoutput>
                        <div id="#i.varname#" style="display:block; <cfif i.type neq TYPES.HTML>padding-left:#paddingLeft#px; padding-top:#paddingTop#px;</cfif>">
                        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="formCaption">
                              <cfif i.type is TYPES.HIDDEN>
                                <input type="hidden" name="#i.varname#" value="#HTMLEditFormat(value)#">
                              <cfelse>
                              <cfif Len(Trim(i.title)) and not ListFind("#TYPES.BOOLEAN#,#TYPES.HTML#,#TYPES.LIST#", i.type)>
                                <tr>
                                    <td valign="top" width="#width#">#translate(i.title)#:<cfif isDefined("i.required") and i.required><span class="txtRequired">&nbsp;*</span></cfif>
                                    </td>
                                </tr>
                               </cfif>
                                <tr>
                                    <td valign="top" align="left">

                              <cfif isDefined("i.edit") and not i.edit>
                                    <input disabled class="formTextbox" style="width: #width#px;" type="Text" size="50" value="#HTMLEditFormat(getItemView(formData, i, value))#" maxlength="<cfif StructKeyExists(i, "maxlength")>#val(i.maxlength)#<cfelse>500</cfif>">
                              <cfelseif i.type is TYPES.TYPE>
                                    <select class="formTextbox" id="#i.varname#_select" style="width: #width#px;" name="#i.varname#" onchange="javascript:changeType();">
                                          <option value="">#translate("Select a type")#...</option>
                                          <cfloop from="1" to="#ArrayLen(i.options)#" index="k">
                                                <option value="#i.options[k].value#" <cfif i.options[k].value is value>selected</cfif>>#i.options[k].caption#</option>
                                          </cfloop>
                                    </select>
                              <cfelseif i.type is TYPES.TEXT>
                                    <input class="formTextbox" style="width: #width#px;" type="Text" name="#i.varname#" id="#i.varname#_text" size="50" value="#HTMLEditFormat(value)#" maxlength="<cfif StructKeyExists(i, "maxlength")>#val(i.maxlength)#<cfelse>500</cfif>"<cfif isDefined("i.readonly") and i.readonly> readonly</cfif><cfif isDefined("i.disabled") and i.disabled> disabled</cfif><cfif isDefined("i.onChange")> onChange="#i.onChange#"</cfif>>
                              <cfelseif i.type is TYPES.COLOUR>
                                    <cfif not isDefined("this.dialogHelperDefined")>
                                          <object id="dlgHelper" classid="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></object>
                                          <cfset this.dialogHelperDefined = true>
                                    </cfif>
                                     <input class="formTextbox" style="width: #width#px;" type="Text" name="#i.varname#" id="#i.varname#_text" size="50" value="#HTMLEditFormat(value)#" maxlength="<cfif StructKeyExists(i, "maxlength")>#val(i.maxlength)#<cfelse>500</cfif>">
                                    <script>
                                          var sInitColor = null;
                                          document.getElementById('#i.varname#_text').onclick = function () {
                                                try {
                                                      sColor = document.getElementById('dlgHelper').ChooseColorDlg(document.getElementById('#i.varname#_text').value);
                                                      sColor = sColor.toString(16);
                                                      if (sColor.length < 6) {
                                                        var sTempString = '000000'.substring(0,6-sColor.length);
                                                        sColor = sTempString.concat(sColor);
                                                      }
                                                      document.getElementById('#i.varname#_text').value = sColor;
                                                } catch (e) {}
                                          }
                                    </script>
                              <cfelseif i.type is TYPES.URL>
                                    <cfif isDefined('i.dynamic') and i.dynamic>
                                          <script>
                                                function jsGetLink_#i.varname# () {
                                                      var windowLink = 'popup.cfm?p=rte.insertlink&js=jsSetLink_#i.varname#&return=true';
                                                      var linktxt = document.getElementById('#i.varname#_hidden').value;
                                                      
                                                      //Jason: append the id (sourceID) and the navid(will be converted to sourceType) from the URL to insertlink.cfc
                                                      var URLParams = window.document.location.search.toString();
                                                      var keyvalue = '';
                                                      var sourceID = '';
                                                      var sourceType = '';
                                                      var subType = '';
                                                      URLParams = URLParams.substring(1, URLParams.length);
                                                      URLParams = URLParams.split('&');
                                                      for (var i=0; i < URLParams.length; i++) {
                                                            keyvalue = URLParams[i].split('=');
                                                            switch(keyvalue[0]) {
                                                                  case 'navid':
                                                                        sourceType = keyvalue[1];
                                                                        break;
                                                                  case 'id':
                                                                        sourceID = keyvalue[1];
                                                                        break;
                                                                  case 'tabid':
                                                                        subType = keyvalue[1];
                                                                        break;
                                                                  default:
                                                            }
                                                      }
                                                      if (sourceID == '')
                                                            sourceID = '-999';
                                                      if (sourceID != '' && sourceType != '')
                                                            windowLink += '&sourceID=' + sourceID + '&sourceType=' + sourceType + '&subType=' + subType;
                                                      
                                                      if (linktxt != '')
                                                            windowLink += '&link=' + escape(linktxt);

                                                      if (window.showModalDialog)
                                                            showModalDialog(windowLink, window, 'resizable: yes; help: no; status: no; scroll: no;');
                                                      else
                                                            window.open(windowLink, '', 'help=no,resizable=yes,scroll=no,status=no,modal=yes,width=530,height=355');
                                                }
                                                function jsSetLink_#i.varname# (link) {
                                                      document.getElementById('#i.varname#_text').innerHTML = '<a href="#this.qryCompany.txtWeb#/' + link.split('$')[0] + '" target="_blank">#translate("Preview Link")#</a>';
                                                      document.getElementById('#i.varname#_hidden').value = link;
                                                }
                                          </script>
                                          <img src="images/ed_link.gif" title="Insert Link" border=0 width=18 height=18 align="top" style="float:left;" onmouseover="this.style.cursor='hand'; this.style.cursor='pointer'; document.body.onbeforeunload=null;" onmouseout="if (window.jsSaveWarning) jsSaveWarning();" onclick="jsGetLink_#i.varname#();">
                                          <div style="width:#width-20#px; height:25px; padding:3px; overflow:hidden;" class="formCaption" id="#i.varname#_text"><cfif value neq ""><a <cfif REFindNoCase('http[s]*://',value)>href="#HTMLEditFormat(ListFirst(value, '$'))#"<cfelse>href="#this.qryCompany.txtWeb#/#HTMLEditFormat(ListFirst(value, '$'))#"</cfif> target="_blank">#translate("Preview Link")#</a></cfif></div>
                                          <input type="hidden" name="#i.varname#" id="#i.varname#_hidden" value="#HTMLEditFormat(value)#">
                                    <cfelse>
                                          <input style="width: #width#px;" class="formTextbox" type="Text" name="#i.varname#" id="#i.varname#_text" size="50" value="#HTMLEditFormat(value)#" maxlength="<cfif StructKeyExists(i, "maxlength")>#Val(i.maxlength)#<cfelse>500</cfif>">
                                    </cfif>
                              <cfelseif i.type is TYPES.DATE>
                                    #getFormItem(TYPES.DATE, i.varname, value)#
                              <cfelseif i.type is TYPES.NUMBER>
                                    <input class="formTextbox" type="Text" name="#i.varname#" id="#i.varname#_text" size="10" value="#HTMLEditFormat(value)#" maxlength="10"<cfif isDefined("i.readonly") and i.readonly> readonly</cfif><cfif isDefined("i.disabled") and i.disabled> disabled</cfif>>
                              <cfelseif i.type is TYPES.BOOLEAN>
                                    <input type="checkbox" id="#i.varname#_check" name="#i.varname#" value="on"<cfif value is 1 or value is 'on'> checked</cfif><cfif isDefined("i.disabled") and i.disabled> disabled</cfif><cfif isDefined("i.onClick")> onClick="#i.onClick#"</cfif>> #translate(i.title)#
                              <cfelseif i.type is TYPES.PASSWORD>
                                    <input class="formTextbox" size="50" style="width: #width#px;" type="password" name="#i.varname#" value="#value#" maxlength="500">
                              <cfelseif i.type is TYPES.MEDIA>
                                    <cfparam name="i.ext" default="">
                                    #getFormItem(TYPES.MEDIA, i.varname, value, i.ext)#
                              <cfelseif i.type is TYPES.SELECT>
                                    <cfif isDefined("i.multiple") and i.multiple and isDefined("id") and isDefined("i.relationTable")>
                                          <cfquery name="qryPolicy" datasource="#this.datasource#" cachedwithin="#this.queryCache#">
                                                SELECT       #i.relationValue# AS intID
                                                FROM       #i.relationTable#
                                                WHERE       #i.relationIndex# = #Val(id)#
                                          </cfquery>
                                          <cfset value = ValueList(qryPolicy.intID)>
                                    </cfif>
                                    <select class="formTextarea" name="#i.varname#" id="#i.varname#_select" style="width: #width#px;"<cfif isDefined("i.multiple") and i.multiple> multiple size="<cfif isDefined("i.multiplesize") and Val(i.multiplesize)>#i.multiplesize#<cfelse>5</cfif>"<cfelse><cfif isDefined("i.size") and Val(i.size)>size="#i.size#"</cfif></cfif><cfif isDefined("i.onChange")> onChange="#i.onChange#"</cfif><cfif isDefined("i.disabled") and i.disabled> disabled</cfif>>
                                          <cfif not isDefined("i.selectText")>
                                                <cfset i.selectText = "Please select one...">
                                          </cfif>
                                          <cfif isDefined("i.xml")>
                                                <cfparam name="i.pruneAt" default="0">
                                                <cfparam name="i.showXMLTopItem" default="true">
      
                                                <cfif (ArrayLen(i.xml.item.xmlchildren) gt 1 and Len(i.selectText)) or isDefined("i.showSelectText")>
                                                      <option value="">#translate(i.selectText)#</option>
                                                </cfif>
      
                                                <!--- decide whether to use the top item or not (if it has attributes) --->
                                                <cfif i.showXMLTopItem and isDefined("i.xml.item.xmlattributes.id")>
                                                      <cfset showCategory = true>
                                                      <cfif isDefined("i.showCategory") and isDefined("i.xml.item.xmlattributes.blnCategory")>
                                                            <cfset showCategory = i.showCategory>
                                                      </cfif>
                                                      <option value="#i.xml.item.xmlattributes.id#"<cfif ListFind(value, i.xml.item.xmlattributes.id)> selected</cfif>>#i.xml.item.xmlattributes.caption#</option>
                                                      #getXMLSelectRecursive(i.xml.item, i.varname, value, i.pruneAt, 1, showCategory)#
                                                <cfelse>
                                                      #getXMLSelectRecursive(i.xml.item, i.varname, value, i.pruneAt, 0)#
                                                </cfif>
                                          <cfelseif isDefined("i.query")>
                                                <cfparam name="i.valueVar" default="intID">
                                                <cfparam name="i.displayVar" default="txtTitle">
                                                
                                                <cfif isDefined('i.datasource')>
                                                      <cfset thisDS = i.datasource>
                                                <cfelse>
                                                      <cfset thisDS = this.datasource>
                                                </cfif>
                                                <cfif IsQuery(i.query)>
                                                      <cfset qryGetList = i.query>
                                                <cfelse>
                                                      <cfquery name="qryGetList" datasource="#thisDS#">
                                                            #PreserveSingleQuotes(i.query)#
                                                      </cfquery>
                                                </cfif>
                                                <cfif (qryGetList.recordcount gt 0 and len(i.selectText)) or isDefined("i.showSelectText")>
                                                      <option value="">#translate(i.selectText)#</option>
                                                </cfif>
      
                                                <cfloop query="qryGetList">
                                                      <option value="#qryGetList[i.valueVar][currentRow]#"<cfif ListFind(value, qryGetList[i.valueVar][currentRow])> selected</cfif>>
                                                            #qryGetList[i.displayVar][currentRow]#<cfif isDefined("i.displayVarExt")> #qryGetList[i.displayVarExt][currentRow]#</cfif><cfif isDefined("i.displayVar2")> (#qryGetList[i.displayVar2][currentRow]#)</cfif>
                                                      </option>
                                                </cfloop>
                                          </cfif>
                                    </select>
                              <cfelseif i.type is TYPES.RADIO and isDefined("i.xml")>
                                    <cfset xmlNode = i.xml.item>
                                    <cfloop from="1" to="#ArrayLen(xmlNode.xmlchildren)#" index="idx">
                                          <cfset item = xmlNode.xmlchildren[idx]>
                                          <input type="radio" name="#i.varname#" value="#item.xmlattributes.value#"<cfif (value is "" and i.default is item.xmlattributes.value) or value is item.xmlattributes.value> checked</cfif>> #item.xmlattributes.caption#<br/>
                                    </cfloop>
                              <cfelseif i.type is TYPES.CATEGORY>
                                    <!--- Donny: if the formdata item have query associated to it, use it. (needed by Journal.cfc) --->
                                    <cfif isDefined("i.query") and isQuery(i.query)>
                                          <cfset qryCategory = i.query>
                                    <cfelse>
                                          <cfset category = createObject("component", "hb50.category").init(this.CompanyID)>
                                          <cfset qryCategory = category.getCategories(formData.webid)>
                                    </cfif>

                                    <cfset addnew = ((not isDefined("i.addnew")) or i.addnew)>
                                    <div id="#i.varname#_view">
                                          <select class="formTextbox" id="#i.varname#_select" name="#i.varname#" style="width:#width#px; height:18; z-index:1;"<cfif addnew> onchange="#i.varname#_addnew();"</cfif>>
                                                <option value="">#translate("Please select one...")#</option>
                                                <cfif addnew>
                                                      <option value="">#translate("Add a new #LCase(i.title)#")#</option>
                                                </cfif>
                                                <cfloop query="qryCategory">
                                                      <option value="#intID#"<cfif value is intID> selected</cfif>>#qryCategory["txtTitle"][currentRow]#</option>
                                                </cfloop>
                                          </select>
                                    </div>
                                    <cfif addnew>
                                          <div id="#i.varname#_add" style="display: none; width: #width-15#">                                                
                                                <input id="#i.varname#_add_title" class="formTextbox" style="width: #width#px;" type="Text" name="#i.varname#_add_title" size="50" value="" maxlength="1000">
                                          </div>
                                          <script language='Javascript'>
                                                function #i.varname#_addnew() {
                                                      if (document.getElementById('#i.varname#_select').selectedIndex == 1)
                                                            document.getElementById('#i.varname#_add').style.display = 'block';
                                                      else {
                                                            document.getElementById('#i.varname#_add').style.display = 'none';
                                                            document.getElementById('#i.varname#_add_title').value = '';
                                                      }
                                                }
                                          </script>
                                    </cfif>
                              <cfelseif i.type is TYPES.UPLOAD>
                                    <!--- it's up to you to process this form element, since its outcome is always so custom --->
                                    <input class="formTextarea" style="width: #width#px;" type="file" id="#i.varname#_text" name="#i.varname#" size="21" maxlength="1000" onChange="document.getElementById('#i.varname#_strFile_id').value = this.value;">
                                    <cfif isDefined("i.preview") and Len(Trim(i.preview))>
                                          <div style="padding-top:5px;">#i.preview#</div>
                                    </cfif>
                                    <input type="hidden" id="#i.varname#_strFile_id" name="#i.varname#_strFile" value="">
                              <cfelseif i.type is TYPES.FEATURED>
                                    <cfif value is 1>
                                          <input type="hidden" name="blnFeatured" value="on">
                                          <b>#translate("THIS ITEM IS FEATURED.")#</b>
                                    <cfelse>
                                          <input type="checkbox" name="blnFeatured">
                                    </cfif>
                              <cfelseif i.type is TYPES.MEMO>
                                    <textarea id="#i.varname#_text" class="formTextarea" name="#i.varname#" wrap="PHYSICAL" style="width:<cfif isDefined("i.memoW") and Val(i.memoW)>#i.memoW#<cfelse>#width#</cfif>px; height:<cfif isDefined("i.memoH") and Val(i.memoH)>#i.memoH#<cfelse>50</cfif>px;">#value#</textarea>
                              <cfelseif i.type is TYPES.HTML>
                                    <cfif true or SESSION.richText>
                                          <cfsavecontent variable="toolbar">
                                                <cf_htmltoolbar name="#i.varname#" datasource="#this.datasource#" CompanyID="#this.CompanyID#" imagepath="images" previewpage="t2.cfm" codeview="#SESSION.blnCodeView#">
                                          </cfsavecontent>
                                          #getToolbarLayer(toolbar)#
                                          <cf_htmleditarea name="#i.varname#" class="formTextarea" qryname="#this.qryCompany#">#this.workflow.convertCachedTokens(value, true)#</cf_htmleditarea>
                                    <cfelse>
                                          #getToolbarLayer('<div align="center">#this.language.translate("Warning: You need Internet Explorer 5.5 or higher in order to use the Rich Text Editor.")#</div>')#
                                          <textarea cols="37" class="formTextarea" name="#i.varname#" rows="8" wrap="PHYSICAL" style="width:545px; height:263px;">#value#</textarea>
                                    </cfif>
                                    
                              <!--- Donny:  display list items e.g. meta data list (didn't modify this) --->
                              <cfelseif i.type is TYPES.LIST>
                                    <style type="text/css">
                                    <!--
                                          .item {
                                                position: relative;
                                                width:522px;
                                                left: 1px;
                                                float: left;
                                                border-left: 1px solid ##999999;;
                                                border-right: 1px solid ##999999;;
                                                border-bottom: 1px solid ##999999;;
                                          }
                                    -->
                                    </style>

                                    <div style="position: absolute; top: -43px; left: 0px; z-index: 10;">
                                          <!--- Donny: Metatag Button & List -
                                                        - no add row
                                                        - show metatag template button (depends on flag set on e.g. /hb50/internal/webcontrol.cfc) --->
                                          <cfif isDefined("formData.blnMeta") AND formData.blnMeta>
                                                <input type="reset" name="btnDelete_#i.varname#" value="#translate("Delete Row")#" onclick="return removeItem_#i.varname#();" class="buttons" style="visibility:hidden;">
                                                <input type="reset" name="btnMetaTag_#i.varname#" value="#translate("Meta Data Template")#" onclick="return newMetaTag_#i.varname#('#formData.title#');" class="buttons" style="visibility:hidden;">
                                          <cfelse>
                                                <!--- Donny: Normal List - allow add / remove delete row --->
                                                <input type="reset" value="#translate("Add Row")#" onclick="return newItem_#i.varname#();" class="buttons">
                                                <input type="reset" name="btnDelete_#i.varname#" value="#translate("Delete Row")#" onclick="return removeItem_#i.varname#();" class="buttons">
                                          </cfif>
                                    </div>
                                    <div id="header" style="position:absolute; visibility:visible; left:1px; top:1px; width:540px; height:20px; z-index:2;">#i.headerText#</div>

                                    <div id="list_#i.varname#" style="position: absolute; top: 22; left: 0; overflow: scroll; width:541px; height:241px;" ></div>
                                    #getListColumn(i.listHTML, i.editHTML, 'list_#i.varname#', i.collist, i.varname, value, 'frmAddEdit')#
                              <cfelseif i.type is TYPES.HIDDEN>
                                    <input type="hidden" name="#i.varname#" value="#value#">
                              <cfelseif i.type is TYPES.CUSTOM>
                                    #i.html#
                              <cfelseif i.type is TYPES.DATERANGE>
                                    #getFormItem(TYPES.DATERANGE, i.varname, value)#
                              </cfif>
                                    </td>
                                </tr>
                              </cfif>
                          </table>
                          </div>
                  </cfoutput>
            </cfsavecontent>

            <cfreturn output />
      </cffunction>

      <!--- turns a string formatted like
                   "value1,value2,value3
                    value1,value2,value3
                    value1,value2,value3"
              into a query with rows & columns (column names taken from collist)
      --->      
      <cffunction name="listColumnToQuery" access="public" returntype="query" output="false">
            <cfargument name="result" type="string" required="true">
            <cfargument name="collist" type="string" required="true">

            <cfset var query = QueryNew(collist)>

            <cfloop list="#result#" delimiters="#CHR(13)##CHR(10)#" index="record">
                  <!--- ignore incomplete records --->
                  <cfif ListLen(collist) lte ListLen(record)>
                        <cfset QueryAddRow(query)>
                        <cfif ListLen(collist) is 2> <!--- modified to support value that contains commas - only work for 2 columns --->
                              <cfset QuerySetCell(query, ListFirst(collist), Trim(ListFirst(record)))>
                              <cfset QuerySetCell(query, ListRest(collist), Trim(ListRest(record)))>
                        <cfelse>
                              <cfloop from="1" to="#ListLen(collist)#" index="i">
                                    <cfset QuerySetCell(query, ListGetAt(collist, i), Trim(ListGetAt(record, i)))>
                              </cfloop>
                        </cfif>
                  </cfif>
            </cfloop>

            <cfreturn query />
      </cffunction>

      <cffunction name="getListColumn" access="public" returntype="string" output="false">
            <cfargument name="listHTML" type="any" required="true">
            <cfargument name="editHTML" type="any" required="true">
            <cfargument name="divName" type="any" required="true">
            <cfargument name="collist" type="any" required="true">
            <cfargument name="varname" type="any" required="true">
            <cfargument name="value" type="any" required="true">
            <cfargument name="formName" type="any" required="true">

            <cfsavecontent variable="output">
                  <cfoutput>
                        <input type="hidden" name="#varname#" value="#value#">
                        <script>
                        //<!--
                              var saveDelay_#varname# = false;
                              var idEdited_#varname# = '';
                              var dataObj_#varname# = new Object();
                              var idCount_#varname# = #ListLen(value, '#CHR(13)##CHR(10)#') + 1#;
      
                              <cfloop from="1" to="#ListLen(value, '#CHR(13)##CHR(10)#')#" index="i">
                                    dataObj_#varname#['#varname#_#i#'] = new Object();
                                    <cfif ListLen(collist) is 2> //modified to support value that contains commas - only work for 2 columns
                                          dataObj_#varname#['#varname#_#i#'].#ListFirst(collist)# = '#trim(JSStringFormat(ListFirst(ListGetAt(value, i, '#CHR(13)##CHR(10)#'))))#';
                                          dataObj_#varname#['#varname#_#i#'].#ListRest(collist)# = '#trim(JSStringFormat(ListRest(ListGetAt(value, i, '#CHR(13)##CHR(10)#'))))#';
                                    <cfelse>
                                          <cfloop from="1" to="#ListLen(collist)#" index="j">
                                                dataObj_#varname#['#varname#_#i#'].#ListGetAt(collist, j)# = '#trim(JSStringFormat(ListGetAt(ListGetAt(value, i, '#CHR(13)##CHR(10)#'), j)))#';
                                          </cfloop>
                                    </cfif>
                              </cfloop>
      
                              function getItemDisplay_#varname# (id) {
                                    var item = dataObj_#varname#[id];
                                    return ''
                                          <cfloop from="1" to="#ListLen(collist)#" index="i">
                                                <cfset col = ListGetAt(collist, i)>
                                                + '#JSStringFormat(ListGetAt(ListGetAt(listHTML, i, '#CHR(13)##CHR(10)#'), 1))#'
                                                + item.#col#
                                                + '#JSStringFormat(ListGetAt(ListGetAt(listHTML, i, '#CHR(13)##CHR(10)#'), 2))#'
                                          </cfloop>
                                                ;
                              }
      
                              function removeItem_#varname#() {
                                    if (idEdited_#varname# == '') {
                                          alert("#translate('Click an item to edit/delete')#");
                                          return false;
                                    }
                                    var obj = document.getElementById(idEdited_#varname#);
                                    delete(dataObj_#varname#[idEdited_#varname#]);
                                    obj.outerHTML = '';
                                    idEdited_#varname# = '';
                                    updateHiddenField_#varname#();
                                    return false;
                              }
      
                              function saveItem_#varname#() {
                                    if (idEdited_#varname# == '') {
                                          return false;
                                    }
                                    var obj = document.getElementById(idEdited_#varname#);
                                    <cfloop list="#collist#" index="col">
                                          dataObj_#varname#[idEdited_#varname#].#col# = document.#formName#.#col#.value;
                                    </cfloop>
                                    obj.outerHTML = dataObj_#varname#[idEdited_#varname#].outerhtml.split(/>/)[0] + '>' + getItemDisplay_#varname#(idEdited_#varname#) + '</div>';
                                    idEdited_#varname# = '';
                                    updateHiddenField_#varname#();
                                    return false;
                              }
      
                              function newItem_#varname#() {
                                    var divlist = document.getElementById('#divName#');
                                    var newID = '#varname#_' + idCount_#varname#++ + '';
                                    if (idEdited_#varname# != '') {
                                          saveItem_#varname#();
                                    }
                                    dataObj_#varname#[newID] = new Object();
                                    <cfloop list="#collist#" index="col">
                                          dataObj_#varname#[newID].#col# = '';
                                    </cfloop>
                                    dataObj_#varname#[newID].id = newID;
                                    divlist.innerHTML += '<div id="' + newID + '" class="item" onclick="editItem_#varname#(this)">' + getItemDisplay_#varname#(newID) + '</div>';
                                    updateHiddenField_#varname#();
                                    editItem_#varname#(document.getElementById(newID));
                                    return false;
                              }
      
                              // Donny: callback from Meta Data Template Modal Dialog
                              function newMetaTagItem_#varname#(metaTagType,metaTagName,metaTagContent) {
                                    if (metaTagName.length && metaTagContent.length) {
                                          var divlist = document.getElementById('#divName#');
                                          var newID = '#varname#_' + idCount_#varname#++ + '';
                                          if (idEdited_#varname# != '') {
                                                saveItem_#varname#();
                                          }
                                          dataObj_#varname#[newID] = new Object();
      
                                          // Donny: assign Name and Content to according column in #collist#
                                          <cfloop list="#collist#" index="col">
                                                <cfswitch expression="#col#">
                                                      <cfcase value="txtMetaType">
                                                            dataObj_#varname#[newID].#col# = metaTagType;
                                                      </cfcase>
                                                      <cfcase value="txtMetaName">
                                                            dataObj_#varname#[newID].#col# = metaTagName;
                                                      </cfcase>
                                                      <cfdefaultcase>
                                                            dataObj_#varname#[newID].#col# = metaTagContent;
                                                      </cfdefaultcase>
                                                </cfswitch>
                                          </cfloop>
      
                                          dataObj_#varname#[newID].id = newID;
                                          divlist.innerHTML += '<div id="' + newID + '" class="item" onclick="editItem_#varname#(this)">' + getItemDisplay_#varname#(newID) + '</div>';
                                          updateHiddenField_#varname#();
                                          editItem_#varname#(document.getElementById(newID));
      
                                          setTimeout('saveItem_#varname#();', 100)
                                    }
                                    return false;
                              }
      
                              // Donny:  popup Meta Tag Modal Dialog
                              function newMetaTag_#varname#(title) {
                                    showModalDialog('popup/metaDataTemplate.cfm?varname=#varname#&title='+title+'&navid=#url.navid#&subid=#subid#',window,'help=no;resizable=yes;scroll=no;status=no;center=yes');
                                    return false;
                              }
      
                              function editItem_#varname# (obj) {
                                    var innerhtml = obj.innerHTML;
                                    if (idEdited_#varname# != '') {
                                          saveItem_#varname#();
                                    }
                                    idEdited_#varname# = obj.id;
                                    dataObj_#varname#[idEdited_#varname#].obj = obj;
                                    dataObj_#varname#[idEdited_#varname#].innerhtml = obj.innerHTML;
                                    dataObj_#varname#[idEdited_#varname#].outerhtml = obj.outerHTML;
                                    obj.innerHTML = '<cfoutput>#JSStringFormat(editHTML)#</cfoutput>';
                                    obj.onclick = '';
      
                                    /*Trying to make it work for FireFox (and failing)
                                    for (var i=0;i < document.#formName#.elements.length;i++) {
                                          var column = document.#formName#.elements[i];
                                          if (typeof(dataObj_#varname#[idEdited_#varname#][column.name]) != 'undefined') {
                                                column.value = dataObj_#varname#[idEdited_#varname#][column.name];
                                                if (column.addEventListener) {
                                                      column.addEventListener('blur', function () { saveDelay_#varname# = true; setTimeout('if (saveDelay_#varname#) saveItem_#varname#();', 100) }, true);
                                                      column.addEventListener('focus', function () { saveDelay_#varname# = false; }, true);
                                                } else {
                                                      column.onblur = function () { saveDelay_#varname# = true; setTimeout('if (saveDelay_#varname#) saveItem_#varname#();', 100) };
                                                      column.onfocus = function () { saveDelay_#varname# = false; };
                                                }
                                          } else {
                                                alert(column.name);
                                          }
                                    }
                                    */
                                    <cfloop list="#collist#" index="col">
                                          document.#formName#.#col#.value = dataObj_#varname#[idEdited_#varname#].#col#;
                                          document.#formName#.#col#.onblur = function () { saveDelay_#varname# = true; setTimeout('if (saveDelay_#varname#) saveItem_#varname#();', 100) };
                                          document.#formName#.#col#.onfocus = function () { saveDelay_#varname# = false; };
                                    </cfloop>
      
                                    //setTimeout('document.#formName#.#ListFirst(collist)#.focus();', 100);      
                              }
      
                              function editItem2_#varname# (obj) {
                                    var innerhtml = obj.innerHTML;
                                    alert('#varname#');
                                    if (idEdited_#varname# != '') {
                                          saveItem_#varname#();
                                    }
      
                                    idEdited_#varname# = obj.id;
                                    dataObj_#varname#[idEdited_#varname#].obj = obj;
                                    dataObj_#varname#[idEdited_#varname#].innerhtml = obj.innerHTML;
                                    dataObj_#varname#[idEdited_#varname#].outerhtml = obj.outerHTML;
                                    obj.innerHTML = '<cfoutput>#JSStringFormat(editHTML)#</cfoutput>';
      
                                    obj.onclick = '';
                                    <cfloop list="#collist#" index="col">
                                          document.#formName#.#col#.value = dataObj_#varname#[idEdited_#varname#].#col#;
                                          document.#formName#.#col#.onblur = function () { saveDelay_#varname# = true; setTimeout('if (saveDelay_#varname#) saveItem_#varname#();', 100) };
                                          document.#formName#.#col#.onfocus = function () { saveDelay_#varname# = false; };
                                    </cfloop>
                              }
      
                              function updateHiddenField_#varname#() {
                                    var field = document.#formName#.#varname#;
                                    var str = '';
                                    for (var k in dataObj_#varname#) {
                                          str +=
                                                <cfloop from="1" to="#ListLen(collist)#" index="j">
                                                      <cfset col = ListGetAt(collist, j)>
                                                      (dataObj_#varname#[k].#col# == '' ? ' ' : dataObj_#varname#[k].#col#) <cfif j lt ListLen(collist)>+ ','</cfif> +
                                                </cfloop>
                                                '\n';
                                    }
                                    field.value = str;
                              }
      
                              var divlist = document.getElementById('#divName#');
                              for (var k in dataObj_#varname#) {
                                    divlist.innerHTML += '<div id="' + k + '" class="item" onclick="editItem_#varname#(this)">' + getItemDisplay_#varname#(k) + '</div>';
                              }
                              updateHiddenField_#varname#();
                        //-->
                        </script>
                  </cfoutput>
            </cfsavecontent>
            
            <cfreturn output />
      </cffunction>

      <!--- returns the display for TYPES.MEDIA and TYPES.DATE --->
      <cffunction name="getFormItem" access="public" returntype="string" output="false">
            <cfargument name="type" type="any" required="true">
            <cfargument name="varname" type="any" required="true">
            <cfargument name="value" type="any" required="true">
            <cfargument name="options" type="string" required="false" default="">
            <cfargument name="width" type="numeric" required="false" default="225">
                        
            <cfscript>
                  var media = '';
                  var qryGetMedia = '';
                  var qryGetMediaCategory = '';
                  var qryGetMediaSorted = '';
                  
                  var lastCat = -1;
                  var mediacount = 0;

                  var dtStart = '';
                  var chkStart = true;
                  var dtEnd = '';
                  var chkEnd = true;
            </cfscript>

            <cfsavecontent variable="output">
                  <cfoutput>
                        <!--- DATE --->
                        <cfif arguments.type is TYPES.DATE>
                              <!--- date always has a default of now (due to the flash movie) --->
                              <cfif not isDate(arguments.value)>
                                    <cfset arguments.value = now()>
                              </cfif>
                              <script type="text/javascript" src="js/swfobject.js"></script>
                                    
                              <div id="#arguments.varname#_flash" style="display:block">
                                    <input class="formTextbox" type="hidden" id="#arguments.varname#_hidden" name="#arguments.varname#" size="50" style="width: #arguments.width#px;" value="#DateFormat(arguments.value, "mmm-dd-yy")#" maxlength="500">
                                    <div id="#arguments.varname#_date">
                                    </div>
                                    <script type="text/javascript">
                                          //not needed unless you want to reference the flash movie object later
                                          //var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
                                          
                                          // Handle all the the FSCommand messages in a Flash movie. Uncomment
                                          function #arguments.varname#flashOb_DoFSCommand(command, args) {
                                                //the line below is left as a guide in case you want to reference
                                                //the movie object
                                            //var weekviewObj = InternetExplorer ? weekview : document.dt;
                                            
                                            //alert(args);
                                            document.getElementById('#arguments.varname#_hidden').value = args;
                                          }
                                          // Hook for Internet Explorer
                                          if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
                                                  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1)
                                          {
                                                document.write('<SCRIPT LANGUAGE=VBScript\> \n');
                                                document.write('on error resume next \n');
                                                document.write('Sub #arguments.varname#flashOb_FSCommand(ByVal command, ByVal args)\n');
                                                document.write('  call #arguments.varname#flashOb_DoFSCommand(command, args)\n');
                                                document.write('end sub\n');
                                                document.write('</SCRIPT\> \n');
                                          }      
                                       var so = new SWFObject("flash/weekview.swf", "#arguments.varname#flashOb", "200", "31", "7", "##336699");
                                       <cfif IsDate(arguments.value)>
                                             so.addVariable("day","#Day(arguments.value)#");
                                             so.addVariable("month","#Month(arguments.value)#");
                                             so.addVariable("year","#Year(arguments.value)#");
                                       </cfif>
                                       so.write("#arguments.varname#_date");
                                    </script>
                              </div>
                              
                        <!--- DATERANGE --->      
                        <cfelseif arguments.type is TYPES.DATERANGE>
                              <cfscript>
                                    //parse the date value pair ('dtStart, dtEnd')
                                    dtStart = ListFirst(arguments.value, ',');
                                    dtEnd = ListLast(arguments.value, ',');
                                    
                                    if (Left(dtStart, 1) is 'e')
                                          dtEnd = Right(dtEnd, Len(dtEnd) - 1);
                                    else if (Left(dtEnd, 1) is 's')
                                          dtStart = Right(dtStart, Len(dtStart) - 1);
                                    else if (Len(dtStart) and Len(dtEnd)) {
                                          dtStart = Right(dtStart, Len(dtStart) - 1);
                                          dtEnd = Right(dtEnd, Len(dtEnd) - 1);
                                    }
                                    
                                    if (not isDate(dtStart)) { dtStart = now(); chkStart = false; }
                                    if (not isDate(dtEnd)) { dtEnd = now(); chkEnd = false; }
                              </cfscript>
                              <script type="text/javascript" src="js/swfobject.js"></script>
                              <script>
                                    function #arguments.varname#_dtStart_set (day, month, year) {
                                          var element = document.getElementById('#arguments.varname#_hidden');
                                          //var element_chk = document.getElementById('#arguments.varname#_dtStart_chk');
                                          
                                          if (element) {
                                                var dtArray = element.value.split(',');
                                                //alert(element.value);
                                                //alert(dtArray.length);
                                                //alert(document.frmAddEdit.onsubmit);
                                                
                                                //if (dtArray.length == 2)
                                                      element.value = month + '/' + day + '/' + year + ',' + dtArray[1];
                                                //else
                                                //      element.value = month + '/' + day + '/' + year + ',null';
                                          }
                                    }
                                    
                                    function #arguments.varname#_dtEnd_set (day, month, year) {
                                          var element = document.getElementById('#arguments.varname#_hidden');
                                          //var element_chk = document.getElementById('#arguments.varname#_dtEnd_chk');
                                          
                                          if (element) {
                                                var dtArray = element.value.split(',');
                                                //alert(element.value);
                                                //alert(dtArray.length);
                                                
                                                //if (dtArray.length == 1)
                                                //      element.value = 'null,' + month + '/' + day + '/' + year;
                                                //else
                                                      element.value = dtArray[0] + ',' + month + '/' + day + '/' + year;
                                          }
                                    }                                    
                              </script>
                              
                              &nbsp;<font color="black">start:</font><br />
                              <div id="#arguments.varname#_dtStart_flash" style="display:block">                                    
                                    <input name="#arguments.varname#_dtStart_chk" id="#arguments.varname#_dtStart_chk" type="checkbox" <cfif chkStart>checked</cfif>>
                                    <div id="#arguments.varname#_startdate">
                                    </div>
                                    <script type="text/javascript">
                                          //not needed unless you want to reference the flash movie object later
                                          //var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
                                          
                                          // Handle all the the FSCommand messages in a Flash movie. Uncomment
                                          function #arguments.varname#dtStartflash_DoFSCommand(command, args)      {
                                                //the line below is left as a guide in case you want to reference
                                                //the movie object
                                            //var weekviewObj = InternetExplorer ? weekview : document.dt;
                                            
                                            //alert(args);
                                            //document.getElementById('dtStart_hidden').value = args;
                                          }
                                          // Hook for Internet Explorer
                                          if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
                                                  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1)
                                          {
                                                document.write('<SCRIPT LANGUAGE=VBScript\> \n');
                                                document.write('on error resume next \n');
                                                document.write('Sub #arguments.varname#dtStartflash_FSCommand(ByVal command, ByVal args)\n');
                                                document.write('  call #arguments.varname#dtStartflash_DoFSCommand(command, args)\n');
                                                document.write('end sub\n');
                                                document.write('</SCRIPT\> \n');
                                          }      
                                       var so = new SWFObject("flash/weekview.swf", "#arguments.varname#dtStartflash", "200", "31", "7", "##336699");
                                       so.addVariable("day","#Day(dtStart)#");
                                       so.addVariable("month","#Month(dtStart)#");
                                       so.addVariable("year","#Year(dtStart)#");
                                       so.write("#arguments.varname#_startdate");
                                    </script>                                    
                              </div>
                              &nbsp;<font color="black">end:</font><br />
                              <div id="#arguments.varname#_dtEnd_flash" style="display:block">
                                    <input name="#arguments.varname#_dtEnd_chk" id="#arguments.varname#_dtEnd_chk" type="checkbox" <cfif chkEnd>checked</cfif>>
                                    <div id="#arguments.varname#_enddate">
                                    </div>
                                    <script type="text/javascript">
                                          //not needed unless you want to reference the flash movie object later
                                          //var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
                                          
                                          // Handle all the the FSCommand messages in a Flash movie. Uncomment
                                          function #arguments.varname#dtEndflash_DoFSCommand(command, args) {
                                                //the line below is left as a guide in case you want to reference
                                                //the movie object
                                            //var weekviewObj = InternetExplorer ? weekview : document.dt;
                                            
                                            //alert(args);
                                            //document.getElementById('dtStart_hidden').value = args;
                                          }
                                          // Hook for Internet Explorer
                                          if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
                                                  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1)
                                          {
                                                document.write('<SCRIPT LANGUAGE=VBScript\> \n');
                                                document.write('on error resume next \n');
                                                document.write('Sub #arguments.varname#dtEndflash_FSCommand(ByVal command, ByVal args)\n');
                                                document.write('  call #arguments.varname#dtEndflash_DoFSCommand(command, args)\n');
                                                document.write('end sub\n');
                                                document.write('</SCRIPT\> \n');
                                          }      
                                       var so = new SWFObject("flash/weekview.swf", "#arguments.varname#dtEndflash", "200", "31", "7", "##336699");
                                       so.addVariable("day","#Day(dtEnd)#");
                                       so.addVariable("month","#Month(dtEnd)#");
                                       so.addVariable("year","#Year(dtEnd)#");
                                       so.write("#arguments.varname#_enddate");
                                    </script>
                              </div>
                              <input class="formTextbox" type="hidden" id="#arguments.varname#_hidden" name="#arguments.varname#" size="50" style="width: #arguments.width#px;" value="#DateFormat(dtStart, "m/d/yyyy")#,#DateFormat(dtEnd, "m/d/yyyy")#" maxlength="500">
                        
                        <!--- MEDIA --->
                        <cfelseif arguments.type is TYPES.MEDIA>
                              <cfset media = createObject('component', 'hb50.media').init(this.CompanyID)>
                              <cfset qryGetMedia = media.getMediaByExt(arguments.options)>
                              
                              <cfquery name="qryGetMediaCategory" dbtype="query">
                                    SELECT DISTINCT intCategoryID, txtCategory
                                    FROM       qryGetMedia
                                    ORDER BY txtCategoryNoCase, intCategoryID
                              </cfquery>
                              
                              <cfquery name="qryGetMediaSorted" dbtype="query">
                                    SELECT       *
                                    FROM       qryGetMedia
                                    ORDER BY txtCategoryNoCase, intCategoryID
                              </cfquery>
                              
                              <script name="javascript">
                                    var pdfs#arguments.varname# = new Array();
                                    var defaultpdftext#arguments.varname# = new Array();
                                    var defaultpdfvalue#arguments.varname# = new Array();
            
                                    <cfloop query="qryGetMediaSorted">
                                          <cfif lastCat neq intCategoryID>
                                                <cfif lastCat neq -1>
                                                      null];
                                                </cfif>
                                                <cfset mediacount = mediacount + 1>
                                                <cfset lastCat = intCategoryID>
                                                pdfs#arguments.varname#[#mediacount#] = [
                                            </cfif>
                                          '#replace(txtTitle, "'", "\'", "ALL")#','#intID#',
                                    </cfloop>
                                    <cfif qryGetMedia.recordCount neq 0>
                                          null];
                                    </cfif>
            
                                    function PDFUpdate#arguments.varname#(selCat, selPDF) {
                                          var curValue = selCat.selectedIndex;
                                             var list = pdfs#arguments.varname#[curValue];
            
                                          if (!defaultpdftext#arguments.varname#.length) {
                                                   for (var i=0; i< selPDF.length; i++) {
                                                      defaultpdftext#arguments.varname#[i] = selPDF.options[i].text;
                                                       defaultpdfvalue#arguments.varname#[i] = selPDF.options[i].value;
                                                 }
                                             }
            
                                             while (selPDF.options.length)
                                                   selPDF.options[0] = null;
            
                                             if (curValue <= 0) {
                                                for(var i=0; i<defaultpdftext#arguments.varname#.length; i++)
                                                      selPDF.options[i] = new Option(defaultpdftext#arguments.varname#[i], defaultpdfvalue#arguments.varname#[i]);

                                                  return;
                                            }
            
                                             selPDF.options[0] = new Option('#translate("Select a resource")#...', "");
                                             selPDF.options[1] = new Option('#translate("Add a new resource")#...', "");
                                             for(var i=0; i<list.length - 1; i+=2)
                                             selPDF.options[i/2 + 2] = new Option(list[i],list[i+1]);

                                             selPDF.selectedIndex = 0;
                                             selCat.options[0].text = "All Categories";
                                    }
            
                                    function jsNewFile_#arguments.varname#(mySelect) {
                                          var category = document.getElementById('#arguments.varname#_category_select');
                                          var catid = category.options[category.selectedIndex].value;
                                          
                                          if (mySelect.options[mySelect.selectedIndex].text == '#translate("Add a new resource")#...') {
                                                var link = 'popup/upload_file.cfm?js=jsAddFile_#arguments.varname#&catid=' + catid + '<cfif ListLen(arguments.options)>&ext=#arguments.options#</cfif>';
                                                if (window.showModalDialog)
                                                      showModalDialog(link, window, 'resizable: yes; help: no; status: no; scroll: no; ');
                                                else
                                                      window.open(link, '', 'help=no,resizable=yes,scroll=no,status=no,modal=yes,width=300,height=425');
                                          }
                                    }
            
                                    function jsAddFile_#arguments.varname#(title, id, category) {
                                          var newoption = new Option(title, id);
                                          var selobj = document.getElementById('#arguments.varname#_select');
                                          selobj.options[selobj.options.length] = newoption;
                                          selobj.selectedIndex = selobj.options.length - 1;
                                          selobj.value = id;
                                    }
                              </script>
                              
                              <select class="formTextbox" style="width: #width#px;" name="#arguments.varname#_category" id="#arguments.varname#_category_select" onChange='PDFUpdate#arguments.varname#(this, document.getElementById("#arguments.varname#_select"));'>
                                    <option value="">#translate("Select a file category")#...</option>
                                    <cfloop query="qryGetMediaCategory">
                                          <option value="#qryGetMediaCategory.intCategoryID#">#qryGetMediaCategory.txtCategory#</option>
                                    </cfloop>
                              </select>
                              <br>
      
                              <div id="#arguments.varname#_pickold" style="display: block;">
                                    <select class="formTextbox" name="#arguments.varname#" id="#arguments.varname#_select" style="width: #width#px;" onchange="jsNewFile_#arguments.varname#(this)">
                                          <option value="">#translate("Select a resource")#...</option>
                                          <cfif SESSION.blnAddResource>
                                                <option value="">#translate("Add a new resource")#...</option>
                                          </cfif>
                                          <cfloop query="qryGetMedia">
                                                <option value="#intID#"<cfif value is intID> selected</cfif>>#txtTitle#</option>
                                          </cfloop>
                                    </select>
                              </div>
                        </cfif>
                  </cfoutput>
            </cfsavecontent>

            <cfreturn output />
      </cffunction>
</cfcomponent>
Avatar of Scott Bennett
Scott Bennett
Flag of United States of America image

The error is occuring on line 2795 of display.cfc
 <cfquery name="qryGetList" datasource="#this.datasource#" cachedwithin="#this.queryCache#">
                                          #PreserveSingleQuotes(i.query)#
                                    </cfquery>
You need to make sure that the i.query variable that is being passed to the getItemView function on that cfc actually contains a valid sql statement.

Can you post the detailed information about the database error you are getting? try looking in your coldfusion error logs (c:\cfusionmx7\logs\exeption.log) to see if there is anything more detailed there. or maybe turn on debugging in coldfusion administrator.

Also, instead of posting 6249 lines of code to ask a question... i would be better to just post the portions that are relevant to the question.
Avatar of erikTsomik

ASKER

I am getting the error : Database Exception - in C:\Hotbanana\hb50\display.cfc : line 2795
          Error Executing Database Query.
which I think has something to do with SP the it converts the string maybe some single quotes preventing the query from execution. I do not know. Also I did not find anything suspisious in the log files. It was a few error saying that the very few parameters were provided in the SP. , but that was a while ago
When you have a database error there is usually a database error code returned with the error message. It would help if you cold turn on full debugging in coldfusion adminstrator and post the error information that is being returned from the database.
this is the exact error I am getting I checked the logs and did not find anything related. I can also supply the stored procedures that I wrote maybe the error there but I tested them inquery analizer and they work just fine

 Database Exception - in C:\Hotbanana\hb50\display.cfc : line 2795
          Error Executing Database Query.
put this code where the current query is on line 2795. run it and then post the results of the errorinfo.txt file. It should give us some more details to work with.

<cftry>
<cfquery name="qryGetList" datasource="#this.datasource#" cachedwithin="#this.queryCache#">
      #PreserveSingleQuotes(i.query)#
</cfquery>
<cfcatch type="Database">
<cfsavecontent variable="ErrorInfo">
Path:           #cgi.path_translated#
Type:           #cfcatch.type#
Message:        #cfcatch.message#                      
<cfif isdefined("cfcatch.nativeerrorcode")>
Error Code:     #cfcatch.nativeerrorcode#
</cfif>
<cfif isdefined("cfcatch.sqlstate")>
SQL State:      #cfcatch.sqlstate#
SQL: #cfcatch.Sql#
Database Error Message: #cfcatch.queryError#
</cfif>
Detail:         #cfcatch.detail#
Template: #cfcatch.tagcontext[1].TEMPLATE# LINE:#cfcatch.tagcontext[1].LINE#
</cfsavecontent>
<cffile action = "write" file = "c:\ErrorInfo.txt" output="#ErrorInfo#">
<cfrethrow>
</cfcatch>
</cftry>
ASKER CERTIFIED SOLUTION
Avatar of Scott Bennett
Scott Bennett
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I inserted the code above, however It does not create a file ErrorInfo.txt

And I also wondering if this query will be executed
<cfquery name="qryGetList" datasource="#this.datasource#" >
      #PreserveSingleQuotes(i.query)#
</cfquery>
Is cffile disabled on your server?

Try setting the cfcatch tag to type="Any":


<cftry>
<cfquery name="qryGetList" datasource="#this.datasource#" cachedwithin="#this.queryCache#">
      #PreserveSingleQuotes(i.query)#
</cfquery>
<cfcatch type="Any">
<cfoutput>
<cfsavecontent variable="ErrorInfo">
Path:           #cgi.path_translated#
Type:           #cfcatch.type#
Message:        #cfcatch.message#                      
<cfif isdefined("cfcatch.nativeerrorcode")>
Error Code:     #cfcatch.nativeerrorcode#
</cfif>
<cfif isdefined("cfcatch.sqlstate")>
SQL State:      #cfcatch.sqlstate#
SQL: #cfcatch.Sql#
Database Error Message: #cfcatch.queryError#
</cfif>
Detail:         #cfcatch.detail#
Template: #cfcatch.tagcontext[1].TEMPLATE# LINE:#cfcatch.tagcontext[1].LINE#
</cfsavecontent>
</cfoutput>
<cffile action = "write" file = "c:\ErrorInfo.txt" output="#ErrorInfo#">
<cfrethrow>
</cfcatch>
</cftry>
you may want to remove the cachedwithin attribute from the cfquery tag as well temporarily so that the query get executed.
OK . I got the errorInfoLog.txt. from there It says Incorect syntax near 'DIVISION' Line 1. Here is my Stored procedure. I do not know what is wrong with it

CREATE PROCEDURE dbo.qryCourseNumbers @AY varchar(6), @dept varchar(20), @dept2 varchar(20) AS
delete from tmpCourseNumbers
insert into tmpCourseNumbers
select distinct c.courseid, left(c.coursenumber,3)+'.'+right(c.coursenumber,3)+' '+replace(c.coursetitle, " ' ", " '' ") as coursename, division
from courseschedule.dbo.tblcourseinformation c inner join courseschedule.dbo.vw_courses_and_departments v
on c.courseid = v.courseid
where c.academicyear=@AY and (v.division=@dept or v.division=@dept2) and c.includeincatalog=-1 and (substring(c.coursenumber,4,1) <> '1' and substring(c.coursenumber,4,1) <> '2')
select * from tmpCourseNumbers
order by coursename
GO

can you please post the full errorinfo.txt?

in particular I wan to see the

SQL State:      #cfcatch.sqlstate#
SQL: #cfcatch.Sql#
Database Error Message: #cfcatch.queryError#
 portion of it

Path:           D:\DevWeb\hotbanana\tabs.cfm
Type:           Database
Message:        Error Executing Database Query.                      

Error Code:     170
 

SQL State:      HY000
SQL:
      [Table (rows 392 columns COURSEID, COURSENAME, DIVISION): [COURSEID: coldfusion.sql.QueryColumn@100a3f8] [COURSENAME: coldfusion.sql.QueryColumn@10d1c6e] [DIVISION: coldfusion.sql.QueryColumn@1c59705] ]

Database Error Message: [Macromedia][SQLServer JDBC Driver][SQLServer]Line 1: Incorrect syntax near 'DIVISION: coldfusion.sql.QueryColumn@1c59705'.
 
Detail:         [Macromedia][SQLServer JDBC Driver][SQLServer]Line 1: Incorrect syntax near 'DIVISION: coldfusion.sql.QueryColumn@1c59705'.
Template: C:\Hotbanana\hb50\display.cfc LINE:2804

ok so #PreserveSingleQuotes(i.query)# is generating the following string:

[Table (rows 392 columns COURSEID, COURSENAME, DIVISION): [COURSEID: coldfusion.sql.QueryColumn@100a3f8] [COURSENAME: coldfusion.sql.QueryColumn@10d1c6e] [DIVISION: coldfusion.sql.QueryColumn@1c59705] ]

This string is not a valid SQL statement.

If you want to run the stored procedure you posted you would need a string like this to be in that variable:

exec dbo.qryCourseNumbers('2007', 'deptvlue', 'dept2value')

this variable seems to be set by what ever code is calling this function.



Here is my calling stored procedure
<cfstoredproc datasource='#this.datasource#' procedure='qryCourseNumbers'>
                  <cfprocresult name='qryCourseNumbers'>                  
                  <cfprocparam type='In' cfsqltype='cf_sql_varchar' variable='@AY' value='07-08' null='no'></cfprocparam>
                  <cfswitch expression="#this.companyid#">
                  <cfcase value="2">
                  <cfprocparam type='in' cfsqltype='cf_sql_varchar' variable='@dept' value='PSL' null='no'></cfprocparam>
                  <cfprocparam type='in' cfsqltype='cf_sql_varchar' variable='@dept2' value='PSL' null='no'></cfprocparam>
                  </cfcase>
                  <cfcase value="9">
                  <cfprocparam type='in' cfsqltype='cf_sql_varchar' variable='@dept' value='business' null='no'></cfprocparam>
                  <cfprocparam type='in' cfsqltype='cf_sql_varchar' variable='@dept2' value='undergraduate' null='no'></cfprocparam>
                  </cfcase>
                  <cfcase value="10">
                  <cfprocparam type='in' cfsqltype='cf_sql_varchar' variable='@dept' value='education' null='no'></cfprocparam>
                  <cfprocparam type='in' cfsqltype='cf_sql_varchar' variable='@dept2' value='education' null='no'></cfprocparam>
                  </cfcase>
      
    </cfswitch>
                  </cfstoredproc>      
         
I don't see how this stored procedure has anything to do with the problem. Which line is calling the getItemView function? and where is the i.query variable being set?
If you look at the code of courseSchedule module that posted before here the set. Also why do we get the error in "division' txt file
<cfscript>
                  this.formData = newFormData();
                  this.formData.columns = xmlDataToArray(this.xmlData);
                  this.formData.tablename = "tblCourseListing";
                  this.formData.title = "Course Details";
                  tabCount = 1;
                  
                  x = StructNew();
                  x.title = 'Course Number/Title';
                  x.varname = 'intCourseID';
                  x.required = true;
                  x.type = TYPES.SELECT;
                  x.query = qryCourseNumbers;
                  x.displayVar = "CourseName";
                  x.valueVar = "CourseID";                  
                  x.onChange = "txtTitle.value=intCourseID.options[intCourseID.selectedIndex].text;";
                  ArrayPrepend(this.formData.columns, x);      
                  
You also may wanna check this components because it calls display.cfc components that may explains more


<cfcomponent displayname="workflow" extends="hb50.object">
      <cffunction name="init" access="public" returntype="any" output="false">
            <cfargument name="CompanyID" required="true" type="numeric">            
            
            <cfset super.init(CompanyID)>
            
            <!--- set up global action variables (use like workflowObject.EDIT) --->
            <cfset StructAppend(this, enum("add,save,checkin,approve,decline,edit,delete,restore"))>
            
            <!--- IF YOU UPDATE THIS STATUS, UPDATE IT IN NAVIGATION!!! --->
            <cfset this.STATUS = enum("active,inactive,pending,expired,lock,unapproved,featured,deleted,untranslated,unshared,cloned")>

            <cfset this.MAX_VERSIONS = 5>

            <cfreturn this />
      </cffunction>

      <cfscript>
            // define form data for workflow (blnLive, etc.)
            this.workflowData = newFormData();
            this.workflowData.blnExtraColumns = false;
            this.workflowData.columns = ArrayNew(1);

            x = StructNew();
            x.varname = "txtTitle";
            x.title = "The title of this Item";
            x.type = TYPES.TEXT;
            x.required = true;
            ArrayAppend(this.workflowData.columns, x);
            
            x = StructNew();
            x.varname = "intItemID";
            x.title = "The foreign ID of the associated Item";
            x.type = TYPES.NUMBER;
            x.required = true;
            ArrayAppend(this.workflowData.columns, x);
            
            x = StructNew();
            x.varname = "intResourceID";
            x.title = "The foreign ID of the additional resources associated with this item";
            x.type = TYPES.NUMBER;
            x.required = true;
            ArrayAppend(this.workflowData.columns, x);
            
            x = StructNew();
            x.varname = "blnLive";
            x.title = "Is this data live? (only one should be per ItemID)";
            x.type = TYPES.BOOLEAN;
            x.required = true;
            ArrayAppend(this.workflowData.columns, x);

            x = StructNew();
            x.varname = "dtAdded";
            x.title = "The date/time this data was added";
            x.type = TYPES.DATE;
            x.required = true;
            ArrayAppend(this.workflowData.columns, x);            

            x = StructNew();
            x.varname = "dtStart";
            x.title = "The date/time this data is scheduled to start";
            x.type = TYPES.DATE;
            x.required = true;
            ArrayAppend(this.workflowData.columns, x);            

            x = StructNew();
            x.varname = "dtEnd";
            x.title = "The date/time this data is scheduled to end";
            x.type = TYPES.DATE;
            x.required = true;
            ArrayAppend(this.workflowData.columns, x);            

            x = StructNew();
            x.varname = "txtMetaKeywords";
            x.title = "Meta data keywords associated with this item";
            x.type = TYPES.MEMO;
            x.required = true;
            ArrayAppend(this.workflowData.columns, x);            

            x = StructNew();
            x.varname = "txtMetaDescription";
            x.title = "Meta data description associated with this item";
            x.type = TYPES.MEMO;
            x.required = true;
            ArrayAppend(this.workflowData.columns, x);            
            
            x = StructNew();
            x.varname = "intMetaID";
            x.title = "Meta ID";
            x.type = TYPES.SELECT;
            x.required = false;
            ArrayAppend(this.workflowData.columns, x);
            
            x = StructNew();
            x.varname = "blnNotification";
            x.title = "Send notification?";
            x.type = TYPES.BOOLEAN;
            x.required = true;
            ArrayAppend(this.workflowData.columns, x);
            
            
            // these are columns that should be in non-workflow tables
            this.basicData = newFormData();
            this.basicData.blnExtraColumns = false;
            this.basicData.columns = ArrayNew(1);

            x = StructNew();
            x.varname = "txtTitle";
            x.title = "The title of this Item";
            x.type = TYPES.TEXT;
            x.required = true;
            ArrayAppend(this.basicData.columns, x);
            
            x = StructNew();
            x.varname = "intItemID";
            x.title = "The foreign ID of the associated Item";
            x.type = TYPES.NUMBER;
            x.required = true;
            ArrayAppend(this.basicData.columns, x);
            
            x = StructNew();
            x.varname = "blnLive";
            x.title = "Is this data live? (only one should be per ItemID)";
            x.type = TYPES.BOOLEAN;
            x.required = true;
            ArrayAppend(this.basicData.columns, x);

            x = StructNew();
            x.varname = "blnDeleted";
            x.title = "Is this item deleted?";
            x.type = TYPES.BOOLEAN;
            x.required = false;
            ArrayAppend(this.basicData.columns, x);

            x = StructNew();
            x.varname = "intAdminIDAdded";
            x.title = "The Administrator who added this item";
            x.type = TYPES.NUMBER;
            x.required = false;
            ArrayAppend(this.basicData.columns, x);

            x = StructNew();
            x.varname = "dtStart";
            x.title = "The date/time this data is scheduled to start";
            x.type = TYPES.DATE;
            x.required = true;
            ArrayAppend(this.basicData.columns, x);            

            x = StructNew();
            x.varname = "dtEnd";
            x.title = "The date/time this data is scheduled to end";
            x.type = TYPES.DATE;
            x.required = true;
            ArrayAppend(this.basicData.columns, x);            

            x = StructNew();
            x.varname = "dtAdded";
            x.title = "The date/time this data was added";
            x.type = TYPES.DATE;
            x.required = true;
            ArrayAppend(this.basicData.columns, x);

            x = StructNew();
            x.varname = "dtUpdated";
            x.title = "The date/time this data was last updated";
            x.type = TYPES.DATE;
            x.required = true;
            ArrayAppend(this.basicData.columns, x);

            x = StructNew();
            x.varname = "txtMetaKeywords";
            x.title = "Meta data keywords associated with this item";
            x.type = TYPES.MEMO;
            x.required = true;
            ArrayAppend(this.basicData.columns, x);            

            x = StructNew();
            x.varname = "txtMetaDescription";
            x.title = "Meta data description associated with this item";
            x.type = TYPES.MEMO;
            x.required = true;
            ArrayAppend(this.basicData.columns, x);      
            
            x = StructNew();
            x.varname = "intMetaID";
            x.title = "Meta ID";
            x.type = TYPES.SELECT;
            x.required = true;
            ArrayAppend(this.basicData.columns, x);      

            x = StructNew();
            x.varname = "intCategoryID";
            x.title = "The foreign ID from tblNavigation of the category that this belongs to";
            x.type = TYPES.NUMBER;
            x.required = false;
            ArrayAppend(this.basicData.columns, x);

            x = StructNew();
            x.varname = "intCompanyID";
            x.title = "The foreign ID from tblCompany that this belongs to";
            x.type = TYPES.NUMBER;
            x.required = true;
            ArrayAppend(this.basicData.columns, x);
            
            x = StructNew();
            x.varname = "blnNotification";
            x.title = "Send notification?";
            x.type = TYPES.BOOLEAN;
            x.required = true;
            ArrayAppend(this.basicData.columns, x);
      </cfscript>
      
      <!--- returns query of all data -- containing at least some minimal set of columns --->
      <cffunction name="getQuery" access="public" returntype="query" output="false">
            <cfargument name="formData" type="struct" required="true">

            <cfset verifyColumns(formData)>

            <cfif not formData.blnWorkflow>
                  <cfquery name="qryRecords" datasource="#this.datasource#" >
                        SELECT *, intStatusID =
                                          CASE
                                                WHEN #formData.tablename#.blnDeleted = 1 THEN #this.STATUS.DELETED#
                                                                                                
                                                <cfif formData.blnScheduling>
                                                      WHEN #formData.tablename#.dtStart > #getODBCNow()#
                                                      THEN #this.STATUS.PENDING#

                                                      WHEN #formData.tablename#.dtEnd < #getODBCNow()#
                                                      THEN #this.STATUS.EXPIRED#
                                                </cfif>

                                                ELSE #this.STATUS.ACTIVE#
                                          END
                        FROM #formData.tablename#
                        WHERE (intCompanyID IS NULL OR intCompanyID = #this.CompanyID#)
                  </cfquery>
            <cfelse>
                  <!--- ensure workflow columns are in place --->
                  <cfquery name="qryRecords" datasource="#this.datasource#" >
                        SELECT isnull(#formData.tablename#.intItemID,tblItem.intID) as intItemID,
                                    <cfif formData.blnCategory>
                                       isnull(isnull(#formData.tablename#.intCategoryID, tblItem.intCategoryID), 0) as intCategoryID,
                                    </cfif>
                                 #formData.tablename#.*,
                                 tblItem.*,
                                 intStatusID =
                                          CASE
                                                WHEN tblItem.blnDeleted = 1 THEN #this.STATUS.DELETED#
                                                <cfif formData.blnApproval>
                                                      WHEN tblItem.blnApproved = 0 THEN #this.STATUS.UNAPPROVED#
                                                </cfif>

                                                WHEN tblItem.blnNeedsTranslation = 1 THEN #this.STATUS.UNTRANSLATED#
                                                WHEN #formData.tablename#.intID IS NULL THEN #this.STATUS.INACTIVE#
                                                
                                                <cfif formData.blnLock>
                                                      WHEN tblItemLock.intID IS NOT NULL THEN #this.STATUS.LOCK#
                                                </cfif>
                                                <cfif formData.blnScheduling>
                                                      WHEN #formData.tablename#.dtStart > #getODBCNow()#
                                                      THEN #this.STATUS.PENDING#

                                                      WHEN #formData.tablename#.dtEnd < #getODBCNow()#
                                                      THEN #this.STATUS.EXPIRED#
                                                </cfif>

                                                ELSE #this.STATUS.ACTIVE#
                                          END
                        FROM tblItem
                        LEFT JOIN #formData.tablename# ON
                              tblItem.intID = #formData.tablename#.intItemID
                              AND #formData.tablename#.intID IN
                                (SELECT TOP 1 intID
                                    FROM #formData.tablename#
                                    WHERE intItemID = tblItem.intID
                                    <!--- ORDER BY blnLive DESC, dtAdded DESC) --->
                                    ORDER BY dtAdded DESC)
                        LEFT JOIN tblItemLock ON
                              tblItem.intID = tblItemLock.intItemID
                              AND tblItemLock.intID IN
                                (SELECT TOP 1 intID
                                    FROM tblItemLock
                                    WHERE intItemID = tblItem.intID)
                        LEFT JOIN tblNavigation ON tblItem.intWebID = tblNavigation.intID
                        WHERE tblItem.intWebID = #val(formData.webid)#
                        AND tblItem.intDataType = #val(formData.datatype)#
                        AND tblNavigation.intCompanyID = #this.CompanyID#
                        <cfif formData.blnCategory and not session.superuser>
                              AND #formData.tablename#.intCategoryID IN (
                                     SELECT intNavID
                                     FROM tblAccessNav
                                     WHERE intUserID = #session.userid#
                              )
                        </cfif>
                         ORDER BY
                              <cfif formData.blnOrder>
                                    tblItem.intOrder
                              <cfelse>
                                    #formData.tablename#.#formData.sortcolumn# #formData.sortdirection#
                              </cfif>
                  </cfquery>
            </cfif>
            
            <cfreturn qryRecords />            
      </cffunction>

      <!--- returns query of all publicly accessible data --->
      <cffunction name="getPublicQuery" access="public" returntype="query" output="false">
            <cfargument name="formData" type="struct" required="true">

            <cfset var qryRecords = "">

            <cfif not formData.blnWorkflow>
                  <cfset verifyColumns(formData)>
                  <cfquery name="qryRecords" datasource="#this.datasource#" >
                        SELECT *
                        FROM #formData.tablename#
                        WHERE (intCompanyID IS NULL OR intCompanyID = #this.CompanyID#)
                        <cfif formData.blnRestore>
                              AND blnDeleted = 0
                        </cfif>
                        ORDER BY #formData.tablename#.#formData.sortcolumn# #formData.sortdirection#
                  </cfquery>
                  <cfreturn qryRecords />
            <cfelse>
                  <!--- ensure workflow columns are in place --->
                  <cfset verifyColumns(formData)>
                  <cfquery name="qryRecords" datasource="#this.datasource#" >
                        SELECT tblItem.intWebID,
                              <cfif formData.blnCategory>
                                 isnull(isnull(tblItem.intCategoryID, #formData.tablename#.intCategoryID), 0) AS intCategoryID,
                              </cfif>
                                 #formData.tablename#.*,
                                 tblItem.*
                        FROM tblItem
                        INNER JOIN #formData.tablename# ON
                              tblItem.intID = #formData.tablename#.intItemID
                              AND #formData.tablename#.blnLive = 1
                              <!--- AND tblItem.blnApproved = 1 --->
                        LEFT JOIN tblItemLock ON
                              tblItem.intID = tblItemLock.intItemID
                              AND tblItemLock.intID IN
                                (SELECT TOP 1 intID
                                    FROM tblItemLock
                                    WHERE intItemID = tblItem.intID)
                        LEFT JOIN tblNavigation ON tblItem.intWebID = tblNavigation.intID
                        WHERE tblItem.intDataType = #val(formData.datatype)#
                        AND tblNavigation.intCompanyID = #this.CompanyID#
                        AND tblItem.blnDeleted = 0
                        AND tblItem.intWebID = #Val(formData.webid)#
                        <cfif formData.blnScheduling>
                              AND (#formData.tablename#.dtStart IS NULL OR #formData.tablename#.dtStart <= #getODBCNow()#)
                              AND (#formData.tablename#.dtEnd IS NULL OR #formData.tablename#.dtEnd >= #getODBCNow()#)
                        </cfif>
                         ORDER BY
                              <cfif formData.blnOrder>
                                    tblItem.intOrder
                              <cfelse>
                                    #formData.tablename#.#formData.sortcolumn# #formData.sortdirection#
                              </cfif>
                  </cfquery>
                  <cfreturn qryRecords />
                  
                  <!---
                        Jason: replaced this selectFrom function call with this line above 'AND tblItem.intWebID = #Val(formData.webid)#'
                        - reason being that the old way is bringing back every single row from the table and perform a query on query in memory to select the single row based on the webid
                        - the old way was just overkill
                        - the new ways would speed up this query significantly
                        
                        <cfreturn selectFrom(qryRecords, "intWebID", val(formData.webid)) /> --->
            </cfif>
      </cffunction>
      
      <cffunction name="hasPrivileges" access="public" returntype="boolean">
            <cfargument name="formData" type="any" required="true">
            
            <cfif SESSION.superuser>
                  <cfreturn true/>
            </cfif>
            
            <!--- see if we have workflow setup for this page --->
            <cfquery name="qryMods" datasource="#this.datasource#">
                  SELECT intID
                  FROM tblModerator
                  WHERE intNavID = #formData.webid#
            </cfquery>
            
            <cfif not qryMods.recordCount>
                  <cfreturn true />
            </cfif>
            
            <cfquery name="qryAccess" datasource="#this.datasource#">
                  SELECT tblModerator.intID
                  FROM tblModerator
                  JOIN tblUserGroup ON tblUserGroup.intGroupID = tblModerator.intModeratorID
                  JOIN tblUser ON tblUserGroup.intUserID = tblUser.intID
                  WHERE tblUser.intID = #session.userid#
                  AND tblModerator.intNavID = #formData.webid#
            </cfquery>
            
            <cfif qryAccess.recordCount>
                  <cfreturn true />
            </cfif>
            
            <cfreturn false />
      </cffunction>

      <!--- calls doAction based on data (add, save, check in, delete) and returns the action message --->
      <cffunction name="processForm" access="public" returntype="string" output="false">
            <cfargument name="formData" type="any" required="true">
            
            <cfset varList = "button">
            <cfloop from="1" to="#ArrayLen(formData.columns)#" index="i">
                  <cfset ListAppend(varList, formData.columns[i].varname)>
            </cfloop>
            
            <cfif varsExist(varList, "FORM")>            
                  <!--- check that this user is even allowed to perform changes to content --->
                  <cfif hasPrivileges(formData) is false>
                        <cfreturn "You have not been added to a group that has change privileges." />
                  </cfif>
                  <!--- set the default action based on form.ID (adding, or editing) --->
                  <cfif FORM.button is translate("Add")>
                        <cfset action = this.ADD>
                        <cfset message = "Added.">
                  <cfelseif FORM.button is translate("Save")>
                        <cfset action = this.SAVE>
                        <cfset message = "Saved.">
                  <cfelseif FORM.button is translate("Delete")>
                        <cfset action = this.DELETE>
                        <cfset message = "Deleted.">
                  <cfelseif FORM.button is translate("Restore")>
                        <cfset action = this.RESTORE>
                        <cfset message = "Restored.">
                  <cfelseif FORM.button is translate("Check In")>
                        <cfset action = this.CHECKIN>
                        <cfif isDefined("FORM.ID")>
                              <cfset message = "Checked In.">
                        <cfelse>
                              <cfset message = "Added.">
                        </cfif>
                  <cfelseif FORM.button is translate("Approve")>
                        <cfset action = this.APPROVE>
                        <cfset message = "Approved.">
                  <cfelseif FORM.button is translate("Decline")>
                        <cfset action = this.DECLINE>
                        <cfset message = "Declined.">
                  <cfelseif FORM.button is translate("Edit")>
                        <cfset action = this.EDIT>
                        <cfset message = "Edited">
                  <cfelse>
                        <!--- we don't know what to do --->
                        <cfreturn ""/>
                  </cfif>
                  <cfset FORM.ID = doAction(SESSION.userid, action, message, formData)>
                  
                  <cfreturn message />
            </cfif>
            
            <cfreturn "" />
      </cffunction>

      <!--- Performs the steps associated with main actions (add, edit, delete, approve, etc.).
              Ensures that the action gets logged, and deals with all steps involved.
      --->
      <cffunction name="doAction" access="public" returntype="string" output="false">
            <cfargument name="userID" type="numeric" required="true">
            <cfargument name="action" type="numeric" required="true">
            <cfargument name="message" type="string" required="true">
            <cfargument name="formData" type="any" required="true">

            <cfobjectcache action="clear" />

            <cfif formData.blnWorkflow>
                  <!--- ensure workflow columns are in place --->
                  <cfset this.workflowData.tablename = formData.tablename>
                  <cfset verifyColumns(this.workflowData)>
            <cfelse>
                  <!--- ensure other columns are in place --->
                  <cfset this.basicData.tablename = formData.tablename>
                  <cfset verifyColumns(this.basicData)>
            </cfif>

            <!--- if declining, we need a default reason in place.
                    if not, set this so we can pass it on to logAction harmlessly
            --->
            <cfparam name="form.txtDeclineReason" default="">
            <cfparam name="form.txtEditReason" default="">
            
            <cfif isDefined("FORM.ID")>
                  <cfset ID = Val(FORM.ID)>
            </cfif>

            <!--- ADD --->
            <cfif action is this.ADD>
                  <!--- i suppose this action only happens when the tool doesn't use locks ? --->
                  <cfset ID = insertRecord(formData)>
                  <cfset checkIn(ID, formData)>
            <!--- SAVE --->      
            <cfelseif action is this.SAVE>
                  <cfif not isDefined("FORM.ID")>
                        <cfset ID = insertRecord(formData)>                        
                  <cfelse>
                        <cfset updateRecord(ID, formData)>
                  </cfif>
                  <!--- stay on the same page if we also would have an option to 'check in' --->
                  <cfif formData.blnLock>                        
                        <cfset checkOut(ID, formdata)>
                        <cfset url.ID = ID>
                        <cfset url.mode = "edit">
                  <cfelse>
                        <cfset checkIn(ID, formdata)>
                  </cfif>
            <!--- CHECK-IN --->
            <cfelseif action is this.CHECKIN>
                  <cfif not isDefined("form.ID")>
                        <cfset ID = insertRecord(formData)>
                  <cfelse>
                        <cfset updateRecord(ID, formData)>
                  </cfif>
                  <cfset checkIn(ID, formData, form.txtEditReason)>
                  <!--- new workflow notification email --->
                  <cfset sendWorkflowNotification(formData,ID)>
                  <!--- notification --->
                  <cfif isDefined("this.qryCompany.blnNotification") and this.qryCompany.blnNotification is 1>
                        <cfset sendNotification(formData,ID)>
                  </cfif>
                  
            <!--- APPROVE --->
            <cfelseif action is this.APPROVE>
                  <cfset checkIn(ID, formdata)>
                  <!--- new workflow notification email --->
                  <cfset sendWorkflowNotification(formData,ID)>
                  <!--- notification --->
                  <cfif isDefined("this.qryCompany.blnNotification") and this.qryCompany.blnNotification is 1>
                        <cfset sendNotification(formData,ID)>
                  </cfif>
            <!--- DECLINE --->
            <cfelseif action is this.DECLINE>
                  <cfset decline(ID, formdata, form.txtDeclineReason)>
            <!--- EDIT --->            
            <cfelseif action is this.EDIT>
                  <!--- edit refers to an Editor taking over a record in order to edit it.
                          This involves silently approving the item after checking it out under this user,
                          then staying on the edit page (url.mode=edit).
                  --->
                  <cfset checkOut(ID, formdata)>
                  
                  <cfquery datasource="#this.datasource#">
                        UPDATE       tblItem
                        SET       blnApproved = <cfqueryparam value="1" cfsqltype="cf_sql_bit">
                        WHERE       intID = <cfqueryparam value="#ID#" cfsqltype="cf_sql_integer">
                  </cfquery>
                  <cfset URL.mode = "edit">
                  <cfset URL.ID = ID>
            <!--- DELETE --->            
            <cfelseif action is this.DELETE>
                  <cfset deleteRecord(ID, formData)>
            <!--- RESTORE --->                  
            <cfelseif action is this.RESTORE>
                  <!--- we update following a restore in case the user changed things
                          in the add/edit form before clicking Restore.
                         
                          We also need to update url.statusid for the display.getListing() function,
                          so that the status bar stops displaying deleted items.
                  --->
                  <cfset restoreRecord(ID, formData)>
                  <cfset updateRecord(ID, formData)>
                  <cfset checkIn(ID, formdata)>
                  <cfset URL.statusid = 0>
                  
            <cfelse>
                  <cfthrow message="Bad action type: #action#">
            </cfif>
            
            <!--- only log it if the ID relates to tblItem --->
            <cfif formData.blnWorkflow>
                  <cfset logAction(ID, userID, message, form.txtDeclineReason)>
            </cfif>

            <cfreturn ID />
      </cffunction>
      
      <!--- notification --->
      <cffunction name="sendNotification" access="public" returntype="any" output="false">
            <cfargument name="formData" type="any" required="true">
            <cfargument name="itemID" type="numeric" required="false">
            
            <cfset var qryItem = ''>
            <cfset var notifier = ''>
            <cfset var theItemID = itemID>
            
            <cftrace text="workflow.cfc: sendNotification"/>            
            <cfquery name="qryItem" datasource="#this.datasource#" maxrows="1">
                  SELECT       TOP 1 blnNotification, blnLive, dtStart
                  FROM       #formData.tablename#
                  WHERE       intItemID = <cfqueryparam value="#Val(arguments.itemID)#" cfsqltype="cf_sql_integer">
                  ORDER BY dtAdded DESC
            </cfquery>
            
            <cfif qryItem.recordCount and isDefined("qryItem.blnNotification") and qryItem.blnNotification is 1 and qryItem.blnLive is 1>
                  <cftry>
                  <cfset notifier = getObject('hb50.plugins.generic.notifier',this.companyID,true)>
                  
                        <cfif StructKeyExists(formData, 'tablename') and formData.tablename is 'tblContent'>
                        <cfset theItemID = 0>
                  </cfif>
                        <cfif formData.blnScheduling and isDefined("qryItem.dtStart") and isDate(qryItem.dtStart)>
                        <!--- <cftrace text="workflow.cfc: call schedule notification"> --->
                        <cfset notifier.scheduleTask(qryItem.dtStart,Val(formData.webid),theItemID)>
                  <cfelse>
                        <!--- <cftrace text="workflow.cfc: call send notification"> --->
                        <cfset notifier.sendNotification(Val(formData.webid),theItemID)>
                  </cfif>
                        <cfcatch>
                              <cftrace text="workflow.cfc: notification failed." />
                        </cfcatch>
                  </cftry>      
            </cfif>            
      </cffunction>      
      
      <cffunction name="logAction" access="public" output="false">
            <cfargument name="itemID" type="numeric" required="true">
            <cfargument name="userID" type="numeric" required="true">
            <cfargument name="actionmsg" type="string" required="true">
            <cfargument name="declinemsg" type="string" required="false" default="">

            <!--- record the data in tblActionLog.
                    Explicitly save the action msg instead of the action ID, because
                    its much more practical.. and we dont want to go look it up every time
                    when all we want is the action msg itself.
            --->
            <cfquery datasource="#this.datasource#">
                  INSERT INTO tblActionLog
                        (intUserID, intItemID, txtActionMsg, txtDeclineMsg)
                  VALUES (
                        #userID#,
                        #itemID#,
                        N'#actionmsg#',
                        N'#left(declinemsg, 1000)#')
            </cfquery>
      </cffunction>

      <cffunction name="addTranslation" access="public" output="false">
            <cfargument name="intItemID" type="numeric" required="true">
            <cfargument name="intTranslateID" type="numeric" required="true">
            
            <cfquery name="qryAddTranslation" datasource="#this.datasource#">
                  INSERT INTO tblItemTranslate
                  (intItemID, intTranslateID)
                  VALUES
                  (#intItemID#, #intTranslateID#)
            </cfquery>
      </cffunction>

      <cffunction name="getTranslation" access="public" output="false">
            <cfargument name="intItemID" type="numeric" required="true">
            
            <cfset var map = StructNew()>
            <cfset var qryTranslations = "">
            
            <cfquery name="qryTranslations" datasource="#this.datasource#" >
                  SELECT tblItemTranslate.intTranslateID, tblNavigation.intCompanyID
                  FROM       tblItemTranslate
                  LEFT JOIN tblItem ON tblItemTranslate.intTranslateID = tblItem.intID
                  LEFT JOIN tblNavigation ON tblItem.intWebID = tblNavigation.intID
                  WHERE tblItemTranslate.intItemID = #intItemID#
                  OR tblItemTranslate.intItemID IN (
                        SELECT tblItemTranslate.intItemID
                        FROM tblItemTranslate
                        WHERE intTranslateID = #intItemID#
                  )
            </cfquery>

            <cfloop query="qryTranslations">
                  <cfset map[intCompanyID] = intTranslateID>
            </cfloop>
            
            <cfreturn map />
      </cffunction>

      <cffunction name="insertRecord" access="public" output="false">
            <cfargument name="formData" type="any" required="true">
            <cfargument name="fItemID" type="numeric" required="false">
            
            <cfscript>
                  var itemID = 0;
                  var display = '';
                  var navigation = '';
                  var localFormData = '';
                  var transMap = '';
                  var catMap = '';
                  var origCatID = '';
                  var translatedItemID = '';
                  var date_start = 'NULL';
                  var date_end = 'NULL';
                  //Donny: to store column and value in a format that is ready to use to insert query
                  var formDataQueryValue = '';
                  var formDataQueryColumn = '';
                  var resources = '';
                  var tagMgr = '';
                  var htmlhead = '';
                  var qPageType = QueryNew('');
                  var pageID = 0;
                  var i = '';
                  var key = '';
                  var html = '';
                  var ll = '';
                  var delFound = false;
                  var compFound = false;
                  var adminFound = false;
                  var updatedFound = false;
                  var lpCount = 0;
                  
                  if (isDefined("arguments.fItemID"))
                        itemID = arguments.fItemID;
            </cfscript>
            
            <cfobjectcache action="clear" />
            
            <!--- make sure the columns all exist --->
            <cfset verifyColumns(formData)>
            <cfset this.workflowData.tablename = formData.tablename>
            <cfset verifyColumns(this.workflowData)>
            <cfset TYPES = this.TYPES>

            <cfif formData.blnWorkflow and not Val(itemID)>
                  <cfif StructKeyExists(FORM, 'id')>
                        <cfset itemID = FORM.id />
                  <cfelse>
                        <cfif formData.blnOrder>
                              <cfquery name="qryOrder" datasource="#this.datasource#">
                                    SELECT      MAX(intOrder) + 1 AS intOrder
                                    FROM       tblItem
                                    WHERE       intWebID = <cfqueryparam value="#Val(formData.webid)#" cfsqltype="cf_sql_integer">
                                    AND       intDataType = <cfqueryparam value="#Val(formData.datatype)#" cfsqltype="cf_sql_integer">
                              </cfquery>
                        </cfif>
                        <cfquery name="qryInsertItem" datasource="#this.datasource#">
                              INSERT INTO tblItem
                                    (intWebID, intDataType, intNavID, intSubID, intTabID, intOrder, intCategoryID)
                              VALUES (
                                    #Val(formData.webid)#,
                                    #Val(formData.datatype)#,
                                    #Val(formData.navid)#,
                                    #Val(formData.subid)#,
                                    #Val(formData.tabid)#,
                                    <cfif formData.blnOrder>
                                          #Val(qryOrder.intOrder)#
                                    <cfelse>
                                          0
                                    </cfif>,
                                    <cfif formData.blnCategory and isDefined("intCategoryID")>
                                          #Val(intCategoryID)#
                                    <cfelse>
                                          NULL
                                    </cfif>
                              );
                              
                              SELECT IDENT_CURRENT('tblItem') AS intID
                        </cfquery>
                        <!--- Cache: Monitor Cache update --->
                        <cfquery name="qryUpdateCacheDate" datasource="#this.datasource#">
                              UPDATE       tblNavigation
                              SET       dtUpdated = GETDATE()
                              WHERE       intID = #Val(formData.webid)#;
                        </cfquery>
                        <cfset itemID = qryInsertItem.intID>
                  </cfif>
            </cfif>

            <!--- ADDITIONAL RESOURCES --->
            <cfif formData.blnResources and isDefined("FORM.resources")>
                  <cfif ListLen(FORM.resources)>
                        <cfquery name="qryResource" datasource="#this.datasource#">
                              INSERT INTO tblAddlResource
                                    (intItemID)
                              VALUES (
                                    <cfqueryparam value="#itemID#" cfsqltype="cf_sql_integer">);
                              
                              SELECT IDENT_CURRENT('tblAddlResource') AS intID;
                        </cfquery>
                        <cfset FORM.intResourceID = qryResource.intID>
                        
                        <cfquery name="qryAddResources" datasource="#this.datasource#">
                              <cfloop list="#FORM.resources#" index="i" delimiters="#CHR(10)##CHR(13)#">
                                    <cfset uid = ListFirst(i, " ")>
                                    <cfif Val(uid) is uid>
                                          INSERT INTO tblAddlResourceItem
                                                (intAddlResourceID, intLinkID, txtTitle)
                                          VALUES (
                                                #qryResource.intID#,
                                                #Val(uid)#,
                                                N'#ListRest(i, " ")#');
                                    <cfelse>
                                          INSERT INTO tblAddlResourceItem
                                                (intAddlResourceID, txtLinkUID, txtTitle)
                                          VALUES (
                                                #qryResource.intID#,
                                                '#ListFirst(i, " ")#',
                                                N'#ListRest(i, " ")#'
                                          );
                                    </cfif>
                              </cfloop>
                        </cfquery>
                  </cfif>
            </cfif>

            <cfquery name="qryInsert" datasource="#this.datasource#">
                  INSERT INTO #formData.tablename# (
                        <cfsavecontent variable="formDataQueryColumn">
                              <cfloop from="1" to="#ArrayLen(formData.columns)#" index="key">
                                    <cfset i = formData.columns[key]>
                                  <cfif (not isDefined("i.insert")) or i.insert neq "false">
                                          #i.varname#,
                                    </cfif>
                                    <cfif i.varname IS "blnDeleted">
                                          <cfset delFound = true>
                                    </cfif>
                                    <cfif i.varname IS "intCompanyID">
                                          <cfset compFound = true>
                                    </cfif>
                                    <cfif i.varname IS "intAdminIDAdded">
                                          <cfset adminFound = true>
                                    </cfif>
                                    <cfif i.varname IS "dtUpdated">
                                          <cfset updatedFound = true>
                                    </cfif>
                              </cfloop>
                        </cfsavecontent>
                        #formDataQueryColumn#
                        <cfif formData.blnScheduling>
                              dtStart,
                              dtEnd,
                        </cfif>
                        <cfif formData.blnResources>
                              intResourceID,
                        </cfif>
                        <cfif formData.blnMeta>
                              txtMetaKeywords,
                              txtMetaDescription,
                        </cfif>
                        <cfif formData.blnWorkflow>
                              intItemID,
                              blnLive,
                        <cfelse>
                              <cfif delFound IS false>
                                    blnDeleted,
                              </cfif>
                              <cfif compFound IS false>
                                    intCompanyID,
                              </cfif>
                              <cfif adminFound IS false>
                                    intAdminIDAdded,
                              </cfif>
                              <cfif updatedFound IS false>
                                    dtUpdated,
                              </cfif>
                        </cfif>
                        dtAdded
                        <cfif isDefined("this.qryCompany.blnNotification") AND Val(this.qryCompany.blnNotification) AND isDefined("formData.blnNotification") AND formData.blnNotification>
                        , blnNotification
                        </cfif>)
                  VALUES (
                  <cfsavecontent variable="formDataQueryValue">
                        <cfloop from="1" to="#ArrayLen(formData.columns)#" index="key">
                          <cfset i = formData.columns[key]>
                          <cfif (not isDefined("i.insert")) or i.insert neq "false">
                              <cfif ListFind("#TYPES.TEXT#,#TYPES.URL#,#TYPES.COLOUR#,#TYPES.MEMO#,#TYPES.SELECT#,#TYPES.HIDDEN#,#TYPES.CUSTOM#", i.type)>
                                    N'<cfif StructKeyExists(FORM, i.varname)>#FORM[i.varname]#</cfif>'
                                    <!--- Jason: prepare list of TYPES.URL fields --->
                                    <cfif i.type is TYPES.URL>
                                          <cfset ll = ListAppend(ll, i.varname)>
                                    </cfif>
                              <cfelseif i.type is TYPES.HTML>
                                    <!--- Jason: prepare list of TYPES.HTML fields --->
                                    <cfset ll = ListAppend(ll, i.varname)>
                                    <cfif StructKeyExists(FORM, i.varname)>
                                          <cfset html = prepareTokens(FORM[i.varname])>
                                    <cfelse>
                                          <cfset html = "">
                                    </cfif>      
                                    N'#html#'
                              <cfelseif ListFind("#TYPES.DATE#", i.type)>
                                    <cfif StructKeyExists(FORM, i.varname) and isDate(FORM[i.varname])>
                                          #CreateODBCDateTime(FORM[i.varname])#
                                    <cfelse>
                                          NULL
                                    </cfif>
                              <cfelseif ListFind("#TYPES.CATEGORY#", i.type)>                                 
                                    <cfif StructKeyExists(FORM, "#i.varname#_add_title") and FORM["#i.varname#_add_title"] neq "">
                                          #formData.object.addCategory(FORM["#i.varname#_add_title"])#
                                    <cfelseif StructKeyExists(FORM, i.varname) and FORM[i.varname] neq "">
                                          #val(FORM[i.varname])#
                                    <cfelse>
                                          0
                                    </cfif>
                              <cfelseif ListFind("#TYPES.MEDIA#", i.type)>
                                    <cfif SESSION.blnAddResource
                                      and StructKeyExists(FORM, "#i.varname#_add_title") and FORM["#i.varname#_add_title"] neq ""
                                      and StructKeyExists(FORM, "#i.varname#_upload") and FORM["#i.varname#_upload"] neq ""
                                      and StructKeyExists(FORM, "#i.varname#_category") and FORM["#i.varname#_category"] neq "">
                                          <cfset resources = createObject('component', 'hb50.internal.resources').init(this.CompanyID, this.qryCompany.intMediaID)>
                                          #resources.addResource(FORM["#i.varname#_add_title"], FORM["#i.varname#_category"], "#i.varname#_upload")#
                                    <cfelseif StructKeyExists(FORM, i.varname) and FORM[i.varname] neq "">
                                          #val(FORM[i.varname])#
                                    <cfelse>
                                          0
                                    </cfif>
                              <cfelseif ListFind("#TYPES.NUMBER#,#TYPES.TYPE#", i.type)>
                                    <cfif StructKeyExists(FORM, i.varname) and FORM[i.varname] neq "">
                                          #val(FORM[i.varname])#
                                    <cfelse>
                                          0
                                    </cfif>
                              <cfelseif ListFind("#TYPES.FEATURED#,#TYPES.BOOLEAN#", i.type)>
                                    <cfif StructKeyExists(FORM, i.varname) and FORM[i.varname] neq "" and FORM[i.varname] is "on">
                                          1
                                    <cfelse>
                                          0
                                    </cfif>      
                              <cfelseif ListFind("#TYPES.RADIO#", i.type)>
                                    <cfif StructKeyExists(FORM, i.varname)>
                                          <cfif isDefined("i.varType")>
                                                <cfif i.varType is "int">
                                                      #Val(FORM[i.varname])#
                                                <cfelseif i.varType is "bit">
                                                      <cfif Val(FORM[i.varname]) GT 0>
                                                            1
                                                      <cfelse>
                                                            0
                                                      </cfif>
                                                <cfelse>
                                                      N'#FORM[i.varname]#'
                                                </cfif>
                                          <cfelse>
                                                N'#Val(FORM[i.varname])#'
                                          </cfif>
                                    </cfif>                        
                              </cfif>
                              ,
                          </cfif>
                        </cfloop>
                  </cfsavecontent>
                  #PreserveSingleQuotes(formDataQueryValue)#
                  <cfif formData.blnScheduling>
                        <cfif isDefined("dtStart_hidden") and isDefined("dtEnd_hidden") and isDate(dtStart_hidden) and isDate(dtEnd_hidden)>
                              <cfif StructKeyExists(FORM, "dtStart_chk") and FORM.dtStart_chk neq "" and FORM.dtStart_chk is "on">
                                    <cfif not isDate("#dtStart_hidden# #dtStart_time#")>
                                          <cfset date_start = CreateODBCDateTime(ParseDateTime(dtStart_hidden))>
                                    <cfelse>
                                          <cfset date_start = CreateODBCDateTime(ParseDateTime("#dtStart_hidden# #dtStart_time#"))>
                                    </cfif>
                              </cfif>
                              <cfif StructKeyExists(FORM, "dtEnd_chk") and FORM.dtEnd_chk neq "" and FORM.dtEnd_chk is "on">
                                    <cfif not isDate("#dtEnd_hidden# #dtEnd_time#")>
                                          <cfset date_end = CreateODBCDateTime(ParseDateTime(dtEnd_hidden))>
                                    <cfelse>
                                          <cfset date_end = CreateODBCDateTime(ParseDateTime("#dtEnd_hidden# #Replace(dtEnd_time, '.', ':')#"))>
                                    </cfif>
                              </cfif>
                        </cfif>

                        #date_start#,
                        #date_end#,
                  </cfif>
                  <cfif formData.blnResources>
                        <cfif isDefined("FORM.intResourceID")>#form.intResourceID#<cfelse>NULL</cfif>,
                  </cfif>
                  <cfif formData.blnMeta>
                        N'<cfif StructKeyExists(FORM, 'txtMetaKeywords')>#txtMetaKeywords#</cfif>',
                        N'<cfif StructKeyExists(FORM, 'txtMetaDescription')>#txtMetaDescription#</cfif>',
                  </cfif>
                  <cfif formData.blnWorkflow>
                        #itemID#,
                        0,
                  <cfelse>
                        <cfif delFound IS false>
                              0,
                        </cfif>
                        <cfif compFound IS false>
                              #this.CompanyID#,
                        </cfif>
                        <cfif adminFound IS false>
                              #SESSION.userid#,
                        </cfif>
                        <cfif updatedFound IS false>
                              GETDATE(),
                        </cfif>
                  </cfif>
                  GETDATE()
                  <cfif isDefined("this.qryCompany.blnNotification") AND Val(this.qryCompany.blnNotification)  AND isDefined("formData.blnNotification") AND formData.blnNotification>
                  , <cfif StructKeyExists(FORM, 'HB_sendNotification') AND FORM.HB_sendNotification is 1>1<cfelse>0</cfif>
                  </cfif>
                  );
                  
                  SELECT SCOPE_IDENTITY() AS intTableID;
            </cfquery>

            <!--- Donny: save additional metaTag to database: tblHTMLHead --->
            <cfif formData.blnMeta>
                  <cfset display = createObject("component", "hb50.display").init(this.CompanyID)>
                  <cfif isDefined("FORM.txtNameValues")>
                        <cfset qryNameValues = display.listColumnToQuery(FORM.txtNameValues, 'type,name,content')>
                  </cfif>
                  
                  <!--- our HTML head tag management library --->
                  <cfset htmlhead = getObject('hb50.util.htmlhead', this.CompanyID, true)>

                  <!--- process form when submitted --->
                  <cfif (isDefined("FORM.button") and isDefined("FORM.txtNameValues"))>
                        <cfset htmlhead.clearMetaTags()> <!--- clear tags and start over --->
                        <!--- loop over query generated from list form type --->
                        <cfloop query="qryNameValues">
                              <cfset htmlhead.setMetaTag(qryNameValues.type, qryNameValues.name, qryNameValues.content)>
                        </cfloop>
                        <cfif Val(itemID)> <!--- workflow - with intItemID --->
                              <cfset htmlhead.save(Val(itemID), qryInsert.intTableID)> <!--- save to database --->
                        <cfelse> <!--- no workflow - no intItemID in table --->
                              <cfset htmlhead.save(Val(qryInsert.intTableID), 0)>
                        </cfif>
                  </cfif>
            </cfif>
            
            <!--- Jason: process content containers petite tab--->
            <cfif formData.blnContainers>
                  <!--- process the petite tab --->
                  <cfif isDefined('FORM.hidden_container_tab_indicator') and FORM.hidden_container_tab_indicator is 1>
                        <cfquery name="qPageType" datasource="#this.datasource#">
                              SELECT      intPageType
                              FROM      tblNavigation
                              WHERE      intID = <cfqueryparam value="#Val(formData.subid)#" cfsqltype="cf_sql_integer">
                        </cfquery>
                        
                        <cfif qPageType.recordCount>
                              <cfquery datasource="#this.datasource#">
                                    <!--- non-landing page --->
                                    <cfif qPageType.intPageType neq 6>
                                          DELETE FROM tblContentContainerPages
                                          WHERE       intNavID = <cfqueryparam value="#Val(formData.subid)#" cfsqltype="cf_sql_integer">;
                                          
                                          <cfif isDefined("FORM.intContainers")>
                                                <cfloop list="#FORM.intContainers#" index="pageID">
                                                      INSERT INTO tblContentContainerPages
                                                            (intContainerID, intNavID, intCompanyID)
                                                      VALUES (
                                                            <cfqueryparam value="#Val(pageID)#" cfsqltype="cf_sql_integer">,
                                                            <cfqueryparam value="#Val(formData.subid)#" cfsqltype="cf_sql_integer">,
                                                            <cfqueryparam value="#this.companyID#" cfsqltype="cf_sql_integer">);
                                                </cfloop>
                                          </cfif>

                                    <!--- landing page specific --->
                                    <cfelse>
                                          DELETE FROM tblContentContainersItem
                                          WHERE       intItemID = <cfqueryparam value="#itemID#" cfsqltype="cf_sql_integer">;
                                          
                                          <cfif isDefined("FORM.intContainers")>
                                                <cfloop list="#FORM.intContainers#" index="pageID">
                                                      INSERT INTO tblContentContainersItem
                                                            (intContainerID, intItemID, dtAdded)
                                                      VALUES (
                                                            <cfqueryparam value="#Val(pageID)#" cfsqltype="cf_sql_integer">,
                                                            <cfqueryparam value="#itemID#" cfsqltype="cf_sql_integer">,
                                                            GETDATE());
                                                </cfloop>
                                          </cfif>
                                    </cfif>
                              </cfquery>
                        </cfif>
                  </cfif>
            </cfif>
            
            <!---
                  Jason: save tagging info to database: tblTags, tblParentTags
                  - and based on FORM.groupid, insert to the relation table (e.g. tblGlobalContentTags)
            --->
            <cfif formData.blnTagging>
                  <!--- hb tagging management library --->
                  <cfset tagMgr = getObject("hb50.internal.CTagManager", this.CompanyID, true) />

                  <!--- process form if tagging enabled --->
                  <cfif isDefined("FORM.blnEnableTagging") and Val(itemID)>
                        <cfset tagMgr.saveTags(Val(itemID), FORM) />
                  </cfif>
            </cfif>
            
            <!--- Jason: hack the initial check-in for TYPES.URL and TYPES.HTML fields to append the link params --->
            <cfif not StructKeyExists(FORM, 'id')>
                  <cftry>
                  <cfquery name="qUpdateContent" datasource="#this.datasource#">
                        UPDATE       #formData.tablename#
                        SET            
                        <cfloop list="#ll#" index="key">
                              <cfset lpCount = lpCount + 1>
                            <cfif StructKeyExists(FORM, key)>
                                  <cfif formData.blnWorkflow>
                                          <cfset html = fixLinkParams(FORM[key], Val(itemID)) />
                                    <cfelse>
                                          <cfset html = fixLinkParams(FORM[key], qryInsert.intTableID) />
                                    </cfif>
                              <cfelse>
                                    <cfset html = "">
                              </cfif>
                              <cfif lpCount IS 1>
                                    #key# = N'#html#'
                              <cfelse>
                                    #key# = ,N'#html#'
                              </cfif>
                        </cfloop>      
                        WHERE      intID = #qryInsert.intTableID#
                  </cfquery>
                  <cfcatch></cfcatch>
                  </cftry>
            </cfif>
            
            <cfif formData.blnWorkflow>
                  <cfif FORM.button is translate("Check In")>
                        <!--- we need to add an item for translated web sites if necessary --->                        
                        <cfif formData.blnTranslate>
                              <cfset navigation = getObject('hb50.navigation', this.CompanyID, true)>
                              <cfif not StructIsEmpty(navigation.getTranslationMap())>
                                    <cfset transMap = navigation.getTranslation(formData.webid)>
                                    <cfif formData.webid is formData.navid>
                                          <cfset navMap = transMap>
                                    <cfelse>
                                          <cfset navMap = navigation.getTranslation(formData.navid)>
                                    </cfif>
                                    <cfif formData.subid gt 0>
                                          <cfset subMap = navigation.getTranslation(formData.subid)>
                                    </cfif>
                                    <cfif not (isDefined("arguments.fitemID") or isDefined("FORM.ID"))>
                                          <cfif formData.blnCategory and isDefined("FORM.intCategoryID")>
                                                <cfset catMap = navigation.getTranslation(FORM.intCategoryID)>
                                          </cfif>

                                          <cfloop collection="#transMap#" item="i">
                                                <cfif formData.blnCategory and isDefined("FORM.intCategoryID")>
                                                      <cfset newFormDataQueryValue = Replace(formDataQueryValue,FORM.intCategoryID,catMap[i],"ALL")>
                                                </cfif>
                                                <cfquery name="qryTranslateItem" datasource="#this.datasource#">
                                                      INSERT INTO tblItem
                                                      (blnNeedsTranslation, intWebID, intDataType, intNavID, intSubID, intTabID, intOrder, intCategoryID)
                                                      VALUES (1, #transMap[i]#, #val(formData.datatype)#, #navMap[i]#, <cfif formData.subid gt 0>#subMap[i]#<cfelse>0</cfif>, #val(formData.tabid)#, <cfif formData.blnOrder>#val(qryOrder.intOrder)#<cfelse>0</cfif>, <cfif formData.blnCategory and isDefined("intCategoryID")>#catMap[i]#<cfelse>NULL</cfif>);
                                                      
                                                      INSERT INTO #formData.tablename#
                                                      (
                                                            intItemID,
                                                            <cfif formData.blnScheduling>dtStart, dtEnd,</cfif>
                                                            #formDataQueryColumn#
                                                            blnLive
                                                      )
                                                      VALUES
                                                      (
                                                            IDENT_CURRENT('tblItem'),
                                                            <cfif formData.blnScheduling>#date_start#, #date_end#, </cfif>
                                                            <cfif isDefined("newFormDataQueryValue")>
                                                                  #PreserveSingleQuotes(newFormDataQueryValue)#
                                                            <cfelse>
                                                                  #PreserveSingleQuotes(formDataQueryValue)#
                                                            </cfif>
                                                            0
                                                      );
                                                      
                                                      SELECT IDENT_CURRENT('tblItem') as intID
                                                </cfquery>
                                                <!--- Cache: Monitor Cache update --->
                                                <cfquery name="qryUpdateCacheDate" datasource="#this.datasource#">
                                                      UPDATE       tblNavigation
                                                      SET       dtUpdated = GETDATE()
                                                      WHERE       intID = #Val(transMap[i])#;
                                                </cfquery>

                                                <cfset addTranslation(itemID, qryTranslateItem.intID)>
                                          </cfloop>
                                    <cfelse>
                                          <cfquery name="qryTranslateItem" datasource="#this.datasource#">
                                                UPDATE       tblItem
                                                SET       blnNeedsTranslation = 1
                                                WHERE       intID IN (
                                                      SELECT       intTranslateID
                                                      FROM       tblItemTranslate
                                                      WHERE       intItemID = #Val(itemID)#
                                                )
                                          </cfquery>
                                    </cfif>
                                    <!--- send emails out to translators --->
                                    <cfloop collection="#transMap#" item="i">
                                          <cfset sendAllTranslateEmails(i)>
                                    </cfloop>
                              </cfif>
                        </cfif>
                  </cfif>
                  
                  <cfreturn itemID />
            <cfelse>
                  <cfreturn qryInsert.intTableID />
            </cfif>
      </cffunction>
      
      <!--- UPDATES AN EXISTING RECORD IN THE DB GIVEN THE FORMID --->
      <cffunction name="updateRecord" access="public" output="false">
            <cfargument name="ID" type="numeric" required="true">
            <cfargument name="formData" type="any" required="true">
            <cfobjectcache action="clear" />

            <!--- make sure the columns all exist --->
            <cfset verifyColumns(formData)>
            <cfset TYPES = this.TYPES>

            <cfif formData.blnWorkflow>
                  <cfset insertRecord(formData, arguments.ID)>
            <cfelse>
                  <cfquery name="qryUpdate" datasource="#this.datasource#">
                        UPDATE #formData.tablename#
                        SET
                        <cfloop from="1" to="#ArrayLen(formData.columns)#" index="key">
                          <cfset i = formData.columns[key]>
                        <cfif (not isDefined("i.insert")) or i.insert neq "false">
                                    <cfset t = "#Val(i.type)#">
                              #i.varname# =
                              <cfif ListFind("#TYPES.TEXT#,#TYPES.URL#,#TYPES.COLOUR#,#TYPES.MEMO#,#TYPES.SELECT#,#TYPES.HIDDEN#,#TYPES.CUSTOM#", i.type)>
                                    N'<cfif StructKeyExists(FORM, i.varname)>#FORM[i.varname]#</cfif>'
                              <cfelseif i.type is TYPES.HTML>
                                    <cfset htmltext = prepareTokens(FORM[i.varname])>
                                    N'<cfif StructKeyExists(FORM, i.varname)>#htmltext#</cfif>'
                              <cfelseif ListFind("#TYPES.DATE#", i.type)>
                                    <cfif StructKeyExists(FORM, i.varname) and isDate(FORM[i.varname])>
                                          #CreateODBCDate(FORM[i.varname])#
                                    <cfelse>
                                          NULL
                                    </cfif>
                              <cfelseif ListFind("#TYPES.CATEGORY#", i.type)>                                 
                                    <cfif StructKeyExists(FORM, "#i.varname#_add_title") and FORM["#i.varname#_add_title"] neq "">
                                          #formData.object.addCategory(FORM["#i.varname#_add_title"])#
                                    <cfelseif StructKeyExists(FORM, i.varname) and FORM[i.varname] neq "">
                                                #Val(FORM[i.varname])#
                                    <cfelse>
                                          0
                                    </cfif>
                              <cfelseif ListFind("#TYPES.MEDIA#", i.type)>
                                          <cfif SESSION.blnAddResource
                                      and StructKeyExists(FORM, "#i.varname#_add_title") and FORM["#i.varname#_add_title"] neq ""
                                      and StructKeyExists(FORM, "#i.varname#_upload") and FORM["#i.varname#_upload"] neq ""
                                      and StructKeyExists(FORM, "#i.varname#_category") and FORM["#i.varname#_category"] neq "">
                                          <cfset resources = createObject('component', 'hb50.internal.resources').init(this.CompanyID, this.qryCompany.intMediaID)>
                                          #resources.addResource(FORM["#i.varname#_add_title"], FORM["#i.varname#_category"], "#i.varname#_upload")#
                                    <cfelseif StructKeyExists(FORM, i.varname) and FORM[i.varname] neq "">
                                                #Val(FORM[i.varname])#
                                    <cfelse>
                                          0
                                    </cfif>
                              <cfelseif ListFind("#TYPES.NUMBER#,#TYPES.TYPE#", i.type)>
                                    <cfif StructKeyExists(FORM, i.varname) and FORM[i.varname] neq "">
                                                #Val(FORM[i.varname])#
                                    <cfelse>
                                          0
                                    </cfif>
                              <cfelseif ListFind("#TYPES.FEATURED#,#TYPES.BOOLEAN#", i.type)>
                                    <cfif StructKeyExists(FORM, i.varname) and FORM[i.varname] neq "" and FORM[i.varname] eq "on">
                                          1
                                    <cfelse>
                                          0
                                    </cfif>
                              <cfelseif ListFind("#TYPES.RADIO#", i.type)>
                                    <cfif StructKeyExists(FORM, i.varname)>
                                          <cfif isDefined("i.varType") >
                                                      <cfif i.varType is "int">
                                                      #Val(FORM[i.varname])#
                                                      <cfelseif i.varType is "bit">
                                                            <cfif Val(FORM[i.varname]) gt 0>
                                                                  1
                                                            <cfelse>
                                                                  0
                                                            </cfif>
                                                      <cfelse>
                                                            N'#FORM[i.varname]#'
                                                      </cfif>
                                                <cfelse>
                                                 N'#Val(FORM[i.varname])#'
                                                </cfif>                                    
                                          </cfif>
                                    </cfif>
                                    ,
                                </cfif>
                        </cfloop>
                        <cfif formData.blnResources>
                              intResourceID = <cfif isDefined("qryResource.intID")>#qryResource.intID#<cfelse>NULL</cfif>,
                        </cfif>
                        <cfif formData.blnScheduling>
                              <cfif isDefined("dtStart_hidden") and isDefined("dtEnd_hidden") and isDate(dtStart_hidden) and isDate(dtEnd_hidden)>
                                    dtStart =
                                    <cfif StructKeyExists(FORM, "dtStart_chk") and FORM.dtStart_chk neq "" and FORM.dtStart_chk eq "on">
                                          <cfif not isDate(dtStart_time)>
                                                <cfset date = ParseDateTime(dtStart_hidden)>
                                          <cfelse>
                                                <cfset date = ParseDateTime("#dtStart_hidden# #dtStart_time#")>
                                          </cfif>
                                          #CreateODBCDateTime(date)#
                                    <cfelse>
                                          NULL
                                    </cfif>,
                                    dtEnd =
                                    <cfif StructKeyExists(FORM, "dtEnd_chk") and FORM.dtEnd_chk neq "" and FORM.dtEnd_chk eq "on">
                                          <cfif not isDate(dtEnd_time)>
                                                <cfset date = ParseDateTime(dtEnd_hidden)>
                                          <cfelse>
                                                <cfset date = ParseDateTime("#dtEnd_hidden# #dtEnd_time#")>
                                          </cfif>
                                          #CreateODBCDateTime(date)#
                                    <cfelse>
                                          NULL
                                    </cfif>,
                              <cfelse>
                                    dtStart = NULL,
                                    dtEnd = NULL,
                              </cfif>
                        </cfif>
                        <cfif formData.blnMeta>
                              txtMetaKeywords = N'<cfif StructKeyExists(FORM, 'txtMetaKeywords')>#txtMetaKeywords#</cfif>',
                              txtMetaDescription = N'<cfif StructKeyExists(FORM, 'txtMetaDescription')>#txtMetaDescription#</cfif>',
                        </cfif>
                        dtUpdated = getdate()
                        WHERE       #formData.varID# = #Val(arguments.ID)#;
                  </cfquery>

                  <!--- update the ssl flag for the children of this navigation table to be the same --->
                  <cfif formData.tablename is 'tblNavigation'>
                        <cfquery name="qryUpdateSSL" datasource="#this.datasource#">
                              UPDATE tblNavigation
                              SET       blnSSL = <cfif isDefined("FORM.blnSSL") and FORM.blnSSL neq "" and FORM.blnSSL is "on">1<cfelse>0</cfif>
                              WHERE       intParentID = #arguments.ID#
                        </cfquery>
                  </cfif>

                  <!--- Cache: Monitor Cache update --->
                  <cfif isDefined("formData.webid") AND Val(formData.webid)>
                        <cfquery name="qryUpdateCacheDate" datasource="#this.datasource#">
                              UPDATE tblNavigation
                              SET dtUpdated = GETDATE()
                              WHERE intID = #Val(formData.webid)#;
                        </cfquery>
                  </cfif>
            </cfif>
      </cffunction>

      <cffunction name="deleteRecord" access="public" output="false">
            <cfargument name="ID" type="numeric" required="true">
            <cfargument name="formData" type="any" required="true">

            <cfobjectcache action="clear"/>
            <cfif not formData.blnWorkflow>
                  <cfif formData.blnRestore>
                        <cfquery name="qryDelete" datasource="#this.datasource#">
                              UPDATE       #formData.tablename#
                              SET       blnDeleted = <cfqueryparam value="1" cfsqltype="cf_sql_bit">
                              WHERE       intID = <cfqueryparam value="#Val(arguments.ID)#" cfsqltype="cf_sql_integer">
                        </cfquery>
                  <cfelse>
                        <cfquery datasource="#this.datasource#">
                              DELETE FROM #formData.tablename#
                              WHERE       intID = <cfqueryparam value="#Val(arguments.ID)#" cfsqltype="cf_sql_integer">
                        </cfquery>
                  </cfif>
            <cfelseif formData.blnWorkflow>
                  <cfquery name="qryDelete" datasource="#this.datasource#">
                        UPDATE       tblItem
                        SET       blnDeleted = <cfqueryparam value="1" cfsqltype="cf_sql_bit">,
                                    blnStagingChange = <cfqueryparam value="1" cfsqltype="cf_sql_bit">
                        WHERE       intID = <cfqueryparam value="#Val(arguments.ID)#" cfsqltype="cf_sql_integer">
                  </cfquery>
            </cfif>
      </cffunction>

      <cffunction name="restoreRecord" access="public" output="false">
            <cfargument name="ID" type="numeric" required="true">
            <cfargument name="formData" type="any" required="true">

            <cfobjectcache action="clear" />

            <cfif formData.blnWorkflow>
                  <cfquery name="qryDelete" datasource="#this.datasource#">
                        UPDATE       tblItem
                        SET       blnDeleted = <cfqueryparam value="0" cfsqltype="cf_sql_bit">,
                                    blnStagingChange = <cfqueryparam value="1" cfsqltype="cf_sql_bit">,
                                    blnStagingNew = <cfqueryparam value="1" cfsqltype="cf_sql_bit">
                        WHERE       intID = <cfqueryparam value="#Val(arguments.ID)#" cfsqltype="cf_sql_integer">
                  </cfquery>
            <cfelse>
                  <cfquery name="qryDelete" datasource="#this.datasource#">
                        UPDATE       #formData.tablename#
                        SET       blnDeleted = <cfqueryparam value="0" cfsqltype="cf_sql_bit">
                        WHERE       intID = <cfqueryparam value="#Val(arguments.ID)#" cfsqltype="cf_sql_integer">
                  </cfquery>
            </cfif>
      </cffunction>

      <!--- sets the edit copy to be the active copy, archive old active, unlock item --->
      <cffunction name="checkIn" access="public" output="false">
            <cfargument name="itemID" type="numeric" required="true">
            <cfargument name="formData" type="struct" required="true">
            <cfargument name="editReason" type="string" default="" required="false">

            <cfif not formData.blnWorkflow>
                  <cfreturn>
            </cfif>

            <cfobjectcache action="clear" />

            <cfquery name="qryItem" datasource="#this.datasource#">
                  SELECT       TOP 1 *
                  FROM       #formData.tablename#
                  WHERE       intItemID = #Val(arguments.itemID)#
                  AND       blnLive = 0
                  ORDER BY dtAdded DESC
            </cfquery>

            <cfloop from="1" to="#ArrayLen(formData.columns)#" index="i">
                  <cfif formData.columns[i].type is TYPES.FEATURED>
                        <cfif qryItem[formData.columns[i].varname][1] is 1>
                              <cfquery name="qryClearFeatured" datasource="#this.datasource#">
                                    UPDATE tblItem
                                    SET       blnFeatured = 0,
                                                blnStagingChange = 1
                                    WHERE       intWebID = #formData.webid#
                                    AND             blnFeatured = 1;
                                    
                                    UPDATE       #formData.tablename#
                                    SET       #formData.columns[i].varname# = 0
                                    WHERE       intItemID IN
                                                      (SELECT intID
                                                       FROM       tblItem
                                                       WHERE       intWebID = #formData.webid#
                                                       AND       intItemID <> #Val(arguments.itemID)#);
                              </cfquery>
                              <!--- Cache: Monitor Cache update --->
                              <cfquery name="qryUpdateCacheDate" datasource="#this.datasource#">
                                    UPDATE tblNavigation
                                    SET dtUpdated = GETDATE()
                                    WHERE intID = #Val(formData.webid)#;
                              </cfquery>
                        </cfif>
                  </cfif>
            </cfloop>

            <cfif requestApproval(itemID, formData, editReason) or (not formData.blnApproval)>
                  <cfquery name="qryCheckIn" datasource="#this.datasource#">
                        DELETE FROM tblItemLock
                        WHERE       intItemID = #Val(arguments.itemID)#;
                        
                        UPDATE       tblItem
                        SET       intNavID = #formData.navid#,
                                    intSubID = #formData.subid#,
                                    intTabID = #formData.tabid#,
                                    blnNeedsTranslation = 0,
                                    blnStagingChange = 1
                                    <cfif isDefined("FORM.intCategoryID")>
                                    , intCategoryID = #Val(FORM.intCategoryID)#
                                    </cfif>
                                    <cfif ListFindNoCase(qryItem.columnlist, "blnFeatured") and qryItem.blnFeatured is 1>
                                    , blnFeatured = 1
                                    </cfif>
                        WHERE       intID = #Val(arguments.itemID)#
                  </cfquery>
                  <!--- Cache: Monitor Cache update --->
                  <cfquery name="qryUpdateCacheDate" datasource="#this.datasource#">
                        UPDATE tblNavigation
                        SET dtUpdated = GETDATE()
                        WHERE intID = #Val(formData.subid)#;
                  </cfquery>
            </cfif>

            <cfset deleteOldVersions(itemID, formData)>
      </cffunction>

      <!--- creates an edit copy, sets the item as locked --->
      <cffunction name="checkOut" access="public" output="false">
            <cfargument name="itemID" type="numeric" required="true">
            <cfargument name="formData" type="struct" required="true">

            <cfobjectcache action="clear"/>

            <cfquery name="qryCheckOut" datasource="#this.datasource#">
                  UPDATE tblItem
                  SET       intNavID = #formData.navid#,
                              intSubID = #formData.subid#,
                              intTabID = #formData.tabid#
                  WHERE       intID = #Val(arguments.itemID)#;
                  
                  DELETE FROM tblItemLock
                  WHERE       intItemID = #Val(arguments.itemID)#;
                  
                  INSERT INTO tblItemLock
                        (intUserID, intItemID)
                  VALUES (
                        #SESSION.userid#,
                        #Val(arguments.itemID)#
                  )
            </cfquery>
      </cffunction>

      <!--- returns a query with user IDs who have itemID locked out --->
      <cffunction name="getLockUsers" access="public" returntype="query" output="false">
            <cfargument name="itemID" type="numeric" required="true">

            <cfquery name="qryLockUsers" datasource="#this.datasource#" >
                  SELECT       *
                  FROM       tblItemLock
                  WHERE       intItemID = #Val(arguments.itemID)#
            </cfquery>
            
            <cfreturn qryLockUsers />
      </cffunction>

      <!--- checks if there are moderators. if so, tell them to moderate. if not, approve the item. returns true if approved. --->
      <cffunction name="requestApproval" access="public" returntype="boolean" output="false">
            <cfargument name="itemID" type="numeric" required="true">
            <cfargument name="formData" type="struct" required="true">
            <cfargument name="editReason" type="string" required="true">

            <cfobjectcache action="clear" />
            
            <!--- return variable --->
            <cfparam name="retVal" default="false" type="boolean">

            <cfif SESSION.superuser>
                  <cfset setLive(itemID, formData)>
                  <cfreturn true />
            </cfif>
            
            <!--- we first need to get the last level of approval from the item table --->
            <cfquery name="qryLastApproved" datasource="#this.datasource#">
                  SELECT       intID, intLastLevel
                  FROM       tblItem
                  WHERE       intID = #itemID#
            </cfquery>
            
            <!--- we also need to get the number of approval levels for this page. There should
                    be at least one level i.e. 0 --->
            <cfquery name="qryModLevels" datasource="#this.datasource#">
                  SELECT       TOP 1 intLevel
                  FROM       tblModerator
                  WHERE       intNavID = #formData.webid#
                  ORDER BY intLevel DESC
            </cfquery>
            
            <!--- these vars will be sent to the approve function --->
            <cfset approveLevel = qryLastApproved.intLastLevel + 1>
            <cfset maxApproveLevel = Val(qryModLevels.intLevel)>
            <!--- <cfset modLevel = 1> --->

            <!--- we want to see if the current session user is at the correct access level
                    for this page to be allowed to approve --->
            <cfif qryLastApproved.recordCount>
                  <!--- using our highest approval level, we add one to that to define our level filter
                          for the query below --->
                  <cfset levelFilter = qryLastApproved.intLastLevel + 1>
                  <!--- check if moderator is not a superuser --->
                  <cfif formData.blnCategory and isdefined("FORM.intCategoryID")>
                        <cfquery name="qryCheckModerator" datasource="#this.datasource#">
                              SELECT tblUser.intID, tblUserGroup.intGroupID,
                                    tblUserGroup.intUserID, tblModerator.intModeratorID, tblModerator.intLevel
                              FROM tblUserGroup
                              INNER JOIN tblUser ON tblUser.intID = tblUserGroup.intUserID
                              INNER JOIN tblModerator ON tblUserGroup.intGroupID = tblModerator.intModeratorID
                              WHERE tblUser.intID = #session.userid#
                              AND tblModerator.intNavID = #val(form.intCategoryID)#
                              AND tblModerator.intLevel = #levelFilter#
                        </cfquery>      
                        
                        <!--- if current user is a moderator, then approve and increment the level --->
                        <cfif qryCheckModerator.recordCount>
                              <cfset retVal = approve(itemID, formData,approveLevel,maxApproveLevel)>      
                              <!--- if false, then we want to increment the level by two i.e. skip a level --->
                              <cfif retVal EQ false>
                                    <cfset modLevel = qryLastApproved.intLastLevel + 2>
                              <cfelse>
                                    <!--- since our approval went through, we simply return --->
                                    <cfreturn retVal>
                              </cfif>      
                        <cfelse>
                              <cfset modLevel = qryLastApproved.intLastLevel + 1>
                        </cfif>
                  <cfelse>
                        <cfquery name="qryCheckModerator" datasource="#this.datasource#">
                              SELECT tblUser.intID, tblUserGroup.intGroupID,
                                    tblUserGroup.intUserID, tblModerator.intModeratorID, tblModerator.intLevel
                              FROM tblUserGroup
                              INNER JOIN tblUser ON tblUser.intID = tblUserGroup.intUserID
                              INNER JOIN tblModerator ON tblUserGroup.intGroupID = tblModerator.intModeratorID
                              WHERE tblUser.intID = #session.userid#
                              AND tblModerator.intNavID = #formData.webid#
                              AND tblModerator.intLevel = #levelFilter#
                        </cfquery>      

                        <!--- if current user is a moderator, then approve and increment the level --->
                        <cfif qryCheckModerator.recordCount>
                              <cfset retVal = approve(itemID, formData,approveLevel,maxApproveLevel)>
                              <!--- if false, then we want to increment the level by two i.e. skip a level --->
                              <cfif retVal EQ false>
                                    <cfset modLevel = qryLastApproved.intLastLevel + 2>
                              <cfelse>
                                    <!--- since our approval went through, we simply return --->
                                    <cfreturn retVal>
                              </cfif>
                        <cfelse>
                              <cfset modLevel = qryLastApproved.intLastLevel + 1>
                        </cfif>                  
                  </cfif>
            </cfif>

            <!--- get a list of moderators that will need to be notified of approvals --->
            <cfset qryModerators = getApprovalModerators(modLevel,formData)>

            <cfif qryModerators.recordcount>
                  <cfquery datasource="#this.datasource#">
                        DELETE FROM tblItemLock
                        WHERE intItemID = #itemID#;
                        
                        UPDATE tblItem
                        SET blnApproved = 0,
                              intApproveUserID = #session.userid#
                        WHERE intID = #itemID#;
                        
                        <cfloop query="qryModerators">
                              INSERT INTO tblItemLock (intUserID, intItemID, blnApproval, txtEditReason)
                              VALUES (#intID#, #itemID#, 1, '#editReason#');
                        </cfloop>
                  </cfquery>
                  <cfloop query="qryModerators">
                        <cfset sendApprovalEmail(intID, editReason)>
                  </cfloop>
                  <cfset retVal = false>
            <cfelse>
                  <cfreturn approve(itemID, formData,approveLevel,maxApproveLevel)>
            </cfif>
            
            <cfreturn retVal />
      </cffunction>
      
      <!--- this function retrieves all the users at the given moderator level --->
      <cffunction name="getApprovalModerators" access="private" output="true" returntype="query">
            <cfargument name="modLevel" type="numeric" required="true">
            <cfargument name="formData" type="struct" required="true">
            
            <cfobjectcache action="clear" />
            
            <!---perform a query to determine the list of moderators for the given level --->
            <cfif formData.blnCategory and isdefined("form.intCategoryID")>
                  <cfquery name="qryModerators" datasource="#this.datasource#">
                        SELECT tblModerator.intModeratorID, tblUser.txtFirstName + ' ' + tblUser.txtLastName as txtName, tblUser.txtUsername,tblUser.intID
                        FROM tblModerator
                        LEFT JOIN tblUserGroup ON tblModerator.intModeratorID = tblUserGroup.intGroupID
                        JOIN tblUser ON tblUserGroup.intUserID = tblUser.intID
                        WHERE intLevel = #modLevel#
                        AND intNavID = #val(form.intCategoryID)#
                  </cfquery>
            </cfif>
            <cfif (not isDefined("qryModerators")) or qryModerators.recordcount eq 0>
                  <cfobjectcache action="clear" />
                  
                  <cfquery name="qryModerators" datasource="#this.datasource#">
                        SELECT tblModerator.intModeratorID, tblUser.txtFirstName + ' ' + tblUser.txtLastName as txtName, tblUser.txtUsername,tblUser.intID
                        FROM tblModerator
                        LEFT JOIN tblUserGroup ON tblModerator.intModeratorID = tblUserGroup.intGroupID
                        JOIN tblUser ON tblUserGroup.intUserID = tblUser.intID
                        WHERE intLevel = #modLevel#
                        AND intNavID = #formData.webid#
                  </cfquery>
            </cfif>
            
            <cfreturn qryModerators />
      </cffunction>
      
      <!--- this function retrieves all the users at the given notification level --->
      <cffunction name="getNotificationUsers" access="private" output="true" returntype="query">
            <cfargument name="modLevel" type="numeric" required="true">
            <cfargument name="formData" type="struct" required="true">
            
            <cfobjectcache action="clear" />
            
            <!---perform a query to determine the list of moderators for the given level --->
            <cfif formData.blnCategory and isdefined("form.intCategoryID")>
                  <!--- if the modlevel is -1, then this is notification for last level.
                          The reason for this logic is that the intlastlevel is set to zero in tblitem,
                        so no notifications would be sent to last level notify group --->
                  <cfif modLevel IS -1>
                        <cfquery name="qryLastMod" datasource="#this.datasource#">
                              SELECT intLevel
                              FROM tblModerator
                              WHERE intNavID = #val(form.intCategoryID)#
                              ORDER BY intLevel DESC
                        </cfquery>
                        <cfif qryLastMod.recordCount>
                              <cfset modLevel = qryLastMod.intLevel>
                        </cfif>
                  </cfif>
                  <cfquery name="qryNotifiers" datasource="#this.datasource#">
                        SELECT tblModerator.intNotifierID, tblUser.txtFirstName + ' ' + tblUser.txtLastName as txtName, tblUser.txtUsername,tblUser.intID
                        FROM tblModerator
                        LEFT JOIN tblUserGroup ON tblModerator.intNotifierID = tblUserGroup.intGroupID
                        JOIN tblUser ON tblUserGroup.intUserID = tblUser.intID
                        WHERE intLevel = #modLevel#
                        AND intNavID = #val(form.intCategoryID)#
                  </cfquery>
            </cfif>
            <cfif (not isDefined("qryNotifiers")) or qryNotifiers.recordcount eq 0>
                  <cfobjectcache action="clear"/>
                  <!--- if the modlevel is -1, then this is notification for last level.
                          The reason for this logic is that the intlastlevel is set to zero in tblitem,
                        so no notifications would be sent to last level notify group --->
                  <cfif modLevel IS -1>
                        <cfquery name="qryLastMod" datasource="#this.datasource#">
                              SELECT intLevel
                              FROM tblModerator
                              WHERE intNavID = #formData.webid#
                              ORDER BY intLevel DESC
                        </cfquery>
                        <cfif qryLastMod.recordCount>
                              <cfset modLevel = qryLastMod.intLevel>
                        </cfif>
                  </cfif>
                  <cfquery name="qryNotifiers" datasource="#this.datasource#">
                        SELECT tblModerator.intNotifierID, tblUser.txtFirstName + ' ' + tblUser.txtLastName as txtName, tblUser.txtUsername,tblUser.intID
                        FROM tblModerator
                        LEFT JOIN tblUserGroup ON tblModerator.intNotifierID = tblUserGroup.intGroupID
                        JOIN tblUser ON tblUserGroup.intUserID = tblUser.intID
                        WHERE intLevel = #modLevel#
                        AND intNavID = #formData.webid#
                  </cfquery>
            </cfif>

            <cfreturn qryNotifiers/>
      </cffunction>

      <cffunction name="sendWorkflowNotification" access="public" output="false">
            <cfargument name="formData" type="any" required="true">
            <cfargument name="itemID" type="numeric" required="false">
            
            <cfparam name="modLevel" default="0">
            
            <!--- we first need to get the last level of approval from the item table --->
            <cfquery name="qryLastApproved" datasource="#this.datasource#">
                  SELECT intID, intLastLevel, blnApproved
                  FROM tblItem
                  WHERE intID = #itemID#
            </cfquery>
            
            <cfquery name="qryTitle" datasource="#this.datasource#">
                  SELECT txtTitle,'index.cfm?navid=' + CAST(tblItem.intNavID as varchar)
                                     + '&subid=' + CAST(tblItem.intSubID as varchar)
                                     + '&id=' + CAST(tblItem.intID as varchar)
                                     + '&tabid=' + CAST(tblItem.intTabID as varchar)
                                     + '&mode=edit' as txtLink
                  FROM tblNavigation                  
                  LEFT JOIN tblItem ON tblItem.intWebID = tblNavigation.intID
                  WHERE tblNavigation.intID = #formData.webid#
            </cfquery>
            
            <cfif qryLastApproved.recordCount>
                  <cfset modLevel = qryLastApproved.intLastLevel>
                  <!--- check if this is the last level. If so, then set modlevel to -1 so that
                          only notifiers in final notification level are notified. see getnotificationusers()--->
                  <cfif modLevel IS 0 AND qryLastApproved.blnApproved IS 1>
                        <cfset modLevel = -1>
                  </cfif>
            </cfif>
            
            <!--- get a list of moderators that will need to be notified of changes --->
            <cfset qryNotifiers = getNotificationUsers(modLevel,formData)>

            <cfif qryNotifiers.recordcount>
                  <cfloop query="qryNotifiers">
                        <cftry>
                              <cfset userInfo = getObject("hb50.access", this.CompanyID, true).getUserData(intID)>
                              <cfcatch>
                                    <cfreturn>
                              </cfcatch>
                        </cftry>
                        <cfset this.communication = getObject("hb50.communication", this.CompanyID, true)>
                        <cfset this.communication.sendInternal(userInfo.email, "Workflow Change Notification", '#userInfo.realname#, the page <a href="#this.qryCompany.txtWeb#/#qryTitle.txtTitle#"><nobr>#qryTitle.txtTitle#</nobr></a> has been modified.')>
                  </cfloop>
            </cfif>
            
      </cffunction>

      <cffunction name="sendApprovalEmail" access="public" output="false">
            <cfargument name="intUserID" type="numeric" required="true">
            <cfargument name="editReason" type="string" required="true">

            <!--- if this is a bad user ID, just return --->
            <cftry>
                  <cfset userInfo = getObject("hb50.access", this.CompanyID, true).getUserData(intUserID)>
                  <cfcatch>
                        <cfreturn>
                  </cfcatch>
            </cftry>
            
            <cftry>
            <cfquery name="qryTools" datasource="#this.datasource#" >
                  SELECT DISTINCT txtTable
                  FROM (
                              SELECT txtTitle as txtTool, txtTablename as txtTable FROM tblPlugin
                              UNION
                              SELECT txtTitle + ' Category' as txtTool, txtCategoryTable as txtTable FROM tblPlugin
                         ) tblPlugins
                  WHERE txtTable != '' AND txtTable IS NOT NULL AND txtTable != 'tblTheme' AND txtTable != 'tblDisplaySettings'
            </cfquery>            

             <cftransaction>
                  <cfquery name="qryLocked" datasource="#this.datasource#" >
                        SELECT tblItem.*, tblItem.intID as intItemID,
                                    tblItemLock.blnApproval, tblItemLock.txtEditReason, tblNavigation.txtTitle, tblNavigation.txtTitle + ' &gt; ' + tblAll.txtTitle as txtLabel, tblAll.dtAdded,
                                    'index.cfm?navid=' + CAST(tblItem.intNavID as varchar)
                                     + '&subid=' + CAST(tblItem.intSubID as varchar)
                                     + '&id=' + CAST(tblItem.intID as varchar)
                                     + '&tabid=' + CAST(tblItem.intTabID as varchar)
                                     + '&mode=edit' as txtLink,
                                     tblUser.txtFirstName + ' ' + tblUser.txtLastName as txtApproveUser,
                                     tblAll.dtStart
                        FROM tblItemLock
                        LEFT JOIN tblItem ON intItemID = tblItem.intID
                        LEFT JOIN tblNavigation ON tblItem.intWebID = tblNavigation.intID
                        LEFT JOIN (
                              <cfloop query="qryTools">
                                SELECT intID, intItemID, txtTitle, dtAdded, blnLive, dtStart
                                FROM #qryTools.txtTable#
            
                                UNION
                              </cfloop>
                         
                                SELECT intID, intItemID, txtTitle, dtAdded, blnLive, dtStart
                                FROM tblContent
            
                                UNION
            
                                SELECT intID, intItemID, txtTitle, dtAdded, blnLive, dtStart
                                FROM tblResourceCategory
                        ) tblAll
                               ON tblAll.intItemID = tblItem.intID
                                    AND tblAll.intID IN
                                      (SELECT TOP 1 intID
                                          FROM (
                                                <cfloop query="qryTools">
                                                  SELECT intID, intItemID, txtTitle, dtAdded, blnLive, dtStart
                                                  FROM #qryTools.txtTable#
                              
                                                  UNION
                                                </cfloop>
                                            
                                                  SELECT intID, intItemID, txtTitle, dtAdded, blnLive, dtStart
                                                  FROM tblContent
                              
                                                  UNION
                              
                                                  SELECT intID, intItemID, txtTitle, dtAdded, blnLive, dtStart
                                                  FROM tblResourceCategory

                                                 
                                          ) tblAll2
                                          WHERE intItemID = tblItem.intID
                                          ORDER BY dtAdded DESC)
                        LEFT JOIN tblUser ON tblItem.intApproveUserID = tblUser.intID
                        WHERE tblItemLock.intUserID = #intUserID#
                        AND tblItem.blnDeleted = 0
                        AND tblItemLock.blnApproval = 1
                        AND tblNavigation.intCompanyID = #this.CompanyID#
                        ORDER BY tblNavigation.txtTitle, tblAll.txtTitle
                  </cfquery>
            </cftransaction>
            <cfcatch>
            </cfcatch>
            </cftry>

            <cfsavecontent variable="msg"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><cfoutput>#this.qryCompany.txtTitle#</cfoutput> Content Approval</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<cfoutput><base href="#this.qryCompany.txtWeb#/"></cfoutput>
<style type="text/css">
<!--
body {
      background-color: #E5E5E5;
      margin-left: 0px;
      margin-top: 0px;
      margin-right: 0px;
      margin-bottom: 0px;
}
.hbTitle {
      font-family: Arial, Helvetica, sans-serif;
      font-size: 18px;
      color: #CCCCCC;
}
.hbRegular {
      font-family: Arial, Helvetica, sans-serif;
      font-size: 12px;
      color: #333333;
}
.hbRegular a:link {color: #333333; text-decoration: underline}
.hbRegular a:visited {color: #333333; text-decoration: underline}
.hbRegular a:hover {color: #333333; text-decoration: underline}
.hbRegular a:active {color: #333333; text-decoration: underline}

.bhList {
      font-family: Arial, Helvetica, sans-serif;
      font-size: 11px;
      color: #333333;
      width: 250px;
}
.hbTable {
      font-family: Arial, Helvetica, sans-serif;
      font-size: 11px;
      color: #333333;
}
-->
</style></head>

<body>
<br>
<table width="640" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#D8D8D8"><img src="images/shim.gif" width="1" height="16"></td>
  </tr>
  <tr>
    <td align="right" valign="bottom" bgcolor="#FFFFFF" class="hbTitle"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="25" colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td width="332"><img src="images/shim.gif" width="332" height="1"></td>
        <td width="308" align="left" class="hbTitle"><p><cfoutput>#this.qryCompany.txtTitle#</cfoutput> Content Approval</p></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td bgcolor="#CCCCCC"><img src="images/shim.gif" width="1" height="1"></td>
  </tr>
  <tr>
    <td height="200" bgcolor="#FFFFFF">      <table width="640" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="25" colspan="5">&nbsp;</td>
        </tr>
      <tr>
        <td width="50">&nbsp;</td>
        <td width="258" align="left" valign="middle"><a href="<cfoutput>#this.qryCompany.txtWeb#</cfoutput>"><img src="images/logo_company.gif" width="191" height="107" border="0"></a></td>
        <td width="24">&nbsp;</td>
        <td width="258" valign="top" class="hbRegular"><strong><cfoutput>#userInfo.realname#</cfoutput>,</strong><br>The Web pages listed below are waiting for approval. To approve the Web pages, log in to Hot Banana and click on the "Unapproved" tab in your "My Overview" section.</td>
        <td width="50">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" colspan="5">&nbsp;</td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td bgcolor="#CCCCCC"><img src="images/shim.gif" width="1" height="1"></td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#FFFFFF"><table width="640" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="25" colspan="5">&nbsp;</td>
      </tr>
      <tr>
        <td width="50">&nbsp;</td>
        <td colspan="3" align="left" valign="top" class="hbRegular">
          <table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td bgcolor="#CCCCCC"><table width="100%"  border="0" cellspacing="1" cellpadding="3">
                <tr bgcolor="#E6E6E6" class="hbTable">
                  <td>Web Page</td>
                  <td style="padding-right: 5px; padding-left: 5px;">Author</td>
                  <td style="padding-right: 5px; padding-left: 5px;">Note</td>
                  <td style="padding-right: 5px; padding-left: 5px;">Live Date</td>
                </tr>
                <cfif isDefined("qryLocked") AND qryLocked.recordCount>
                              <cfoutput query="qryLocked">
                      <tr class="hbTable">
                        <td bgcolor="##F7F7F7"><a href="#this.qryCompany.txtHBWeb#/#txtLink#" title="#txtLabel#"><nobr>#txtTitle#</nobr></a></td>
                        <td bgcolor="##FFFFFF" style="padding-right: 5px; padding-left: 5px;"><nobr>#txtApproveUser#</nobr></td>
                        <td bgcolor="##FFFFFF" style="padding-right: 5px; padding-left: 5px;">#qryLocked.txtEditReason#</td>
                        <td bgcolor="##F7F7F7" style="padding-right: 5px; padding-left: 5px;"><nobr><cfif len(dtStart)>#DateFormat(dtStart, "mmm d, yyyy")#<cfelse>On Approval</cfif></nobr></td>
                      </tr>
                              </cfoutput>
                        </cfif>
              </table></td>
            </tr>
          </table>          </td>
        <td width="50">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" colspan="5">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td bgcolor="#CCCCCC"><img src="images/shim.gif" width="1" height="1"></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF"><table width="640" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="25" colspan="5">&nbsp;</td>
      </tr>
      <tr>
        <td width="50">&nbsp;</td>
        <td width="258" align="left" valign="middle" class="hbRegular"><p><strong>Log in to Hot Banana now: </strong><cfoutput><a href="#this.qryCompany.txtHBWeb#">#this.qryCompany.txtHBWeb#</a></cfoutput></p>
          <p>This is an automated message please do not respond to it.</p></td>
        <td width="24">&nbsp;</td>
        <td width="258" align="right" valign="bottom" class="hbRegular"><p><a href="http://www.hotbanana.ca"><img src="images/logo_hotbanana.gif" width="129" height="25" border="0"></a></p></td>
        <td width="50">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" colspan="5">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td bgcolor="#D8D8D8"><img src="images/shim.gif" width="1" height="16"></td>
  </tr>
</table>
<br>
</body>
</html>
</cfsavecontent>
            <cfset this.communication = getObject("hb50.communication", this.CompanyID, true)>
            <cfset this.communication.sendPreFormat(userInfo.email, this.qryCompany.txtWorkflowEmail, "Web Site Content Approval Notification", msg)>
      </cffunction>

      <!--- dummy function for approve function to be called from outsite this object --->
      <cffunction name="setLive" access="public">
            <cfargument name="itemID" type="numeric" required="true">
            <cfargument name="formData" type="struct" required="true">

            <!--- force the live status by ensuring the level is greater than the maxlevel --->
            <cfset approve(itemID, formData,1,0)>
            
      </cffunction>
      
      <!--- sets the record as approved, replaces the current active with the most recent edit copy --->
      <cffunction name="approve" access="public" output="true" returntype="boolean">
            <cfargument name="itemID" type="numeric" required="true">
            <cfargument name="formData" type="struct" required="true">
            <cfargument name="level" type="numeric" required="true">
            <cfargument name="maxlevel" type="numeric" required="true">

            <cfobjectcache action="clear"/>
            
            <cfset qryModerators = getApprovalModerators(level,formData)>
            <cfif qryModerators.recordCount>
                  <!--- send an email to the author to keep him informed --->
                  <cfquery name="qryApproveUser" datasource="#this.datasource#" maxrows="1">
                        SELECT       TOP 1 tblUser.txtEmail
                        FROM       tblItem
                        LEFT JOIN tblUser
                        ON             tblItem.intApproveUserID = tblUser.intID
                        WHERE       tblItem.intID = <cfqueryparam value="#arguments.itemID#" cfsqltype="cf_sql_integer">
                  </cfquery>
                  
                  <!--- get the live (active?!) copy --->
                  <cfquery name="qryActiveCopy" datasource="#this.datasource#" maxrows="1">
                        SELECT       TOP 1 #formData.tablename#.txtTitle, tblNavigation.txtCaption
                        FROM       #formData.tablename#
                        LEFT JOIN tblItem
                        ON             tblItem.intID = #formData.tablename#.intItemID
                        LEFT JOIN tblNavigation
                        ON             tblItem.intWebID = tblNavigation.intID
                        WHERE       #formData.tablename#.intItemID = <cfqueryparam value="#arguments.itemID#" cfsqltype="cf_sql_integer">
                        ORDER BY #formData.tablename#.blnLive DESC
                  </cfquery>
                                    
                  <cfif Len(qryApproveUser.txtEmail)>
                        <cfset this.communication = getObject("hb50.communication", this.CompanyID, true)>
                        <cfset this.communication.sendInternal(qryApproveUser.txtEmail, "Web Site Content Approved Notification", "#qryActiveCopy.txtCaption# &gt; #qryActiveCopy.txtTitle# was approved by #session.realname#.")>
                  </cfif>
            </cfif>
            <!--- now check whether the level passed in matches the max level of approval.
                    If it does, then we can make this item live since it received the last
                  level of approval. Otherwise, simply update the itme table by incrementing
                  the intlastlevel --->
            <cfif val(level) LT val(maxlevel)>
                  <cfquery datasource="#this.datasource#">
                        UPDATE tblItem
                        SET intLastLevel = #val(level)#
                        WHERE intID = #val(itemID)#
                  </cfquery>
            <cfelse>
                  <cfquery name="qrySetActive" datasource="#this.datasource#">
                        UPDATE #formData.tablename#
                        SET blnLive = 0
                        WHERE intItemID = #val(itemID)#;
      
                        UPDATE #formData.tablename#
                        SET blnLive = 1
                        WHERE intID IN (
                              SELECT TOP 1 intID
                              FROM #formData.tablename#
                              WHERE intItemID = #val(itemID)#
                              ORDER BY dtAdded DESC
                        );
                        
                        UPDATE tblItem
                        SET intNavID = #formData.navid#,
                              intSubID = #formData.subid#,
                              intTabID = #formData.tabid#,
                              blnStagingChange = 1,
                              blnApproved = 1,
                              intApproveUserID = #session.userid#,
                              intLastLevel = 0
                        WHERE intID = #val(itemID)#
                  </cfquery>
                  <cfreturn true/>
            </cfif>
            <cfreturn false/>
      </cffunction>

      <!--- sets the record as approved, replaces the current active with the most recent edit copy --->
      <cffunction name="decline" access="public" output="false">
            <cfargument name="itemID" type="numeric" required="true">
            <cfargument name="formData" type="struct" required="true">
            <cfargument name="reason" type="string" required="true">

            <cfobjectcache action="clear" />

            <!---
                  get the userid awaiting approval
                  - tblItem.intApproveUserID
            --->
            <cfquery name="qryApproveUser" datasource="#this.datasource#" maxrows="1">
                  SELECT       TOP 1 tblUser.txtEmail
                  FROM       tblItem
                  LEFT JOIN tblUser
                  ON             tblItem.intApproveUserID = tblUser.intID
                  WHERE       tblItem.intID = <cfqueryparam value="#arguments.itemID#" cfsqltype="cf_sql_integer">
            </cfquery>
            
            <!--- get the live (active?!) copy --->
            <cfquery name="qryActiveCopy" datasource="#this.datasource#" maxrows="1">
                  SELECT       TOP 1 #formData.tablename#.txtTitle, tblNavigation.txtCaption
                  FROM       #formData.tablename#
                  LEFT JOIN tblItem
                  ON             tblItem.intID = #formData.tablename#.intItemID
                  LEFT JOIN tblNavigation
                  ON             tblItem.intWebID = tblNavigation.intID
                  WHERE       #formData.tablename#.intItemID = <cfqueryparam value="#arguments.itemID#" cfsqltype="cf_sql_integer">
                  ORDER BY #formData.tablename#.blnLive DESC
            </cfquery>
            
            <!--- we first need to get the last level of approval from the item table --->
            <cfquery name="qryLastApproved" datasource="#this.datasource#">
                  SELECT       intID, intLastLevel
                  FROM       tblItem
                  WHERE       intID = <cfqueryparam value="#arguments.itemID#" cfsqltype="cf_sql_integer">
            </cfquery>
            
            <!--- if the last level is not 1, then simply set the item table intlastlevel down by one --->
            <cfif qryLastApproved.intLastLevel gte 1>
                  <cfset newLevel = qryLastApproved.intLastLevel - 1>
                  <cfset qryModerators = getApprovalModerators(qryLastApproved.intLastLevel,formData)>
                  
                  <cfquery name="qryDeclineLevel" datasource="#this.datasource#">
                        UPDATE       tblItem
                        SET       intLastLevel = <cfqueryparam value="#newLevel#" cfsqltype="cf_sql_integer">;
                                                
                        DELETE FROM tblItemLock
                        WHERE       intItemID = <cfqueryparam value="#arguments.itemID#" cfsqltype="cf_sql_integer">;
                                                
                        <cfloop query="qryModerators">
                              INSERT INTO tblItemLock (
                                    intUserID, intItemID, blnApproval, txtEditReason)
                              VALUES (
                                    <cfqueryparam value="#intID#" cfsqltype="cf_sql_integer">,
                                    <cfqueryparam value="#arguments.itemID#" cfsqltype="cf_sql_integer">,
                                    <cfqueryparam value="1" cfsqltype="cf_sql_bit">,
                                    <cfqueryparam value="#arguments.reason#" cfsqltype="cf_sql_varchar">);
                        </cfloop>
                  </cfquery>
            <cfelse>            
                  <!--- if this is not a superuser and this moderator has declined, then
                          drop the lastlevel down by one so that the next mod level down can reapprove ???--->
                  <cfquery name="qryDelApprove" datasource="#this.datasource#">
                        DELETE FROM #formData.tablename#
                        WHERE intID IN (
                              SELECT       TOP 1 intID
                              FROM      #formData.tablename#
                              WHERE      blnLive = <cfqueryparam value="0" cfsqltype="cf_sql_bit">
                              AND       intItemID = <cfqueryparam value="#arguments.itemID#" cfsqltype="cf_sql_integer">
                              ORDER BY dtAdded DESC);
                        
                        DELETE FROM tblItemLock
                        WHERE       intItemID = <cfqueryparam value="#arguments.itemID#" cfsqltype="cf_sql_integer">;
      
                        UPDATE       tblItem
                        SET       intNavID = <cfqueryparam value="#formData.navid#" cfsqltype="cf_sql_integer">,
                                    intSubID = <cfqueryparam value="#formData.subid#" cfsqltype="cf_sql_integer">,
                                    intTabID = <cfqueryparam value="#formData.tabid#" cfsqltype="cf_sql_integer">,
                                    blnApproved = <cfqueryparam value="1" cfsqltype="cf_sql_bit">                              
                        WHERE       intID = <cfqueryparam value="#arguments.itemID#" cfsqltype="cf_sql_integer">
                  </cfquery>
                  
                  <cfquery name="qryAnyLeft" datasource="#this.datasource#" maxrows="1">
                        SELECT       TOP 1 intItemID
                        FROM       #formData.tablename#
                        WHERE       intItemID = <cfqueryparam value="#arguments.itemID#" cfsqltype="cf_sql_integer">
                  </cfquery>
      
                  <cfif qryAnyLeft.recordcount is 0>
                        <cfquery name="qryEraseItem" datasource="#this.datasource#">
                              DELETE FROM tblItem
                              WHERE      intID = <cfqueryparam value="#arguments.itemID#" cfsqltype="cf_sql_integer">
                        </cfquery>
                  </cfif>
            </cfif>

            <cfif Len(qryApproveUser.txtEmail)>
                  <cfset this.communication = getObject("hb50.communication", this.CompanyID, true)>
                  <cfset this.communication.sendInternal(qryApproveUser.txtEmail, "Web Site Content Decline Notification", "#qryActiveCopy.txtCaption# &gt; #qryActiveCopy.txtTitle# was declined by #session.realname#.<br><br>Reason: #reason#")>
            </cfif>
      </cffunction>

      <cffunction name="isLocked" access="public" output="false">
            <cfargument name="itemID" type="numeric" required="true">
            <cfargument name="userID" type="numeric" required="true">
            
            <cfif SESSION.superuser>
                  <cfreturn false />
            </cfif>

            <cfquery name="qryItemLock" datasource="#this.datasource#">
                  SELECT       intUserID
                  FROM       tblItemLock
                  WHERE       intItemID = <cfqueryparam value="#arguments.itemID#" cfsqltype="cf_sql_integer">
            </cfquery>

            <cfreturn qryItemLock.recordCount gt 0 and not ListFind(ValueList(qryItemLock.intUserID), userID) />
      </cffunction>

      <cffunction name="canApprove" access="public" output="false">
            <cfargument name="itemID" type="numeric" required="true">
            <cfargument name="userID" type="numeric" required="true">
            
            <cfif isLocked(itemID, userID)>
                  <cfreturn false />
            </cfif>

            <cfquery name="qryNeedsApproval" datasource="#this.datasource#">
                  SELECT       blnApproved
                  FROM       tblItem
                  WHERE       intID = <cfqueryparam value="#arguments.itemID#" cfsqltype="cf_sql_integer">
            </cfquery>

            <cfreturn qryNeedsApproval.blnApproved is 0 />
      </cffunction>

      <cffunction name="deleteOldVersions" access="private" returntype="string" output="false">
            <cfargument name="itemID" type="numeric" required="true">
            <cfargument name="formData" type="struct" required="true">

            <cfobjectcache action="clear" />

            <cfquery name="qryDeleteVersions" datasource="#this.datasource#">
                  DELETE FROM #formData.tablename#
                  WHERE       blnLive = 0
                  AND       intItemID = <cfqueryparam value="#arguments.itemID#" cfsqltype="cf_sql_integer">
                  <cfif formData.blnVersion>
                         AND intID NOT IN (
                              SELECT       TOP #this.MAX_VERSIONS# intID
                              FROM       #formData.tablename#
                              WHERE       intItemID = <cfqueryparam value="#arguments.itemID#" cfsqltype="cf_sql_integer">
                              AND       blnLive = <cfqueryparam value="0" cfsqltype="cf_sql_bit">
                              ORDER BY dtAdded DESC
                        )
                  </cfif>
            </cfquery>
      </cffunction>

      <cffunction name="sendAllTranslateEmails" access="public" output="false">
            <cfargument name="intCompanyID" type="numeric" required="true">

            <cfquery name="qryTranslators" datasource="#this.datasource#">
                  SELECT       intCompanyID, intUserID
                  FROM       tblTranslator
                  WHERE       intCompanyID = <cfqueryparam value="#arguments.intCompanyID#" cfsqltype="cf_sql_integer">
            </cfquery>
            
            <cfloop query="qryTranslators">
                  <cfset sendTranslateEmail(intCompanyID, intUserID)>
            </cfloop>
      </cffunction>
      
      <cffunction name="sendTranslateEmail" access="public" output="false">
            <cfargument name="intCompanyID" type="numeric" required="true">
            <cfargument name="intUserID" type="numeric" required="true">
            
            <!--- if this is a bad user ID, just return --->
            <cftry>
                  <cfset userInfo = getObject("hb50.access", this.CompanyID, true).getUserData(intUserID)>
                  <cfcatch>
                        <cfreturn>
                  </cfcatch>
            </cftry>
            
            <cfquery name="qryTools" datasource="#this.datasource#" >
                  SELECT DISTINCT txtTable
                  FROM
                        (SELECT      txtTitle AS txtTool, txtTablename AS txtTable
                         FROM       tblPlugin
                         UNION
                         SELECT txtTitle + ' Category' AS txtTool, txtCategoryTable AS txtTable
                         FROM       tblPlugin)
                        tblPlugins
                  WHERE       txtTable != ''
                  AND       txtTable IS NOT NULL
            </cfquery>

            <cftransaction>
                  <cfquery name="qryLocked" datasource="#this.datasource#" >
                        SELECT tblItem.*, tblItem.intID as intItemID, tblNavigation.txtTitle + ' &gt; ' + tblAll.txtTitle as txtLabel, tblAll.dtAdded,
                                    'index.cfm?navid=' + CAST(tblItem.intNavID as varchar)
                                     + '&subid=' + CAST(tblItem.intSubID as varchar)
                                     + '&id=' + CAST(tblItem.intID as varchar)
                                     + '&tabid=' + CAST(tblItem.intTabID as varchar)
                                     + '&mode=edit' as txtLink,
                                     tblAll.dtStart,
                                     tblUser.txtFirstName + ' ' + tblUser.txtLastName as txtAuthor
                        FROM tblItem
                        LEFT JOIN tblNavigation ON tblItem.intWebID = tblNavigation.intID
                        LEFT JOIN (
                              <cfloop query="qryTools">
                                SELECT intID, intItemID, txtTitle, dtAdded, blnLive, dtStart
                                FROM #qryTools.txtTable#
            
                                UNION
                              </cfloop>
                         
                                SELECT intID, intItemID, txtTitle, dtAdded, blnLive, dtStart
                                FROM tblContent
            
                                UNION
            
                                SELECT intID, intItemID, txtTitle, dtAdded, blnLive, dtStart
                                FROM tblResourceCategory

                                UNION
            
                                SELECT intID, intItemID, txtTitle, dtAdded, blnLive, dtStart
                                FROM tblResource
                        ) tblAll
                               ON tblAll.intItemID = tblItem.intID
                                    AND tblAll.intID IN
                                      (SELECT TOP 1 intID
                                          FROM (
                                                <cfloop query="qryTools">
                                                  SELECT intID, intItemID, txtTitle, dtAdded, blnLive, dtStart
                                                  FROM #qryTools.txtTable#
                              
                                                  UNION
                                                </cfloop>
                                            
                                                  SELECT intID, intItemID, txtTitle, dtAdded, blnLive, dtStart
                                                  FROM tblContent
                              
                                                  UNION
                              
                                                  SELECT intID, intItemID, txtTitle, dtAdded, blnLive, dtStart
                                                  FROM tblResourceCategory

                                                  UNION
                              
                                                  SELECT intID, intItemID, txtTitle, dtAdded, blnLive, dtStart
                                                  FROM tblResource
                                          ) tblAll2
                                          WHERE intItemID = tblItem.intID
                                          ORDER BY dtAdded DESC)
                        LEFT JOIN tblItemTranslate ON tblItem.intID = tblItemTranslate.intTranslateID
                        LEFT JOIN tblActionLog ON tblItemTranslate.intItemID = tblActionLog.intItemID AND tblActionLog.intID = (SELECT TOP 1 intID FROM tblActionLog WHERE intItemID = tblItemTranslate.intItemID ORDER BY dtDate DESC)
                        LEFT JOIN tblUser ON tblActionLog.intUserID = tblUser.intID
                        WHERE tblItem.blnNeedsTranslation = 1
                        AND tblNavigation.intCompanyID = #intCompanyID#
                        ORDER BY tblNavigation.txtTitle, tblAll.txtTitle
                  </cfquery>
            </cftransaction>

            <cfsavecontent variable="msg"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><cfoutput>#this.qryCompany.txtTitle#</cfoutput> Content Translation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<cfoutput><base href="#this.qryCompany.txtWeb#/"></cfoutput>
<style type="text/css">
<!--
body {
      background-color: #E5E5E5;
      margin-left: 0px;
      margin-top: 0px;
      margin-right: 0px;
      margin-bottom: 0px;
}
.hbTitle {
      font-family: Arial, Helvetica, sans-serif;
      font-size: 18px;
      color: #CCCCCC;
}
.hbRegular {
      font-family: Arial, Helvetica, sans-serif;
      font-size: 12px;
      color: #333333;
}
.hbRegular a:link {color: #333333; text-decoration: underline}
.hbRegular a:visited {color: #333333; text-decoration: underline}
.hbRegular a:hover {color: #333333; text-decoration: underline}
.hbRegular a:active {color: #333333; text-decoration: underline}

.bhList {
      font-family: Arial, Helvetica, sans-serif;
      font-size: 11px;
      color: #333333;
      width: 250px;
}
.hbTable {
      font-family: Arial, Helvetica, sans-serif;
      font-size: 11px;
      color: #333333;
}
-->
</style></head>

<body>
<br>
<table width="640" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#D8D8D8"><img src="images/shim.gif" width="1" height="16"></td>
  </tr>
  <tr>
    <td align="right" valign="bottom" bgcolor="#FFFFFF" class="hbTitle"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="25" colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td width="332"><img src="images/shim.gif" width="332" height="1"></td>
        <td width="308" align="left" class="hbTitle"><p><cfoutput>#this.qryCompany.txtTitle#</cfoutput> Content Translation</p></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td bgcolor="#CCCCCC"><img src="images/shim.gif" width="1" height="1"></td>
  </tr>
  <tr>
    <td height="200" bgcolor="#FFFFFF">      <table width="640" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="25" colspan="5">&nbsp;</td>
        </tr>
      <tr>
        <td width="50">&nbsp;</td>
        <td width="258" align="left" valign="middle"><a href="<cfoutput>#this.qryCompany.txtWeb#</cfoutput>"><img src="images/logo_company.gif" width="191" height="107" border="0"></a></td>
        <td width="24">&nbsp;</td>
        <td width="258" valign="top" class="hbRegular"><strong><cfoutput>#userInfo.realname#</cfoutput>,</strong><br>The Web pages listed below are waiting for translation. To translate the Web pages, log in to Hot Banana and click on the "Translation" tab in your "My Overview" section.</td>
        <td width="50">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" colspan="5">&nbsp;</td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td bgcolor="#CCCCCC"><img src="images/shim.gif" width="1" height="1"></td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#FFFFFF"><table width="640" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="25" colspan="5">&nbsp;</td>
      </tr>
      <tr>
        <td width="50">&nbsp;</td>
        <td colspan="3" align="left" valign="top" class="hbRegular">
          <table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td bgcolor="#CCCCCC"><table width="100%"  border="0" cellspacing="1" cellpadding="3">
                <tr bgcolor="#E6E6E6" class="hbTable">
                  <td width="80%">Web Page</td>
                  <td style="padding-right: 5px; padding-left: 5px;">Author</td>
                  <td style="padding-right: 5px; padding-left: 5px;">Live Date</td>
                </tr>
                        <cfoutput query="qryLocked">
                <tr class="hbTable">
                  <td bgcolor="##F7F7F7"><a href="#this.qryCompany.txtHBWeb#/#txtLink#"><cfif len(txtLabel)>#txtLabel#<cfelse>no title</cfif></a></td>
                  <td bgcolor="##FFFFFF" style="padding-right: 5px; padding-left: 5px;"><nobr>#txtAuthor#</nobr></td>
                  <td bgcolor="##F7F7F7" style="padding-right: 5px; padding-left: 5px;"><nobr><cfif len(dtStart)>#DateFormat(dtStart, "mmm d, yyyy")#<cfelse>On Approval</cfif></nobr></td>
                </tr>
                        </cfoutput>
              </table></td>
            </tr>
          </table>          </td>
        <td width="50">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" colspan="5">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td bgcolor="#CCCCCC"><img src="images/shim.gif" width="1" height="1"></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF"><table width="640" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="25" colspan="5">&nbsp;</td>
      </tr>
      <tr>
        <td width="50">&nbsp;</td>
        <td width="258" align="left" valign="middle" class="hbRegular"><p><strong>Log in to Hot Banana now: </strong><cfoutput><a href="#this.qryCompany.txtHBWeb#/">#this.qryCompany.txtHBWeb#</a></cfoutput></p>
          <p>This is an automated message please do not respond to it.</p></td>
        <td width="24">&nbsp;</td>
        <td width="258" align="right" valign="bottom" class="hbRegular"><p><a href="http://www.hotbanana.ca"><img src="images/logo_hotbanana.gif" width="129" height="25" border="0"></a></p></td>
        <td width="50">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" colspan="5">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td bgcolor="#D8D8D8"><img src="images/shim.gif" width="1" height="16"></td>
  </tr>
</table>
<br>
</body>
</html>
</cfsavecontent>

            <cfset this.communication = getObject("hb50.communication", this.CompanyID, true)>
            <cfset this.communication.sendPreFormat(userInfo.email, this.qryCompany.txtWorkflowEmail, "Web Site Content Translation Notification", msg)>
      </cffunction>

      <!--- Creates any columns that aren't already present in the table.
              Actually creates the whole table if necessary.
       --->
      <cffunction name="verifyColumns" access="public" returntype="any" output="false">
            <cfargument name="formData" required="true" type="any">

            <cfif not formData.blnVerifyColumns>
                  <cfreturn>
            </cfif>

            <cftry>
                  <cfquery name="qryTable" datasource="#this.datasource#" >
                        SELECT       TOP 1 *
                        FROM      #formData.tablename#
                  </cfquery>
                  <cfset columnlist = qryTable.columnlist>
                  <cfcatch>
                        <cfset columnlist = "">
                        <cfquery name="qryCreateTable" datasource="#this.datasource#">
                              CREATE TABLE dbo.#formData.tablename# (
                                    #formData.varID# INT IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL,
                                    intUID uniqueidentifier NOT NULL
                              );
                              
                              ALTER TABLE #formData.tablename# WITH NOCHECK ADD
                              CONSTRAINT [PK_#formData.tablename#] PRIMARY KEY CLUSTERED
                              (
                                    #formData.varID#
                              );
                              
                              ALTER TABLE #formData.tablename# WITH NOCHECK ADD
                                    CONSTRAINT [DF_#formData.tablename#_intUID] DEFAULT (newid()) FOR intUID;
                              
                              EXEC sp_addextendedproperty N'MS_Description', N'The primary key of this item version', N'user', N'dbo', N'table', N'#formData.tablename#', N'column', N'#formData.varID#';
                              EXEC sp_addextendedproperty N'MS_Description', N'The UID of this item version', N'user', N'dbo', N'table', N'#formData.tablename#', N'column', N'intUID';
                        </cfquery>
                  </cfcatch>
            </cftry>

            <!---
                  when adding extra columns, to add descriptions, use
                        exec sp_addextendedproperty N'MS_Description', N'Can the user edit content or items?', N'user', N'dbo', N'table', N'tblAdminPermission', N'column', N'blnEdit'
                        OR   sp_updateextendedproperty
            --->
            <cfloop from="1" to="#ArrayLen(formData.columns)#" index="key">
                  <cfset i = formData.columns[key]>
                  <cfset column = i.varname>

                  <cfif  ((isDefined("i.column") and i.column is true) or not (isDefined("i.insert") and i.insert is false)) and not ListFindNoCase(columnlist, column)>
                        <cfif isDefined("i.vartype")>
                              <cfset type = i.vartype>
                        <cfelse>
                              <cfif ListFind("#TYPES.TEXT#,#TYPES.COLOUR#,#TYPES.HIDDEN#", i.type)>
                                    <cfset type = "nvarchar(500)">
                              <cfelseif ListFind("#TYPES.URL#", i.type)>
                                    <cfset type = "nvarchar(1000)">
                              <cfelseif ListFind("#TYPES.HTML#,#TYPES.MEMO#", i.type)>
                                    <cfset type = "ntext">
                              <cfelseif ListFind("#TYPES.DATE#", i.type)>
                                    <cfset type = "datetime">
                              <cfelseif ListFind("#TYPES.CATEGORY#,#TYPES.MEDIA#,#TYPES.SELECT#,#TYPES.NUMBER#,#TYPES.TYPE#", i.type)>
                                    <cfset type = "int">
                              <cfelseif ListFind("#TYPES.FEATURED#,#TYPES.BOOLEAN#", i.type)>
                                    <cfset type = "bit">
                              <cfelse>
                                    <cfset type = "">
                              </cfif>
                        </cfif>

                         <!--- if we haven't added support for it, don't deal with it. --->
                         <cfif Len(type)>
                              <cfquery datasource="#this.datasource#">
                                    ALTER TABLE #formData.tablename#
                                    ADD #column# #type# <cfif isDefined("i.allownull") AND NOT i.allownull AND ListFindNoCase("int,bit",type)>NOT NULL <cfif isDefined("i.default") AND Len("#i.default#")>DEFAULT (#i.default#)</cfif></cfif>;
                                                                        
                                    EXEC sp_addextendedproperty N'MS_Description', N'#i.title#', N'user', N'dbo', N'table', N'#formData.tablename#', N'column', N'#column#';
                              </cfquery>
                              
                              <cfobjectcache action="clear" />
                        </cfif>
                  </cfif>
            </cfloop>
            
            <cfif formData.blnExtraColumns>
                  <cfif formData.blnWorkflow>
                        <cfset this.workflowData.tablename = formData.tablename>
                        <cfset verifyColumns(this.workflowData)>
                  <cfelse>
                        <cfset this.basicData.tablename = formData.tablename>
                        <cfset verifyColumns(this.basicData)>
                  </cfif>
            </cfif>
      </cffunction>      
      
      <!---
            wrapper function to convertCachedTokens
            - preserved for backward compatibility support
      --->
      <cffunction name="convertTokens" output="false">
            <cfargument name="input" required="true">
            <cfargument name="leaveToken" required="false" default="false">
            <cfargument name="webid" required="false" default="-1">
            
            <cfreturn convertCachedTokens(input, leaveToken, webid) />
      </cffunction>
      
      <!---
            takes a url and checks if the current page is an ssl page
            - if so, converts the prefix to https
      --->
      <cffunction name="setSSLPrefix" output="true" returntype="string">
            <cfargument name="input" required="true" type="string">
            <cfargument name="webid" required="true">
            
            <cfquery name="qrySSL" datasource="#this.datasource#" maxrows="1">
                  SELECT       TOP 1 intID,blnSSL
                  FROM       tblNavigation
                  WHERE       intID = <cfqueryparam value="#arguments.webid#" cfsqltype="cf_sql_integer">
            </cfquery>
            
            <cfif qrySSL.recordCount and isDefined("qrySSL.blnSSL") and qrySSL.blnSSL>
                  <cfset input = REReplaceNoCase(input,'http://', 'https://', 'ALL')>
            </cfif>
            
            <cfreturn input />
      </cffunction>
      
      <!--- converts tokens in a way that is one way, stripping off the token --->
      <cffunction name="convertCachedTokens" output="false">
            <cfargument name="input" required="true">
            <cfargument name="leaveToken" required="false" default="false">
            <cfargument name="webid" required="false" default="-1">

            <cfscript>
                  var links = getObject("hb50.links", this.companyID, true);
                  var media = getObject("hb50.media", this.companyID, true);
                  var wtod = getObject("hb50.util.wtod", this.companyID, true);
                  
                  var length = Len(arguments.input);
                  var j = 1;
                  var pos = 0;
                  var end = 0;
                  var index = '';
                  var width = 0;
                  var height = 0;
                  var exclam = 0;
                  var token = '';
                  var newSrc = '';
                  
                  var tagStart = 0;
                  var tagEnd = 0;
                  
                  //WebTrends
                  var wtodEnabled = wtod.isWTODEnabled();
                  var mediaStruct = StructNew();
                  
                  //tracking code manager
                  var plugins = getObject("hb50.plugins", this.companyID, true);
                  var blnTCODE = plugins.checkAccessByObject("hb50.plugins.generic.trackingCodeManager", this.companyID);
            </cfscript>
                              
            <!--- convert image --->
            <cfloop from="1" to="#length#" index="j">
                  <cfset pos = Find('$HB_IMG$', input, pos)>
                  <cfif pos is 0>
                        <cfbreak />
                  </cfif>
                  <cfset end = Find('$', input, pos + 8)>
                  <cfif end is 0>
                        <cfbreak />
                  </cfif>

                  <cfset index = Mid(input, pos + 8, end - pos - 8)>

                  <cfif index contains '!'>
                        <cfset token = index>
                        <cfset mediaID = Val(token)>
                        
                        <!--- get the width --->
                        <cfset width = 0>
                        <cfset exclam = Len(token) - Find('!', token)>
                        <cfif exclam gt 0>
                              <cfset token = Right(token, exclam)>
                              <cfset width = Val(token)>
                        </cfif>
                        
                        <!--- get the height --->
                        <cfset height = 0>
                        <cfset exclam = Len(token) - Find('!', token)>
                        <cfif exclam gt 0>
                              <cfset token = Right(token, exclam)>
                              <cfset height = Val(token)>
                        </cfif>
                        
                        <cfset newSrc = media.getURL(mediaID, width, height, 1)>
                  <cfelse>
                        <cfset newSrc = media.getURL(Val(index), -1, -1, 1)>
                  </cfif>
                  
                  <!--- replace the token with the filename plus the token --->
                  <cfif arguments.leaveToken>
                        <cfif Find("?", newSrc)>
                              <cfset newSrc = "#newSrc#%26$HB_IMG$#index#$">
                        <cfelse>
                              <cfset newSrc = "#newSrc#?$HB_IMG$#index#$">
                        </cfif>
                  </cfif>
                  
                  <!--- no token appended at the filename --->
                  <cfset input = Left(input, pos - 1) & newSrc & Right(input, Len(input) - end)>

                  <!--- advance the pos counter --->
                  <cfset pos = pos + Len(newSrc) + 1>
            </cfloop>

            <!--- convert flash (SWF) --->
            <cfloop from="1" to="#length#" index="j">
                  <cfset pos = Find('$HB_FLASH$', input, pos)>
                  <cfif pos is 0>
                        <cfbreak />
                  </cfif>
                  <cfset end = Find('$', input, pos + 10)>
                  <cfif end is 0>
                        <cfbreak />
                  </cfif>
                                    
                  <cfset index = Mid(input, pos + 10, end - pos - 10)>
                  
                  <!--- leave it as an image, with the token --->
                  <cfif arguments.leaveToken>
                        <cfset newSrc = 'images/thumb_flash.gif'>
                        <cfif Find("?", newSrc)>
                              <cfset newSrc = "#newSrc#%26$HB_FLASH$#index#$">
                        <cfelse>
                              <cfset newSrc = "#newSrc#?$HB_FLASH$#index#$">
                        </cfif>
                        <cfset input = Left(input, pos - 1) & newSrc & Right(input, Len(input) - end)>
                        <cfset pos = pos + Len(newSrc) + 1>
                  <cfelse>
                        <cfset length = Len(input)>
                        <cfset newSrc = media.getMediaDisplay(Val(index))>
                        
                        <cfset tagStart = length - Find('<', Reverse(input), length - pos) + 1>
                        <cfset tagEnd = Find('>', input, tagStart)>
                        
                        <cfif tagStart lte 1>
                              <cfset input = newSrc & Right(input, length - tagEnd)>
                        <cfelse>
                              <cfset input = Left(input, tagStart - 1) & newSrc & Right(input, length - tagEnd)>
                        </cfif>
                        <cfset pos = pos + 1>
                  </cfif>
            </cfloop>
            
            <!--- convert flash (FLV) --->
            <cfloop from="1" to="#length#" index="j">
                  <cfset pos = Find('$HB_FLV$', input, pos)>
                  <cfif pos is 0>
                        <cfbreak />
                  </cfif>
                  <cfset end = Find('$', input, pos + 8)>
                  <cfif end is 0>
                        <cfbreak />
                  </cfif>
                  
                  <cfset index = mid(input, pos + 8, end - pos - 8)>
                  
                  <!--- leave it as an image, with the token --->
                  <cfif arguments.leaveToken>
                        <cfset newSrc = 'images/thumb_flash.gif'>
                        <cfif Find("?", newSrc)>
                              <cfset newSrc = "#newSrc#%26$HB_FLV$#index#$">
                        <cfelse>
                              <cfset newSrc = "#newSrc#?$HB_FLV$#index#$">
                        </cfif>
                        <cfset input = Left(input, pos - 1) & newSrc & Right(input, Len(input) - end)>
                        <cfset pos = pos + Len(newSrc) + 1>
                  <cfelse>
                        <cfset length = Len(input)>
                        <cfset newSrc = media.getMediaDisplay(Val(index))>
                        
                        <cfset tagStart = length - Find('<', reverse(input), length - pos) + 1>
                        <cfset tagEnd = Find('>', input, tagStart)>
                        <cfif tagStart lte 1>
                              <cfset input = newSrc & Right(input, length - tagEnd)>
                        <cfelse>
                              <cfset input = Left(input, tagStart - 1) & newSrc & Right(input, length - tagEnd)>
                        </cfif>
                        <cfset pos = pos + 1>
                  </cfif>
            </cfloop>
            
            <!--- change all of the resources except links to be https if ssl enabled --->
            <cfset input = setSSLPrefix(input,webid)>

            <!--- convert links --->
            <cfif not arguments.leaveToken>
                  <!--- don't even bother converting link tokens if we're preserving the token --->
                  <cfset pos = 0>
                  <cfset length = Len(input)>
                                    
                  <!--- uid --->
                  <cfloop from="1" to="#length#" index="j">
                        <cfset pos = Find('"link.cfm?u=', input, pos)>
                        <cfset end = Find('"', input, pos + 12)>
                        <cfif pos is 0 or end is 0>
                              <cfbreak />
                        </cfif>

                        <cfset index = Mid(input, pos + 12, end - pos - 12)>

                        <!--- replace the token with the filename plus the token --->
                        <cfif wtodEnabled>
                              <cfset mediaStruct = links.getCachedURLStruct(index)>
                              <cfset newSrc = '"' & mediaStruct.url & '"'>
                              
                              <cfif isDefined("mediaStruct.multitrack") AND mediaStruct.multitrack is 1>
                                    <cfif mediaStruct.domain neq CGI.SERVER_NAME>                                          
                                          <cfset newSrc = newSrc & ' onclick="' & "dcsMultiTrack('DCS.dcssip', '#mediaStruct.domain#', 'DCS.dcsuri', '#mediaStruct.url#','WT.ti','#mediaStruct.title#', 'WT.cg_n', '', 'WT.cg_s', '', 'WT.si_n', '', 'WT.si_x', '', 'WT.mc_id', '');" & '"'>
                                    <cfelse>
                                          <cfset newSrc = newSrc & ' onclick="' & "dcsMultiTrack('DCS.dcsuri','#mediaStruct.url#', 'WT.ti', '#mediaStruct.title#', 'WT.cg_n', '', 'WT.cg_s', '', 'WT.si_n', '', 'WT.si_x', '', 'WT.mc_id', '');" & '"'>
                                    </cfif>
                              </cfif>
                        <cfelse>
                              <cfset newSrc = '"' & links.getCachedURL(index) & '"'>
                        </cfif>
                        <cfset input = Left(input, pos - 1) & newSrc & Right(input, Len(input) - end)>

                        <cfset pos = pos + Len(newSrc) + 1>
                  </cfloop>
                  
                  <cfset pos = 0>
                  <cfset length = Len(input)>
                  
                  <!--- lid --->
                  <cfloop from="1" to="#length#" index="j">
                        <cfset pos = Find('"link.cfm?lid=', input, pos)>
                        <cfset end = Find('"', input, pos + 14)>
                        <cfif pos is 0 or end is 0>
                              <cfbreak />
                        </cfif>
                        
                        <cfset index = Mid(input, pos + 14, end - pos - 14)>

                        <!--- replace the token with the filename plus the token --->
                        <cfif wtodEnabled>
                              <cfset mediaStruct = links.getCachedLinkURLStruct(index)>
                              
                              <!--- hack the flv links --->
                              <cfif FindNoCase('viewFLV.cfm', mediaStruct.url) is 0>
                                    <cfset newSrc = '"' & mediaStruct.url & '"'>
                              <cfelse>
                                    <cfset newSrc = '"' & 'javascript:void(0)' & '"' & ' onClick="' & mediaStruct.url & '"'>
                              </cfif>
                              
                              <cfif isDefined("mediaStruct.multitrack") AND mediaStruct.multitrack is 1>
                                    <cfif mediaStruct.domain neq CGI.SERVER_NAME>
                                          <cfset newSrc = newSrc & ' onclick="' & "dcsMultiTrack('DCS.dcssip', '#mediaStruct.domain#', 'DCS.dcsuri', '#mediaStruct.url#','WT.ti','#mediaStruct.title#', 'WT.cg_n', '', 'WT.cg_s', '', 'WT.si_n', '', 'WT.si_x', '', 'WT.mc_id', '');" & '"'>
                                    <cfelse>
                                          <cfset newSrc = newSrc & ' onclick="' & "dcsMultiTrack('DCS.dcsuri','#mediaStruct.url#', 'WT.ti', '#mediaStruct.title#', 'WT.cg_n', '', 'WT.cg_s', '', 'WT.si_n', '', 'WT.si_x', '', 'WT.mc_id', '');" & '"'>
                                    </cfif>
                              </cfif>
                        <cfelse>
                              
                              <cfif blnTCODE>
                                    <!--- tracking code handling --->
                                    <cfquery name="qryTCODE" datasource="#this.datasource#" maxrows="1">
                                          SELECT      TOP 1 intResourceID
                                          FROM      tblLink
                                          WHERE      intID = <cfqueryparam value="#val(index)#" cfsqltype="cf_sql_integer">
                                          AND            intResourceID IN (SELECT DISTINCT intLinkID FROM tblTrackingCodeLinks)
                                    </cfquery>
                              </cfif>
                        
                              <cfif isDefined("qryTCODE") and qryTCODE.recordCount>
                                    <cfset newSrc = '"link.cfm?lid=' & index & '"'>
                              <cfelse>
                                    <cfset linkURL = links.getCachedLinkURL(Val(index)) />
                                    
                                    <!--- hack the flv links --->
                                    <cfif FindNoCase('viewFLV.cfm', linkURL) is 0>
                                          <cfset newSrc = '"' & linkURL & '"' />
                                    <cfelse>
                                          <cfset newSrc = '"' & 'javascript:void(0)' & '"' & ' onClick="' & linkURL & '"' />
                                    </cfif>
                              </cfif>
                        </cfif>
                        
                        <cfset input = Left(input, pos - 1) & newSrc & Right(input, Len(input) - end) />
                        <cfset pos = pos + Len(newSrc) + 1 />
                  </cfloop>
            </cfif>
            
            <cfreturn input />
      </cffunction>
      
      <!---
            returns the body content with all filenames stripped out from image/flash/flv src parameters
            - leaves the token intact so that only the token is persisted in the db
      --->
      <cffunction name="prepareTokens" access="public" returntype="string" output="false">
            <cfargument name="input" type="string" required="true" />
            
            <cfscript>
                  var c = arguments.input;
                  //strip out all filenames from image src parameters, but leave the token
                  c = ReReplaceNoCase(c, '(["\''])[^\''"]*\$HB_IMG\$', '\1$HB_IMG$', "ALL");
                  c = ReReplaceNoCase(c, '(["\''])[^"\'']*\$HB_FLASH\$', '\1$HB_FLASH$', "ALL");
                  c = ReReplaceNoCase(c, '(["\''])[^"\'']*\$HB_FLV\$', '\1$HB_FLV$', "ALL");
      
                  return c;
            </cfscript>
      </cffunction>
      
      <!---
            returns the body content with all placeholder tokens (s--999) replaced by the actual itemid of the content
            - hack for initial check-in of body content
      --->
      <cffunction name="fixLinkParams" access="private" returntype="string" output="false">
            <cfargument name="input" type="string" required="true" />
            <cfargument name="itemID" type="numeric" required="true" />
            
            <cfscript>
                  var c = arguments.input;
                  //replace the placeholder token with the itemid for each link in the params list
                  c = ReplaceNoCase(c, '_s--999_t-#URL.navid#_', '_s-#arguments.itemID#_t-#URL.navid#_', "ALL");

                  return c;
            </cfscript>
      </cffunction>

</cfcomponent>
I'm sorry but I just don't have time to hunt through 10,000 lines of code as to what you are trying to do. but I can say that it looks like you are taking the result set from your stored procedure then passing that into the i.query variable in you function. What I don't understand is why you are taking a result set and puting it in a cfquery tag as if it were a sql string.  
Because the diplay.cfc components is the core file that was given to me by manufacture
Therefore #PreserveSingleQuote(i.quey# is valid
I am sure that it is valid for the use it was intended for. but you added the storedprocedure part of it and I think you are doing that wrong. you should not be putting a result set in the i.query or x.query you should be putting a string with a valid sql statement in that variable that will be executed by the cfquery tag within the function.
I think what you trying to say is get rid of stored procedure and put that stored procedure into query. If so pleas e provide an example i you can, this is urgent . Thank you
I am not sure what the exact query statement will need to be but you will need to replace the stored procedure code to be something like:

<cfswitch expression="#this.companyid#">
      <cfcase value="2">
            <cfset myQuery = "exec dbo.qryCourseNumbers('07-08', 'PSL', 'PSL')">
      </cfcase>
      <cfcase value="9">
            <cfset myQuery = "exec dbo.qryCourseNumbers('07-08', 'business', 'undergraduate')">
      </cfcase>
      <cfcase value="10">
            <cfset myQuery = "exec dbo.qryCourseNumbers('07-08', 'education', 'education')">
      </cfcase>
</cfswitch>


then a litlle lower you will set
x.query = myQuery;
I am trying to get courseId , coursetitle and division .
So can I do something like this
<cfquery name="qryCourseNumbers" datasource="#this.datasource#">

I am trying to get courseId , coursetitle and division . I can not think of anything that can build the query since we calling the stored procedure
OK. I still can not get this to work, What I did is I got rid of the stored procedure and put <cfquery> instead , so my <query lokks like this now. I just have no idea what should I be doing next, I keep getting the error saying Incorrect sytax near 'DIVISION. PLeas e help

<cfquery name="qryCourseNumbers2" datasource="#this.datasource#">
                select distinct c.courseid, left(c.coursenumber,3)+'.'+right(c.coursenumber,3)+' '+replace (c.coursetitle, ' '' ', ' '''' ') as CourseName, v.division
from courseschedule.dbo.tblcourseinformation c inner join courseschedule.dbo.vw_courses_and_departments v
on c.courseid = v.courseid
where

<cfswitch expression="#this.companyid#">
      <cfcase value="2">
           c.academicyear='07-08' and v.division in ('PSL')
      </cfcase>
      <cfcase value="9">
             c.academicyear='07-08' and v.division in ('Business','Undergraduate')
      </cfcase>
      <cfcase value="10">
            c.academicyear='07-08' and v.division in ('Education')
      </cfcase>
</cfswitch>
and c.includeincatalog=-1 and (substring(c.coursenumber,4,1) <> 1 and substring(c.coursenumber,4,1) <> 2)

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks. It works. Would you please explain to me why it did not work for neither SP nor cfquery. Thank you for you help
cfquery tag needs a SQL satement to be within the start and end tags. It passes that SQL statement to the database, then the database returns the results of the query passes them back to coldfusion which creates a variable containing a query resultset to the page being processed. The resultset is not another SQL statment.

You were running a stored procedure that was returning a query resultset and then attempting to put the resultset into a cfquery, and that was causing an error.