﻿
var arrImage = new Array();
var arrHref = new Array();
var arrTitle = new Array();
arrImage = strImageUtl.split("|");
arrHref = strHref.split("|");
arrTitle = strTitle.split("|");
var nowfocus = 1;
var androidInterval;
$(document).ready(function() {

    $("#imgad").ADSlide({
        speed: "normal",
        num: 4,
        timer: 3000,
        flowSpeed: 300
    });
});

function showKaoGuaAD() {
    $("#imgAd").attr("src", arrImage[nowfocus - 1]);
    $("#a_Ad").attr("href", arrHref[nowfocus - 1]);
    $("#a_Ad").attr("title", arrTitle[nowfocus - 1]);
    var ahtml = "<a href='" + arrHref[nowfocus - 1] + "' target='_blank'>" + arrTitle[nowfocus - 1] + "</a>";
    $("#divAd").html(ahtml);
    for (var i = 1; i <= jsFocusCount; i++) {
        $("#li_Ad_Btn_" + i).attr("class", "em");
    }
    $("#focus_a_" + nowfocus).attr("class", "so");
    androidInterval = setInterval(function() {
        changeFocus();
    }, 3000);
}

function changeFocus() {
    if (nowfocus > jsFocusCount) {
        nowfocus = 1;
    }
    $("#imgAd").attr("src", arrImage[nowfocus - 1]);
    $("#a_Ad").attr("href", arrHref[nowfocus - 1]);
    $("#a_Ad").attr("title", arrTitle[nowfocus - 1]);
    var ahtml = "<a href='" + arrHref[nowfocus - 1] + "' target='_blank'>" + arrTitle[nowfocus - 1] + "</a>";
    $("#divAd").html(ahtml);
    
    for (var i = 1; i <= jsFocusCount; i++) {
        var classname = $("#li_Ad_Btn_" + i).attr("class");
        classname = "em";
        $("#li_Ad_Btn_" + i).attr("class", classname);
    }
    var classname = $("#li_Ad_Btn_" + nowfocus).attr("class");
    classname = "so";
    $("#li_Ad_Btn_" + nowfocus).attr("class", classname);
    nowfocus = nowfocus + 1;
}

function goFocus(id) {
    $("#imgAd").attr("src", arrImage[id - 1]);
    $("#a_Ad").attr("href", arrHref[id - 1]);
    $("#a_Ad").attr("title", arrTitle[id - 1]);
     var ahtml = "<a href='" + arrHref[nowfocus - 1] + "' target='_blank'>" + arrTitle[nowfocus - 1] + "</a>";
    $("#divAd").html(ahtml);
    for (var i = 1; i <= jsFocusCount; i++) {
        var classname = $("#li_Ad_Btn_" + i).attr("class");
        classname = "em"
        $("#li_Ad_Btn_" + i).attr("class", classname);
    }
    var classname = $("#li_Ad_Btn_" + id).attr("class");
    classname = "so";
    $("#li_Ad_Btn_" + id).attr("class", classname);
    nowfocus = id;
}

var ChangeTopRightCommend = function(id) {
    var TopCommendId = $(id).attr("id").replace("a_Top_Right_", "");
    if (TopCommendId == 0 || TopCommendId == 1 || TopCommendId == 2) {
        $("li:[name='liTopRight']").each(function() {
            $(this).attr("class", "");
        });
        $("#li_Top_Right_" + TopCommendId).attr("class", "now");
        $.post("/ASCX/TopCommendApp/" + TopCommendId, "", function(data) {
            if (data != null && data != "") {
                $("#DivTopRightCommend").html("");
                $("#DivTopRightCommend").html(data);
            }
        });
    }
    else {
        return;
    }
}
var ChangeSecondCatrgoryGame = function(id) {
    var GameCommendId = $(id).attr("id").replace("a_Second_Game_", "");
    $("li:[name='liSecondGame']").each(function() {
        $(this).attr("class", "");
    });
    $("#li_Second_Game_" + GameCommendId).attr("class", "now");
    $.post("/ASCX/CategoryAppList/" + GameCommendId, "", function(data) {
        if (data != null && data != "") {
            $("#ul_Second_Game").html("");
            $("#ul_Second_Game").html(data);
        }
    });
}
var ChangeSecondCatrgorySoft = function(id) {
    var GameCommendId = $(id).attr("id").replace("a_Second_Soft_", "");
    $("li:[name='liSecondSoft']").each(function() {
        $(this).attr("class", "");
    });
    $("#li_Second_Soft_" + GameCommendId).attr("class", "now");
    $.post("/ASCX/CategoryAppList/" + GameCommendId, "", function(data) {
        if (data != null && data != "") {
            $("#ul_Second_Soft").html("");
            $("#ul_Second_Soft").html(data);
        }
    });
}
