﻿


    // 实现滤镜的效果
    function filtersEffects(obj) {
        //首先判断是否存在滤镜，如果存在则应用滤镜效果
        if ($(obj)[0].filters) {
            //每次请求应用不同的效果
            $(obj)[0].filters.revealTrans.Transition = Math.random() * 23;
            // 应用并播放切换效果
            $(obj)[0].filters.revealTrans.apply();
            $(obj)[0].filters.revealTrans.play();
        }

    }


    $(document).ready(function() {



        // 定时器
        var timeDelay;
        // 公告自动浏览时的时间间隔
        var timeInterval = 5000;
        // Array对象,存储公告内容
        var bulletin = new Array();
        //button下划线on的颜色#ce0609
        var buttonLineOn = "#009900";
        //button下划线off的颜色
        var buttonLineOff = "#000";
        // 当前显示的公告序号
        var num;
        var bulletincount = 0;

        //公告滑动播放
        var BulletinSlide = function() {
            // 当前公告的序号向后移动,如果已经是最后一张,
            // 则切换到第一条公告
            if (bulletin.length > 0) {
                num++;
                num %= bulletin.length;
                // 公告的切换效果
                //filtersEffects("#slideShow");

                // 将<img>对象的src属性设置为当前num对应的路径
                // 切换公告的显示
                $("#slideShow").fadeOut();
                $("#slideShow").html(bulletin[num]).fadeIn("slow");
                $("#link" + num).css("background", buttonLineOn);
                for (var i = 0; i < bulletincount; i++) {
                    if (i != num) { $("#link" + i).css("background", buttonLineOff); }
                }
                timeDelay = setTimeout(function() {
                    BulletinSlide();
                }, timeInterval);
            }
        };

        $.getJSON('/pagehandle/bulletinHandle.ashx', function(result) {
            $("#slideShow").empty();
            $.each(result, function(entryIndex, entry) {
                bulletin[entryIndex] = entry['bulletinContent'];
                var html = '<a id="link' + entryIndex + '" rel="' + entryIndex + '" class="button" style="cursor:pointer;" onFocus="this.blur()">' + (entryIndex + 1) + '</a>';
                $("#imgTitle").append(html);
            });
            // 初始化一些变量
            num = -1;
            bulletincount = bulletin.length
            BulletinSlide();

            //公告栏按钮点击切换
            $("#imgTitle .button").click(function() {
                var linkrel = $(this).attr('rel');
                num = parseInt(linkrel, 10);
                clearTimeout(timeDelay);
                //alert(num);
                num--;
                BulletinSlide();
            });
        });



        //获取团体会员会议图像介绍
        $.getJSON('/pagehandle/memberimgHandle.ashx', function(result) {
            $.each(result, function(entryIndex, entry) {
                var html = '<li style="margin:0px;"><img src="' + entry['imgUrl'] + '" alt="' + entry['imgtext'] + '" style="margin:0px;width:188px;height:116px;"/></li>';
                $("#MemberPicBox > ul").append(html);

            });
            $("#MemberPicBox.smallslider").smallslider({ SwitchEffect: 'fadeIn', ShowButton: false, ShowText: true, TextLink: false, Position: 'Center', SwitchMode: 'Hover' });
        });


        // 定时器
        var timePublisherDelay;
        // 图像自动浏览时的时间间隔
        var timePublisherInterval = 6000;
        // 当前显示的图像序号
        var picnum;


        var PublisherSlideShow = function() {
            // 当前图像的序号向后移动,如果已经是最后一张,
            // 则切换到第一条图像
            picnum++;
            picnum %= publisherimg.length;
            // 图像的切换效果
            //filtersEffects("#PublisherSlideShow");

            // 将<img>对象的src属性设置为当前num对应的路径
            // 切换出版物图像的显示
            $("#slideShow").hide();
            $("#slideShow").html(bulletin[num]).fadeIn("slow");
            $("#link" + num).css("background", buttonLineOn);
            for (var i = 0; i < bulletincount; i++) {
                if (i != num) { $("#link" + i).css("background", buttonLineOff); }
            }
            timePublisherDelay = setInterval(function() {
                PublisherSlideShow();
            }, timePublisherInterval);

        };

        $('#playerBox').html("<div style='color:green;font-size:20px;font-weight:bold;padding-top:120px;width:100%;text-align:center;'>图像新闻加载中，请稍候...</div>");
        $.getJSON('/pagehandle/picnewsHandle.ashx', function(result) {
            $('#playerBox').empty();
            var arrImg = new Array();
            var arrText = new Array();
            var arrUrl = new Array();
            var newsimgLen = 0
            $.each(result, function(entryIndex, entry) {
                arrImg[newsimgLen] = "\"" + entry['imgUrl'] + "\"";
                arrText[newsimgLen] = "\"" + entry['imgtext'] + "\"";
                arrUrl[newsimgLen] = "\"" + entry['imgLink'] + "\"";
                newsimgLen++

            });
            $("#playerBox").showNews(eval("([" + arrImg.join(",") + "])"), eval("([" + arrText.join(",") + "])"), eval("([" + arrUrl.join(",") + "])"));
            //$("#playerBox").showNews(["/img/20111116/201111160309573107.jpg","/img/20111116/201111160310154659.jpg","/img/20111116/201111160313573495.jpg"], ["宜宾市茶业产销战略合作洽谈会举行","19785全国茶叶标准化生产专题研讨会在五峰隆重召开","湖南古丈“五步棋”走活茶叶产业化新路子"], ["/news/6/4639.aspx","/news/9/4623.aspx","/news/6/4603.aspx"]);

        });




    });






