//左侧无缝滚动,itemOrderID为当前页面中调用此方法的次序
jQuery.fn.marqueeLeft = function(width,height,speed,itemOrderID) {
	var w = arguments[0] || "1000";
	var h = arguments[1] || "200";
	var s = arguments[2] || 100;
	var o = arguments[3] || 0;
	$(this).before("<div class='marqueeLeftMain' style='overflow:hidden;height:"+h+"px;width:"+w+"px'></div>");
	$(".marqueeLeftMain").append("<div style='width:800%'><div class='marqueeLeftSub1' style='float:left'></div><div class='marqueeLeftSub2' style='float:left'></div></div>");
	$(this).prependTo(".marqueeLeftSub1");

	var tab=$(".marqueeLeftMain")[o];
	var tab1=$(".marqueeLeftSub1")[o];
	var tab2=$(".marqueeLeftSub2")[o];
	tab2.innerHTML=tab1.innerHTML;
	var Marquee=function(){
		if (tab2.offsetWidth-tab.scrollLeft<=0)
			tab.scrollLeft-=tab1.offsetWidth;
		else
			tab.scrollLeft++;
	}
	var MyMar=setInterval(Marquee,s);
	tab.onmouseover=function() {clearInterval(MyMar)};
	tab.onmouseout=function() {MyMar=setInterval(Marquee,s)};
};
jQuery.fn.marqueeRight = function(width,height,speed,itemOrderID) {
	var w = arguments[0] || "1000";
	var h = arguments[1] || "200";
	var s = arguments[2] || 100;
	var o = arguments[3] || 0;
	$(this).before("<div class='marqueeRightMain' style='overflow:hidden;height:"+h+"px;width:"+w+"px'></div>");
	$(".marqueeRightMain").append("<div style='width:800%'><div class='marqueeRightSub1' style='float:left'></div><div class='marqueeRightSub2' style='float:left'></div></div>");
	$(this).prependTo(".marqueeRightSub1");

	var tab=$(".marqueeRightMain")[o];
	var tab1=$(".marqueeRightSub1")[o];
	var tab2=$(".marqueeRightSub2")[o];
	tab2.innerHTML=tab1.innerHTML;
	var Marquee=function(){
		if (tab.scrollLeft<=0)
			tab.scrollLeft+=tab2.offsetWidth;
		else
			tab.scrollLeft--;
	}
	var MyMar=setInterval(Marquee,s);
	tab.onmouseover=function() {clearInterval(MyMar)};
	tab.onmouseout=function() {MyMar=setInterval(Marquee,s)};
};

(function($){
     var ELMS = [];
     $.fn.ArticleScroll = function(settings) {
        settings = $.extend({}, arguments.callee.defaults, settings);
        $(this).each(function(){
            this.$settings    = settings;
            this.$pause = false;
            this.$counter    = settings.beginTime;
            $(this).hover(function(){ $(this).ArticleScrollPause(true) }, function(){ $(this).ArticleScrollPause(false) });
            ELMS.push(this);
        });
        return this;
    };
    $.fn.ArticleScroll.defaults = {
        beginTime: 20,
        delay:     20,
        step:    2
    };
    $.fn.ArticleScrollPause = function(pause) {
        return this.each(function() {
            this.$pause = pause;
        });
    }
    $.fn.outerHeight=function(options){
        if (!this[0]) 0;
        options = $.extend({ margin: false }, options || {});
        return this[0] == window || this[0] == document ?
            this.height() : this.is(':visible') ?
                this[0].offsetHeight + (options.margin ? (num(this, 'marginTop') + num(this, 'marginBottom')) : 0) :
                this.height() 
                    + num(this,'borderTopWidth') + num(this, 'borderBottomWidth') 
                    + num(this, 'paddingTop') + num(this, 'paddingBottom')
                    + (options.margin ? (num(this, 'marginTop') + num(this, 'marginBottom')) : 0);
    }

    setInterval(scroll, 80);
    function scroll() {
        for (var i = 0; i < ELMS.length; i++) {
            var elm = ELMS[i];
            if (elm && !elm.$pause) {
                if (elm.$counter == 0) {
                    var ul     = $('> ul', elm)[0];
                    if (!elm.$steps) {
                        elm.$steps = $('> li:first-child', ul).outerHeight();
                        elm.$step    = 0;
                    }
                    if ((elm.$steps + elm.$step) <= 0) {
                        elm.$counter     = elm.$settings.delay;
                        elm.$steps         = false;
                        $(ul).css('top', '0').find('> li:last-child').after($('> li:first-child', ul));
                        $('> *', ul).not('li').remove();
                    } else {
                        elm.$step -= elm.$settings.step;
                        if (-elm.$step > elm.$steps) {
                            elm.$step = -elm.$steps;
                        }
                        ul.style.top = elm.$step + 'px';
                    }
                } else {
                    elm.$counter--;
                }
            }
        }
    };
})(jQuery);