function ScrollControl ( targetIframe, instanceName, direction, wheelable, delta, wheelDelta ) {
	this.target = null;
	this.timer = null;
	this.instanceName = ( typeof instanceName == "undefined" ) ? "scrollControl" : instanceName;
	this.direction = ( typeof direction == "undefined" ) ? "y" : direction;
	this.wheelable = ( typeof wheelable == "undefined" ) ? true : wheelable;
	
	if( typeof delta != "undefined" ) {
		this.delta = delta;
	}
	if( typeof wheelDelta != "undefined" ) {
		this.wheelDelta = wheelDelta;
	}

	if( typeof targetIframe != "undefined" ) this.init( targetIframe );
	else this.init();

}


ScrollControl.prototype.delta = 10;
ScrollControl.prototype.wheelDelta = 20;

ScrollControl.prototype.init = function( targetIframe ) {
	this.target = null;

	if( this.timer != null ) {
		clearTimeout(this.timer);
		this.timer = null;
	}
	if( typeof targetIframe != "undefined" ) this.setTarget( targetIframe );
}

ScrollControl.prototype.setTarget = function( targetIframe ) {

	this.target = targetIframe;
	//WheelScroll For IE5-/Win
	if(document.all && document.getElementById && navigator.userAgent.toLowerCase().indexOf("mac") == -1)
	{
		var self = this;
		if(this.wheelable && this.target.document && this.target.document.getElementsByTagName && this.target.document.getElementsByTagName("BODY")[0])
		{
			this.target.document.getElementsByTagName("BODY")[0].onmousewheel = function() {
				var e = self.target.event.wheelDelta;
				if(e >= 120)
				{
					self.scrollUp(self.wheelDelta);
				}
				else if(e <= -120)
				{
					self.scrollDown(self.wheelDelta);
				}
			
				self.target.event.returnValue = false;
			};
		}
	}
}

ScrollControl.prototype.up = function() {
	this.timer = setInterval( this.instanceName + ".scrollUp()", 50 );
}

ScrollControl.prototype.scrollUp = function( delta ) {
	if( this.direction == "y" ) {
		this.target.scrollBy(0, (typeof delta != "undefined")? -delta : -this.delta);
	}
	else if( this.direction == "x" ) {
		this.target.scrollBy((typeof delta != "undefined")? -delta : -this.delta, 0);
	}
}

ScrollControl.prototype.down = function() {
	this.timer = setInterval( this.instanceName + ".scrollDown()", 50 );
}

ScrollControl.prototype.scrollDown = function( delta ) {
	if( this.direction == "y" ) {
		this.target.scrollBy(0, (typeof delta != "undefined")? delta : this.delta);
	}
	else if( this.direction == "x" ) {
		this.target.scrollBy((typeof delta != "undefined")? delta : this.delta, 0);
	}
}

ScrollControl.prototype.stop = function() {
	if( this.timer != null ) {
		clearInterval( this.timer );
		this.timer = null;
	}
}
var scrollControl = new ScrollControl();

function scrollUp() {
	if( scrollControl.target != null ) scrollControl.up();
}
function scrollDown() {
	if( scrollControl.target != null ) scrollControl.down();
}
function stopScroll() {
	if( scrollControl.target != null ) scrollControl.stop();
}
