using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Contact_Folders : System.Web.UI.Page
{
    protected override void InitializeCulture()
    {
        string defLang = WebUser.CurrentUser.UiLanguage;
        Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(defLang);
        Thread.CurrentThread.CurrentUICulture = new CultureInfo(defLang);
        base.InitializeCulture();
    }

    protected void Page_Init(object sender, EventArgs e)
    {
        WebUtil.SetMcCommonCss(Page.Header);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Page.Title = AppSetting.GetTitleInfo(Request).Title;
        }
    }

    protected string GetIndent(int indent)
    {
        return (indent * 16).ToString();
    }

    protected string GetFolderInfo(ContactUtil.Type type, string id, string folderName, ContactUtil.FolderFlag flag)
    {
        string html = "";
        folderName = Server.HtmlEncode(folderName);
        switch (type)
        {
            case ContactUtil.Type.Favorite:
                //html = string.Format("<img src='../Images/Contact/{0}' /> {1}", ContactUtil.GetAddrbookImageName(flag), folderName);
                html = string.Format("{0} {1}", FontIcon.ContactFavorate, folderName);
                break;
            case ContactUtil.Type.Private:
                //html = string.Format("<img src='../Images/Contact/{0}' /> {1}", ContactUtil.GetAddrbookImageName(flag), folderName);
                html = string.Format("{0} {1}", ContactUtil.GetAddrbookFontIcon(flag), folderName);
                break;
            case ContactUtil.Type.Share:
                if (id == ContactUtil.ShareID)
                {
                    //html = string.Format("<img src='../Images/Contact/{0}' /> {1}", ContactUtil.GetAddrbookImageName(flag), folderName);
                    html = string.Format("{0} {1}", FontIcon.ContactShareRoot, folderName);
                }
                else
                {
                    //html = string.Format("<img src='../Images/Contact/{0}' /> {1}", ContactUtil.GetAddrbookImageName(flag), folderName);
                    html = string.Format("{0} {1}", ContactUtil.GetAddrbookFontIcon(flag), folderName);
                }
                break;
            case ContactUtil.Type.Organization:
                if (id == ContactUtil.OrgzID)
                {
                    html = string.Format("<img src='../Images/Contact/orgz_16.gif' /> {0}", folderName);
                }
                else
                {
                    html = string.Format("<img src='../Images/Contact/orgz_16.gif' /> {0}", folderName);
                }
                break;
        }
        return html;
    }

    protected string GetClickEventFunction(ContactUtil.Type type, string id)
    {
        string script = "";
        switch (type)
        {
            case ContactUtil.Type.Favorite:
                script = string.Format("location.href = 'List.aspx?folder={0}'", Guid.Empty);
                break;
            case ContactUtil.Type.Private:
                script = string.Format("location.href = 'List.aspx?folder={0}'", id);
                break;
            case ContactUtil.Type.Share:
                if (id == ContactUtil.ShareID)
                {
                    script = "";
                }
                else
                {
                    script = string.Format("location.href = 'List.aspx?folder={0}'", id);
                }
                break;
            case ContactUtil.Type.Organization:
                if (id == ContactUtil.OrgzID)
                {
                    script = "";
                }
                else
                {
                    script = string.Format("location.href = 'Organization.aspx?orgz={0}'", id);
                }
                break;
        }
        return script;
    }
}