﻿var sodaoFashion = {
    auId: 0,
    chinaName: "",
    /**************************************************
    * *功能描述：活动投票
    **************************************************/
    vote: function(au_id) {
        //提交数据 titles: titles, desc: desc, tags: tags, imgs: imgs,
        //alert("au_id:" + au_id + "AppId:" + AppId + "CA_Id:" + CA_Id);
        $.post("http://q.sodao.com/handler/vote.ashx", { AU_Id: au_id, AppId: AppId, CA_Id: CA_Id, rnd: Math.random() }, function(data) {
            // SoDao.alertDiv.show('提示', "正在提交您的请求，请稍候...", "", 0, 200, 150, false, 1);
            //alert(data);
            if (data == "0") {
                SoDao.alertDiv.show('提示', "参数出错,投票失败", "", 0, 200, 150, false, 2);

            } else if (data == "-1") {
                SoDao.alertDiv.show('提示', "浏览器不支持Cookie,投票失败!", "", 0, 200, 150, false, 2);

            }
            else if (data == "-2") {
                SoDao.alertDiv.show('提示', "谢谢您的支持，投票结束，但还有机会猜冠军喔!", "", 0, 200, 150, false, 2);

            }
            else if (data == "-3") {
                SoDao.alertDiv.show('提示', "谢谢您的支持，投票已结束!", "", 0, 200, 150, false, 2);

            }
            else {

                var arr = data.split(",");
                if (arr[0] == "0") {
                    //失败
                    SoDao.alertDiv.show('提示', "感谢您的支持，今天已经为她投过票喽，请明天继续支持^_^", "", 0, 220, 150, false, 5);
                }
                else {
                    var num = parseInt($("#num" + au_id).html());
                    /**

                    if (arr[1] == "1") {
                    $("#num" + au_id).html(num + 10);
                    SoDao.alertDiv.show('提示', "感谢您的支持，今天您已成功为她增加了10张选票", "", 0, 220, 150, false, 5);
                    }
                    else {
                    **/
                    $("#num" + au_id).html(num + 1);
                    SoDao.alertDiv.show('提示', "感谢您的支持，今天您已成功为她增加了1张选票", "", 0, 220, 150, false, 5);
                    // }

                }

            }

        });

    },
    vote2sd: function(au_id) {
        //提交数据 titles: titles, desc: desc, tags: tags, imgs: imgs,
        //alert("au_id:" + au_id + "AppId:" + AppId + "CA_Id:" + CA_Id);
        $.post("http://q.sodao.com/handler/vote.ashx", { AU_Id: au_id, AppId: AppId, CA_Id: CA_Id, rnd: Math.random() }, function(data) {
            // SoDao.alertDiv.show('提示', "正在提交您的请求，请稍候...", "", 0, 200, 150, false, 1);
            if (data == "0") {
                SoDao.alertDiv.show('提示', "参数出错,投票失败", "", 0, 200, 150, false, 2);

            }
            else {

                var arr = data.split(",");
                if (arr[0] == "0") {
                    //失败
                    SoDao.alertDiv.show('提示', "感谢您的支持，今天已经为她投过票喽，请明天继续支持^_^", "", 0, 220, 150, false, 5);
                }
                else {
                    var wnum = parseInt($("#wnum" + au_id).html());
                    var hnum = parseInt($("#hnum" + au_id).html());
                    if (arr[1] == "1") {
                        $("#wnum" + au_id).html(wnum + 10);
                        $("#hnum" + au_id).html(hnum + 10);
                        SoDao.alertDiv.show('提示', "感谢您的支持，今天您已成功为她增加了10张选票", "", 0, 220, 150, false, 5);
                    }
                    else {
                        $("#wnum" + au_id).html(wnum + 1);
                        $("#hnum" + au_id).html(hnum + 1);
                        SoDao.alertDiv.show('提示', "感谢您的支持，今天您已成功为她增加了1张选票", "", 0, 220, 150, false, 5);
                    }

                }

            }

        });

    },
    /**************************************************
    * *功能描述：添加票数
    **************************************************/
    voteAdd:function(au_id)
    {
          var num = parseInt($("#num" + au_id).html());
          $("#num" + au_id).html(num + 1);
    },
    /**************************************************
    * *功能描述：竞猜
    **************************************************/
    guess: function(au_id, chinaName) {
        sodaoFashion.auId = au_id;
        sodaoFashion.chinaName = chinaName;

        $.post("http://q.sodao.com/handler/guess.ashx", { AU_Id: au_id, AppId: AppId, CA_Id: CA_Id, rnd: Math.random() }, function(data) {
            //    SoDao.alertDiv.show('提示', "正在提交您的请求，请稍候...", "", 0, 200, 150, false, 1);
            if (data == "0") {
                SoDao.alertDiv.show('提示', "很遗憾，竞猜失败。请先登陆！", "", 0, 250, 150, false, 2);
                $Wait.Init('/pop/login?rf=fsn_g_log_b', 350, 332);

            }
            else {
                SoDao.alertDiv.show('提示', "感谢您的支持，竞猜" + chinaName + "为冠军成功！", "", 0, 250, 150, false, 5);

            }

        });
    },
    /**************************************************
    * *功能描述：送糖
    **************************************************/
    gift: function(au_id) {
        sodaoFashion.auId = au_id;
        $.post("http://q.sodao.com/handler/gift.ashx", { AU_Id: au_id, AppId: AppId, CA_Id: CA_Id, rnd: Math.random() }, function(data) {
            // SoDao.alertDiv.show('提示', "正在提交您的请求，请稍候...", "", 0, 200, 150, false, 1);          
            if (data == "0") {
                SoDao.alertDiv.show('提示', "参数出错,送糖失败", "", 0, 200, 150, false, 2);
            }
            else if (data == "2") {
                SoDao.alertDiv.show('提示', "很遗憾，送糖失败。请先登陆！", "", 0, 250, 150, false, 2);
                $Wait.Init('/pop/login?rf=fsn_login_back', 350, 332);
            }
            else if (data == "3") {
                SoDao.alertDiv.show('提示', "很遗憾，送糖失败。您的积分不够，一颗糖需要您10个积分！", "", 0, 250, 150, false, 2);
            }
            else {
                var gnum = parseInt($("#gnum" + au_id).html());
                $("#gnum" + au_id).html(gnum + 1);
                SoDao.alertDiv.show('提示', "恭喜您送糖成功！", "", 0, 250, 150, false, 2);


            }

        });

    },
    /**************************************************
    * *功能描述：取得榜单数据
    **************************************************/
    getWeekBind: function(timeNum) {

        $("li[id^='li']").each(function() {
            $(this).removeClass("current");
        });
        $("#li" + timeNum).addClass("current");
        $("#weekBandList").html("正在载入中...");
        $.get("/h/getWeekBandList", { timeNum: timeNum, rnd: Math.random() }, function(data) {
            $("#weekBandList").html(data);

        });

    },
    /**************************************************
    * *功能描述：初始化索引框
    **************************************************/
    iniSearchText: function() {
        var str = $("#txtChinaName").val();
        if (str == "输入参选人姓名")
            $("#txtChinaName").val("");

    },
    /**************************************************
    * *功能描述：添加好友
    **************************************************/
    addFriend: function(umd) {
        $.post("/h/addFriend", { umd: umd, rnd: Math.random() }, function(data) {
            // SoDao.alertDiv.show('提示', "正在提交您的请求，请稍候...", "", 0, 200, 150, false, 1);           
            var s = eval("(" + data + ")");
            SoDao.alertDiv.show('提示', s.msg, "", 0, 200, 150, false, 2);


        });

    }



}
