// JavaScript Document
function updownscroll(box,upper,downer,children) {
	this.Box = box;
	this.Upper = upper;
	this.Downer = downer;
	this.Fowards = "up";
	this.Speed = 1;
	this.Name = "图片滚动控制";
	this.Author = "Keboy";
	this.Version = "1.0";
	this.CreateDate = "2009-11-5"
}
updownscroll.prototype = {
	BeforeStart: function() {
		var _this = this;
		$("#" + _this.Box).html("<div class='demo1'>" + $("#" + _this.Box).html() + "</div><div class='demo2'>" + $("#" + _this.Box).html() + "</div>");
		var inHeight = $("#" + _this.Box + " .demo1").get(0).offsetHeight * 2;
		if ( inHeight <= $("#" + _this.Box).get(0).offsetHeight * 2 ) {
			$("#" + _this.Box).html($("#" + _this.Box).html() + $("#" + _this.Box).html());
		}
	},
	Start: function() {
		var _this = this;
		var mar = setInterval(getMarquee,10);
		function getMarquee() {
			if ( _this.Fowards == "up" ) {
				if ( $("#" + _this.Box).get(0).scrollTop >= $("#" + _this.Box + " .demo1:first").get(0).offsetHeight ) {
					 $("#" + _this.Box).get(0).scrollTop -= $("#" + _this.Box + " .demo1:first").get(0).offsetHeight;
				}
				else {
					 $("#" + _this.Box).get(0).scrollTop += _this.Speed;
				}
			}
			else if ( _this.Fowards == "down" ) {
				if ( $("#" + _this.Box).get(0).scrollTop <= 0 ) {
					 $("#" + _this.Box).get(0).scrollTop += $("#" + _this.Box + " .demo1:first").get(0).offsetHeight;
				}
				else {
					 $("#" + _this.Box).get(0).scrollTop -= _this.Speed;
				}
			}
		}
		$("#" + _this.Upper).mouseover( function() {
			_this.Fowards = "up";
		} ).mousedown( function() {
			_this.Speed = 10;
		} ).mouseup( function() {
			_this.Speed = 1;
		} );
		$("#" + _this.Downer).mouseover( function() {
			_this.Fowards = "down";
		} ).mousedown( function() {
			_this.Speed = 10;
		} ).mouseup( function() {
			_this.Speed = 1;
		} );
		$("#" + _this.Box).mouseover( function() {
			clearInterval(mar);
		} ).mouseout( function() {
			mar = setInterval(getMarquee,10);
		} );
	}
};
$().ready( function() {
	var myscroll = new updownscroll("scrollbox","goup","godown");
	myscroll.BeforeStart();
	myscroll.Start();
} );
