/*

	CSME PRO SlideShow Class
	
	Example:
	
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<script type="text/javascript" src="ContentScroller.js"></script>
<body dir="rtl">

<table>
	<tr><td><button onmouseover="cs1.move(-5,'v');" onmouseout="cs1.stop();" style="width: 100%;">UP</button></td></tr>
	<tr><td>
	<div id="ContentScroller1" style="width: 200px; height: 300px; overflow:hidden; background: yellow;">
		<ol>
			<li> menu</li><li> menu</li><li> menu</li><li> menu</li><li> menu</li><li> menu</li>
			<li> menu</li><li> menu</li><li> menu</li><li> menu</li><li> menu</li><li> menu</li>
			<li> menu</li><li> menu</li><li> menu</li><li> menu</li><li> menu</li><li> menu</li>
			<li> menu</li><li> menu</li><li> menu</li><li> menu</li><li> menu</li><li> menu</li>
			<li> menu</li><li> menu</li><li> menu</li><li> menu</li><li> menu</li><li> menu</li>
		</ol>
	</div>
	</td></tr>
	<tr><td><button onmouseover="cs1.move(+5,'v');" onmouseout="cs1.stop();" style="width: 100%;">DOWN</button></td></tr>
</table>

<script>
	var cs1 = new ContentScroller( document.getElementById("ContentScroller1") );
</script>

<hr>

<table>
	<tr>
	<td><button onmouseover="cs2.move(-5,'h');" onmouseout="cs2.stop();" style="height: 100px;">LEFT</button></td>
	<td>
	<div id="ContentScroller2" style="width: 400px; height: 100px; overflow:hidden; background: orange;">
		<table>
		<tr>
		<td>ContentScroller 1</td><td>ContentScroller 2</td><td>ContentScroller 3</td><td>ContentScroller 4</td><td>ContentScroller 5</td>
		<td>ContentScroller 6</td><td>ContentScroller 7</td><td>ContentScroller 8</td><td>ContentScroller 9</td><td>ContentScroller 0</td>
		</tr>
		</table>
	</div>
	</td>
	<td><button onmouseover="cs2.move(+5,'h');" onmouseout="cs2.stop();" style="height: 100px;">RIGHT</button></td>
	</tr>
</table>

<hr>
	
<script>
	var cs2 = new ContentScroller( document.getElementById("ContentScroller2") );
	// 
	cs2.repeat = true;
	cs2.move(-2,'h');
	//

</script>

</body>
</html>
	
*/

var ContentScroller = function(container) {

	this.obj = ContentScroller;
	this.container = container;
	this.ScrollDir = 0;
	this.ScrollType = "none";
	this.repeat = false;
	//

	this.obj.prototype.stop = function() {	
		this.ScrollDir = 0;
		this.ScrollType = "none";
		}
	
	this.obj.prototype.move = function (dirspeed,dirtype) {
		this.ScrollDir = dirspeed;
		this.ScrollType = dirtype;		
		}
	
	this.obj.prototype.interval = function() {	
		if ( this.ScrollDir != 0 ) {
			
			switch(this.ScrollType) {
			
				case "v":
					if ( this.container.scrollHeight > this.container.offsetHeight) {
						this.container.scrollTop += this.ScrollDir;
						if ( this.container.scrollTop <= 0 ) {
							this.container.scrollTop = ( this.repeat == true ? this.container.scrollHeight - this.container.offsetHeight : 0 );
							} else if ( this.container.scrollTop >= this.container.scrollHeight - this.container.offsetHeight ) {
							this.container.scrollTop = ( this.repeat == true ? 0 : this.container.scrollHeight - this.container.offsetHeight );
							}
						}
					break;
					
				case "h":
					if ( this.container.scrollWidth > this.container.offsetWidth) {
						this.container.scrollLeft += this.ScrollDir;
						if ( this.container.scrollLeft <= 0 ) {
							this.container.scrollLeft = ( this.repeat == true ? this.container.scrollWidth - this.container.offsetWidth :  0);
							} else if ( this.container.scrollLeft >= this.container.scrollWidth - this.container.offsetWidth ) {
							this.container.scrollLeft = ( this.repeat == true ? 0 : this.container.scrollWidth - this.container.offsetWidth );
							}
						}
					break;

				}
				
			}
	
		var self = this; 
		setTimeout(function(){ self.interval(); }, 10); 			
		}

	this.interval();
	
	};