﻿function floatBox(){}
floatBox.prototype = {
	name:null,
	positionY:0,
	init:function(){
		$(this.name).style.top = document.documentElement.clientHeight - $(this.name).offsetHeight + "px";
		return parseInt($(this.name).style.top);
		},
	toScroll:function(){
		$(this.name).style.top = this.positionY + document.documentElement.scrollTop + "px";
		}
	}
var floatBox1 = new floatBox();
window.onload=function(){
	
	floatBox1.name = "floatBox";
	floatBox1.positionY = floatBox1.init();
window.onscroll=function(){
	floatBox1.toScroll();
	}
	}
function NarrowBox(){
var arrDD=$("floatBox").getElementsByTagName("dd");
var bDT=$("floatBox").getElementsByTagName("dt")[0];
bDT.style.height="15px";
for(var i=0;i<arrDD.length;i++){
arrDD[i].style.display="none";
$("floatBox").style.width="90px";
}
}
function EnlargeBox(){
var arrDD=$("floatBox").getElementsByTagName("dd");
var bDT=$("floatBox").getElementsByTagName("dt")[0];
bDT.style.height="30px";
for(var i=0;i<arrDD.length;i++){
arrDD[i].style.display="block";
$("floatBox").style.width="190px";

}

}
function CloseBox(){
$("floatBox").style.display="none";
}			

function ImagePlay(Imgs, ImgCtl, Msec, WordCtl, WordTagName, WordClassName,TitleCtl)
{
    this.Images = Imgs; //图片集合

    var img = document.createElement("img");
    this.AControl = null; //文字容器
    this.Control = null; //图片容器
    if (ImgCtl.tagName.toUpperCase() == "A")//假如是超链接容器
    {
        this.AControl = ImgCtl;
        this.Control = this.AControl.getElementsByTagName("IMG")[0];
    }
    else
    {
        this.Control = ImgCtl;
    }
    var img = document.createElement("img");
    this.WordControl = WordCtl; //用于显示所有文字项的容器
    this.TitleControl = TitleCtl; //用于显示所有标题的容器
    this.WordOptionTagName = WordTagName; //用于显示文字项的标签名称
    this.WordOptionClassName = WordClassName; //文字项的聚焦样式名
    this.Msec = Msec; //渐变秒数
    this.Times = null; //定时器
    var Model = this;
    if (document.all)
    { this.Control.style.filter = "blendTrans(duration=2)"; }
    if (this.WordControl && this.WordOptionTagName)
    {
        for (var i = 0; i < this.Images.length; i++)
        {
            var option = document.createElement(this.WordOptionTagName);
            option.innerHTML = (i + 1);
            option.index = i;
            if (i == 0) { option.className = this.WordOptionClassName; }
            option.onclick = function()
            {
                if (Model.Times) { clearTimeout(Model.Times); }
                Model.Play(this.index);
            }
            this.WordControl.appendChild(option);
        }
    }
    this.Play = function(index)
    {
        if (index >= this.Images.length) { index = 0; }

        if (document.all) { this.Control.filters.blendTrans.apply(); }
        if (this.AControl)
        {
            this.Control.src = this.Images[index][0];
            this.Control.style.display = "";
            this.AControl.href = this.Images[index][1];
            this.Control.title = this.Images[index][2];
            if (this.TitleControl)
            {
                this.TitleControl.innerHTML = this.Control.title;
                this.TitleControl.href = this.AControl.href;
            }
        }
        else { this.Control.src = this.Images[index]; }

        if (document.all) { this.Control.filters.blendTrans.play(); }

        var ThisModel = this;
        if (this.WordControl)
        {
            var Options = this.WordControl.getElementsByTagName(this.WordOptionTagName);
            for (var i = 0; i < Options.length; i++)
            {
                Options[i].className = "";
            }
            Options[index].className = ThisModel.WordOptionClassName;
        }
        this.Control.onload = function() { ThisModel.Times = setTimeout(function() { ThisModel.Play((index + 1)); }, ThisModel.Msec); }
    },
            this.Start = function()
            {
                this.Times = setTimeout(function() { Model.Play(0); }, 100);
            }
}
