﻿//图片滚动列表
var Speed = 3; //速度(毫秒)
var Space = 5; //每次移动(px)
var PageWidth = 86; //翻页宽度,如果要滚动范围更多，则可以乘以显示的图片数量，如遮罩区显示5张，可以乘以5
var fill = 0; //整体移位
var MoveLock = false;
var MoveTimeObj;
var Comp = 0;
var AutoPlayObj = null;

$().ready(function() {
    var url = window.location.href;
    if (url.indexOf(".html") == -1) {
        HotGameList();
        ExcellenceBusiness();
        HotGameVideo();
        InfoIndustry();
        NewGoPublic(-1);
        HotOperationGame(-1);
        FamousEnterprise();
        BussnissDynamic();
        TalentsRecruitment();
        CooperationNeeds();
        LoginVerify();
    }
    $(".list_title3 li").each(function(i) {
        $(this).bind("click", { a: i }, ChangeLiTab);
    });
});


function ChangeLiTab(e) {
    $(".list_title3 li").each(function(i) {
        $(this).removeClass("hotli");
        if (i == e.data.a) {
            $(this).addClass("hotli");
        }
    });
    NewGoPublic(e.data.a);
    HotOperationGame(e.data.a);
}

function HotGameList() {
    $.ajax({ url: "ashx/SystemManager/SysGameSummary.ashx", type: "POST", data: { flag: "0", CID: "0", PT: "", KW: "", FH: "1", FS: "", Sort: "a.FlagHot desc,a.UpdateDate desc", StartIndex: 1, EndIndex: 11 },
        success: function(r) {
            var html = "";
            var shtml = "";
            var res = eval('(' + r + ')');
            if (res.length > 0) {
                for (var i = 0; i < res.length; i++) {
                    var url = "DetailHotGame.aspx?param=" + res[i].GameProductID + "_" + res[i].UCompanyID;
                    var cp = res[i].GameDetails.replace(/<\/?.+?>/g, "").toString().substr(0, 80) + "...";
                    if (i == 0) {
                        var imgsrc = res[i].ProductLogo == "" ? "images/noimg110_85.gif" : res[i].ProductLogo;
                        $(".intro_2").html("<li><img src=\"" + imgsrc + "\" /><p><a href=\"" + url + "\" target='_blank'>" + res[i].ProductName + "</a></p></li>");
                        $(".intro_2").append("<li class=\"intro_2_txt\"><p><a href=\"" + url + "\">" + res[i].ProductName + "</a></p>" + cp + "</li>");
                    }
                    var src = res[i].ProductLogo == "" ? "noimg80_67.gif" : res[i].ProductLogo;
                    shtml += "<li><img style=\"width:81px;height:67px;\" src=\"" + src + "\" alt=\"" + res[i].ProductName + "\" atl=\"" + cp + "\" url=\"" + url + "\"/><p><a href=\"" + url + "\">" + res[i].ProductName + "</a></p></li>";
                }
            }
            else {
            }
            $("#List1").html(shtml);
            //if (navigator.userAgent.indexOf('Firefox') >= 0)
            //{

            //}
            if (res.length >= 5) {
                GetObj("List2").innerHTML = shtml;
                GetObj('ISL_Cont').scrollLeft = fill;
                GetObj("ISL_Cont").onmouseover = function() { clearInterval(AutoPlayObj); }
                GetObj("ISL_Cont").onmouseout = function() { AutoPlay(); }
                AutoPlay();
                $("#List1").children().each(function() {
                    $(this).hover(function() {
                        var objs = $(this);
                        var href = objs.find("img").attr("url");
                        var sl = objs.find("p").html();
                        var img = objs.find("img").attr("src");
                        var ll = objs.find("img").attr("alt");
                        var summary = objs.find("img").attr("atl");
                        $(".intro_2").children().eq(0).find("img").attr("src", img);
                        $(".intro_2").children().eq(0).find("p").html("<a href=\"" + href + "\">" + sl + "</a>");
                        $(".intro_2").children().eq(1).html("<p><a href=\"" + href + "\">" + sl + "</a></p>" + summary);
                    }, function() {
                    });
                });
                $("#List2").children().each(function() {
                    $(this).hover(function() {
                        var objs = $(this);
                        var href = objs.find("img").attr("url");
                        var sl = objs.find("p").html();
                        var img = objs.find("img").attr("src");
                        var ll = objs.find("img").attr("alt");
                        var summary = objs.find("img").attr("atl");
                        $(".intro_2").children().eq(0).find("img").attr("src", img);
                        $(".intro_2").children().eq(0).find("p").html("<a href=\"" + href + "\">" + sl + "</a>");
                        $(".intro_2").children().eq(1).html("<p><a href=\"" + href + "\">" + sl + "</a></p>" + summary);
                    }, function() {
                    });
                });
            }
        },
        error: function(r) {
            //alert(r.responseText);
        }
    });
}


