﻿

    function BindImageForBannerTopRightRoll(NewIndex) {

        if(NewIndex == BannerTopRightRollIndex) return;

        var ImagePath   = BannerImagePath;
        var DisplayData = BannerTopRightRollData[NewIndex].split("|");

        if(DisplayData.length != 3) return;

        ImagePath                 += DisplayData[0];
        BannerTopRightRollLinkUrl  = DisplayData[1];
        BannerTopRightRollTarget   = DisplayData[2];

        self.document.getElementById(IdAreaForTopRightRoll).style.backgroundImage = "url('" + ImagePath + "')";

        ToggleNumberForBannerTopRightRoll(NewIndex);

        BannerTopRightRollIndex = NewIndex;

    }





    function ToggleNumberForBannerTopRightRoll(NewIndex) {

        var TargetId          = Head_IdNumberForTopRightRoll;
        var TargetImagePath   = "/img/Share/Icon/Number/";
        var FooterActiveImage = "_on"
        var FileExt           = ".gif";

        self.document.getElementById( (TargetId+NewIndex) ).src = (TargetImagePath + (NewIndex+1) + FooterActiveImage + FileExt);


        if(BannerTopRightRollIndex > -1 && NewIndex != BannerTopRightRollIndex)
            self.document.getElementById( (TargetId+BannerTopRightRollIndex) ).src = (TargetImagePath + (BannerTopRightRollIndex+1) + FileExt);

    }





    function BindNumberForBannerTopRightRoll() {

        var TargetId;

        for(var Count = 0; Count < BannerTopRightRollCount; Count++) {

            TargetId = Head_IdNumberForTopRightRoll + Count;
            self.document.getElementById(TargetId).style.display = "inline";

        }


    }





    function SelectForTopRightRoll(Index) {

        if(BannerTopRightRollCount <= 0) return;

        if(Index > -1) {
            BindImageForBannerTopRightRoll(Index);
            return;
        }

        StopForBannerTopRightRoll = true;
        window.clearTimeout(TimeIdForBannerTopRightRoll);

//        BindImageForBannerTopRightRoll(Index);

    }





    function UnSelectForTopRightRoll(Index) {

        if(BannerTopRightRollCount <= 0) return;

        if(Index > -1) return;

        StopForBannerTopRightRoll = false;
        TimeIdForBannerTopRightRoll = window.setTimeout("ChangeImageForBannerTopRightRoll()", BannerTopRightRollSpeed);

    }




    function ChangeImageForBannerTopRightRoll() {

        if(StopForBannerTopRightRoll) return;

        var NewIndex = BannerTopRightRollIndex; 

        NewIndex++;

        if(NewIndex >= BannerTopRightRollCount)
            NewIndex = 0;


        BindImageForBannerTopRightRoll(NewIndex);


        TimeIdForBannerTopRightRoll = window.setTimeout("ChangeImageForBannerTopRightRoll()", BannerTopRightRollSpeed);

    }





    function BannerLinkForTopRightRoll() {

        if(BannerTopRightRollCount <= 0) return;

        if(BannerTopRightRollTarget.toUpperCase() == "_BLANK")
            window.open(BannerTopRightRollLinkUrl);
        else
            self.location.href = BannerTopRightRollLinkUrl;

    }





    var BannerTopRightRollData;

    var BannerTopRightRollCount = 0, BannerTopRightRollIndex = -1;
    var StopForBannerTopRightRoll = false;
    var TimeIdForBannerTopRightRoll;


    var Head_IdNumberForTopRightRoll = "IdNumberForTopRightRoll_";
    var IdAreaForTopRightRoll        = "IdAreaForTopRightRoll";

    var BannerTopRightRollLinkUrl, BannerTopRightRollTarget;


    function BindBannerTopRightRoll() {

        if(BannerTopRightRoll == "") return;


        BannerTopRightRollData  = BannerTopRightRoll.split("*");
        BannerTopRightRollCount = BannerTopRightRollData.length;

        if(BannerTopRightRollCount <= 0) return;

        if(BannerTopRightRollCount > BannerTopRightRollCountMax) BannerTopRightRollCount = BannerTopRightRollCountMax;

        BindImageForBannerTopRightRoll(0);
        BindNumberForBannerTopRightRoll();

        TimeIdForBannerTopRightRoll = window.setTimeout("ChangeImageForBannerTopRightRoll()", BannerTopRightRollSpeed);

    }










    function BindBannerForTopCenter() {

        if(BannerTopCenter == "") return;


        var BannerData = BannerTopCenter.split("*");
        var DataCount  = BannerData.length;

        if(DataCount <= 0) return;


        var DisplayIndex = BannerRotateCount % DataCount;
        var DisplayData  = BannerData[DisplayIndex].split("|");

        if(DisplayData.length != 3) return;

        self.document.getElementById("BannerImgIdForTopCenter").src     = BannerImagePath + DisplayData[0];
        self.document.getElementById("BannerLinkIdForTopCenter").href   = DisplayData[1];
        self.document.getElementById("BannerLinkIdForTopCenter").target = DisplayData[2];

    } 





    function BindBannerForBottomHot() {

        if(BannerBottomHot == "") return;


        var BannerData = BannerBottomHot.split("*");
        var DataCount  = BannerData.length;

        if(DataCount <= 0) return;


        var DisplayData = BannerData[0].split("|");

        self.document.getElementById("BannerImgIdForBottomHot1").src     = BannerImagePath + DisplayData[0];
        self.document.getElementById("BannerLinkIdForBottomHot1").href   = DisplayData[1];
        self.document.getElementById("BannerLinkIdForBottomHot1").target = DisplayData[2];


        if(DisplayData.length < 2) return;

        DisplayData = BannerData[1].split("|");

        self.document.getElementById("BannerImgIdForBottomHot2").src     = BannerImagePath + DisplayData[0];
        self.document.getElementById("BannerLinkIdForBottomHot2").href   = DisplayData[1];
        self.document.getElementById("BannerLinkIdForBottomHot2").target = DisplayData[2];

    } 