﻿
function CTranFilter()
{
    this.filterStr = "";
    this.filterName = "";

    this.SetAsBarn = function (duration, orientation, motion)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.Barn(" +
                         "enabled=false, duration=" + duration + ", orientation=" + orientation + ", motion=" + motion + ")";
        this.filterName = "DXImageTransform.Microsoft.Barn";
    }
    

    this.SetAsBlendTrans = function (duration)
    {
        this.filterStr = "BlendTrans(" +
                         "duration=" + duration + ")";
        this.filterName = "BlendTrans";
    }

    this.SetAsBlinds = function (duration, bands, direction)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.Blinds(" +
                         "enabled=false, duration=" + duration + ", bands=" + bands　+ ", direction=" + direction + ")";
        this.filterName = "DXImageTransform.Microsoft.Blinds";
    }
    

    this.SetAsCheckerBoard = function (duration, squaresX, squaresY, direction)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.CheckerBoard(" +
                         "enabled=false, duration=" + duration +
                         ", squaresX=" + squaresX + ", squaresY=" + squaresY + ", direction=" + direction + ")";
        this.filterName = "DXImageTransform.Microsoft.CheckerBoard";
    }

    this.SetAsFade = function (duration, overlap)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.Fade(" +
                         "enabled=false, duration=" + duration + ", overlap=" + overlap　+ ")";
        this.filterName = "DXImageTransform.Microsoft.Fade";
    }

    this.SetAsGradientWipe = function (duration, gradientSize, wipeStyle, motion)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.GradientWipe(" +
                         "enabled=false, duration=" + duration + ", gradientSize=" + gradientSize +
                         ", wipeStyle=" + wipeStyle + ", motion=" + motion + ")";
        this.filterName = "DXImageTransform.Microsoft.GradientWipe";
    }
        this.SetAsInset = function (duration)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.Inset(" +
                         "enabled=false, duration=" + duration + ")";
        this.filterName = "DXImageTransform.Microsoft.Inset";
    }

    this.SetAsIris = function (duration, irisStyle, motion)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.Iris(" +
                         "enabled=false, duration=" + duration + ", irisStyle=" + irisStyle + ", motion=" + motion + ")";
        this.filterName = "DXImageTransform.Microsoft.Iris";
    }

    this.SetAsPixelate = function (duration, maxSquare)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.Pixelate(" +
                         "enabled=false, duration=" + duration + ", maxSquare=" + maxSquare + ")";
        this.filterName = "DXImageTransform.Microsoft.Pixelate";
    }

    this.SetAsRadialWipe = function (duration, wipeStyle)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.RadialWipe(" +
                         "enabled=false, duration=" + duration + ", wipeStyle=" + wipeStyle + ")";
        this.filterName = "DXImageTransform.Microsoft.RadialWipe";
    }

    this.SetAsRandomBars = function (duration, orientation)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.RandomBars(" +
                         "enabled=false, duration=" + duration + ", orientation=" + orientation + ")";
        this.filterName = "DXImageTransform.Microsoft.RandomBars";
    }

    this.SetAsRandomDissolve = function (duration)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.RandomDissolve(" +
                         "enabled=false, duration=" + duration + ")";
        this.filterName = "DXImageTransform.Microsoft.RandomDissolve";
    }
 
    this.SetAsSlide = function (duration, bands, slideStyle)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.Slide(" +
                         "enabled=false, duration=" + duration + ", bands=" + bands + ", slideStyle=" + slideStyle + ")";
        this.filterName = "DXImageTransform.Microsoft.Slide";
    }

    this.SetAsSpiral = function (duration, gridSizeX, gridSizeY)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.Spiral(" +
                         "enabled=false, duration=" + duration +
                         ", gridSizeX=" + gridSizeX + ", gridSizeY=" + gridSizeY + ")";
        this.filterName = "DXImageTransform.Microsoft.Spiral";
    }

    this.SetAsStretch = function (duration, stretchStyle)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.Stretch(" +
                         "enabled=false, duration=" + duration + ", stretchStyle=" + stretchStyle + ")";
        this.filterName = "DXImageTransform.Microsoft.Stretch";
    }
    

    this.SetAsStrips = function (duration, motion)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.Strips(" +
                         "enabled=false, duration=" + duration + ", motion=" + motion + ")";
        this.filterName = "DXImageTransform.Microsoft.Strips";
    }
    

    this.SetAsWheel = function (duration, spokes)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.Wheel(" +
                         "enabled=false, duration=" + duration + ", spokes=" + spokes + ")";
        this.filterName = "DXImageTransform.Microsoft.Wheel";
    }

    this.SetAsZigzag = function (duration, gridSizeX, gridSizeY)
    {
        this.filterStr = "progid:DXImageTransform.Microsoft.Zigzag(" +
                         "enabled=false, duration=" + duration +
                         ", gridSizeX=" + gridSizeX + ", gridSizeY=" + gridSizeY + ")";
        this.filterName = "DXImageTransform.Microsoft.Zigzag";
    }
}