function ExcellenceBusiness() {
    $.ajax({ url: "ashx/SystemManager/SysCompanyData.ashx", type: "POST", data: { flag: "3", TO: "1", OT: "1", TT: "1", OO: "2" },
        success: function(r) {
            var html = "";
            var res = eval('(' + r + ')');
            if (res.length > 0) {
                for (var i = 0; i < res.length; i++) {
                    var imgsrc = res[i].LogoPath == "" ? "images/noimg80_67.gif" : res[i].LogoPath;
                    var url = "BusinessDetail.aspx?param=" + res[i].CompanyID;
                    if (res[i].FlagHot == "1001") {
                        $("#divRDBusiness").html("<ul><li><img style=\"width:80px;height:66px;\" src=\"" + imgsrc + "\" /></li><li class=\"Hot_content_txt\"><a href=\"" + url + "\">" + res[i].ShortName + "</a><p><a href=\"" + res[i].WebSite + "\" target=\"_blank\">官网地址</a></p></li></ul>");
                    }
                    if (res[i].FlagHot == "1002") {
                        var platname = "";
                        if (res[i].CompanyPlat.indexOf('^') != -1) {
                            var platArr = res[i].CompanyPlat.split(',');
                            for (var j = 0; j < 1; j++) {
                                var aa = platArr[j].split('^');
                                platname += "<a href='" + aa[1] + "' target='_blank'>" + aa[0] + "</a></br>";
                            }
                        } else
                            platname = res[i].CompanyPlat;
                        $("#divOPBusiness").html("<ul><li><img style=\"width:80px;height:66px;\" src=\"" + imgsrc + "\" /></li><li class=\"Hot_content_txt\"><a href=\"" + url + "\">" + res[i].ShortName + "</a><p>" + platname + "</p><p><a href=\"" + res[i].WebSite + "\" target=\"_blank\">官网地址</a></p></li></ul>");
                    }
                }
            }
            else {
            }
        },
        error: function(r) {
            //alert(r.responseText);
        }
    });
}

function HotGameVideo() {
    $.ajax({ url: "ashx/UCenter/GameVideo.ashx", type: "POST", data: { flag: "0", CID: "0", PID: "0", FP: "1", KW: "", Sort: "", StartIndex: 1, EndIndex: 10 },
        success: function(r) {
            var html = "";
            var res = eval('(' + r + ')');
            if (res.length > 0) {
                html += "<div id=\"pic_button1\" class=\"next\"></div><div class=\"auto\"><ul>";
                for (var i = 0; i < res.length; i++) {
                    var imgsrc = res[i].VideoPic == "" ? "images/noimg110_85.gif" : res[i].VideoPic;
                    var info = HYTsubstr(res[i].VideoInfo, 16);
                    var url = "VideoPlayer.aspx?param=" + res[i].ProductVideoID;
                    html += "<li><a href=\"" + url + "\" target='_blank' title=\"" + res[i].VideoInfo + "\"><img src=\"" + imgsrc + "\" style=\"width:116px;height:97px;border:0;\"/></a><p><a href=\"" + url + "\" target='_blank' title=\"" + res[i].VideoInfo + "\">" + info + "</a></p></li>"
                }
                html += "</ul></div><div id=\"pic_button2\" class=\"prev\"></div>";
            }
            else {

            }
            $("#pic1").html(html);
            if (res.length >= 5) {
                $(".auto").jCarouselLite({
                    btnNext: ".prev",
                    btnPrev: ".next",
                    auto: 800,
                    speed: 2000,
                    visible: 5
                });
            }
        },
        error: function(r) {
            //alert(r.responseText);
        }
    });
}

