﻿var char1 = "\x1c";
var char2 = "\x1d";

//新闻图片array
var NewsPictList = new Array();
var serviceTrainList = new Array();
var InfomationShareLeftList = new Array();
var InfomationShareRightList = new Array();


//明星企业array
var StarCompanyScrollerArray = new Array();

function PictureNews(picsrc, url, title, content) {
    this.PicSrc = picsrc;
    this.Url = url;
    this.Title = title;
    this.Content = content;
}

//新闻图片切换
function switchNewsPicts() 
{
    if (!NewsPictList || NewsPictList.length <= 0)
        NewsPictList = getArrayList(newsPictStr);

    var tempArray = NewsPictList;

    if (tempArray && tempArray.length > 0) {
        var sw = new ContentSwitcher();
        var cv = sw.AddCanvas("newsImgs", 137, 110);
        cv.ControlPanelTop = 96;
        cv.ControlPanelLeft = 50;
        if (tempArray && tempArray.length > 0) {
            for (var picArrayIndex in tempArray) {
                var pic = tempArray[picArrayIndex];

                //                var html = "<div class='news_img'><a href='" + pic.Url + "'>" +
                //                            "<img onerror=\"this.src='images/newsimg.jpg'\" src='" + pic.PicSrc + "' alt='" + pic.Title + "' border='0' /></a></div>" +
                //                        "<div class='news_text_div2'>" +
                //                            "<a href='" + pic.Url + "'>"+pic.Content +"<a>"
                //                        "</div>";
                var html = "<a href='" + pic.Url + "' target='_blank'>" +
                "<img onerror=\"this.src='images/syxgt.jpg'\" src='" + pic.PicSrc + "' alt='" + pic.Title + "' width='118' height='92' /></a>" +
                "";
                cv.AddContent(new HTMLContent(html));
            }
        }
        sw.Interval = 6000;
        sw.Start();
    }
}

//服务直通车
function switchServiceTrain(id) {
    var li = document.getElementById("liServiceTrain");
    li.innerHTML = serviceTrainList[id];
}


function InitServiceTrainArray() {
    var serviceTrainStr = document.getElementById("hidServiceTrain").value;

    if (serviceTrainStr && serviceTrainStr.length > 0) {
        var s = serviceTrainStr.split(char2);
        if (s && s.length > 0) {
            for (var index in s) {
                var ss = s[index].split(char1);
                if (ss && ss.length == 2) {
                    serviceTrainList[ss[0]] = ss[1];
                }
            }
        }
    }
}

//信息共享
function switchInfomationShare(id) {
    var ulLeft = document.getElementById("ulInfomationShareLeft");
    var ulRight = document.getElementById("ulInfomationShareRight");

    ulLeft.innerHTML = InfomationShareLeftList[id];
    ulRight.innerHTML = InfomationShareRightList[id];
}


function InitInfomationShareArray() {
    var InfomationShareLeftStr = document.getElementById("hidInfomationShareLeft").value;
    var InfomationShareRightStr = document.getElementById("hidInfomationShareRight").value;

    if (InfomationShareLeftStr && InfomationShareLeftStr.length > 0) {
        var sLeft = InfomationShareLeftStr.split(char2);
        var sRight = InfomationShareRightStr.split(char2);
        if (sLeft && sLeft.length > 0) {
            for (var index in sLeft) {
                var ssLeft = sLeft[index].split(char1);
                var ssRight = sRight[index].split(char1);
                if (ssLeft && ssLeft.length == 2) {
                    InfomationShareLeftList[ssLeft[0]] = ssLeft[1];
                    InfomationShareRightList[ssRight[0]] = ssRight[1];
                }
            }
        }
    }
}



function getArrayList(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 PictureNews(ss[0], ss[1], ss[2], ss[3]));
                }
            }
        }
    }
    return temp;
}




function FillScroller() {
    var StarCompanyInfo = document.getElementById("hidStarCompanyInfo").value;
    var StarCompanyCount = document.getElementById("hidStarCompanyCount").value;
    StarCompanyScrollerArray[0] = GetScroller("star_text_div", StarCompanyInfo, StarCompanyCount > 23);

    var tb = document.getElementById("star_text_div");
    if (tb) {
       
        StarCompanyScrollerArray[0].Start();
    }

}


function GetScroller(aContenterID, aHtml, aRollAble) {

    var sc = new Scroller("up", 500, 3);
    if (aRollAble == null)
        aRollAble = true;
    sc.RollAble = aRollAble;

    var can = sc.AddCanvas(aContenterID, 600, 30);
    if (can) {
        can.AddContent(aHtml);
    }
    return sc;
}
