﻿$(document).ready(function() {

    //loading('top');
    $('#top').load("../zt/include/top.jsp");   //加载首页头部
    //loading('menu');
    $('#menu').load("../zt/index/menu.html");   //加载首页导航栏
    $('#about').load("../zt/include/about.jsp");   //加载首页导航栏
    $('#copyRight').load("../zt/include/copyRight.jsp");   //加载首页导航栏
    //loading('userLogin');
    var pars = "action=check&ajax=XML";
    $.ajax({
        type:"Post",
        url:"../userLogin.tbs",
        dataType:"json",
        data:pars,
        success:function(msg) {
            if (msg.message == '0') {
                $('#userLogin').load("../zt/index/userLogin.jsp");
            } else {
                $('#userLogin').load("../zt/index/userInfo.jsp");
            }
        }
    });
    //loading('date');
    $('#date').load("../zt/index/calendar.jsp");   //加载首页日期页面
    //loading('flink');
    $('#flink').load("../zt/index/fLink.html");   //加载首页友情链接
    // loading('ad');
    $('#ad').load("../zt/index/ad.html");   //加载首页广告
    //  loading('search');
    $('#search').load("../zt/index/search.jsp");   //加载首页中部搜索区
    // loading('news_pic');
    $('#news_pic').load("../zt/index/news_pic.html");   //加载首页中部最新新闻图片区
    // loading('news_content_new');
    $('#news_content_new').load("../zt/index/news_content_new.html");   //加载首页中部最新新闻
    //  loading('c_ad');
    $('#c_ad').load("../zt/index/c_ad.html");   //加载首页中部广告
    //loading('c_news_1');
    $('#c_news_1').load("../zt/index/c_news_1.html");   //加载首页中部新闻区
    //  loading('c_news_2');
    $('#c_news_2').load("../zt/index/c_news_2.html");   //加载首页中部新闻区
    //  loading('c_news_3');
    $('#c_news_3').load("../zt/index/c_news_3.html");   //加载首页中部新闻区
    //  loading('c_news_4');
    $('#c_news_4').load("../zt/index/c_news_4.html");   //加载首页中部新闻区
    //  loading('tjxx');
    $('#tjxx').load("../zt/index/tjxx.html");   //加载首页右侧推荐信息

    $('#ymyc').load("../zt/index/r_ad.html");  //加载页面右侧广告
    //  loading('pic_center');
    $('#pic_center').load("../zt/index/pic_center.html");   //加载首页右侧图片中心
    //  loading('message');
    $('#message').load("../zt/index/notice_list.html");   //加载首页右侧中心通知

    /* $('#slider').s3Slider({

     timeOut: 3000
     });*/

});

function userLogin() {
    var txtName = $('#txtName').val();
    var txtPwd = $('#txtPwd').val();
    var pars = "action=userEbsLogin&ajax=XML&txtName=" + txtName + "&txtPwd=" + txtPwd;
    //alert(pars);
    $.ajax({
        type:"Post",
        url:"../userLogin.tbs",
        dataType:"json",
        data:pars,
        success:function(msg) {
            //alert(msg.message);
            if (msg.message == '0') {
                $('#userLogin').load("index/userLogin.jsp");
            } else if (msg.message == '1') {
                $('#userLogin').load("index/userInfo.jsp");
            } else {
                alert(msg.message);
            }
        }
    });
    /*alert($('#userLogin'));
     $("form:first").submit();
     $('#userLogin').submit(); */
}
function userLogout() {

    var pars = "action=userEbsLogout&ajax=XML";

    $.ajax({
        type:"Post",
        url:"../userLogin.tbs",
        dataType:"json",
        data:pars,
        success:function(msg) {
            //alert(msg.message);
            if (msg.message == '0') {
                $('#userLogin').load("index/userLogin.jsp");
            } else {
                $('#userLogin').load("index/userInfo.jsp");
            }
        }
    });
    /*alert($('#userLogin'));
     $("form:first").submit();
     $('#userLogin').submit(); */
}

function loading(id) {
    $('#' + id).html("<span id='loading'><img src='../images/loading2.gif'/></span>");
    $("#loading").css({ "margin-left": "50%","margin-top": "30%"});
}
function check() {
    if ($("#searchkey").val() == null || $("#searchkey").val().length <= 0 || $("#searchkey").val().replace(/\s/g, "") == "") {
        alert("检索词不能为空!");
        return false;
    }
}