function InfoIndustry() {
    $.ajax({ url: "ashx/SystemManager/SysInfoNews.ashx", type: "POST", data: { flag: "0", IT: "", KW: "", IP: "1", FH: "1", Sort: " ListOrder desc", StartIndex: 1, EndIndex: 4 },
        success: function(r) {
            var html = "<div class=\"information3\">";
            var res = eval('(' + r + ')');
            if (res.length > 0) {
                for (var i = 0; i < res.length; i++) {
                    var url = "DetailIndustryInfo.aspx?IID=" + res[i].sysInformationID;
                    var info = HYTsubstr(res[i].Caption.toString(), 28);
                    var cp = res[i].Contents.replace(/<\/?.+?>/g, "").toString().substr(0, 32) + "...";
                    html += "<ul><li><img src=\"" + res[i].CaptionPic + "\" style=\"width:100px;height:75px;border:solid 1px #ddd;\"/></li><li class=\"information4\">";
                    html += "<p><a href=\"" + url + "\" target='_blank'>" + info + "</a></p>" + cp + "</li></ul>";
                    if (i == 1) {
                        html += "</div><div style=\"clear:both\"></div><div class=\"information3\">";
                    }
                }
                html += "</div>";
                $(".information2").html(html);
            }
            else {
            }

        },
        error: function(r) {
            //alert(r.responseText);
        }
    });
}


function NewGoPublic(pt) {
    $("#divhotRperation").html("<ul><li><span>最新游戏：</span></li></ul>");
    $.ajax({ url: "ashx/SystemManager/SysGameSummary.ashx", type: "POST", data: { flag: "0", CID: "0", PT: pt, KW: "", FH: "-1", FS: "", Sort: "a.FlagHot desc,a.UpdateDate desc", StartIndex: 1, EndIndex: 50 },
        success: function(r) {
            var html = "<ul><li><span>最新游戏：</span></li>";
            var res = eval('(' + r + ')');
            if (res.length > 0) {
                for (var i = 0; i < res.length; i++) {
                    var url = "DetailHotGame.aspx?param=" + res[i].GameProductID + "_" + res[i].UCompanyID;
                    var name = res[i].ProductName;
                    if (name.length > 5)
                        name = name.substr(0, 5);
                    html += "<li><a href=\"" + url + "\" target=\"_blank\" title='" + res[i].ProductName + "'>" + name + "</a></li>";
                }
                html += "<li><s><a href=\"HotGame.aspx?param=1_" + pt + "_\">更多>></a></s></li>";
            }
            else {

            }
            $("#divhotRperation").html(html + "</ul>");
        },
        error: function(r) {
            //alert(r.responseText);
        }
    });
}



function HotOperationGame(pt) {
    $("#divhotOperation").html("<ul><li><span>热门运营：</span></li></ul>");
    $.ajax({ url: "ashx/SystemManager/SysGameOperate.ashx", type: "POST", data: { flag: "0", CID: "0", GN: "", GT: pt, KW: "", RD: "", GP: "1", FO: "1", Sort: "", StartIndex: 1, EndIndex: 50 },
        success: function(r) {
            var html = "<ul><li><span>热门运营：</span></li>";
            var res = eval('(' + r + ')');
            if (res.length > 0) {
                for (var i = 0; i < res.length; i++) {
                    var url = res[i].GameWeb
                    var name = HYTsubstr(res[i].GameName, 10);
                    html += "<li><a href=\"" + url + "\" target=\"_blank\" title='" + res[i].GameName + "'>" + name + "</a></li>";

                }
                html += "<li><s><a href=\"HotGame.aspx?param=2_" + pt + "_\">更多>></a></s></li>";
            }
            else {

            }
            $("#divhotOperation").html(html + "</ul>");
        },
        error: function(r) {
            //alert(r.responseText);
        }

    });
}

