﻿function fillData(ID, Text) {
    $.ajax({
        type: "POST", //URL类型
        contentType: "application/json",
        url: "Web/ToHomePage/Content.aspx?type=" + ID, //调用后台处理方法
        dataType: 'text', //返回的数据类型
        success: function(result) {
            document.getElementById(Text).innerHTML = result;
        },
        error: function(err) {

        }
    });
}
function fillTemplateContent() {
    $.ajax({
        type: "POST", //URL类型
        contentType: "application/json",
        url: "Web/ToHomePage/GroupContent.aspx", //调用后台处理方法
        dataType: 'text', //返回的数据类型
        success: function(result) {
        document.getElementById("getValue1").innerHTML = result;
        },
        error: function(err) {
            alert(err);
        }
    });
    toWriteMatch();
    toAwardNum();
    toAwardNum1();
    fillTemplateContent1();
    fillTemplateContent2();
    fillTemplateContent3();
}
function fillTemplateContent1() {
    $.ajax({
        type: "POST", //URL类型
        contentType: "application/json",
        url: "Web/ToHomePage/GroupContent.aspx?id=1", //调用后台处理方法
        dataType: 'text', //返回的数据类型
        success: function(result) {
            document.getElementById("getValue2").innerHTML = result;
        },
        error: function(err) {
            alert(err);
        }
    });

}
function fillTemplateContent2() {
    $.ajax({
        type: "POST", //URL类型
        contentType: "application/json",
        url: "Web/ToHomePage/GroupContent.aspx?id=3", //调用后台处理方法
        dataType: 'text', //返回的数据类型
        success: function(result) {
        document.getElementById("getValue3").innerHTML = result;
        },
        error: function(err) {
            alert(err);
        }
    });

}
function fillTemplateContent3() {
    $.ajax({
        type: "POST", //URL类型
        contentType: "application/json",
        url: "Web/ToHomePage/GroupContent.aspx?id=2", //调用后台处理方法
        dataType: 'text', //返回的数据类型
        success: function(result) {
        document.getElementById("getValue4").innerHTML = result;
        },
        error: function(err) {
            alert(err);
        }
    });

}
function fillNewsData(ID,divId) {
    $.ajax({
        type: "POST", //URL类型
        contentType: "application/json",
        url: "Web/ToHomePage/News.aspx?typeId=" + ID, //调用后台处理方法
        dataType: 'text', //返回的数据类型
        success: function(result) {
        if (document.getElementById(divId) != null) {
                document.getElementById(divId).innerHTML = result;
            }
        },
        error: function(err) {

        }
    });
}
function RegUserStatus()
{
    $.ajax({
        type: "POST", //URL类型
        async: false,
        contentType: "application/json",
        url: "/Web/ToHomePage/News.aspx?Test=status", //调用后台处理方法
        dataType: 'text', //返回的数据类型
        success: function(result) {
            if (result != "false") {

                var str = "<span class=\"recharge right\"><a href=\"Web/Member/UserCenter/User_Buy.aspx\" class=\"a1\" >充值</a>&nbsp;(<a href=\"Web/Html/help/20110606_31.html\" class=\"a2\">充值指南</a>)</span>欢迎 <span class=\"red\">" + result + "</span> 来到投注网！";
                var strA = "<a href=\"/Web/Member/UserCenter/My_Status.aspx\" class=\"a3\">用户中心</a><a href=\"javascript:void(0)\" onclick=\"exit();\" class=\"a2\">退出</a>"
                document.getElementById("UserStatus").innerHTML = str;
                document.getElementById("UserStatusA").innerHTML = strA;
              
            }

        },
        error: function(err) { return false; }
    });
  }


//获取帮助文件
  function GetHelpsFile() {
    
      $.ajax({
          type: "POST", //URL类型
          async: false,
          contentType: "application/json",
          url: "/Web/Help/JSpagefooter.aspx/getHelpfiles", //调用后台处理方法
          dataType: 'json', //返回的数据类型
          success: function(result) {
          //alert(result.d);
          var myvalue = result.d;
          document.getElementById("ulhelps").innerHTML = myvalue;

          },
          error: function(err) { return false; }
      });

  }

