﻿var char1 = "\x1c";
var char2 = "\x1d";

//热点话题图片列表
var hotNewsPicList = new Array();

function Pictures(src, url, title, alt)
{
    this.Src = src;
    this.Url = url;
    this.Title = title;
    this.alt = alt;
}
function PageLoad()
{
    switchhotNewsPicts();
}
function getPictureList(infoStr)
{
    var temp = new Array();
    if (infoStr && infoStr.length > 0)
    {
        var s = infoStr.split(char2);
        if (s && s.length > 0)
        {
            for (var index in s)
            {
                var ss = s[index].split(char1);
                if (ss && ss.length ==4)
                {
                    temp.push(new Pictures(ss[0], ss[1], ss[2], ss[3]));
                }
            }
        }
    }
    return temp;
}
//热点话题图片切换
function switchhotNewsPicts()
{
    if (!hotNewsPicList || hotNewsPicList.length <= 0)
    {
        var hotNewsPicStr = document.getElementById("hidhotNewsPic").value;
        hotNewsPicList = getPictureList(hotNewsPicStr);
    }
    var tempArray = hotNewsPicList;


    if (tempArray && tempArray.length > 0)
    {
        var sw = new ContentSwitcher();
        var cv = sw.AddCanvas("divNewsPic", 280, 190,"margin:5px 4px");
        if (tempArray && tempArray.length > 0)
        {
            for (var picArrayIndex in tempArray)
            {
                var pic = tempArray[picArrayIndex];
                var html;
                if (pic.Url != "")
                    html = "<a href='" + pic.Url + "'><img title='" + pic.Title + "' src='" + pic.Src + "' width='277px' height='187px' style='margin:0 0 0 0' /></a>";
                else
                    html = "<img src='" + pic.Src + "' title='" + pic.Title + "' width='277px' height='187px' style='margin:0 0 0 0' />";           
                cv.AddContent(new HTMLContent(html));
            }
        }
        sw.Start();
    }
}