function FamousEnterprise() {
    var ito = 36;
    var itt = 36;
    $.ajax({ url: "ashx/SystemManager/SysCompanyData.ashx", type: "POST", data: { flag: "3", TO: ito, OT: "1", TT: itt, OO: "2" },
        success: function(r) {
            var rdhtml = "<ul><li><span>研发商家：</span></li>";
            var ophtml = "<ul><li><span>运营商家：</span></li>";
            var res = eval('(' + r + ')');
            if (res.length > 0) {
                var rd = 1;
                var op = 1;
                for (var i = 0; i < res.length; i++) {
                    var url = "BusinessDetail.aspx?param=" + res[i].CompanyID;
                    var name = HYTsubstr(res[i].ShortName, 10);
                    if (res[i].CompanyType == "1" | res[i].CompanyType == "0") {
                        if (rd <= ito) {
                            rdhtml += "<li><a href=\"" + url + "\" title='" + res[i].ShortName + "'>" + name + "</a></li>";
                        }
                        rd++;
                    }
                    if (res[i].CompanyType == "2" | res[i].CompanyType == "0") {
                        if (op <= itt)
                            ophtml += "<li><a href=\"" + url + "\" title='" + res[i].ShortName + "'>" + name + "</a></li>";
                        op++;
                    }
                }
            }
            else { }
            rdhtml += "<li><s><a href=\"RDBusiness.aspx\">更多>></a></s></li></ul>";
            ophtml += "<li><s><a href=\"OPBusiness.aspx\">更多>></a></s></li></ul>";
            $("#divFamousRD").html(rdhtml);
            $("#divFamousOP").html(ophtml);
        },
        error: function(r) {
            //alert(r.responseText);
        }
    });
}

function BussnissDynamic() {
    $.ajax({ url: "ashx/SystemManager/SysCompanyNews.ashx", type: "POST", data: { flag: "0", CID: "0", MT: "", KW: "", Sort: "", StartIndex: 1, EndIndex: 5 },
        success: function(r) {
            var html = "";
            var res = eval('(' + r + ')');
            if (res.length > 0) {
                for (var i = 0; i < res.length; i++) {
                    var url = "SysAnnounce.aspx?param=1_" + res[i].GameActiveMsgID;
                    html += "<p>[" + res[i].ChildtypeName + "]<span style='color:#0056a6;'>"+res[i].ShortName+"</span>&nbsp;<a href=\"" + url + "\" target=\"_blank\">" + res[i].MsgTitle + "</a></p>";
                }
            }
            else {
            }
            $("#divBussnissDynamic").html(html);
        },
        error: function(r) {
            //alert(r.responseText);
        }
    });
}

function TalentsRecruitment() {
    $.ajax({ url: "ashx/SystemManager/SysCompanyJob.ashx", type: "POST", data: { flag: "0", CID: "0", JT: "", JD: "", JP: "", KW: "", JS: "1", StartIndex: 1, EndIndex: 5 },
        success: function(r) {
            var html = "<table width=\"711\" border=\"0\" cellspacing=\"0\">";
            var res = eval('(' + r + ')');
            if (res.length > 0) {
                for (var i = 0; i < res.length; i++) {
                    var url = "DetailIndustryJob.aspx?JID=" + res[i].GameJobOfferID;
                    var curl = "IncIndustryJob.aspx?CID=" + res[i].UCompanyID;
                    var d = eval("new " + res[i].AddDate.toString().replace("/", "").replace("/", ""));
                    html += "<tr><td width=\"350\"><a href=\"" + url + "\" target+\"_blank\">" + res[i].row + "、" + res[i].JobDetails + "</a></td>";
                    html += "<td width=\"159\"><a href=\"" + curl + "\" target+\"_blank\">" + res[i].ShortName + "</a></td>";
                    html += "<td width=\"200\">最新更新：" + d.format("yyyy-MM-dd hh:mm:ss") + "</td>";
                }
            }
            else {
            }
            html += "</table>";
            $("#divTalentsRecruitment").html(html);
        },
        error: function(r) {
            //alert(r.responseText);
        }
    });
}

