var index;
/*<![CDATA[*/
(function($){ // 滚动插件代码
    $.fn.scroll = function(options){
        options = options || {};
        this.css('overflow', 'hidden');
        var scroll = (function(self){
            return function(){
                if (self.data('scroll_stop')) {
                    return;
                }
                var li = self.find('li:first');
                var t = parseInt(li.css('marginTop')) || 0;
                li.animate({
                    'marginTop': (t - li.outerHeight()) * (options.step || 1) + 'px'
                }, options.speed || 'slow', function(){
                    self.append(li);
                    li.css('marginTop', t + 'px');
                });
            };
        })(this);
        setInterval(scroll, options.delay || 2000);
        this.hover(function(){
            $(this).data('scroll_stop', true);
        }, function(){
            $(this).removeData('scroll_stop');
        });
    };
})(jQuery);
/*]]>*/
$(document).ready(function(){
    $('#clock').epiclock({
        format: ' Y年F月j日　G:i:s　D'
    });
    $.epiclock();
    $('.topdiv').animate({
        opacity: '0.5'
    }, 100).hover(function(){
        $(this).stop().animate({
            opacity: '1.0'
        }, 100);
    }, function(){
        $(this).stop().animate({
            opacity: '0.5'
        }, 100);
    });
    $('.clock').animate({
        opacity: '1.0'
    }, 100);
    $('#weather_inc').attr('src', 'http://tianqi.xixik.com/cframe?type=1');
    $('#gosearch').click(function(){
        location.href = '/search/index.asp?searchword=' + $('#searchword').val() + '&classid=' + $('#classid').val();
    });
    $('.footernav').corner('5px');
    $('.nav').corner('bl 10px br 10px');
    $('div[tab]').each(function(){
        $('span', this).each(function(){
            $(this).hover(function(){
                $(this).siblings().addClass('ntopnotselected');
                $(this).removeClass('ntopnotselected');
                $($(this).attr('alt')).siblings().addClass('displaynone');
                $($(this).attr('alt')).removeClass('displaynone');
            });
        });
    });
    $('.scrollBox:first').scroll({
        delay: 3000
    });
    //$('.scroll:first').scroll({
    //    delay: 2000,
    //    step: 8,
    //   speed: 1000
    //});
    //$('.scroll:last').rollList();
    //$('.scroll:last').scroll({
    //   delay: 2500,
    //   step: 9,
    //  speed: 1000
    //});
    $('#mainnav ul li').each(function(){
        $(this).click(function(){
            $(this).siblings().removeClass('mainnavselected');
            $(this).addClass('mainnavselected');
            $('#sub' + $(this).attr('id')).siblings().slideUp(100);
            $('#sub' + $(this).attr('id')).slideDown(100);
        });
    });
    index = {
        ajaxmanager: null,
        init: function(){
            this.getnews();
        },
        picnews: function(){
            var ii = 0;
            $('.slideshow').cycle({
                fx: 'zoom',
                speed: 2000,
                delay: -2000,
                pause: 1,
                before: function(t){
                    var ptitle = $('.pictitle>span').get(($('.slideshow>a').index($(t)) + (ii == 0 ? ii++ : 1)) % 5);
                    $(ptitle).siblings().hide();
                    $(ptitle).show();
                }
            });
        },
        getnews: function(){
            this.ajaxmanager = new $.manageAjax.create({
                queue: true
            });
            var ajaxgetnews = this.ajaxmanager;
            $('.ajaxgetnews[newsflag]').each(function(){
                var t = this;
                ajaxgetnews.add({
                    success: function(html){
                        //alert(html);
                        $(t).append('d');
                        $(t).html(html);
                        index.picnews();
                    },
                    url: 'index/news.asp',
                    data: {
                        flag: ($(t).attr('newsflag') || 0),
                        len: ($(t).attr('len') || 12),
                        ps: ($(t).attr('ps') || 10),
                        gt: ($(t).attr('gt') || 1)
                    }
                });
            });
        }
    };
    index.init();
});

