using System;
using System.Data;
using System.Xml;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Web;
using IlgharCMS;
using IlgharCMS.GuestBookModule;
public partial class CIndex : IlgharCMS.Page
{
public CIndex()
: base("index.dwt.aspx")
{}
protected XmlDocument _xmlTemplate;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
_xmlTemplate = XmlData.GetXmlDocument();
if (!String.IsNullOrEmpty(Request.QueryString["GetPageCount"]))
                            {
                                Response.Write(t3850);
                                Response.End();
                            }
                        
Response.AddCacheItemDependency("ClearAllCache");
}

                                protected DataRow ShopChannel
                                {
                                    get
                                    {
                                        if (_ShopChannel == null)
                                            _ShopChannel = Manager.GetExtraInstance(Channel, "Shop");

                                        return _ShopChannel;
                                    }
                                }
                                private DataRow _ShopChannel;

                            protected string MetaKeywords
                                            {
                                                get
                                                {
                                                    StringBuilder result = new StringBuilder();
                                                    result.Append(Channel[IlgharCMS.SystemModule.Alias.Channel.Name + PageLang]);
                                    if (!String.IsNullOrEmpty(Channel[IlgharCMS.SystemModule.Alias.Channel.MetaKeywords].ToString()))
                                        result.Append(" - " + Channel[IlgharCMS.SystemModule.Alias.Channel.MetaKeywords]);

                                    if (!String.IsNullOrEmpty(Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.MetaKeywords + PageLang].ToString()))
                                        result.Append(" - " + Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.MetaKeywords + PageLang]);
                                    
                                                    return result.ToString();
                                                }
                                            }
                            protected string MetaDescription
                                            {
                                                get
                                                {
                                                    StringBuilder result = new StringBuilder();
                                                    result.Append(Channel[IlgharCMS.SystemModule.Alias.Channel.Name + PageLang]);
                                    if (!String.IsNullOrEmpty(Channel[IlgharCMS.SystemModule.Alias.Channel.MetaDescription].ToString()))
                                        result.Append(" - " + Channel[IlgharCMS.SystemModule.Alias.Channel.MetaDescription]);

                                    if (!String.IsNullOrEmpty(Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.MetaDescription + PageLang].ToString()))
                                        result.Append(" - " + Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.MetaDescription + PageLang]);
                                    
                                                    return result.ToString();
                                                }
                                            }
                            protected string Notice
                                            {
                                                get
                                                {
                                                    if (String.IsNullOrEmpty(Channel[IlgharCMS.SystemModule.Alias.Channel.Notice].ToString()))
                                                        return Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Notice + PageLang].ToString();
                                                    else
                                                        return Channel[IlgharCMS.SystemModule.Alias.Channel.Notice].ToString();
                                                }
                                            }
                            protected string Footer
                                            {
                                                get
                                                {
                                                    if (String.IsNullOrEmpty(Channel[IlgharCMS.SystemModule.Alias.Channel.Footer].ToString()))
                                                        return Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Footer + PageLang].ToString();
                                                    else
                                                        return Channel[IlgharCMS.SystemModule.Alias.Channel.Footer].ToString();
                                                }
                                            }
                            protected string StatisticsCode
                                            {
                                                get
                                                {
                                                    if (String.IsNullOrEmpty(Channel[IlgharCMS.SystemModule.Alias.Channel.StatisticsCode].ToString()))
                                                        return Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.StatisticsCode + PageLang].ToString();
                                                    else
                                                        return Channel[IlgharCMS.SystemModule.Alias.Channel.StatisticsCode].ToString();
                                                }
                                            }
                            
                            protected System.Collections.Generic.Dictionary<System.String,System.String> Config
                            {
                                get
                                {
                                    object id = null;
                                    
                                    if (_ConfigID != null && _ConfigID == id)
                                        return _Config;

                                    int instanceID;
instanceID = InstanceID;

                                    using (IlgharCMS.GuestBookModule.IInstanceConfig bll = (IlgharCMS.GuestBookModule.IInstanceConfig)Manager.CreateObject("InstanceConfig", instanceID, PageLang, false))
                                    {
                                        _ConfigID = id;
                                        _Config = bll.GetBasicSettings();
                                    }

                                    return _Config;
                                }
                            }
                            private System.Collections.Generic.Dictionary<System.String,System.String> _Config;
                            private object _ConfigID;
                            
                            protected string t1421Default
                            {
                                get
                                {
                                    StringBuilder result = new StringBuilder(_xmlTemplate.SelectSingleNode("//t1421").InnerText);
                                    object t1523 = ImagePath;
result.Replace("{#t1523#}",t1523 == null ? "" : t1523.ToString());

                                    return result.ToString();
                                }
                            }
                            protected string t1421
                            {
                                get
                                {
                                    int instanceID;
                                    DataRow[] rows = Manager.Instances.Select(IlgharCMS.SystemModule.Alias.Module.Namespace + "='IlgharCMS.AdModule'");if (rows.Length == 0)
{instanceID = 0;}
else
{instanceID = (int)rows[0][IlgharCMS.SystemModule.Alias.Instance.InnerID];}
                                    if (instanceID == 0)
                                        return t1421Default;

                                    string path = String.Empty;
                                    int id = -1;
                                    
                            using (IlgharCMS.AdModule.IPosition bll = (IlgharCMS.AdModule.IPosition)Manager.CreateObject("Position", instanceID, PageLang, false))
                            {
                                id = bll.GetInnerIDFromGuid(new Guid("{099A2FEC-2278-4b03-BC08-A3C1FC3ADC66}"));
                                path = Manager.GetCachePath() + "ad/" + instanceID + "_" + PageLang + "_" + id + ".js";
                                if (id > 0 && !System.IO.File.Exists(Manager.MapPath(path)))
                                {
                                    path = bll.GenerateCacheFile(id);
                                    if (String.IsNullOrEmpty(path))
                                        id = -1;
                                }
                            }
                            

                                    if (id <= 0)
                                        return t1421Default;
                                    else
                                        return "<script type=\"text/javascript\" src=\"" + path + "\"></script>";
                                }
                            }
                            
                            private string t1884BuildUrl(DataRow record)
                            {
                                string url = record[IlgharCMS.SystemModule.Alias.Menu.Path].ToString();
                                if (url.StartsWith("http://") || url.StartsWith("/"))
                                {
                                    if (url.StartsWith("/") && (Convert.ToBoolean(Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Fake404]) || Request.RawUrl.IndexOf("/ilghar.aspx?/") != -1))
                                        return Manager.GetWebPath() + "ilghar.aspx?" + url;
                                    else
                                        return url;
                                }

                                DataRow[] rows = Manager.Channels.Select(IlgharCMS.SystemModule.Alias.Channel.ID + "='" + record[IlgharCMS.SystemModule.Alias.Menu.ChannelID] + "'");
                                if (rows.Length == 0)
                                    return url;

                                DataRow channel = rows[0];
                                if (!Convert.IsDBNull(Channel[IlgharCMS.SystemModule.Alias.Channel.TranslateLang]))
                                {
                                    string instance = null;
                                    if (Convert.IsDBNull(channel[IlgharCMS.SystemModule.Alias.Instance.ID]))
                                        instance = IlgharCMS.SystemModule.Alias.Instance.ID + " IS NULL AND ";
                                    else
                                        instance = IlgharCMS.SystemModule.Alias.Instance.ID + "='" + channel[IlgharCMS.SystemModule.Alias.Instance.ID] + "' AND ";
                                    rows = Manager.Channels.Select(IlgharCMS.SystemModule.Alias.Channel.ID + " IS NOT NULL AND " + instance + IlgharCMS.SystemModule.Alias.Channel.TemplateLang + "='" + Channel[IlgharCMS.SystemModule.Alias.Channel.TemplateLang] + "' AND " + IlgharCMS.SystemModule.Alias.Channel.TranslateLang + "='" + Channel[IlgharCMS.SystemModule.Alias.Channel.TranslateLang] + "'");
                                    if (rows.Length > 0)
                                        channel = rows[0];
                                }

                                string content = record[IlgharCMS.SystemModule.Alias.Menu.Content].ToString();
                                if (!String.IsNullOrEmpty(content))
                                {
                                    if (!Convert.IsDBNull(record[IlgharCMS.SystemModule.Alias.Menu.PageTemplate]))
                                    {
                                        if (record[IlgharCMS.SystemModule.Alias.Menu.PageExtension].ToString() == String.Empty)
                                            url = BuildUrl(channel, record[IlgharCMS.SystemModule.Alias.Menu.PageTemplate].ToString(), "ID=" + record[IlgharCMS.SystemModule.Alias.Menu.PageID] + "&Ext=" + channel[IlgharCMS.SystemModule.Alias.Channel.Extension]);
                                        else
                                            url = BuildUrl(channel, record[IlgharCMS.SystemModule.Alias.Menu.PageTemplate].ToString(), "ID=" + record[IlgharCMS.SystemModule.Alias.Menu.PageID] + "&Ext=" + record[IlgharCMS.SystemModule.Alias.Menu.PageExtension]);
                                    }
                                    else
                                    {
                                        rows = Manager.Pages.Select(IlgharCMS.SystemModule.Alias.Template.Page.TemplatePath + "='" + channel[IlgharCMS.SystemModule.Alias.Channel.TemplatePath] + "' AND " + IlgharCMS.SystemModule.Alias.Template.Page.Mark + "='System' AND " + IlgharCMS.SystemModule.Alias.Template.Page.Object + "='Menu'");
                                        if (rows.Length == 0)
                                        {
                                            url = String.Empty;
                                        }
                                        else
                                        {
                                            if (record[IlgharCMS.SystemModule.Alias.Menu.PageExtension].ToString() == String.Empty)
                                                url = BuildUrl(channel, rows[0][IlgharCMS.SystemModule.Alias.Template.Page.PathInTemplate].ToString(), "ID=" + record[IlgharCMS.SystemModule.Alias.Menu.PageID] + "&Ext=" + channel[IlgharCMS.SystemModule.Alias.Channel.Extension]);
                                            else
                                                url = BuildUrl(channel, rows[0][IlgharCMS.SystemModule.Alias.Template.Page.PathInTemplate].ToString(), "ID=" + record[IlgharCMS.SystemModule.Alias.Menu.PageID] + "&Ext=" + record[IlgharCMS.SystemModule.Alias.Menu.PageExtension]);
                                        }
                                    }
                                }
                                else
                                {
                                    string channelPath = String.Empty;
                                    if (!String.IsNullOrEmpty(channel[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString()))
                                    {
                                        Uri domain = new Uri(channel[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString().Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[0]);
                                        if (channel == Channel)
                                            channelPath = domain.LocalPath;
                                        else
                                            channelPath = domain.ToString();
                                    }
                                    else if (!String.IsNullOrEmpty(Channel[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString()))
                                    {
                                       channelPath = Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Domain].ToString() + channel[IlgharCMS.SystemModule.Alias.Channel.Path].ToString().TrimStart('/');
                                    }
                                    else
                                    {
                                        channelPath = channel[IlgharCMS.SystemModule.Alias.Channel.Path].ToString();
                                        
                                    }
                                    if (!String.IsNullOrEmpty(url))
                                    {
                                        url = channelPath + url;
                                        url = url.Replace(".ext", channel[IlgharCMS.SystemModule.Alias.Channel.Extension].ToString());
                                    }
                                    else
                                    {
                                        url = channelPath + channel[IlgharCMS.SystemModule.Alias.Channel.DefaultDocument].ToString() + channel[IlgharCMS.SystemModule.Alias.Channel.Extension];
                                    }

                                    if (Convert.ToBoolean(Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Fake404]) || Request.RawUrl.IndexOf("/ilghar.aspx?/") != -1)
                                        url = Manager.GetWebPath() + "ilghar.aspx?" + url;
                                }

                                return url;
                            }

                            private int t1884IDCounter = 0;
                            private object t1884IDRecord = null;
                            private DataTable t1884ID;
                            private DataTable t1884ID_
                            {
                                get
                                {
                                    string condition = null;
condition += "P2131_24_403=";
condition += "true";
condition += " and P2131_24_264 IS ";
condition += "NULL";
condition += " and P2131_24_263 IS ";
condition += "NULL";


                                    string sort = null;

                                    using (IlgharCMS.SystemModule.IMenu bll = (IlgharCMS.SystemModule.IMenu)Manager.CreateObject("Menu", SystemInstanceID, PageLang, false))
                                    {
                                        t1884ID = bll.List(-1, -1, condition, sort);
                                    }

                                    return t1884ID;
                                }
                            }
                            protected string t1884
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t1884");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    
                                        replacementPair["{#URL#}"] = new CustomBuild(
                                                                        delegate(DataRow record, int index)
                                                                        {
                                                                            return t1884BuildUrl(record);
                                                                        }
                                                                        );
                                                replacementPair["{#Target#}"] = IlgharCMS.SystemModule.Alias.Menu.Target;replacementPair["{#Name#}"] = IlgharCMS.SystemModule.Alias.Menu.Name;
                                    StringBuilder all = Manager.Build(node, t1884ID_, replacementPair, ref t1884IDRecord, ref t1884IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                        protected int t2514IDRecordCount
                        {
                            get
                            {
                                int instanceID;
instanceID = (int)ShopChannel[IlgharCMS.SystemModule.Alias.Instance.InnerID];
                                using (IlgharCMS.ShopModule.IGoods bll = (IlgharCMS.ShopModule.IGoods)Manager.CreateObject("Goods", instanceID, PageLang, false))
                                {
                                    string condition = null;
condition += "P1896_2_64=";
condition += "false";
condition += " and P1896_2_63=";
condition += "true";


                                    return bll.GetRecordCount(condition);
                                }
                            }
                        }
                        
                            protected int t2514IDCounter = 0;
                            protected object t2514IDRecord = null;
                            private DataTable t2514IDData;
                            protected DataTable t2514ID
                            {
                                get
                                {
                                    if (t2514IDData != null)
                                        return t2514IDData;

                                    t2514IDData = t2514ID_;
                                    return t2514IDData;
                                }
                            }
                        
                                private DataTable t2514ID_
                                {
                                    get
                                    {
                                        string condition = null;
condition += "P1896_2_64=";
condition += "false";
condition += " and P1896_2_63=";
condition += "true";


                                        string sort = null;sort = "P1896_2_57 DESC";

                                        int instanceID;
instanceID = (int)ShopChannel[IlgharCMS.SystemModule.Alias.Instance.InnerID];

                                        using (IlgharCMS.ShopModule.IGoods bll = (IlgharCMS.ShopModule.IGoods)Manager.CreateObject("Goods", instanceID, PageLang, false))
                                        {
                                            t2514IDData = bll.List(1, 10, condition, sort);
                                        }

                                        return t2514IDData;
                                    }
                                }
                            
                            protected string t2514
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t2514");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    
                                        replacementPair[@"{#BuildUrl()#}"] = new CustomBuild(
                                                                        delegate(DataRow record, int index)
                                                                        {
                                                                            object t2730 = BuildUrl(ShopChannel,"goods","ID=" + t2514ID.Rows[t2514IDCounter]["P1896_2_415"] + "&Ext=" + t2514ID.Rows[t2514IDCounter]["P1896_2_416"] + "&PageTemplate=" + t2514ID.Rows[t2514IDCounter]["P1896_2_414"]);
                                                                            if (t2730 != null)
                                                                                return t2730.ToString();
                                                                            else
                                                                                return String.Empty;
                                                                        }
                                                                        );
                                                replacementPair["{#Name#}"] = IlgharCMS.ShopModule.Alias.Goods.Name;replacementPair["{#Thumbnail#}"] = IlgharCMS.ShopModule.Alias.Goods.Thumbnail;
                                    StringBuilder all = Manager.Build(node, t2514ID_, replacementPair, ref t2514IDRecord, ref t2514IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                        protected int t3062IDRecordCount
                        {
                            get
                            {
                                int instanceID;
instanceID = (int)SystemChannel[IlgharCMS.SystemModule.Alias.Instance.InnerID];
                                using (IlgharCMS.SystemModule.ILink bll = (IlgharCMS.SystemModule.ILink)Manager.CreateObject("Link", instanceID, PageLang, false))
                                {
                                    string condition = null;
condition += "P2131_46_402=";
condition += "true";


                                    return bll.GetRecordCount(condition);
                                }
                            }
                        }
                        
                            protected int t3062IDCounter = 0;
                            protected object t3062IDRecord = null;
                            private DataTable t3062IDData;
                            protected DataTable t3062ID
                            {
                                get
                                {
                                    if (t3062IDData != null)
                                        return t3062IDData;

                                    t3062IDData = t3062ID_;
                                    return t3062IDData;
                                }
                            }
                        
                                private DataTable t3062ID_
                                {
                                    get
                                    {
                                        string condition = null;
condition += "P2131_46_402=";
condition += "true";


                                        string sort = null;

                                        int instanceID;
instanceID = (int)SystemChannel[IlgharCMS.SystemModule.Alias.Instance.InnerID];

                                        using (IlgharCMS.SystemModule.ILink bll = (IlgharCMS.SystemModule.ILink)Manager.CreateObject("Link", instanceID, PageLang, false))
                                        {
                                            t3062IDData = bll.List(-1, -1, condition, sort);
                                        }

                                        return t3062IDData;
                                    }
                                }
                            
                            protected string t3062
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t3062");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    replacementPair["{#URL#}"] = IlgharCMS.SystemModule.Alias.Link.URL;replacementPair["{#Name#}"] = IlgharCMS.SystemModule.Alias.Link.Name;replacementPair["{#Logo#}"] = IlgharCMS.SystemModule.Alias.Link.Logo;
                                    StringBuilder all = Manager.Build(node, t3062ID_, replacementPair, ref t3062IDRecord, ref t3062IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                            private int t3497IDCounter = 0;
                            private object t3497IDRecord = null;
                            private DataTable t3497ID_;
                            private DataTable t3497ID
                            {
                                get
                                {
                                    if (t3497ID_ != null)
                                        return t3497ID_;

                                    t3497ID_ = new DataTable();
                                    t3497ID_.Columns.Add("Name", typeof(string));
                                    t3497ID_.Columns.Add("URL", typeof(string));

                                    DataRow newRow = null;

                                    

                                    Guid parentID = (Guid)Channel[IlgharCMS.SystemModule.Alias.Channel.ParentID];
                                    while (parentID != Guid.Empty)
                                    {
                                        DataRow row = Manager.Channels.Select(IlgharCMS.SystemModule.Alias.Channel.ID + "='" + parentID + "'")[0];

                                        newRow = t3497ID_.NewRow();
                                        newRow["Name"] = row[IlgharCMS.SystemModule.Alias.Channel.Name + PageLang];
                                        string path = row[IlgharCMS.SystemModule.Alias.Channel.Path].ToString();
                                        if (Convert.IsDBNull(row[IlgharCMS.SystemModule.Alias.Channel.TemplatePath]))
                                            newRow["URL"] = path;
                                        else if (!String.IsNullOrEmpty(row[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString()))
                                            newRow["URL"] = row[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString().Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries) + row[IlgharCMS.SystemModule.Alias.Channel.DefaultDocument].ToString() + row[IlgharCMS.SystemModule.Alias.Channel.Extension];
                                        else if (!String.IsNullOrEmpty(Channel[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString()))
                                            newRow["URL"] = Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Domain] + path.TrimStart('/') + row[IlgharCMS.SystemModule.Alias.Channel.DefaultDocument].ToString() + row[IlgharCMS.SystemModule.Alias.Channel.Extension];
                                        else
                                            newRow["URL"] = Manager.GetWebPath() + path.TrimStart('/') + row[IlgharCMS.SystemModule.Alias.Channel.DefaultDocument].ToString() + row[IlgharCMS.SystemModule.Alias.Channel.Extension];
                                        if (newRow["URL"].ToString().StartsWith("/") && (Convert.ToBoolean(Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Fake404]) || Request.RawUrl.IndexOf("/ilghar.aspx?/") != -1))
                                            newRow["URL"] = Manager.GetWebPath() + "ilghar.aspx?" + newRow["URL"];
                                        t3497ID_.Rows.InsertAt(newRow, 0);

                                        parentID = (Guid)row[IlgharCMS.SystemModule.Alias.Channel.ParentID];
                                    }

                                    

                                    return t3497ID_;
                                }
                            }
                            protected string t3497
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t3497");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    replacementPair["{#URL#}"] = "URL";replacementPair["{#Name#}"] = "Name";
                                    StringBuilder all = Manager.Build(node, t3497ID, replacementPair, ref t3497IDRecord, ref t3497IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                            
                        private string t3850URL_ = null;
                        private string t3850URL
                        {
                            get
                            {
                                if (t3850URL_ != null)
                                    return t3850URL_;

                                t3850URL_ = BuildUrl(null, null, "Page={Page}");
                                return t3850URL_;
                            }
                        }
                        
                            private int t3850Page;
                            private int t3850PageCount;
                            private int t3850RecordCount;
                            private int t3850PageSize;
                            private int t3850Index;
                            protected string t3850
                            {
                                get
                                {
                                    t3850Page = Convert.ToInt32(PageNumber);
                                    if (t3850Page <= 0)
                                        t3850Page = 1;
                                    t3850PageSize = 5;
                                    t3850RecordCount = Convert.ToInt32(ListRecordCount);

                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t3850");

                                    StringBuilder all = new StringBuilder(node.SelectSingleNode("All").InnerText);

                                    t3850PageCount = t3850RecordCount / t3850PageSize;
                                    if (t3850RecordCount % t3850PageSize > 0)
                                        t3850PageCount += 1;

                                    if (!String.IsNullOrEmpty(Request.QueryString["GetPageCount"]))
                                        return t3850PageCount.ToString();

                                    //--------------------------------------
                                    //Start : FirstPage
                                    StringBuilder firstPage = new StringBuilder();
                                    string firstPageYesTpl = node.SelectSingleNode("FirstPage/Yes").InnerText;
                                    string firstPageNoTpl = node.SelectSingleNode("FirstPage/No").InnerText;
                                    if (t3850Page > 1)
                                    {
                                        firstPage.Append(firstPageNoTpl);
                                        object t4183 = t3850URL.Replace("{Page}", "1");
firstPage.Replace("{#t4183#}", t4183 == null ? "" : t4183.ToString());
object t4232 = t3850URL.Replace("{Page}", Convert.ToString(t3850Page - 1));
firstPage.Replace("{#t4232#}", t4232 == null ? "" : t4232.ToString());

                                    }
                                    else
                                    {
                                        firstPage.Append(firstPageYesTpl);
                                        
                                    }
                                    all.Replace("{#FirstPage#}", firstPage.ToString());
                                    //End : FirstPage
                                    //--------------------------------------

                                    //--------------------------------------
                                    //Start : CurrentPage
                                    StringBuilder currentPage = new StringBuilder();

                                    if (t3850PageCount > 1)
                                    {
                                        string currentPageYesTpl = node.SelectSingleNode("CurrentPage/Yes").InnerText;
                                        string currentPageNoTpl = node.SelectSingleNode("CurrentPage/No").InnerText;

                                        bool isAll = false;
                                        int pageEnd = 0;
                                        if (isAll)
                                        {
                                            t3850Index = 1;
                                            pageEnd = t3850PageCount;
                                        }
                                        else
                                        {
                                            t3850Index = t3850Page - 5;
                                            if (t3850Index <= 0)
                                                t3850Index = 1;

                                            pageEnd = t3850Page + 5;
                                            if (pageEnd > t3850PageCount)
                                                pageEnd = t3850PageCount;
                                        }

                                        while (t3850Index <= pageEnd)
                                        {
                                            if (t3850Index == t3850Page)
                                            {
                                                currentPage.Append(currentPageYesTpl);
                                                object t4399 = t3850Index;
currentPage.Replace("{#t4399#}", t4399 == null ? "" : t4399.ToString());

                                            }
                                            else
                                            {
                                                currentPage.Append(currentPageNoTpl);
                                                object t4477 = t3850URL.Replace("{Page}", Convert.ToString(t3850Index));
currentPage.Replace("{#t4477#}", t4477 == null ? "" : t4477.ToString());
object t4487 = t3850Index;
currentPage.Replace("{#t4487#}", t4487 == null ? "" : t4487.ToString());

                                            }
                                            t3850Index++;
                                        }
                                    }
                                    all.Replace("{#CurrentPage#}", currentPage.ToString());
                                    //End : CurrentPage
                                    //--------------------------------------

                                    //--------------------------------------
                                    //Start : LastPage
                                    StringBuilder lastPage = new StringBuilder();

                                    string lastPageYesTpl = node.SelectSingleNode("LastPage/Yes").InnerText;
                                    string lastPageNoTpl = node.SelectSingleNode("LastPage/No").InnerText;

                                    if (t3850Page < t3850PageCount)
                                    {
                                        lastPage.Append(lastPageNoTpl);
                                        object t4754 = t3850URL.Replace("{Page}", Convert.ToString(t3850Page + 1));
lastPage.Replace("{#t4754#}", t4754 == null ? "" : t4754.ToString());
object t4798 = t3850URL.Replace("{Page}", Convert.ToString(t3850PageCount));
lastPage.Replace("{#t4798#}", t4798 == null ? "" : t4798.ToString());

                                    }
                                    else
                                    {
                                        lastPage.Append(lastPageYesTpl);
                                        
                                    }
                                    all.Replace("{#LastPage#}", lastPage.ToString());
                                    //End : LastPage
                                    //--------------------------------------

                                    

                                    return all.ToString();
                                }
                            }
                          
                        protected int ListRecordCount
                        {
                            get
                            {
                                int instanceID;
instanceID = InstanceID;
                                using (IlgharCMS.GuestBookModule.IGuestBook bll = (IlgharCMS.GuestBookModule.IGuestBook)Manager.CreateObject("GuestBook", instanceID, PageLang, false))
                                {
                                    string condition = null;


                                    return bll.GetRecordCount(condition);
                                }
                            }
                        }
                        
                            protected int ListCounter = 0;
                            protected object ListRecord = null;
                            private DataTable ListData;
                            protected DataTable List
                            {
                                get
                                {
                                    if (ListData != null)
                                        return ListData;

                                    ListData = List_;
                                    return ListData;
                                }
                            }
                        
                                private DataTable List_
                                {
                                    get
                                    {
                                        string condition = null;


                                        string sort = null;

                                        int instanceID;
instanceID = InstanceID;

                                        using (IlgharCMS.GuestBookModule.IGuestBook bll = (IlgharCMS.GuestBookModule.IGuestBook)Manager.CreateObject("GuestBook", instanceID, PageLang, false))
                                        {
                                            ListData = bll.List(Convert.ToInt32(PageNumber), 5, condition, sort);
                                        }

                                        return ListData;
                                    }
                                }
                            
                            protected string t5018
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t5018");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    
                                        replacementPair["{#t5600#}"] = new CustomBuild(
                                                                        delegate(DataRow record, int index)
                                                                        {string t5600 = String.Empty;
if ((Convert.ToString(List.Rows[ListCounter][IlgharCMS.GuestBookModule.Alias.GuestBook.Reply])!=""))
{t5600 = _xmlTemplate.SelectSingleNode("/" + "/t5600/If").InnerText;}

                                                                            return t5600;
                                                                        }
                                                                        );
                                                
                                        replacementPair[@"{#HttpUtility.HtmlEncode(Convert.ToString(Content))#}"] = new CustomBuild(
                                                                        delegate(DataRow record, int index)
                                                                        {
                                                                            object t5531 = HttpUtility.HtmlEncode(Convert.ToString(List.Rows[ListCounter][IlgharCMS.GuestBookModule.Alias.GuestBook.Content]));
                                                                            if (t5531 != null)
                                                                                return t5531.ToString();
                                                                            else
                                                                                return String.Empty;
                                                                        }
                                                                        );
                                                replacementPair["{#Head#}"] = IlgharCMS.GuestBookModule.Alias.GuestBook.Head;replacementPair["{#Name#}"] = IlgharCMS.GuestBookModule.Alias.GuestBook.Name;replacementPair["{#Email#}"] = IlgharCMS.GuestBookModule.Alias.GuestBook.Email;replacementPair["{#QQ#}"] = IlgharCMS.GuestBookModule.Alias.GuestBook.QQ;replacementPair["{#CreateTime#}"] = IlgharCMS.GuestBookModule.Alias.GuestBook.CreateTime;replacementPair["{#Subject#}"] = IlgharCMS.GuestBookModule.Alias.GuestBook.Subject;replacementPair["{#Reply#}"] = IlgharCMS.GuestBookModule.Alias.GuestBook.Reply;
                                    StringBuilder all = Manager.Build(node, List_, replacementPair, ref ListRecord, ref ListCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                            private string t8222BuildUrl(DataRow record)
                            {
                                string url = record[IlgharCMS.SystemModule.Alias.Menu.Path].ToString();
                                if (url.StartsWith("http://") || url.StartsWith("/"))
                                {
                                    if (url.StartsWith("/") && (Convert.ToBoolean(Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Fake404]) || Request.RawUrl.IndexOf("/ilghar.aspx?/") != -1))
                                        return Manager.GetWebPath() + "ilghar.aspx?" + url;
                                    else
                                        return url;
                                }

                                DataRow[] rows = Manager.Channels.Select(IlgharCMS.SystemModule.Alias.Channel.ID + "='" + record[IlgharCMS.SystemModule.Alias.Menu.ChannelID] + "'");
                                if (rows.Length == 0)
                                    return url;

                                DataRow channel = rows[0];
                                if (!Convert.IsDBNull(Channel[IlgharCMS.SystemModule.Alias.Channel.TranslateLang]))
                                {
                                    string instance = null;
                                    if (Convert.IsDBNull(channel[IlgharCMS.SystemModule.Alias.Instance.ID]))
                                        instance = IlgharCMS.SystemModule.Alias.Instance.ID + " IS NULL AND ";
                                    else
                                        instance = IlgharCMS.SystemModule.Alias.Instance.ID + "='" + channel[IlgharCMS.SystemModule.Alias.Instance.ID] + "' AND ";
                                    rows = Manager.Channels.Select(IlgharCMS.SystemModule.Alias.Channel.ID + " IS NOT NULL AND " + instance + IlgharCMS.SystemModule.Alias.Channel.TemplateLang + "='" + Channel[IlgharCMS.SystemModule.Alias.Channel.TemplateLang] + "' AND " + IlgharCMS.SystemModule.Alias.Channel.TranslateLang + "='" + Channel[IlgharCMS.SystemModule.Alias.Channel.TranslateLang] + "'");
                                    if (rows.Length > 0)
                                        channel = rows[0];
                                }

                                string content = record[IlgharCMS.SystemModule.Alias.Menu.Content].ToString();
                                if (!String.IsNullOrEmpty(content))
                                {
                                    if (!Convert.IsDBNull(record[IlgharCMS.SystemModule.Alias.Menu.PageTemplate]))
                                    {
                                        if (record[IlgharCMS.SystemModule.Alias.Menu.PageExtension].ToString() == String.Empty)
                                            url = BuildUrl(channel, record[IlgharCMS.SystemModule.Alias.Menu.PageTemplate].ToString(), "ID=" + record[IlgharCMS.SystemModule.Alias.Menu.PageID] + "&Ext=" + channel[IlgharCMS.SystemModule.Alias.Channel.Extension]);
                                        else
                                            url = BuildUrl(channel, record[IlgharCMS.SystemModule.Alias.Menu.PageTemplate].ToString(), "ID=" + record[IlgharCMS.SystemModule.Alias.Menu.PageID] + "&Ext=" + record[IlgharCMS.SystemModule.Alias.Menu.PageExtension]);
                                    }
                                    else
                                    {
                                        rows = Manager.Pages.Select(IlgharCMS.SystemModule.Alias.Template.Page.TemplatePath + "='" + channel[IlgharCMS.SystemModule.Alias.Channel.TemplatePath] + "' AND " + IlgharCMS.SystemModule.Alias.Template.Page.Mark + "='System' AND " + IlgharCMS.SystemModule.Alias.Template.Page.Object + "='Menu'");
                                        if (rows.Length == 0)
                                        {
                                            url = String.Empty;
                                        }
                                        else
                                        {
                                            if (record[IlgharCMS.SystemModule.Alias.Menu.PageExtension].ToString() == String.Empty)
                                                url = BuildUrl(channel, rows[0][IlgharCMS.SystemModule.Alias.Template.Page.PathInTemplate].ToString(), "ID=" + record[IlgharCMS.SystemModule.Alias.Menu.PageID] + "&Ext=" + channel[IlgharCMS.SystemModule.Alias.Channel.Extension]);
                                            else
                                                url = BuildUrl(channel, rows[0][IlgharCMS.SystemModule.Alias.Template.Page.PathInTemplate].ToString(), "ID=" + record[IlgharCMS.SystemModule.Alias.Menu.PageID] + "&Ext=" + record[IlgharCMS.SystemModule.Alias.Menu.PageExtension]);
                                        }
                                    }
                                }
                                else
                                {
                                    string channelPath = String.Empty;
                                    if (!String.IsNullOrEmpty(channel[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString()))
                                    {
                                        Uri domain = new Uri(channel[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString().Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[0]);
                                        if (channel == Channel)
                                            channelPath = domain.LocalPath;
                                        else
                                            channelPath = domain.ToString();
                                    }
                                    else if (!String.IsNullOrEmpty(Channel[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString()))
                                    {
                                       channelPath = Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Domain].ToString() + channel[IlgharCMS.SystemModule.Alias.Channel.Path].ToString().TrimStart('/');
                                    }
                                    else
                                    {
                                        channelPath = channel[IlgharCMS.SystemModule.Alias.Channel.Path].ToString();
                                        
                                    }
                                    if (!String.IsNullOrEmpty(url))
                                    {
                                        url = channelPath + url;
                                        url = url.Replace(".ext", channel[IlgharCMS.SystemModule.Alias.Channel.Extension].ToString());
                                    }
                                    else
                                    {
                                        url = channelPath + channel[IlgharCMS.SystemModule.Alias.Channel.DefaultDocument].ToString() + channel[IlgharCMS.SystemModule.Alias.Channel.Extension];
                                    }

                                    if (Convert.ToBoolean(Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Fake404]) || Request.RawUrl.IndexOf("/ilghar.aspx?/") != -1)
                                        url = Manager.GetWebPath() + "ilghar.aspx?" + url;
                                }

                                return url;
                            }

                            private int t8222IDCounter = 0;
                            private object t8222IDRecord = null;
                            private DataTable t8222ID;
                            private DataTable t8222ID_
                            {
                                get
                                {
                                    string condition = null;
condition += "P2131_24_264=";
condition += "{BAC035A8-F6BB-4772-8D51-A7F4F3AB7AD3}";


                                    string sort = null;

                                    using (IlgharCMS.SystemModule.IMenu bll = (IlgharCMS.SystemModule.IMenu)Manager.CreateObject("Menu", SystemInstanceID, PageLang, false))
                                    {
                                        t8222ID = bll.List(-1, -1, condition, sort);
                                    }

                                    return t8222ID;
                                }
                            }
                            protected string t8222
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t8222");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    
                                        replacementPair["{#URL#}"] = new CustomBuild(
                                                                        delegate(DataRow record, int index)
                                                                        {
                                                                            return t8222BuildUrl(record);
                                                                        }
                                                                        );
                                                replacementPair["{#Target#}"] = IlgharCMS.SystemModule.Alias.Menu.Target;replacementPair["{#Name#}"] = IlgharCMS.SystemModule.Alias.Menu.Name;
                                    StringBuilder all = Manager.Build(node, t8222ID_, replacementPair, ref t8222IDRecord, ref t8222IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          }
