/// <reference path="jquery-1.10.2.min.js" />
var editor;

$(function () {
    editor = CKEDITOR.replace('Game_body',
{
    filebrowserImageUploadUrl: "/ajax/Admin_AjaxUpImage.ashx?cmd=uploadImage"
});
    $("#Game_Btn").click(function (e) {
        e.preventDefault();
        var Game_Name = $.trim($("#Game_Name").val());
        var Game_Simple = $.trim($("#Game_Simple").val());
        var img = $.trim($("#img").attr("src"));
        var imgSelf = $.trim($("#imgSelf").attr("src"));
        var imgSelfs = $.trim($("#imgSelfs").attr("src"));
        var imgSelfn = $.trim($("#imgSelfn").attr("src"));
        var imgSelfj = $.trim($("#imgSelfj").attr("src"));
        var imgSelfz = $.trim($("#imgSelfz").attr("src"));
        var Game_Cate = $.trim($("#Game_Cate").val());
        var Game_Big = $.trim($("#Game_Big").val());
        var Game_Fen = $.trim($("#Game_Fen").val());
        var Game_Grade = $.trim($("#Game_Grade").val());
        var Game_Lang = $.trim($("#Game_Lang").val());
        var Game_Version = $.trim($("#Game_Version").val());
        var Game_Mood = $.trim($("#Game_Mood").val());
        var Game_Zan = $.trim($("#Game_Zan").val());
        var Game_Cai = $.trim($("#Game_Cai").val());
        var Game_Downs = $.trim($("#Game_Downs").val());
        var Game_grant = $.trim($("#Game_grant").val());
        var Game_Link = $.trim($("#Game_Link").val());
        var Game_Links = $.trim($("#Game_Links").val());
        var Game_Top = $.trim($("#Game_Top").val());
        var Game_Rotion = $.trim($("#Game_Rotion").val());
        var Rotionimg = $.trim($("#Rotionimg").attr("src"))
        var text = editor.getData();
        if (Game_Name == "") {
            alert("手游名称不能为空");
            return;

        }
        if (Game_Simple == "") {
            alert("手游简称不能为空");
            return;

        }
        if (img == "") {
            alert("手游主图不能为空");
            return;

        } if (Game_Cate == "") {
            alert("手游分类不能为空");
            return;
        } if (Game_Big == "") {
            alert("手游大小不能为空");
            return;
        } if (Game_Lang == "") {
            alert("手游语言不能为空");
            return;
        } if (text == "") {
            alert("手游内容不能为空");
            return;
        } else {
            $.post("/ajax/Admin_GameBase.ashx", { "type": "GameAdd", "Game_Name": Game_Name, "Game_Simple": Game_Simple, "img": img, "imgSelf": imgSelf, "imgSelfs": imgSelfs, "imgSelfn": imgSelfn, "imgSelfj": imgSelfj, "imgSelfz": imgSelfz, "Game_Cate": Game_Cate, "Game_Big": Game_Big, "Game_Lang": Game_Lang, "Game_Version": Game_Version, "Game_Mood": Game_Mood, "Game_Zan": Game_Zan, "Game_Cai": Game_Cai, "Game_Link": Game_Link, "Game_Links": Game_Links, "text": text, "Game_Top": Game_Top, "Game_Rotion": Game_Rotion, "Rotionimg": Rotionimg, "Game_Fen": Game_Fen, "Game_Grade": Game_Grade, "Game_Downs": Game_Downs, "Game_grant": Game_grant }, function (data) {
                var data = eval('(' + data + ')');
                if (data.Success == true) {
                    alert("添加成功");
                    window.location.href = "./Admin_GameList.aspx";
                    return;
                } 
                if (data.Success == false) {
                    alert("手游内容不能以空格提交");
                    
                } else {
                    alert("添加失败");
                    return;
                }



            })


        }


    })

    $("#Game_Edit_Btn").click(function (e) {
        e.preventDefault();
        var id = $.trim($("#usersid").val());
        var Game_Edit_Id = $.trim($("#Game_Edit_Id").val());
        var Game_Edit_Name = $.trim($("#Game_Edit_Name").val());
        var Game_Edit_Simple = $.trim($("#Game_Edit_Simple").val());
        var img = $.trim($("#img").attr("src"));
        var imgSelf = $.trim($("#imgSelf").attr("src"));
        var imgSelfs = $.trim($("#imgSelfs").attr("src"));
        var imgSelfn = $.trim($("#imgSelfn").attr("src"));
        var imgSelfj = $.trim($("#imgSelfj").attr("src"));
        var imgSelfz = $.trim($("#imgSelfz").attr("src"));
        var imgs = $.trim($("#imgs").attr("src"));
        var imgd = $.trim($("#imgd").attr("src"));
        var Game_Edit_Cate = $.trim($("#Game_Edit_Cate").val());
        var Game_Edit_Big = $.trim($("#Game_Edit_Big").val());
        var Game_Edit_Fen = $.trim($("#Game_Edit_Fen").val());
        var Game_Edit_Grade = $.trim($("#Game_Edit_Grade").val());
        var Game_Edit_Lang = $.trim($("#Game_Edit_Lang").val());
        var Game_Edit_Version = $.trim($("#Game_Edit_Version").val());
        var Game_Edit_Mood = $.trim($("#Game_Edit_Mood").val());
        var Game_Edit_Zan = $.trim($("#Game_Edit_Zan").val());
        var Game_Edit_Cai = $.trim($("#Game_Edit_Cai").val());
        var Game_Edit_Downs = $.trim($("#Game_Edit_Downs").val());
        var Game_Edit_grant = $.trim($("#Game_Edit_grant").val());
        var Game_Edit_Status = $.trim($("#Game_Edit_Status").val());
        var Game_Edit_Top = $.trim($("#Game_Edit_Top").val());
        var Game_Edit_Notes = $.trim($("#Game_Edit_Notes").val());
        var Game_Edit_Jujue = $.trim($("#Game_Edit_Jujue").val());
        var Game_Edit_Rotion = $.trim($("#Game_Edit_Rotion").val());
        var Game_Edit_Link = $.trim($("#Game_Edit_Link").val());
        var Game_Edit_Links = $.trim($("#Game_Edit_Links").val());
        var Rotionimg = $.trim($("#Rotionimg").attr("src"));
        var text = editor.getData();
        if (Game_Edit_Name == "") {
            alert("手游名称不能为空");
            return;

        }
        if (Game_Edit_Simple == "") {
            alert("手游简称不能为空");
            return;

        }
        if (img == "") {
            alert("手游主图不能为空");
            return;

        } if (Game_Edit_Cate == "") {
            alert("手游分类不能为空");
            return;
        } if (Game_Edit_Big == "") {
            alert("手游大小不能为空");
            return;
        } if (Game_Edit_Lang == "") {
            alert("手游语言不能为空");
            return;
        } if (text == "") {
            alert("手游内容不能为空");
            return;
        } else {
            $.post("/ajax/Admin_GameBase.ashx", { "type": "GameEdit", "id": id, "Game_Edit_Id": Game_Edit_Id, "Game_Edit_Name": Game_Edit_Name, "Game_Edit_Simple": Game_Edit_Simple, "img": img, "imgSelf": imgSelf, "imgSelfs": imgSelfs, "imgSelfn": imgSelfn, "imgSelfj": imgSelfj, "imgSelfz": imgSelfz, "Game_Edit_Cate": Game_Edit_Cate, "Game_Edit_Big": Game_Edit_Big, "Game_Edit_Lang": Game_Edit_Lang, "Game_Edit_Version": Game_Edit_Version, "Game_Edit_Mood": Game_Edit_Mood, "Game_Edit_Zan": Game_Edit_Zan, "Game_Edit_Cai": Game_Edit_Cai, "Game_Edit_Link": Game_Edit_Link, "Game_Edit_Links": Game_Edit_Links, "text": text, "Game_Edit_Status": Game_Edit_Status, "Game_Edit_Top": Game_Edit_Top, "Game_Edit_Rotion": Game_Edit_Rotion, "Rotionimg": Rotionimg, "Game_Edit_Fen": Game_Edit_Fen, "Game_Edit_Grade": Game_Edit_Grade, "Game_Edit_Downs": Game_Edit_Downs, "imgs": imgs, "imgd": imgd, "Game_Edit_Notes": Game_Edit_Notes, "Game_Edit_Jujue": Game_Edit_Jujue, "Game_Edit_grant": Game_Edit_grant }, function (data) {
                var data = eval('(' + data + ')');
                if (data.Success == true) {
                    alert("修改成功");
                    window.location.href = "./Admin_GameList.aspx";
                    return;
                }
                if (data.Success == false) {
                    alert("手游内容不能以空格提交");

                } else {
                    alert("修改失败");
                    return;
                }



            })


        }


    })


    $("#Game_Update_Btn").click(function (e) {
        e.preventDefault();
        var Game_Update_Id = $.trim($("#Game_Update_Id").val());
        var Game_Update_Name = $.trim($("#Game_Update_Name").val());
        var Game_Update_Simple = $.trim($("#Game_Update_Simple").val());
        var img = $.trim($("#img").attr("src"));
        var imgSelf = $.trim($("#imgSelf").attr("src"));
        var imgSelfs = $.trim($("#imgSelfs").attr("src"));
        var imgSelfn = $.trim($("#imgSelfn").attr("src"));
        var imgSelfj = $.trim($("#imgSelfj").attr("src"));
        var imgSelfz = $.trim($("#imgSelfz").attr("src"));
        var imgs = $.trim($("#imgs").attr("src"));
        var imgd = $.trim($("#imgd").attr("src"));
        var Game_Update_Cate = $.trim($("#Game_Update_Cate").val());
        var Game_Update_Big = $.trim($("#Game_Update_Big").val());
        var Game_Update_Fen = $.trim($("#Game_Update_Fen").val());
        var Game_Update_Grade = $.trim($("#Game_Update_Grade").val());
        var Game_Update_Lang = $.trim($("#Game_Update_Lang").val());
        var Game_Update_Version = $.trim($("#Game_Update_Version").val());
        var Game_Update_Mood = $.trim($("#Game_Update_Mood").val());
        var Game_Update_Zan = $.trim($("#Game_Update_Zan").val());
        var Game_Update_Cai = $.trim($("#Game_Update_Cai").val());
        var Game_Update_grant = $.trim($("#Game_Update_grant").val());
        var Game_Update_Downs = $.trim($("#Game_Update_Downs").val());
        var Game_Update_Status = $.trim($("#Game_Update_Status").val());
        var Game_Update_Top = $.trim($("#Game_Update_Top").val());
        var Game_Update_Notes = $.trim($("#Game_Update_Notes").val());
        var Game_Update_Jujue = $.trim($("#Game_Update_Jujue").val());
        var Game_Update_Rotion = $.trim($("#Game_Update_Rotion").val());
        var Game_Update_Link = $.trim($("#Game_Update_Link").val());
        var Game_Update_Links = $.trim($("#Game_Update_Links").val());
        var Rotionimg = $.trim($("#Rotionimg").attr("src"));
        var text = editor.getData();
        if (Game_Update_Name == "") {
            alert("手游名称不能为空");
            return;

        }
        if (Game_Update_Simple == "") {
            alert("手游简称不能为空");
            return;

        }
        if (img == "") {
            alert("手游主图不能为空");
            return;

        } if (Game_Update_Cate == "") {
            alert("手游分类不能为空");
            return;
        } if (Game_Update_Big == "") {
            alert("手游大小不能为空");
            return;
        } if (Game_Update_Lang == "") {
            alert("手游语言不能为空");
            return;
        } if (text == "") {
            alert("手游内容不能为空");
            return;
        } else {
            $.post("/ajax/Admin_GameBase.ashx", { "type": "GameUpdate", "Game_Update_Id": Game_Update_Id, "Game_Update_Name": Game_Update_Name, "Game_Update_Simple": Game_Update_Simple, "img": img, "imgSelf": imgSelf, "imgSelfs": imgSelfs, "imgSelfn": imgSelfn, "imgSelfj": imgSelfj, "imgSelfz": imgSelfz, "Game_Update_Cate": Game_Update_Cate, "Game_Update_Big": Game_Update_Big, "Game_Update_Lang": Game_Update_Lang, "Game_Update_Version": Game_Update_Version, "Game_Update_Mood": Game_Update_Mood, "Game_Update_Zan": Game_Update_Zan, "Game_Update_Cai": Game_Update_Cai, "Game_Update_Link": Game_Update_Link, "Game_Update_Links": Game_Update_Links, "text": text, "Game_Update_Status": Game_Update_Status, "Game_Update_Top": Game_Update_Top, "Game_Update_Rotion": Game_Update_Rotion, "Rotionimg": Rotionimg, "Game_Update_Fen": Game_Update_Fen, "Game_Update_Grade": Game_Update_Grade, "Game_Update_Downs": Game_Update_Downs, "imgs": imgs, "imgd": imgd, "Game_Update_Jujue": Game_Update_Jujue, "Game_Update_Notes": Game_Update_Notes, "Game_Update_grant": Game_Update_grant }, function (data) {
                if (data == "empty") {
                    alert("内容不能以空格提交");
                    return;

                }
                var data = eval('(' + data + ')');
                if (data.Success == true) {
                    alert("更新成功");
                    window.location.href = "./Admin_GameList.aspx";
                    return;
                }
                if (data.Success == false) {
                    alert("对不起，版本号一致，请更新最新版本");
                    
                } else {
                    alert("更新失败");
                    return;
                }
               
               


            })


        }


    })




})



$(function () {
    $("#Game_Rotion,#Game_Edit_Rotion,#Game_Update_Rotion").on("change", function () {
        if ($(this).val() == "1") {
            $("#Game_Rtionst").show();
        } else {
            $("#Game_Rtionst").hide();

        }

    })
})