//获取常见问题
  function GetCommonFile() {

      $.ajax({
          type: "POST", //URL类型
          async: false,
          contentType: "application/json",
          url: "/Web/Help/JSpagefooter.aspx/getcommonfiles", //调用后台处理方法
          dataType: 'json', //返回的数据类型
          success: function(result) {
              //alert(result.d);
              var myvalue = result.d;
              document.getElementById("ulcommonfiles").innerHTML = myvalue;

          },
          error: function(err) { return false; }
      });

  }

//获取友情链接
  function GetFriendLinkFile() {

      $.ajax({
          type: "POST", //URL类型
          async: false,
          contentType: "application/json",
          url: "/Web/Help/JSpagefooter.aspx/getFriendlinkfiles", //调用后台处理方法
          dataType: 'json', //返回的数据类型
          success: function(result) {
              //alert(result.d);
              var myvalue = result.d;
              document.getElementById("divFriendlinkFiles").innerHTML = myvalue;

          },
          error: function(err) { return false; }
      });

  }
  //获取文字友情链接
  function GetwordFriendLinkFile() {

      $.ajax({
          type: "POST", //URL类型
          async: false,
          contentType: "application/json",
          url: "/Web/Help/JSpagefooter.aspx/getWordFriendlinkfiles", //调用后台处理方法
          dataType: 'json', //返回的数据类型
          success: function(result) {
              //alert(result.d);
              var myvalue = result.d;
              document.getElementById("wordFriendlink").innerHTML = myvalue;

          },
          error: function(err) { return false; }
      });

  }
  
  
  //加载作者头像
  function Getauthorinfo() {
      $.ajax({
          type: "POST", //URL类型
          async: false,
          contentType: "application/json",
          url: "Web/Help/JSpagefooter.aspx/Getauthorinfo", //调用后台处理方法
          dataType: 'json', //返回的数据类型
          success: function(result) {
              //alert(result.d);
              var myvalue = result.d;
              document.getElementById("ulload").innerHTML = myvalue;

          },
          error: function(err) { return false; }
      });

  }
//加载任九14场等
  function toTradition(typeId,tag,num) {
      $.ajax({
          type: "POST", //URL类型
          contentType: "application/json",
          url: "Web/ToHomePage/ToTradition.aspx?typeId=" + typeId + "&tag=" + tag + "&num=" + num, //调用后台处理方法
          dataType: 'text', //返回的数据类型
          success: function(result) {
              if (result.toString().length > 0) {
                  document.getElementById("fourScore").innerHTML = result;
              } else {
                  alert("该期数据暂无");
              }
          },
          error: function(err) {

          }
      });
  }

  //复选框提交
  function tijiao() {
  
      var k = "";
      var objs = document.getElementsByTagName("input");
      for (var i = 0; i < objs.length; i++) {
          if (objs[i].type == "checkbox") {
              if (objs[i].name == "hobby") {
                  if (objs[i].checked==true) {
                      k = k + objs[i].value + ",";
                  }
              }
          }
      }

      $.ajax({
          type: "POST", //URL类型
          async: false,
          contentType: "application/json",
          url: "Web/ToHomePage/News.aspx?Test=status", //调用后台处理方法
          dataType: 'text', //返回的数据类型
          success: function(result) {
          if (result != "false") {
                  //alert(k);

              }
              else {
                  alert("请先登录！");
                  return false;
              }

          },
          error: function(err) { return false; }
      });

  }

//验证用户是否存在
  function CheckUserIsExists() {
      $.ajax({
          type: "POST", //URL类型
          async: false,
          contentType: "application/json",
          url: "Web/ToHomePage/News.aspx?Test=status", //调用后台处理方法
          dataType: 'text', //返回的数据类型
          success: function(result) {
          if (result != "false") {
                  return true;

              }
              else {
                  alert("请先登录！");
                  return false;
              }

          },
          error: function(err) { return false; }
      });

  }

