using System.Collections.Generic;
using System.Text;

namespace Stat.Html
{
    public class FrendLink
    {
        /// <summary>
        /// 获取图片友情链接
        /// </summary>
        /// <param name="list"></param>
        /// <param name="img_w"></param>
        /// <param name="img_h"></param>
        /// <returns></returns>
        public static string GetImg(IList<Stat.Model.FriendLink> list,int img_w, int img_h)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < list.Count; i++)
            {
                sb.Append("<a href=\"" + list[i].LinkURL + "\" target=\"_blank\" title=\"" + list[i].LinkName + "\"><img src=\"" + list[i].LinkImgPath + "\" border=0 width=" + img_w + " height=" + img_h + " alt=\"" + list[i].LinkName + "\"></a>");
            }
            return sb.ToString();

        }
        /// <summary>
        /// 获取图片友情链接（图文）
        /// </summary>
        /// <param name="num"></param>
        /// <param name="img_w"></param>
        /// <param name="img_h"></param>
        ///<param name="cType">0：一般，1：赞助商</param>
        /// <returns></returns>
        public static string GetImg_Txt(IList<Stat.Model.FriendLink> list, int img_w, int img_h)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < list.Count; i++)
            {
                sb.Append("<div class=\"zzs_img_box\">");
                sb.Append("<div style=\"clear:both;\">");
                sb.Append("<a href=\"" + list[i].LinkURL + "\" target=\"_blank\" title=\"" + list[i].LinkName + "\"><img src=\"" + list[i].LinkImgPath + "\" border=0 width=" + img_w + " height=" + img_h + " alt=\"" + list[i].LinkName + "\"></a>");
                sb.Append("</div><div style=\"clear:both; margin-top:4px;\">" + list[i].LinkName + "</div>");
                sb.Append("</div>");

            }
            return sb.ToString();

        }
        ///// <summary>
        ///// 获取图片友情链接（图文）
        ///// </summary>
        ///// <param name="num"></param>
        ///// <param name="img_w"></param>
        ///// <param name="img_h"></param>
        ///// <param name="cType">2：LOGO</param>
        ///// <param name="Position">0,1,2,3</param>
        ///// <returns></returns>
        //public static string GetImg_Txt(IList<Stat.Model.FriendLink> list, int img_w, int img_h)
        //{
        //    StringBuilder sb = new StringBuilder();
        //    for (int i = 0; i < list.Count; i++)
        //    {
        //        sb.Append("<div class=\"tj_img_box\">");
        //        sb.Append("<div style=\"clear:both;\">");
        //        sb.Append("<a href=\"" + list[i].LinkURL + "\" target=\"_blank\" title=\"" + list[i].LinkName + "\"><img src=\"" + list[i].LinkImgPath + "\" border=0 width=" + img_w + " height=" + img_h + " alt=\"" + list[i].LinkName + "\"></a>");
        //        sb.Append("</div><div style=\"clear:both; margin-top:5px;\">" + list[i].LinkName + "</div>");
        //        sb.Append("</div>");

        //    }
        //    return sb.ToString();

        //}

        /// <summary>
        /// 获取图片友情链接（Js）
        /// </summary>
        /// <param name="num"></param>
        /// <param name="img_w"></param>
        /// <param name="img_h"></param>
        /// <param name="cType">2：LOGO</param>
        /// <param name="Position">0,1,2,3</param>
        /// <returns></returns>
        public static string GetImg_Js(IList<Stat.Model.FriendLink> list, int img_w, int img_h)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<div id=\"imgADPlayer2\"></div>");
            sb.Append("<SCRIPT>");
            for (int i = 0; i < list.Count; i++)
            {
                sb.Append("PImgPlayer.addItem(\"" + list[i].LinkName + "\", \"" + list[i].LinkURL + "\", \"" + list[i].LinkImgPath + "\");");
            }
            sb.Append("PImgPlayer.init(\"imgADPlayer2\", " + img_w + "," + img_h + ");");
            sb.Append("</SCRIPT>");
            return sb.ToString();
        }
        /// <summary>
        /// 获取友情链接（文本）
        /// </summary>
        /// <param name="num">总数</param>
        /// <param name="cType"></param>
        /// <returns></returns>
        public static string GetText(IList<Stat.Model.FriendLink> list)
        {
            StringBuilder sb = new StringBuilder();            
            for (int i = 0; i < list.Count; i++)
            {
                sb.Append("<a href=\"" + list[i].LinkURL + "\" target=\"_blank\" title=\"" + list[i].LinkName + "\">" + list[i].LinkName + "</a>");
            }
            return sb.ToString();
        }
    }
}
