//var effectGm = function() {

var ticks, thisTick, nextTick, state, current = 0, delay = 2000, timeID, timeID2, timeID3,timeID4;
    var speed = 60;
    var value = 1;
    function rotateNews(){
            current = 0;
            var ticker = $ID("show-room");
            ticks = ticker.getElementsByTagName("ul");
            for (var i = 0; i < ticks.length; i++) {
                if (i == 0) {
                    _GMlib.setOpacity(ticks[i], 1);
                }
                else {
                    _GMlib.setOpacity(ticks[i], 0);
                    ticks[i].style.display = 'none';
                }
            }
            loopNews();
    }

    function loopNews(){

        if (current >= ticks.length)
            current = 0;
        //alert(current);
        thisTick = (nextTick) ? nextTick : ticks[current];
        nextTick = (ticks[++current]) ? ticks[current] : ticks[current = 0];
        thisTick.style.display = "block";
        state = 'on';
        value = 1;
        timeID = window.setTimeout(fader, delay);

    }

    function fader(){
        if (state == 'on') {
            value = value - 0.1;
            value = parseInt(value * 100) / 100;
            if (value >= 0) {
                _GMlib.setOpacity(thisTick, value);
                timeID2 = window.setTimeout(fader, speed);
            }
            else {
                thisTick.style.display = "none";
                nextTick.style.display = "block";
                state = 'off';
                timeID2 = window.setTimeout(fader, speed);
            }
        }
        else
            if (state == 'off') {
                value = value + 0.1;
                value = parseInt(value * 100) / 100;
                if (value <= 1) {
                    _GMlib.setOpacity(nextTick, value);
                    timeID3 = window.setTimeout(fader, speed);
                }
                else {
                    loopNews();
                }
            }
    }

    function rebuildShowRoom(){
        var s = $ID("show-room");
        var u = s.getElementsByTagName("ul");
        for (var i = 0; i < u.length; i++) {
            _GMlib.setOpacity(u[i], 1);
            u[i].style.display = 'block';
        }
    }

    function stopRotate(){
        clearTimeout(timeID);
        clearTimeout(timeID2);
        clearTimeout(timeID3);
        clearTimeout(timeID4);
        timeID = null;
        timeID2 = null;
        timeID3 = null;
        thisTick = null;
        nextTick = null;
    }

function getCurrentStyle(obj, cssproperty, csspropertyNS) {
    if (obj.style[cssproperty]) {
        return obj.style[cssproperty];
    }
    if (obj.currentStyle) {// IE5+
        return obj.currentStyle[cssproperty];
    } else if (document.defaultView.getComputedStyle(obj, null)) {//
        // FF / Mozilla
        var currentStyle =
                document.defaultView.getComputedStyle(obj, null);
        var value = currentStyle.getPropertyValue(csspropertyNS);
        if (!value) {//try this method
            value = currentStyle[cssproperty];
        }
        return value;
    } else if (window.getComputedStyle) {// NS6+
        var currentStyle = window.getComputedStyle(obj, "");
        return currentStyle.getPropertyValue(csspropertyNS);
    }
}
//var f=new _GMlib.animationMgr();

//f.start({'left':[ow,mw]});
function sliderFunc() {
    this.ss = [];
    var w = 0.7;
    this.slider = document.getElementById('slider');
    this.slides = $Class(this.slider, 'div', 'slide');
    this.NF = this.slides.length;
    this.wh = this.slider.clientWidth;
    this.ow = this.wh / this.NF;
    this.maxw = this.wh * w;
    this.minw = (this.wh * (1 - w)) / (this.NF - 1);
    for (var i = 0; i < this.NF; i++)
    {
        this.ss[i] = new slider(this, i);
    }
}

sliderFunc.prototype = {
    init:function() {
        for (var i = 0; i < this.NF; i++) {
            this.slides[i].style.left = i * this.ow + "px";
        }
    },
    moveS:function(x) {
        for (var i = 0; i <= x; i++) {
            var o = getCurrentStyle(this.slides[i], 'left', 'left');
            o = parseInt(o.replace(/px/, ''));
            this.ss[i].moveOpen(o, i * this.minw);
        }

        for (var i = x + 1; i < this.NF; i++)
        {
            var o = getCurrentStyle(this.slides[i], 'left', 'left');
            o = parseInt(o.replace(/px/, ''));
            this.ss[i].moveOpen(o, this.maxw + (i - 1) * this.minw);
        }
    },
    moveC:function(x) {
        for (var i = 0; i <= x; i++) {
            var o = getCurrentStyle(this.slides[i], 'left', 'left');
            o = parseInt(o.replace(/px/, ''));
            this.ss[i].moveClose(o, i * this.ow);
        }

        for (var i = x + 1; i < this.NF; i++)
        {
            var o = getCurrentStyle(this.slides[i], 'left', 'left');
            o = parseInt(o.replace(/px/, ''));
            this.ss[i].moveClose(o, i * this.ow);
        }
    }
}

var slider = function(oparent, N) {
    this.oparent = oparent;
    var x = this.Na = N;
    var s = this.obj = oparent.slides[N];
    this.obj.oparent = this;
    this.obj.onmouseover = function(e) {
        var o = _GMlib.catchEvent(e).relatedTarget;
        if (_GMlib.notContains(o, s)) {
            stopRotate();
            rebuildShowRoom();
            oparent.moveS(x);


        }
        //                oparent.moveS(x);
    }

    this.obj.onmouseout = function(e) {
        var o = _GMlib.catchEvent(e).relatedTarget;
        if (_GMlib.notContains(o, s)) {
            oparent.moveC(x);
           timeID4=window.setTimeout(" rotateNews()",500);
        }

    }
}

slider.prototype = {
    moveOpen:function(ow, minw) {
        if (this.close) {
            this.close.stop();
        }
        this.open = new _GMlib.animationMgr(this.obj, {
            duration:500,transition:_GMlib.transition.expo.easeInOut
        })
        this.open.start({'left':[ow,minw]});
    },
    moveClose:function(ow, minw) {
        if (this.open)
        {
            this.open.stop();
        }
        this.close = new _GMlib.animationMgr(this.obj, {
            duration:500,transition:_GMlib.transition.expo.easeInOut
        })
        this.close.start({'left':[ow,minw]});
    }
}






