 /**
 * Auto Check Add Admin
 * @ Author: CS.Fang , Fangcs@hjy123.com
 * @ Create date: 2009-07-10 12:09:26
 */
$(function() {
    showtime();
    $('#task_list').scroll({delay: 2500});
});

//滚动插件
(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'), t = parseInt(li.css('marginTop')) || 0;
            li.animate({ 'marginTop': (t - li.outerHeight()) + 'px'}, options.speed || 'slow', function() {
                li.appendTo(self).css('marginTop', t + 'px');
            });
        };
    })(this);

    setInterval(scroll, options.delay || 3000);

    this.hover(function() {
      $(this).data('scroll_stop', true);
    }, function() {
      $(this).removeData('scroll_stop');
    });
  };
})(jQuery);

function get_new_task_list( area_id,  type_id) {
    $.post( 'ajax.php', { action: 'get_new_task_list', area_id: area_id, type_id: type_id }, function(data) {
        if( 'error' != data )
        {
            $('#task_list').html(data);
        }
        else
        {
            alert('获取任务信息错误!');
        }
    }, 'html' );  //end .post

    setTimeout( 'get_new_task_list(' + area_id + ',' + type_id +')', 200*1000);
};

function get_task_list( area_id,  dept_id) {
    $.post( 'ajax.php', { action: 'get_task_list', area_id: area_id, dept_id: dept_id }, function(data) {
        if( 'error' != data )
        {
            $('#task_list').html(data);
        }
        else
        {
            alert('获取任务信息错误!');
        }
    }, 'html' );  //end .post

    setTimeout( 'get_task_list(' + area_id + ',' + dept_id +')', 200*1000);
};

function get_alltask_list() {
    $.post( 'ajax.php', { action: 'get_alltask_list'}, function(data) {
        if( 'error' != data )
        {
            $('#task_list').html(data);
        }
        else
        {
            alert('获取任务信息错误!');
        }
    }, 'html' );  //end .post
    setTimeout( 'get_alltask_list()', 200*1000);
};

function showtime()
{
    var today,hour,second,minute,year,month,date;
    var strDate ;
       today=new Date();
     var n_day = today.getDay();
     switch (n_day)
     {
     case 0:{
     strDate = "星期日"
     }break;
     case 1:{
     strDate = "星期一"
     }break;
     case 2:{
     strDate ="星期二"
     }break;
     case 3:{
     strDate =  "星期三"
     }break;
     case 4:{
     strDate =  "星期四"
     }break;
     case 5:{
     strDate =  "星期五"
     }break;
     case 6:{
     strDate =  "星期六"
     }break;
     case 7:{
     strDate =  "星期日"
     }break;
     }

    year = today.getYear();
    var month = ( 10 > (today.getMonth()+1) ) ? '0' + (today.getMonth()+1) : today.getMonth()+1;
    var day = ( 10 > today.getDate() ) ? '0' + today.getDate() : today.getDate();
    var hour = ( 10 > today.getHours() ) ? '0' + today.getHours() : today.getHours();
    var minute = ( 10 > today.getMinutes() ) ? '0' + today.getMinutes() : today.getMinutes();
    var second = ( 10 > today.getSeconds() ) ? '0' + today.getSeconds() : today.getSeconds();
    $('#time').html(year + "年" + month + "月" + day + "日 " +  strDate +" " + hour + ":" + minute + ":" + second + "&nbsp;&nbsp;"); //显示时间
    setTimeout("showtime();", 1000); //设定函数自动执行时间为 1000 ms(1 s)
};