//首页关注栏目
function guanzhu(huan,type, id) {

     
      var users = "";
      $.ajax({
          type: "POST", //URL类型
          async: false,
          contentType: "application/json",
          url: "Web/ToHomePage/News.aspx?Test=myyanzheng", //调用后台处理方法
          dataType: 'text', //返回的数据类型
          success: function(result) {
              if (result != "false") {
                  users = result;

              }
              else {
                  alert("请先登录！");
                  return false;
              }

          },
          error: function(err) { return false; }
      });



      var tableId = "0";
      if (users != "") {
          if (type == "MatchContent_List.aspx") {
              tableId = "0";
          }
          else if (type == "BallContent_List.aspx") {
              tableId = "2";
          }
          else if (type == "Tradition_List.aspx") {
              tableId = "1";
          }
          var proid = id;



          var strValues = "{loginname:'" + users + "',proid:'" + proid + "',typeid:'" + tableId + "'}";

          $.ajax({
              type: "POST",
              contentType: "application/json; charset=utf-8",
              url: "Web/Help/JSpagefooter.aspx/getGuanzhu", //调用后台处理方法
              data: strValues, //此方法的参数
              dataType: 'json', //返回的数据类型
              success: function(result) {

                  if (result.d != '0')//更新成功
                  {
                      huan.className = "bottom_gz";
                      huan.disabled = "disabled";
                      huan.value = "已关注";
                      alert("添加关注成功！");

                  }
                  else {
                      alert("已添加的关注！");
                      huan.disabled = "disabled"
                      huan.className = "bottom_gz";
                  }


              },
              error: function() {
                  alert("NO!!!")
              }
          });

        }

    }
    //加载最近比赛
    function toWriteMatch() {
        $.ajax({
            type: "POST", //URL类型
            contentType: "application/json",
            url: "Web/ToHomePage/GetSechlude.aspx?id=2", //调用后台处理方法
            dataType: 'text', //返回的数据类型
            success: function(result) {
                document.getElementById("willMatch").innerHTML = result;
            },
            error: function(err) {
                
            }
        });
    }
    
    //加载数字彩开奖信息
    function toAwardNum() {
        $.ajax({
            type: "POST", //URL类型
            contentType: "application/json",
            url: "Web/ToHomePage/GetSechlude.aspx?id=1", //调用后台处理方法
            dataType: 'text', //返回的数据类型
            success: function(result) {
                document.getElementById("awardS").innerHTML = result;
            },
            error: function(err) {

            }
        });
    }

    //加载足彩开奖信息
    function toAwardNum1() {
        $.ajax({
            type: "POST", //URL类型
            contentType: "application/json",
            url: "Web/ToHomePage/GetSechlude.aspx?id=200", //调用后台处理方法
            dataType: 'text', //返回的数据类型
            success: function(result) {
                document.getElementById("awardS1").innerHTML = result;
            },
            error: function(err) {

            }
        });
    }
    
    
    //添加一键关注功能
    function OneKeyCare(mytype) {
        var users = "";
        $.ajax({
            type: "POST", //URL类型
            async: false,
            contentType: "application/json",
            url: "Web/ToHomePage/News.aspx?Test=myyanzheng", //调用后台处理方法
            dataType: 'text', //返回的数据类型
            success: function(result) {
                if (result != "false") {
                    users = result;

                }
                else {
                    alert("请先登录！");
                    return false;
                }

            },
            error: function(err) { return false; }
        });
        if (users != "") {
            var k = "";
            var objs = document.getElementsByTagName("input");
            for (var i = 0; i < objs.length; i++) {
                if (objs[i].type == "checkbox") {
                    if (objs[i].name == mytype) {
                        if (objs[i].checked == true) {
                            k = k + "," + objs[i].value;
                        }
                    }
                }
            }
            if (k == "") {
                alert("请至少选择一项！");
                return false;
            }
            else {


                var proids = k;

                var strValues = "{loginname:'" + users + "',proids:'" + proids + "'}";

                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "Web/Help/JSpagefooter.aspx/OneKeyCare", //调用后台处理方法
                    data: strValues, //此方法的参数
                    dataType: 'json', //返回的数据类型
                    success: function(result) {

                        if (result.d != '0')//更新成功
                        {
                            alert("添加关注成功！");

                        }
                        else {
                            alert("已添加的关注！");
                        }
                         fillTemplateContent();

//                        for (var i = 0; i < objs.length; i++) {
//                            if (objs[i].type == "checkbox") {
//                                if (objs[i].name == mytype) {
//                                    if (objs[i].checked == true) {
//                                        objs[i].disabled = "disabled";
//                                        objs[i].className = "hotattentioned";
//                                    }
//                                }
//                            }
//                        }


                    },
                    error: function() {
                        alert("NO!!!")
                    }
                });

            }

          
        }


    }

    //帮助文件头部用户名绑定


    function HelpFileRegUserStatus() {
        $.ajax({
            type: "POST", //URL类型
            async: false,
            contentType: "application/json",
            url: "../../ToHomePage/News.aspx?Test=status", //调用后台处理方法
            dataType: 'text', //返回的数据类型
            success: function(result) {
                if (result != "false") {
                    var str = "欢迎<span class=\"red\">" + result + "</span>来到投注网！<span class=\"p15\"><span class=\"grzx\" ><a href=\"../../Member/UserCenter/My_Status.aspx\">用户中心</a></span> | <a onclick=\"HelpExit();\">退出</a></span>"
                    var strs = "<li class=\"li1\">" + result + "您好，投注网欢迎您！<span class=\"recharge right\"><a href=\"#\" class=\"a2\" >帮助指南</a></span></li> <li class=\"li2\"><a href=\"/Web/Member/UserCenter/My_Status.aspx\" class=\"a3\">用户中心</a><a href=\"#\" onclick=\"exit();\" class=\"a2\">退出</a></li>";

                 
                    document.getElementById("UserStatus").innerHTML = str;
                    document.getElementById("UserName").innerHTML = result;
                    document.getElementById("beforeLogin").style.display = "none";
                    document.getElementById("afterLogin").style.display = "";
                }

            },
            error: function(err) { return false; }
        });
    }


    //帮助文件 头部 退出

    function HelpExit() {
        $.ajax({
            type: "POST", //URL类型
            async: false,
            contentType: "application/json",
            url: "../../Member/Tool.aspx?Exit=OK", //调用后台处理方法
            dataType: 'text', //返回的数据类型
            beforeSend: function(XMLHttpRequest) {
            },
            success: function(result) {
                if (result == "true") {
                    var str = "欢迎来到投注网！<span class=\"p15\"><a href=\"../../Member/Login.aspx\">请登录</a> | <a href=\"../../Member/Register.aspx\">注册</a></span>";

                    var strs = "<li class=\"li1\">您好，投注网欢迎您！<span class=\"recharge right\"><a href=\"#\" class=\"a2\" >帮助指南</a></span></li> <li class=\"li2\"><a href=\"../../Member/Login.aspx\" class=\"a3\">登录</a><a href=\"../../Member/Register.aspx\" class=\"a2\">注册</a></li>";
                 
                    document.getElementById("UserStatus").innerHTML = str;
                    
                    
                    
//                    document.getElementById("beforeLogin").style.display = "";
//                    document.getElementById("afterLogin").style.display = "none";
                }
                else {
                    alert("退出失败！");
                }
            },
            error: function(err) { return false; }
        });
    }


    //加载新闻图片
    function loadPicNews() {
        $.ajax({
            type: "POST", //URL类型
            async: false,
            contentType: "application/json",
            url: "/Web/Help/helpFile.aspx/GetNewPic", //调用后台处理方法
            dataType: 'json', //返回的数据类型
            beforeSend: function(XMLHttpRequest) {
            },
            success: function(result) {


            var myvalue = result.d;

            document.getElementById("NewsPic").innerHTML = myvalue;
            },
            error: function(err) { return false; }
        });

    }

    //loadjujiao


    //加载聚焦新闻
    function loadjujiao() {
        $.ajax({
            type: "POST", //URL类型
            async: false,
            contentType: "application/json",
            url: "/Web/Help/helpFile.aspx/GetJujiao", //调用后台处理方法
            dataType: 'json', //返回的数据类型
            beforeSend: function(XMLHttpRequest) {
            },
            success: function(result) {


                var myvalue = result.d;
                document.getElementById("jujiao").innerHTML = myvalue;
            },
            error: function(err) { return false; }
        });

    }

    function clearshuancun() {

        $.ajax({
            type: "POST", //URL类型
            async: false,
            contentType: "application/json",
            url: "/Web/Help/JSpagefooter.aspx/clearshuancun", //调用后台处理方法
            dataType: 'json', //返回的数据类型
            success: function(result) {

            },
            error: function(err) { return false; }
        });

    }

    function loadpics() {
        $.ajax({
            type: "POST", //URL类型
            async: false,
            contentType: "application/json",
            url: "/Web/Help/helpFile.aspx/loadpics", //调用后台处理方法
            dataType: 'json', //返回的数据类型
            beforeSend: function(XMLHttpRequest) {
            },
            success: function(result) {


                var myvalue = result.d;
                document.getElementById("myinners").innerHTML = myvalue;
            },
            error: function(err) { return false; }
        });

    }
