﻿
var EventUtil = {};
EventUtil.addEventHandler = function (a, b, c) {
    if (a.addEventListener) a.addEventListener(b, c, false);
    else if (a.attachEvent) a.attachEvent("on" + b, c);
    else a["on" + b] = c
};
EventUtil.removeEventHandler = function (a, b, c) {
    if (a.removeEventListener) a.removeEventListener(b, c, false);
    else if (a.detachEvent) a.detachEvent("on" + b, c);
    else a["on" + b] = null
};
ScrollCrossLeft = {
    interval: 0,
    count: 0,
    duration: 0,
    step: 0,
    srcObj: null,
    callback: null
};
ScrollCrossLeft.doit = function (a, b, c, d) {
    var e = ScrollCrossLeft,
	f = function (g, h, j, k) {
	    return j * ((g = g / k - 1) * g * g + 1) + h
	} (e.count, b, c, d);
    a.style.marginLeft = f + "px";
    BigNews.currentBegin = f;
    e.count++;
    if (e.count == d) {
        clearInterval(e.interval);
        e.count = 0;
        a.style.marginLeft = b + c + "px";
        BigNews.currentBegin = b + c;
        e.callback()
    }
};
ScrollCrossLeft2 = {
    interval: 0,
    count: 0,
    duration: 0,
    step: 0,
    srcObj: null,
    callback: null
};
ScrollCrossLeft2.doit_2 = function (a, b, c, d) {
    var e = ScrollCrossLeft2;
    a.style.marginLeft = function (f, g, h, j) {
        return h * ((f = f / j - 1) * f * f + 1) + g
    } (e.count, b, c, d) + "px";
    e.count++;
    if (e.count == d) {
        clearInterval(e.interval);
        e.count = 0;
        a.style.marginLeft = b + c + "px";
        e.callback()
    }
};
ScrollCrossLeft2.scroll = function (a, b, c, d, e, f) {
    var g = ScrollCrossLeft2;
    g.duration = f;
    g.callback = e;
    g.interval = setInterval(function () {
        g.doit_2(a, d, b * c, f)
    },
	10)
};
var BigNews = {
    current: 0,
    next: 0,
    scrollInterval: 0,
    autoScroller: 0,
    s: {},
    f: {},
    t: {},
    OnScrolling: false,
    preCss: "",
    currentBegin: 0
};
BigNews.turn = function (a, b) {
    if (a == BigNews.current) return false;
    getEleById("showDiv_" + a).style.zIndex++;
    if (getEleById("bigpic_" + a).src.indexOf(DouYaoKanUI.引用.图片库.默认背景文件) != -1) {
        try {
            setTimeout('getEleById("bigpic_' + a + '").src = ScrollBigPic[' + a + "] ;", 50)
        } catch (c) { }
    }
    BigNews.fadeIn("showDiv_" + a, a, 50, b);
    BigNews.scroll(a, b)
};
BigNews.fadeIn = function (a, b, c, d) {
    try {
        clearInterval(BigNews.f.interval)
    } catch (e) { }
    var f = getEleById(a),
	g = 0;
    BigNews.f.interval = setInterval(function () {
        g += 20;
        f.style.filter = "alpha(opacity=" + g + ")";
        f.style.cssText = f.style.cssText.replace(/;-moz-opacity:.*?;/gi, "") + ";-moz-opacity:" + g * 0.01;
        f.style.cssText = f.style.cssText.replace(/;opacity:.*?;/gi, "") + ";opacity:" + g * 0.01;
        f.style.display = "block";
        if (g == 100) {
            for (var h = 0; h < d.totalcount; h++) {
                getEleById("title_bg_" + h).style.cssText = "position:absolute;left:0;top:269px;float:none;width:740px;height:40px;background:#000;filter:alpha(opacity=60);opacity:0.6;z-index:98;filter:alpha(opacity=0);-moz-opacity:0;opacity:0";
                getEleById("title_" + h).style.cssText = "position:absolute;left:10px;top:282px;font-size:14px;color:#fff;font-weight:normal;z-index:99;filter:alpha(opacity=0);-moz-opacity:0;opacity:0";
                BigNews.showTitles(b, d);
                getEleById("showDiv_" + h).style.cssText = BigNews.preCss;
                if (h == b) getEleById("showDiv_" + h).style.display = "block";
                else getEleById("showDiv_" + h).style.display = "none";
                getEleById("showDiv_" + b).style.zIndex = 0
            }
            BigNews.current = b;
            clearInterval(BigNews.f.interval)
        }
    },
	c)
};
BigNews.showTitles = function (a) {
    try {
        clearInterval(BigNews.t.interval)
    } catch (b) { }
    var c = getEleById("title_" + a),
	d = getEleById("title_bg_" + a),
	e = 0;
    BigNews.t.interval = setInterval(function () {
        e += 10;
        c.style.filter = "alpha(opacity=" + e + ")";
        c.style.cssText = c.style.cssText.replace(/;-moz-opacity:.*?;/gi, "") + ";-moz-opacity:" + e * 0.01;
        c.style.cssText = c.style.cssText.replace(/;opacity:.*?;/gi, "") + ";opacity:" + e * 0.01;
        d.style.filter = "alpha(opacity=" + e * 0.6 + ")";
        d.style.cssText = d.style.cssText.replace(/;-moz-opacity:.*?;/gi, "") + ";-moz-opacity:" +
		e * 0.0060;
        d.style.cssText = d.style.cssText.replace(/;opacity:.*?;/gi, "") + ";opacity:" + e * 0.0060;
        e == 100 && clearInterval(BigNews.t.interval)
    },
	50)
};
BigNews.scroll = function (a, b) {
    var c = b.step;
    BigNews.next = a;
    try {
        clearInterval(BigNews.s.interval)
    } catch (d) { }
    getEleById(b.hover);
    BigNews.s.duration = 16;
    BigNews.s.callback = function () { };
    var e = parseInt(BigNews.currentBegin),
	f = a * c - e;
    BigNews.s.interval = setInterval(function () {
        BigNews.s.doit(getEleById(b.hover), e, f, 16)
    },
	8)
};
BigNews.auto = function (a) {
    clearInterval(BigNews.autoScroller);
    BigNews.autoScroller = setInterval(function () {
        BigNews.turn(BigNews.current == a.totalcount - 1 ? 0 : BigNews.current + 1, a)
    },
	a.autotimeintval)
};
BigNews.pauseSwitch = function () {
    clearTimeout(BigNews.autoScroller)
};
BigNews.showNext = function (a, b) {
    if (a >= MovieRecom.totalcount - 1) return false;
    else {
        BigNews.pauseSwitch();
        BigNews.turn(a + 1, b);
        BigNews.auto(b)
    }
};
BigNews.showPre = function (a, b) {
    if (a <= 0) return false;
    else {
        BigNews.pauseSwitch();
        BigNews.turn(a - 1, b);
        BigNews.auto(b)
    }
};
BigNews.init = function (a) {
    BigNews.s = ScrollCrossLeft;
    BigNews.preCss = a.css;
    EventUtil.addEventHandler(getEleById(a.bigpic), "mouseover", new Function("BigNews.pauseSwitch();"));
    EventUtil.addEventHandler(getEleById(a.bigpic), "mouseout", new Function("BigNews.auto(" + a.objname + ");"));
    for (i = 0; i < a.totalcount; i++) if (a.smallpic != null && a.smallpic != "") {
        EventUtil.addEventHandler(getEleById(a.smallpic + "_" + i), "mouseover", new Function("BigNews.pauseSwitch();BigNews.turn(" + i + "," + a.objname + ");return false;"));
        EventUtil.addEventHandler(getEleById(a.smallpic +
		"_" + i), "mouseout", new Function("BigNews.auto(" + a.objname + ");"))
    }
    BigNews.showTitles(0, a);
    BigNews.auto(a)
};
