﻿// JScript 文件



var D = Detail = {};
Detail.show = function(name, edition, year, renqi, director, actors, focus, user, cp) {
    actors = Detail.actor(actors, 24, ',');
    director = director.split('|')[0];
    if (D.len(focus) > 80) {
        focus = focus.substr(0, 78) + '...';
    }
    var html = '<dl><dt>专家姓名：' + name + '<span>' + edition + '</span></dt><dd><!--<p>专家姓名：' + year + '&nbsp;&nbsp;&nbsp;人气：<strong>' + renqi + '</strong></p>--><p><b>所属地区：</b>' + director + '</p><p><b>专精领域：</b>' + actors + '</p><p><b>专家简介：</b>' + focus + '</p></dd></dl>';
    document.getElementById('div_tip_detail').innerHTML = html;
    var p = KK.position(event.srcElement);
    var tip = document.getElementById('movie_info');
    tip.style.display = '';
    tip.style.top = p.Top + 'px';
    tip.style.left = p.Left - 216 + 'px';
    //tip.style.right=p.right+96+'px';
}
Detail.actor = function(str, len, spliter) {
    spliter = spliter || '|';
    var arr = str.split(spliter);
    var temp = '';
    for (var i = 0; i < arr.length; i++) {
        temp += arr[i] + '&nbsp;';
        if (D.len(temp) < len) {
            str = temp;
        } else {
            break;
        }
    }
    return str;
}
Detail.hide = function() {
    document.getElementById('movie_info').style.display = 'none';
}
Detail.len = function(str) {
    var l = 0;
    var sl = str.length
    for (var i = 0; i < sl; i++) {
        l++;
        if (str.charCodeAt(i) > 256) l++;
    }
    return l;
}
var KK = {};
KK.baseUrl = '';
KK.position = function(o) {
    var p = { Top: 0, Left: 0 };
    while (!!o) {
        p.Top += o.offsetTop;
        p.Left += o.offsetLeft;
        o = o.offsetParent;
    }
    return p;
}

KK.scrollCross = { interval: 0, count: 0, duration: 0, step: 0, srcObj: null, callback: null };

KK.scrollCross.doit = function(obj, b, c, d) {
    var s = KK.scrollCross;
    obj.style.marginLeft = cpu(s.count, b, c, d) + 'px';
    s.count++;
    if (s.count == d) {
        clearInterval(s.interval);
        s.count = 0;
        obj.style.marginLeft = b + c + 'px';
        s.callback();
    }
    function cpu(t, b, c, d) { return c * ((t = t / d - 1) * t * t + 1) + b; };
}
KK.scrollCross.scroll = function(obj, step, span, beign, callback, duration) {
    var s = KK.scrollCross;
    s.duration = duration;
    s.callback = callback;
    s.interval = setInterval(function() { s.doit(obj, beign, step * span, duration) }, 10);
}
KK.playUrl = function(id) {
    return KK.baseUrl + 'movie/' + id % 100 + '/' + id + '.html';
}


function imgerror(obj, type) {
    obj.src = type == 2 ? '/Images/nopic_p.png' : '/Images/nopic_p.png';
}
/*ppp*/

function $(s) {
    return document.getElementById(s);
}

function $P(child, parent) {
    return parent ? parent.appendChild(child) : document.body.appendChild(child);
}

function $C(s) {
    return document.createElement(s);
};
function $R(child, parent) {
    return parent ? parent.removeChild(child) : document.body.removeChild(child);
};
var E = new Object;
E.add = function(o, t, f) {
    if (o.addEventListener) {
        o.addEventListener(t, f, false)
    }
    else if (o.attachEvent) {
        o.attachEvent("on" + t, f)
    }
    else {
        o["on" + t] = f
    }
};
E.remove = function(o, t, f) {
    if (o.removeEventListener) {
        o.removeEventListener(t, f, false)
    }
    else if (o.detachEvent) {
        o.detachEvent("on" + t, f)
    }
    else {
        o["on" + t] = null
    }
};
E.formatEvent = function(e) {
    if (isIE && isWin) {
        e.charCode = (e.type == "keypress") ? e.keyCode : 0;
        e.eventPhase = 2;
        e.isChar = (e.charCode > 0);
        e.pageX = e.clientX + document.body.scrollLeft;
        e.pageY = e.clientY + document.body.scrollTop;
        e.preventDefault = function() {
            this.returnValue = false
        };
        if (e.type == "mouseout") {
            e.relatedTarget = e.toElement
        }
        else if (e.type == "mouseover") {
            e.relatedTarget = e.fromElement
        }
        e.stopPropagation = function() {
            this.cancelBubble = true
        };
        e.target = e.srcElement;
        e.time = (new Date).getTime()
    }
    return e
};
E.get = function() {
    if (window.event) {
        return this.formatEvent(window.event)
    }
    else {
        return E.get.caller.arguments[0]
    }
};
function GetDataByIframe(url, cbf, err, para) {
    if ((cbf[0] && typeof (cbf[0]) != 'function') || typeof (cbf) != 'function') {
        return alert('cbf function is in error!')
    }
    if (url instanceof Array) {
        for (var i = 0; i < arr_url.length; i++) {
            doWork(url[i], cbf[i], para[i])
        }
    }
    else if (typeof (url) == 'string') {
        doWork(url, cbf, para)
    }
    function doWork(u, cb, p) {
        var idp = $C('iframe');
        idp.style.display = 'none';
        idp.src = u;
        E.add(idp, 'load', icb);
        function icb() {
            E.remove(idp, 'load', icb);
            var json = idp.contentWindow.jsonObj;
            if (!json) {
                if (typeof (err) == 'function') {
                    $R(idp);
                    return err();
                }
                else {
                    $R(idp);
                    return;
                }
            }
            $R(idp);
            cb(json, p)
        }
        $P(idp)
    }
}


function setTabs(name, cursel, n) {
    for (i = 1; i <= n; i++) {
        var menu = document.getElementById(name + i);
        var con = document.getElementById("con_" + name + "_" + i);
        menu.className = i == cursel ? "d321LeftTitah" : "d321LeftTita";
        con.style.display = i == cursel ? "block" : "none";
    }
}

function setTabs2(name, cursel, n, classN1, classN2) {
    for (i = 1; i <= n; i++) {
        var menu = document.getElementById(name + i);
        var con = document.getElementById("div_" + name + "_" + i);
        menu.className = i == cursel ? classN1 : classN2;
        con.style.display = i == cursel ? "block" : "none";
    }
}