function CooperationNeeds() {
    $.ajax({ url: "ashx/SystemManager/SysGameNeeds.ashx", type: "POST", data: { flag: "0", CID: "0", PT: "", KW: "", CT: "", FO: "1", StartIndex: 1, EndIndex: 5 },
        success: function(r) {
            var html = "<table width=\"711\" border=\"0\" cellspacing=\"0\">";
            var res = eval('(' + r + ')');
            if (res.length > 0) {
                for (var i = 0; i < res.length; i++) {
                    var url = "BusinessDetail.aspx?param=" + res[i].UCompanyID + "_$";
                    var curl = "BusinessDetail.aspx?param=" + res[i].UCompanyID;
                    var arr = res[i].CooperationType.split(',');
                    var otype = "";
                    for (var j = 0; j < arr.length - 1; j++) {
                        if (arr[j] == "0")
                            otype += "独代&nbsp;";
                        else if (arr[j] == "1")
                            otype += "联运&nbsp;";
                        else if (arr[j] == "2")
                            otype += "混服&nbsp;";
                    }
                    html += "<tr><td width=\"311\">·<a href=\"" + url + "\" target+\"_blank\" title=\"" + res[i].NeedsTitle + "\">" + res[i].NeedsTitle.substr(0, 22) + "</a></td>";
                    html += "<td width=\"210\"><a href=\"" + curl + "\" target+\"_blank\">" + res[i].ShortName + "</a></td>";
                    html += "<td width=\"150\">合作方式：" + otype + "</td>";
                }
            }
            else {
            }
            html += "</table>";
            $("#divCooperationNeeds").html(html);
        },
        error: function(r) {
            //alert(r.responseText);
        }
    });
}


function GetObj(objName) { if (document.getElementById) { return eval('document.getElementById("' + objName + '")') } else { return eval('document.all.' + objName) } }
function AutoPlay() { //自动滚动
    clearInterval(AutoPlayObj);
    AutoPlayObj = setInterval('ISL_GoDown();ISL_StopDown();', 1500); //间隔时间
}
function ISL_GoUp() { //上翻开始
    if (MoveLock) return;
    clearInterval(AutoPlayObj);
    MoveLock = true;
    MoveTimeObj = setInterval('ISL_ScrUp();', Speed);
}
function ISL_StopUp() { //上翻停止
    clearInterval(MoveTimeObj);
    if (GetObj('ISL_Cont').scrollLeft % PageWidth - fill != 0) {
        Comp = fill - (GetObj('ISL_Cont').scrollLeft % PageWidth);
        CompScr();
    } else {
        MoveLock = false;
    }
    AutoPlay();
}
function ISL_ScrUp() { //上翻动作
    if (GetObj('ISL_Cont').scrollLeft <= 0) { GetObj('ISL_Cont').scrollLeft = GetObj('ISL_Cont').scrollLeft + GetObj('List1').offsetWidth }
    GetObj('ISL_Cont').scrollLeft -= Space;
}
function ISL_GoDown() { //下翻
    clearInterval(MoveTimeObj);
    if (MoveLock) return;
    clearInterval(AutoPlayObj);
    MoveLock = true;
    ISL_ScrDown();
    MoveTimeObj = setInterval('ISL_ScrDown()', Speed);
}
function ISL_StopDown() { //下翻停止
    clearInterval(MoveTimeObj);
    if (GetObj('ISL_Cont').scrollLeft % PageWidth - fill != 0) {
        Comp = PageWidth - GetObj('ISL_Cont').scrollLeft % PageWidth + fill;
        CompScr();
    } else {
        MoveLock = false;
    }
    AutoPlay();
}
function ISL_ScrDown() { //下翻动作
    if (GetObj('ISL_Cont').scrollLeft >= GetObj('List1').scrollWidth) { GetObj('ISL_Cont').scrollLeft = GetObj('ISL_Cont').scrollLeft - GetObj('List1').scrollWidth; }
    GetObj('ISL_Cont').scrollLeft += Space;
}
function CompScr() {
    var num;
    if (Comp == 0) { MoveLock = false; return; }
    if (Comp < 0) { //上翻
        if (Comp < -Space) {
            Comp += Space;
            num = Space;
        } else {
            num = -Comp;
            Comp = 0;
        }
        GetObj('ISL_Cont').scrollLeft -= num;
        setTimeout('CompScr()', Speed);
    } else { //下翻
        if (Comp > Space) {
            Comp -= Space;
            num = Space;
        } else {
            num = Comp;
            Comp = 0;
        }
        GetObj('ISL_Cont').scrollLeft += num;
        setTimeout('CompScr()', Speed);
    }
}
