

var getobj = function (id)
{
        return "string" == typeof id ? document.getElementById(id) : id;
}

function Event_(e)
{
        var oEvent = document.all ? window.event : e;
        if (document.all)
        {
                if(oEvent.type == "mouseout")
                {
                        oEvent.relatedTarget = oEvent.toElement;
                }
        }
        return oEvent;
}

function addEventHandler(oTarget, sEventType, fnHandler)
{
        if (oTarget.addEventListener)
        {
                oTarget.addEventListener(sEventType, fnHandler, false);
        }
        else if (oTarget.attachEvent)
        {
                oTarget.attachEvent("on" + sEventType, fnHandler);
        }
        else
        {
                oTarget["on" + sEventType] = fnHandler;
        }
}

var Class =
{
        create_: function()
        {
                return function()
                {
                        this.initialize.apply(this, arguments);
                }
        }
}

Object.extend_ = function(destination, source)
{
        for (var property in source)
        {
                destination[property] = source[property];
        }
        return destination;
}

var GlideView = Class.create_();

GlideView.prototype =
{
        initialize: function(obj, iWidth, sTag, iMaxWidth, options)
        {
                var oContainer = getobj(obj), oThis=this, len = 0;

                this.SetOptions(options);

                this.Step = Math.abs(this.options.Step);
                this.Time = Math.abs(this.options.Time);
                this.Showtext = false;

                this._list = oContainer.getElementsByTagName(sTag);
                len = this._list.length;
                this._count = len;
                this._width = parseInt(iWidth / len);
                this._width_max = parseInt(iMaxWidth);
                this._width_min = parseInt((iWidth - this._width_max) / (len - 1));
                this._timer = null;

                if(this.options.TextTag && this.options.TextHeight > 0)
                {
                        this.Showtext = true;
                        this._text = oContainer.getElementsByTagName(this.options.TextTag);
                        this._height_text = -parseInt(this.options.TextHeight);
                }

                this.Each
                (
                        function(oList, oText, i)
                        {
                                oList._target = this._width * i;
                                oList.style.left = oList._target + "px";
                                oList.style.position = "absolute";
                                addEventHandler(oList, "mouseover", function(){ oThis.Set.call(oThis, i); });

                                if(oText)
                                {
                                        oText._target = this._height_text;
                                        oText.style.bottom = oText._target + "px";
                                        oText.style.position = "absolute";
                                }
                        }
                )

                oContainer.style.width = iWidth + "px";
                oContainer.style.overflow = "hidden";
                oContainer.style.position = "relative";
        },
        SetOptions: function(options)
        {
                this.options =
                {
                        Step:                   30,
                        Time:                   5,      
                        TextTag:                "",     
                        TextHeight:             0       
                }
                Object.extend_(this.options, options || {});
        },
        Set: function(index)
        {
                if (index < 0)
                {
                        this.Each(function(oList, oText, i){ oList._target = this._width * i; if(oText){ oText._target = this._height_text; } })
                }
                else
                {
                        this.Each
                        (
                                function(oList, oText, i)
                                {
                                        oList._target = (i <= index) ? this._width_min * i : this._width_min * (i - 1) + this._width_max;
                                        if(oText){ oText._target = (i == index) ? 0 : this._height_text; }
                                }
                        )
                }
                this.Move();
        },
        Move: function()
        {
                clearTimeout(this._timer);
                var bFinish = true;
                this.Each
                (
                        function(oList, oText, i)
                        {
                                var iNow = parseInt(oList.style.left), iStep = this.GetStep(oList._target, iNow);
                                if (iStep != 0) { bFinish = false; oList.style.left = (iNow + iStep) + "px"; }
                                if (oText)
                                {
                                        iNow = parseInt(oText.style.bottom), iStep = this.GetStep(oText._target, iNow); 
                                        if (iStep != 0) { bFinish = false; oText.style.bottom = (iNow + iStep) + "px"; }
                                }
                        }
                )
                if (!bFinish) { var oThis = this; this._timer = setTimeout(function(){ oThis.Move(); }, this.Time); }
        },
        GetStep: function(iTarget, iNow)
        {
                var iStep = (iTarget - iNow) / this.Step;
                if (iStep == 0) return 0;
                if (Math.abs(iStep) < 1) return (iStep > 0 ? 1 : -1);
                return iStep;
        },
        Each:function(fun)
        {
                for (var i = 0; i < this._count; i++)
                {
                        fun.call(this, this._list[i], (this.Showtext ? this._text[i] : null), i)
                }
        }
}

function showhome()
{
	if(document.all.idGlideView)
	{
		showthis('b');
	}
}