function CTranExhibition(objStr, targetStr, msgDelay)
{
    this.objStr = objStr;
    this.target = document.getElementById(targetStr);
    this.msgDelay = msgDelay;
    this.filter = new CTranFilter;
    

    this.msgIndex = -1; 
    this.msgFrom = 1; 
    this.msgArr = null; 
    this.msgBlock = null; 

    this.timer = null;
    
    this.PrepareMsgData = CTranExhibition_PrepareMsgData;
    this.GetMsgData = CTranExhibition_GetMsgData;
    this.ShowMsg = CTranExhibition_ShowMsg;
}


function CTranExhibition_PrepareMsgData(msgIndex, msgFrom, msgArr, msgBlockStr)
{
    this.msgIndex = msgIndex;
    this.msgFrom = msgFrom;
    this.msgArr = msgArr;
    this.msgBlock = document.getElementById(msgBlockStr);

    var i = 0;
    var j = 0;
    var k = 0;
    for (i=0; i<this.msgFrom; i++)
    {
        var str = "";
        var strp = "";
        for (j=0; j<i; j++)
        {
            str += ".childNodes[0]";
            strp += ".childNodes[0]";
        }
        str += ".childNodes";

        for (k=0; k<eval("this.msgBlock" + str + ".length"); k++)
        {
            if (eval("this.msgBlock" + str + "[k].nodeType") == 3)
            {
                var objp = eval("this.msgBlock" + strp);
                objp.removeChild(eval("this.msgBlock" + str + "[k]"));
            }
        }
    }
}

function CTranExhibition_GetMsgData()
{
    if (this.msgFrom == 0)
    {
        this.msgIndex = ((++this.msgIndex)<this.msgArr.length)?this.msgIndex:0;
        return this.msgArr[this.msgIndex];
    }
    else if (this.msgFrom > 0)
    {
        var i = 0;
        var str = "";
        for (i=0; i<(this.msgFrom-1); i++)
        {
            str += ".childNodes[0]";
        }
        str += ".childNodes";
        
        this.msgIndex = ((++this.msgIndex)<eval("this.msgBlock" + str + ".length"))?this.msgIndex:0;
        return eval("this.msgBlock" + str + "[this.msgIndex].innerHTML");
    }
    else
    {
        return "";
    }
}

function CTranExhibition_ShowMsg()
{
   
    try
    {
   
        this.target.style.filter = this.filter.filterStr;
        this.target.filters.item(this.filter.filterName).apply();
        this.target.style.visibility = "hidden";
        this.target.filters.item(this.filter.filterName).play();
    }
    catch (e)
    {
  
        this.target.style.visibility = "hidden";
    }
 
    this.target.innerHTML = this.GetMsgData();
 
    this.target.style.visibility = "visible";

    this.timer = setTimeout(this.objStr+".ShowMsg()", this.msgDelay);
}
